diff --git a/src/login-web-app/setupTests.ts b/src/login-web-app/setupTests.ts index a4667743..6a63c6b8 100644 --- a/src/login-web-app/setupTests.ts +++ b/src/login-web-app/setupTests.ts @@ -1,6 +1,16 @@ import '@testing-library/jest-dom/vitest'; import { vi } from 'vitest'; +// bootstrap-configuration.ts throws at import time if window.__CONFIG__ is unset. +// @ts-expect-error window.__CONFIG__ is not declared on the Window type +window.__CONFIG__ = { + initialUrl: 'https://example.test/auth', + haapi: { + clientId: 'test-client', + tokenEndpoint: 'https://example.test/oauth/token', + }, +}; + // jsdom doesn't implement — minimal mocks for open/close state. HTMLDialogElement.prototype.show = vi.fn(function mock(this: HTMLDialogElement) { this.open = true; diff --git a/src/login-web-app/src/haapi-stepper/feature/stepper/HaapiStepper.spec.tsx b/src/login-web-app/src/haapi-stepper/feature/stepper/HaapiStepper.spec.tsx index 1b04f134..48bc5904 100644 --- a/src/login-web-app/src/haapi-stepper/feature/stepper/HaapiStepper.spec.tsx +++ b/src/login-web-app/src/haapi-stepper/feature/stepper/HaapiStepper.spec.tsx @@ -29,7 +29,7 @@ import { act } from 'react'; import { useHaapiStepper } from './HaapiStepperHook'; import type { HaapiStepperHistoryEntry, HaapiStepperNextStepAction } from './haapi-stepper.types'; import { HaapiStepperActionStep, HaapiStepperFormAction } from './haapi-stepper.types'; -import type { BootstrapConfiguration } from '../../data-access/bootstrap-configuration'; +import { configuration } from '../../data-access/bootstrap-configuration'; describe('HaapiStepper', () => { const initialStepType = HAAPI_STEPS.AUTHENTICATION; @@ -53,7 +53,7 @@ describe('HaapiStepper', () => { ); - expect(mockHaapiFetch).toHaveBeenCalledWith(mockConfiguration.initialUrl, { method: 'GET' }); + expect(mockHaapiFetch).toHaveBeenCalledWith(configuration.initialUrl, { method: 'GET' }); const stepRendered = await screen.findByTestId('step-type'); @@ -714,17 +714,6 @@ vi.mock('../../data-access/haapi-fetch-initializer', () => { }; }); -const mockConfiguration: Partial = vi.hoisted(() => { - return { - initialUrl: 'https://example.com/auth', - }; -}); -vi.mock('../../data-access/bootstrap-configuration', () => { - return { - configuration: mockConfiguration, - }; -}); - const mockThrowErrorToAppErrorBoundary = vi.fn(); vi.mock('../../util/useThrowErrorToAppErrorBoundary', () => ({ // eslint-disable-next-line @eslint-react/hooks-extra/no-unnecessary-use-prefix