-
Notifications
You must be signed in to change notification settings - Fork 0
OUT-3617-new: AB feature-testing gate for the bank deposit flow #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
92a996c
feat(OUT-3617): add bank-deposit AB gate primitive and config
SandipBajracharya 77d5032
feat(OUT-3617): gate bank-deposit backend paths behind the AB allowlist
SandipBajracharya 7b9aae9
feat(OUT-3617): hide bank-deposit settings UI when the AB gate is off
SandipBajracharya 067e090
test(OUT-3617): cover the bank-deposit AB gate end to end
SandipBajracharya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { abFeatureTestingPortals } from '@/config' | ||
|
|
||
| /** | ||
| * Whether a portal may use the bank deposit feature during its incremental | ||
| * rollout. An empty/unset allowlist means the feature is on for all portals; | ||
| * otherwise only listed portals get it. | ||
| */ | ||
| export function isPortalInBankDepositABTest(portalId: string): boolean { | ||
| if (abFeatureTestingPortals.length === 0) return true | ||
|
priosshrsth marked this conversation as resolved.
|
||
| return abFeatureTestingPortals.includes(portalId) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Drives the bank-deposit AB gate mocked in test/integration/setup.ts. The mock | ||
| // reads its allowlist from a globalThis-pinned holder (the real allowlist is | ||
| // env-parsed at module load and can't be varied per-test). `null` = feature on | ||
| // for all portals. Always reset in afterEach so state doesn't leak across files. | ||
| const AB_GATE_GLOBAL_KEY = '__qbsync_ab_test_gate__' | ||
| type ABGate = { allowlist: string[] | null } | ||
| const ref = globalThis as unknown as Record<string, ABGate | undefined> | ||
| ref[AB_GATE_GLOBAL_KEY] ??= { allowlist: null } | ||
|
|
||
| export const abTestGate = { | ||
| setAllowlist(portalIds: string[] | null) { | ||
| ref[AB_GATE_GLOBAL_KEY]!.allowlist = portalIds | ||
| }, | ||
| reset() { | ||
| ref[AB_GATE_GLOBAL_KEY]!.allowlist = null | ||
| }, | ||
| } |
45 changes: 45 additions & 0 deletions
45
test/integration/quickbooks/invoiceCreated/abTestingGate.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { describe, it, expect, afterEach } from 'vitest' | ||
| import { db } from '@/db' | ||
| import { QBInvoiceSync } from '@/db/schema/qbInvoiceSync' | ||
| import invoiceCreatedPayload from '@test/fixtures/invoiceCreated.webhook' | ||
| import { | ||
| seedHealthyPortal, | ||
| seedProductSync, | ||
| TEST_PORTAL_ID, | ||
| } from '@test/helpers/seed' | ||
| import { setupInvoiceCreatedTest } from '@test/helpers/invoiceCreatedTestSetup' | ||
| import { postWebhook } from '@test/helpers/webhook' | ||
| import { abTestGate } from '@test/helpers/abTestGate' | ||
|
|
||
| // The freeze gate must win over the stored flag: a portal outside the AB | ||
| // allowlist freezes non-batched even with bankDepositFeeFlag=true, so the whole | ||
| // downstream payout/deposit path never engages for it. | ||
| describe('POST /api/quickbooks/webhook — invoice.created AB gate on batched intent', () => { | ||
| setupInvoiceCreatedTest() | ||
|
|
||
| afterEach(() => { | ||
| abTestGate.reset() | ||
| }) | ||
|
|
||
| it('freezes non-batched for a portal outside the allowlist despite the flag being on', async () => { | ||
| abTestGate.setAllowlist(['some-other-portal']) | ||
| await seedHealthyPortal({ setting: { bankDepositFeeFlag: true } }) | ||
| await seedProductSync() | ||
|
|
||
| await postWebhook(invoiceCreatedPayload) | ||
|
|
||
| const [row] = await db.select().from(QBInvoiceSync) | ||
| expect(row.isBatchedDeposit).toBe(false) | ||
| }) | ||
|
|
||
| it('freezes batched for a portal on the allowlist with the flag on', async () => { | ||
| abTestGate.setAllowlist([TEST_PORTAL_ID]) | ||
| await seedHealthyPortal({ setting: { bankDepositFeeFlag: true } }) | ||
| await seedProductSync() | ||
|
|
||
| await postWebhook(invoiceCreatedPayload) | ||
|
|
||
| const [row] = await db.select().from(QBInvoiceSync) | ||
| expect(row.isBatchedDeposit).toBe(true) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.