From 8150cf4d5f31592f89265fec5fa428ae88b4f803 Mon Sep 17 00:00:00 2001 From: Christiaan Scheermeijer Date: Wed, 4 Dec 2024 09:52:07 +0100 Subject: [PATCH] fix: optional integration typings when disabled --- .../src/controllers/AccessController.ts | 6 +- .../src/controllers/AccountController.ts | 95 +++++++++++++------ .../src/controllers/CheckoutController.ts | 52 ++++++---- packages/common/src/modules/container.ts | 4 + .../common/src/services/FavoriteService.ts | 2 +- .../src/services/WatchHistoryService.ts | 6 +- .../access-bridge/test/unit/logger.test.ts | 3 +- 7 files changed, 113 insertions(+), 55 deletions(-) diff --git a/packages/common/src/controllers/AccessController.ts b/packages/common/src/controllers/AccessController.ts index e10d1d52a..f310f965d 100644 --- a/packages/common/src/controllers/AccessController.ts +++ b/packages/common/src/controllers/AccessController.ts @@ -19,7 +19,7 @@ const ACCESS_TOKENS = 'access_tokens'; export default class AccessController { private readonly apiService: ApiService; private readonly accessService: AccessService; - private readonly accountService: AccountService; + private readonly accountService?: AccountService; private readonly storageService: StorageService; private siteId: string = ''; @@ -33,7 +33,7 @@ export default class AccessController { this.apiService = apiService; this.accessService = accessService; this.storageService = storageService; - this.accountService = getNamedModule(AccountService, integrationType); + this.accountService = getNamedModule(AccountService, integrationType, false); } initialize = async () => { @@ -112,7 +112,7 @@ export default class AccessController { return null; } - const auth = await this.accountService.getAuthData(); + const auth = await this.accountService?.getAuthData(); const accessTokens = await this.accessService.generateAccessTokens(this.siteId, auth?.jwt); if (accessTokens) { diff --git a/packages/common/src/controllers/AccountController.ts b/packages/common/src/controllers/AccountController.ts index 3ea615ad9..8264222b3 100644 --- a/packages/common/src/controllers/AccountController.ts +++ b/packages/common/src/controllers/AccountController.ts @@ -32,9 +32,9 @@ import AccessController from './AccessController'; @injectable() export default class AccountController { - private readonly checkoutService: CheckoutService; - private readonly accountService: AccountService; - private readonly subscriptionService: SubscriptionService; + private readonly checkoutService?: CheckoutService; + private readonly accountService?: AccountService; + private readonly subscriptionService?: SubscriptionService; private readonly entitlementService: JWPEntitlementService; private readonly accessController: AccessController; private readonly favoritesController: FavoritesController; @@ -50,9 +50,9 @@ export default class AccountController { favoritesController: FavoritesController, watchHistoryController: WatchHistoryController, ) { - this.checkoutService = getNamedModule(CheckoutService, integrationType); - this.accountService = getNamedModule(AccountService, integrationType); - this.subscriptionService = getNamedModule(SubscriptionService, integrationType); + this.checkoutService = getNamedModule(CheckoutService, integrationType, false); + this.accountService = getNamedModule(AccountService, integrationType, false); + this.subscriptionService = getNamedModule(SubscriptionService, integrationType, false); this.entitlementService = getModule(JWPEntitlementService); // @TODO: Controllers shouldn't be depending on other controllers, but we've agreed to keep this as is for now @@ -60,12 +60,12 @@ export default class AccountController { this.favoritesController = favoritesController; this.watchHistoryController = watchHistoryController; - this.features = integrationType ? this.accountService.features : DEFAULT_FEATURES; + this.features = integrationType && this.accountService ? this.accountService.features : DEFAULT_FEATURES; } loadUserData = async () => { try { - const authData = await this.accountService.getAuthData(); + const authData = await this.getAuthData(); if (authData) { await this.getAccount(); @@ -85,24 +85,28 @@ export default class AccountController { this.refreshEntitlements = refreshEntitlements; useAccountStore.setState({ loading: true }); - const config = useConfigStore.getState().config; - await this.accountService.initialize(config, url, this.logout); + if (this.accountService) { + const config = useConfigStore.getState().config; + await this.accountService.initialize(config, url, this.logout); - // set the accessModel before restoring the user session - useConfigStore.setState({ accessModel: this.accountService.accessModel }); + // set the accessModel before restoring the user session + useConfigStore.setState({ accessModel: this.accountService.accessModel }); + await this.loadUserData(); + } - await this.loadUserData(); await this.getEntitledPlans(); useAccountStore.setState({ loading: false }); }; getSandbox() { - return this.accountService.sandbox; + return !!this.accountService?.sandbox; } updateUser = async (values: FirstLastNameInput | EmailConfirmPasswordInput): Promise> => { + assertModuleMethod(this.accountService?.updateCustomer, 'AccountService#updateCustomer is not available'); + useAccountStore.setState({ loading: true }); const { user } = useAccountStore.getState(); @@ -145,7 +149,7 @@ export default class AccountController { const { config } = useConfigStore.getState(); try { - const response = await this.accountService.getUser({ config }); + const response = await this.accountService?.getUser({ config }); if (response) { await this.afterLogin(response.user, response.customerConsents); @@ -166,6 +170,7 @@ export default class AccountController { }; login = async (email: string, password: string, referrer: string) => { + assertModuleMethod(this.accountService?.login, 'AccountService#login is not available'); useAccountStore.setState({ loading: true }); try { @@ -198,8 +203,16 @@ export default class AccountController { }; register = async (email: string, password: string, referrer: string, consentsValues: CustomerConsent[], captchaValue?: string) => { + assertModuleMethod(this.accountService?.register, 'AccountService#register is not available'); + try { - const response = await this.accountService.register({ email, password, consents: consentsValues, referrer, captchaValue }); + const response = await this.accountService.register({ + email, + password, + consents: consentsValues, + referrer, + captchaValue, + }); if (response) { const { user, customerConsents } = response; @@ -256,6 +269,8 @@ export default class AccountController { // TODO: Decide if it's worth keeping this or just leave combined with getUser // noinspection JSUnusedGlobalSymbols getCustomerConsents = async () => { + assertModuleMethod(this.accountService?.getCustomerConsents, 'AccountService#getCustomerConsents is not available'); + const { getAccountInfo } = useAccountStore.getState(); const { customer } = getAccountInfo(); @@ -269,6 +284,8 @@ export default class AccountController { }; getPublisherConsents = async () => { + assertModuleMethod(this.accountService?.getPublisherConsents, 'AccountService#getPublisherConsents is not available'); + const { config } = useConfigStore.getState(); useAccountStore.setState({ publisherConsentsLoading: true }); @@ -278,6 +295,8 @@ export default class AccountController { }; getCaptureStatus = async (): Promise => { + assertModuleMethod(this.accountService?.getCaptureStatus, 'AccountService#getCaptureStatus is not available'); + const { getAccountInfo } = useAccountStore.getState(); const { customer } = getAccountInfo(); @@ -285,6 +304,8 @@ export default class AccountController { }; updateCaptureAnswers = async (capture: Capture): Promise => { + assertModuleMethod(this.accountService?.updateCaptureAnswers, 'AccountService#updateCaptureAnswers is not available'); + const { getAccountInfo } = useAccountStore.getState(); const { customer, customerConsents } = getAccountInfo(); @@ -299,6 +320,8 @@ export default class AccountController { }; resetPassword = async (email: string, resetUrl: string) => { + assertModuleMethod(this.accountService?.resetPassword, 'AccountService#resetPassword is not available'); + await this.accountService.resetPassword({ customerEmail: email, resetUrl, @@ -306,6 +329,8 @@ export default class AccountController { }; changePasswordWithOldPassword = async (oldPassword: string, newPassword: string, newPasswordConfirmation: string) => { + assertModuleMethod(this.accountService?.changePasswordWithOldPassword, 'AccountService#changePasswordWithOldPassword is not available'); + await this.accountService.changePasswordWithOldPassword({ oldPassword, newPassword, @@ -314,6 +339,8 @@ export default class AccountController { }; changePasswordWithToken = async (customerEmail: string, newPassword: string, resetPasswordToken: string, newPasswordConfirmation: string) => { + assertModuleMethod(this.accountService?.changePasswordWithResetToken, 'AccountService#changePasswordWithResetToken is not available'); + await this.accountService.changePasswordWithResetToken({ customerEmail, newPassword, @@ -323,14 +350,15 @@ export default class AccountController { }; updateSubscription = async (status: 'active' | 'cancelled'): Promise => { - const { getAccountInfo } = useAccountStore.getState(); + assertModuleMethod(this.subscriptionService?.updateSubscription, 'SubscriptionService#updateSubscription is not available'); + const { getAccountInfo } = useAccountStore.getState(); const { customerId } = getAccountInfo(); - const { subscription } = useAccountStore.getState(); + if (!subscription) throw new Error('user has no active subscription'); - const response = await this.subscriptionService?.updateSubscription({ + const response = await this.subscriptionService.updateSubscription({ customerId, offerId: subscription.offerId, status, @@ -359,12 +387,11 @@ export default class AccountController { expYear: number; currency: string; }) => { - const { getAccountInfo } = useAccountStore.getState(); + assertModuleMethod(this.subscriptionService?.updateCardDetails, 'SubscriptionService#updateCardDetails is not available'); + const { getAccountInfo } = useAccountStore.getState(); const { customerId } = getAccountInfo(); - assertModuleMethod(this.subscriptionService.updateCardDetails, 'updateCardDetails is not available in subscription service'); - const response = await this.subscriptionService.updateCardDetails({ cardName, cardNumber, @@ -383,6 +410,8 @@ export default class AccountController { }; checkEntitlements = async (offerId?: string): Promise => { + assertModuleMethod(this.checkoutService?.getEntitlements, 'CheckoutService#getEntitlements is not available'); + if (!offerId) { return false; } @@ -420,6 +449,10 @@ export default class AccountController { retry: 0, }, ): Promise => { + assertModuleMethod(this.subscriptionService?.getActiveSubscription, 'SubscriptionService#getActiveSubscription is not available'); + assertModuleMethod(this.subscriptionService?.getAllTransactions, 'SubscriptionService#getAllTransactions is not available'); + assertModuleMethod(this.subscriptionService?.getActivePayment, 'SubscriptionService#getActivePayment is not available'); + useAccountStore.setState({ loading: true }); const { getAccountInfo } = useAccountStore.getState(); @@ -460,8 +493,8 @@ export default class AccountController { // resolve and fetch the pending offer after upgrade/downgrade try { if (activeSubscription?.pendingSwitchId) { - assertModuleMethod(this.checkoutService.getOffer, 'getOffer is not available in checkout service'); - assertModuleMethod(this.checkoutService.getSubscriptionSwitch, 'getSubscriptionSwitch is not available in checkout service'); + assertModuleMethod(this.checkoutService?.getOffer, 'getOffer is not available in checkout service'); + assertModuleMethod(this.checkoutService?.getSubscriptionSwitch, 'getSubscriptionSwitch is not available in checkout service'); const switchOffer = await this.checkoutService.getSubscriptionSwitch({ switchId: activeSubscription.pendingSwitchId }); const offerResponse = await this.checkoutService.getOffer({ offerId: switchOffer.responseData.toOfferId }); @@ -487,16 +520,16 @@ export default class AccountController { exportAccountData = async () => { const { canExportAccountData } = this.getFeatures(); - assertModuleMethod(this.accountService.exportAccountData, 'exportAccountData is not available in account service'); + assertModuleMethod(this.accountService?.exportAccountData, 'exportAccountData is not available in account service'); assertFeature(canExportAccountData, 'Export account'); - return this.accountService?.exportAccountData(undefined); + return this.accountService.exportAccountData(undefined); }; getSocialLoginUrls = (redirectUrl: string) => { const { hasSocialURLs } = this.getFeatures(); - assertModuleMethod(this.accountService.getSocialUrls, 'getSocialUrls is not available in account service'); + assertModuleMethod(this.accountService?.getSocialUrls, 'getSocialUrls is not available in account service'); assertFeature(hasSocialURLs, 'Social logins'); return this.accountService.getSocialUrls({ redirectUrl }); @@ -505,7 +538,7 @@ export default class AccountController { deleteAccountData = async (password: string) => { const { canDeleteAccount } = this.getFeatures(); - assertModuleMethod(this.accountService.deleteAccount, 'deleteAccount is not available in account service'); + assertModuleMethod(this.accountService?.deleteAccount, 'deleteAccount is not available in account service'); assertFeature(canDeleteAccount, 'Delete account'); try { @@ -522,7 +555,7 @@ export default class AccountController { }; getReceipt = async (transactionId: string) => { - assertModuleMethod(this.subscriptionService.fetchReceipt, 'fetchReceipt is not available in subscription service'); + assertModuleMethod(this.subscriptionService?.fetchReceipt, 'fetchReceipt is not available in subscription service'); const { responseData } = await this.subscriptionService.fetchReceipt({ transactionId }); @@ -530,10 +563,12 @@ export default class AccountController { }; getAuthData = async () => { - return this.accountService.getAuthData(); + return this.accountService?.getAuthData() || null; }; subscribeToNotifications = async ({ uuid, onMessage }: SubscribeToNotificationsPayload) => { + assertModuleMethod(this.accountService?.subscribeToNotifications, 'AccountService#subscribeToNotifications is not available'); + return this.accountService.subscribeToNotifications({ uuid, onMessage }); }; diff --git a/packages/common/src/controllers/CheckoutController.ts b/packages/common/src/controllers/CheckoutController.ts index 8a9acc761..c2835dfdc 100644 --- a/packages/common/src/controllers/CheckoutController.ts +++ b/packages/common/src/controllers/CheckoutController.ts @@ -31,19 +31,21 @@ import { findDefaultCardMethodId } from '../utils/payments'; @injectable() export default class CheckoutController { - private readonly accountService: AccountService; - private readonly checkoutService: CheckoutService; - private readonly subscriptionService: SubscriptionService; + private readonly accountService?: AccountService; + private readonly checkoutService?: CheckoutService; + private readonly subscriptionService?: SubscriptionService; private readonly getCustomerIP: GetCustomerIP; constructor(@inject(INTEGRATION_TYPE) integrationType: IntegrationType, @inject(GET_CUSTOMER_IP) getCustomerIP: GetCustomerIP) { this.getCustomerIP = getCustomerIP; - this.accountService = getNamedModule(AccountService, integrationType); - this.checkoutService = getNamedModule(CheckoutService, integrationType); - this.subscriptionService = getNamedModule(SubscriptionService, integrationType); + this.accountService = getNamedModule(AccountService, integrationType, false); + this.checkoutService = getNamedModule(CheckoutService, integrationType, false); + this.subscriptionService = getNamedModule(SubscriptionService, integrationType, false); } initialiseOffers = async () => { + assertModuleMethod(this.accountService?.svodOfferIds, 'AccountService#svodOfferIds not defined'); + const requestedMediaOffers = useCheckoutStore.getState().requestedMediaOffers; const mediaOffers = requestedMediaOffers ? await this.getOffers({ offerIds: requestedMediaOffers.map(({ offerId }) => offerId) }) : []; useCheckoutStore.setState({ mediaOffers }); @@ -60,13 +62,15 @@ export default class CheckoutController { } }; - getSubscriptionOfferIds = () => this.accountService.svodOfferIds; + getSubscriptionOfferIds = () => this.accountService?.svodOfferIds || []; chooseOffer = async (selectedOffer: Offer) => { useCheckoutStore.setState({ selectedOffer }); }; initialiseOrder = async (offer: Offer): Promise => { + assertModuleMethod(this.checkoutService?.createOrder, 'CheckoutService#createOrder not defined'); + const { getAccountInfo } = useAccountStore.getState(); const { customer } = getAccountInfo(); @@ -92,6 +96,8 @@ export default class CheckoutController { }; updateOrder = async (order: Order, paymentMethodId?: number, couponCode?: string | null): Promise => { + assertModuleMethod(this.checkoutService?.updateOrder, 'CheckoutService#updateOrder is not available'); + try { const response = await this.checkoutService.updateOrder({ order, paymentMethodId, couponCode }); @@ -114,6 +120,8 @@ export default class CheckoutController { }; getPaymentMethods = async (): Promise => { + assertModuleMethod(this.checkoutService?.getPaymentMethods, 'CheckoutService#getPaymentMethods is not available'); + const { paymentMethods } = useCheckoutStore.getState(); if (paymentMethods) return paymentMethods; // already fetched payment methods @@ -129,6 +137,8 @@ export default class CheckoutController { // paymentWithoutDetails = async ({ captchaValue }: { captchaValue?: string } = {}): Promise => { + assertModuleMethod(this.checkoutService?.paymentWithoutDetails, 'CheckoutService#paymentWithoutDetails is not available'); + const { order } = useCheckoutStore.getState(); if (!order) throw new Error('No order created'); @@ -142,6 +152,8 @@ export default class CheckoutController { }; directPostCardPayment = async ({ cardPaymentPayload, referrer, returnUrl }: { cardPaymentPayload: CardPaymentData; referrer: string; returnUrl: string }) => { + assertModuleMethod(this.checkoutService?.directPostCardPayment, 'CheckoutService#directPostCardPayment is not available'); + const { order } = useCheckoutStore.getState(); if (!order) throw new Error('No order created'); @@ -155,7 +167,7 @@ export default class CheckoutController { if (isInitialPayment && !orderId) throw new Error('There is no order to pay for'); - assertModuleMethod(this.checkoutService.createAdyenPaymentSession, 'createAdyenPaymentSession is not available in checkout service'); + assertModuleMethod(this.checkoutService?.createAdyenPaymentSession, 'createAdyenPaymentSession is not available in checkout service'); const response = await this.checkoutService.createAdyenPaymentSession({ orderId: orderId, @@ -174,7 +186,7 @@ export default class CheckoutController { if (!order) throw new Error('No order created'); - assertModuleMethod(this.checkoutService.initialAdyenPayment, 'initialAdyenPayment is not available in checkout service'); + assertModuleMethod(this.checkoutService?.initialAdyenPayment, 'initialAdyenPayment is not available in checkout service'); const response = await this.checkoutService.initialAdyenPayment({ orderId: order.id, @@ -192,7 +204,7 @@ export default class CheckoutController { finalizeAdyenPayment = async (details: unknown, orderId?: number, paymentData?: string): Promise => { if (!orderId) throw new Error('No order created'); - assertModuleMethod(this.checkoutService.finalizeAdyenPayment, 'finalizeAdyenPayment is not available in checkout service'); + assertModuleMethod(this.checkoutService?.finalizeAdyenPayment, 'finalizeAdyenPayment is not available in checkout service'); const response = await this.checkoutService.finalizeAdyenPayment({ orderId, @@ -226,6 +238,8 @@ export default class CheckoutController { if (!order) throw new Error('No order created'); + assertModuleMethod(this.checkoutService?.paymentWithPayPal, 'CheckoutService#paymentWithPayPal is not available'); + const response = await this.checkoutService.paymentWithPayPal({ order: order, successUrl, @@ -249,7 +263,7 @@ export default class CheckoutController { const { customerId } = getAccountInfo(); const { subscription } = useAccountStore.getState(); - if (!subscription || !this.checkoutService.getSubscriptionSwitches) return null; + if (!subscription || !this.checkoutService?.getSubscriptionSwitches) return null; assertModuleMethod(this.checkoutService.getOffer, 'getOffer is not available in checkout service'); @@ -271,7 +285,7 @@ export default class CheckoutController { if (!selectedOffer || !subscription) throw new Error('No offer selected'); - assertModuleMethod(this.checkoutService.switchSubscription, 'switchSubscription is not available in checkout service'); + assertModuleMethod(this.checkoutService?.switchSubscription, 'switchSubscription is not available in checkout service'); const switchDirection: 'upgrade' | 'downgrade' = determineSwitchDirection(subscription); @@ -286,7 +300,7 @@ export default class CheckoutController { }; changeSubscription = async ({ accessFeeId, subscriptionId }: { accessFeeId: string; subscriptionId: string }) => { - assertModuleMethod(this.subscriptionService.changeSubscription, 'changeSubscription is not available in subscription service'); + assertModuleMethod(this.subscriptionService?.changeSubscription, 'changeSubscription is not available in subscription service'); const { responseData } = await this.subscriptionService.changeSubscription({ accessFeeId, @@ -304,8 +318,8 @@ export default class CheckoutController { paymentMethodId: number, currentPaymentId?: number, ) => { - assertModuleMethod(this.checkoutService.updatePaymentMethodWithPayPal, 'updatePaymentMethodWithPayPal is not available in checkout service'); - assertModuleMethod(this.checkoutService.deletePaymentMethod, 'deletePaymentMethod is not available in checkout service'); + assertModuleMethod(this.checkoutService?.updatePaymentMethodWithPayPal, 'updatePaymentMethodWithPayPal is not available in checkout service'); + assertModuleMethod(this.checkoutService?.deletePaymentMethod, 'deletePaymentMethod is not available in checkout service'); const response = await this.checkoutService.updatePaymentMethodWithPayPal({ paymentMethodId, @@ -325,7 +339,7 @@ export default class CheckoutController { }; addAdyenPaymentDetails = async (paymentMethod: AdyenPaymentMethod, paymentMethodId: number, returnUrl: string): Promise => { - assertModuleMethod(this.checkoutService.addAdyenPaymentDetails, 'addAdyenPaymentDetails is not available in checkout service'); + assertModuleMethod(this.checkoutService?.addAdyenPaymentDetails, 'addAdyenPaymentDetails is not available in checkout service'); const response = await this.checkoutService.addAdyenPaymentDetails({ paymentMethodId, @@ -340,7 +354,7 @@ export default class CheckoutController { }; finalizeAdyenPaymentDetails = async (details: unknown, paymentMethodId: number, paymentData?: string): Promise => { - assertModuleMethod(this.checkoutService.finalizeAdyenPaymentDetails, 'finalizeAdyenPaymentDetails is not available in checkout service'); + assertModuleMethod(this.checkoutService?.finalizeAdyenPaymentDetails, 'finalizeAdyenPaymentDetails is not available in checkout service'); const response = await this.checkoutService.finalizeAdyenPaymentDetails({ paymentMethodId, @@ -354,10 +368,14 @@ export default class CheckoutController { }; getOffers: GetOffers = (payload) => { + assertModuleMethod(this.checkoutService?.getOffers, 'CheckoutService#getOffers is not available'); + return this.checkoutService.getOffers(payload); }; getEntitlements: GetEntitlements = (payload) => { + assertModuleMethod(this.checkoutService?.getEntitlements, 'CheckoutService#getEntitlements is not available'); + return this.checkoutService.getEntitlements(payload); }; } diff --git a/packages/common/src/modules/container.ts b/packages/common/src/modules/container.ts index e1438bd60..863b2c514 100644 --- a/packages/common/src/modules/container.ts +++ b/packages/common/src/modules/container.ts @@ -24,6 +24,10 @@ export function getNamedModule(constructorFunction: interfaces.ServiceIdentif export function getNamedModule(constructorFunction: interfaces.ServiceIdentifier, name: string | null): T; export function getNamedModule(constructorFunction: interfaces.ServiceIdentifier, name: string | null, required = true): T | undefined { if (!name) { + // if no name is given we throw an error to satisfy the non-nullable return type + if (required) { + throw new Error(`Service not found '${String(constructorFunction)}' with name '${name}'`); + } return; } diff --git a/packages/common/src/services/FavoriteService.ts b/packages/common/src/services/FavoriteService.ts index e4b8ecfc5..889d4d7e0 100644 --- a/packages/common/src/services/FavoriteService.ts +++ b/packages/common/src/services/FavoriteService.ts @@ -25,7 +25,7 @@ export default class FavoriteService { protected readonly apiService; protected readonly storageService; - protected readonly accountService; + protected readonly accountService?; constructor( @inject(INTEGRATION_TYPE) integrationType: string, diff --git a/packages/common/src/services/WatchHistoryService.ts b/packages/common/src/services/WatchHistoryService.ts index 76a9a1ca5..01f8b4837 100644 --- a/packages/common/src/services/WatchHistoryService.ts +++ b/packages/common/src/services/WatchHistoryService.ts @@ -26,7 +26,7 @@ export default class WatchHistoryService { protected readonly apiService; protected readonly storageService; - protected readonly accountService; + protected readonly accountService?; constructor( @inject(INTEGRATION_TYPE) integrationType: string, @@ -35,7 +35,7 @@ export default class WatchHistoryService { ) { this.apiService = apiService; this.storageService = storageService; - this.accountService = getNamedModule(AccountService, integrationType); + this.accountService = getNamedModule(AccountService, integrationType, false); } // Retrieve watch history media items info using a provided watch list @@ -78,7 +78,7 @@ export default class WatchHistoryService { } protected async getWatchHistoryFromAccount(user: Customer) { - const history = await this.accountService.getWatchHistory({ user }); + const history = await this.accountService?.getWatchHistory({ user }); return this.validateWatchHistory(history); } diff --git a/platforms/access-bridge/test/unit/logger.test.ts b/platforms/access-bridge/test/unit/logger.test.ts index ae20d0d74..94e984d10 100644 --- a/platforms/access-bridge/test/unit/logger.test.ts +++ b/platforms/access-bridge/test/unit/logger.test.ts @@ -32,10 +32,11 @@ describe('Logger Tests', () => { beforeEach(() => { // Mock Sentry's getClient to return an object with captureException and captureMessage + // @ts-expect-error we only need certain Sentry methods vi.mocked(Sentry.getClient).mockReturnValue({ captureException: mockCaptureException, captureMessage: mockCaptureMessage, - } as unknown as Sentry.NodeClient); + }); // Ensure Sentry's captureException and captureMessage methods are also mocked vi.mocked(Sentry.captureException).mockImplementation(mockCaptureException);