Skip to content

Commit

Permalink
fix(api): add feature flag mock to webhook e2e test (#6476)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChmaraX authored Sep 10, 2024
1 parent 7618afd commit c2bd2cb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/api/src/app/testing/billing/webhook.e2e-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sinon from 'sinon';
import { expect } from 'chai';
import { ApiServiceLevelEnum } from '@novu/shared';
import { StripeBillingIntervalEnum } from '@novu/ee-billing/src/stripe/types';
import { InvalidateCacheService } from '@novu/application-generic';
import { GetFeatureFlag } from '@novu/application-generic';

const mockSetupIntentSucceededEvent = {
type: 'setup_intent.succeeded',
Expand Down Expand Up @@ -104,6 +104,7 @@ describe('Stripe webhooks', () => {

let verifyCustomerStub: sinon.SinonStub;
let upsertSubscriptionStub: sinon.SinonStub;
let getFeatureFlagStub: sinon.SinonStub;
const analyticsServiceStub = {
track: sinon.stub(),
};
Expand Down Expand Up @@ -135,14 +136,18 @@ describe('Stripe webhooks', () => {
metered: { id: 'metered_subscription_id' },
} as any);
updateCustomerStub = sinon.stub(stripeStub.customers, 'update').resolves({});
// TODO: remove this after IS_IMPROVED_BILLING_ENABLED flag is removed
const IS_IMPROVED_BILLING_ENABLED = false;
getFeatureFlagStub = sinon.stub(GetFeatureFlag.prototype, 'execute').resolves(IS_IMPROVED_BILLING_ENABLED);
});

const createHandler = () => {
const handler = new SetupIntentSucceededHandler(
stripeStub as any,
{ execute: verifyCustomerStub } as any,
{ execute: upsertSubscriptionStub } as any,
analyticsServiceStub as any
analyticsServiceStub as any,
{ execute: getFeatureFlagStub } as any
);

return handler;
Expand Down

0 comments on commit c2bd2cb

Please sign in to comment.