A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
test(api): restore the stripe webhook secret after mocking it (#2656)
Hampus54128e049a7b
diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.tsindex 5b03cd182..d6725ab44 100644--- a/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts+++ b/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts@@ -113,7 +113,10 @@ export function setupSyncStripeWebhookWorker(): void {setInjectedWorkerService(new SyncTaskWorkerService({processStripeWebhook}));}+let originalWebhookSecretDescriptor: PropertyDescriptor | undefined;+export function mockStripeWebhookSecret(secret = 'whsec_test'): void {+ originalWebhookSecretDescriptor ??= Object.getOwnPropertyDescriptor(Config.stripe, 'webhookSecret');Object.defineProperty(Config.stripe, 'webhookSecret', {get: () => secret,configurable: true,@@ -121,6 +124,11 @@ export function mockStripeWebhookSecret(secret = 'whsec_test'): void {}export function restoreStripeWebhookSecret(): void {+ if (originalWebhookSecretDescriptor) {+ Object.defineProperty(Config.stripe, 'webhookSecret', originalWebhookSecretDescriptor);+ originalWebhookSecretDescriptor = undefined;+ return;+ }delete (Config.stripe as {webhookSecret?: string;