import { test as base, expect } from '@playwright/test'; import { MockApi } from './api'; import { P2PUi } from './ui'; import { O2CUi } from './modules/o2c/ui'; import { O2CApi } from './modules/o2c/api'; import { R2RUi } from './modules/r2r/ui'; import { R2RApi } from './modules/r2r/api'; import { A2RUi } from './modules/a2r/ui'; import { A2RApi } from './modules/a2r/api'; import { EXPUi } from './modules/exp/ui'; import { EXPApi } from './modules/exp/api'; import { SCMUi } from './modules/scm/ui'; import { SCMApi } from './modules/scm/api'; import { P2MUi } from './modules/p2m/ui'; import { P2MApi } from './modules/p2m/api'; import { PPMUi } from './modules/ppm/ui'; import { PPMApi } from './modules/ppm/api'; import { SCPUi } from './modules/scp/ui'; import { SCPApi } from './modules/scp/api'; import { HCMUi } from './modules/hcm/ui'; import { HCMApi } from './modules/hcm/api'; import { CXUi } from './modules/cx/ui'; import { CXApi } from './modules/cx/api'; import { applyLocatorOverrides } from './locator-overrides'; import { beginLiveStatus, liveViewDir, startLiveView } from './live-view'; type Fixtures = { api: MockApi; ui: P2PUi; o2c: O2CUi; o2capi: O2CApi; r2r: R2RUi; r2rapi: R2RApi; a2r: A2RUi; a2rapi: A2RApi; exp: EXPUi; expapi: EXPApi; scm: SCMUi; scmapi: SCMApi; p2m: P2MUi; p2mapi: P2MApi; ppm: PPMUi; ppmapi: PPMApi; scp: SCPUi; scpapi: SCPApi; hcm: HCMUi; hcmapi: HCMApi; cx: CXUi; cxapi: CXApi; resetMock: void; liveStatus: void }; /** Every test starts from a freshly reset MOCK app (synthetic seed data only). */ export const test = base.extend({ // Co-worker self-heal retry hook: a no-op unless PW_LOCATOR_OVERRIDES is set (src/locator-overrides.ts). // Live view ("Watch the test"): a no-op unless FPT_LIVE_VIEW_DIR is set (src/live-view.ts). With the variable unset no // CDP session is opened and nothing is wrapped. page: async ({ page }, use, testInfo) => { applyLocatorOverrides(page); const stopLive = liveViewDir() ? await startLiveView(page, testInfo) : null; await use(page); if (stopLive) await stopLive(); }, api: async ({ request }, use) => { await use(new MockApi(request)); }, ui: async ({ page }, use) => { await use(new P2PUi(page)); }, o2c: async ({ page }, use) => { await use(new O2CUi(page)); }, o2capi: async ({ api }, use) => { await use(new O2CApi(api)); }, r2r: async ({ page }, use) => { await use(new R2RUi(page)); }, r2rapi: async ({ api }, use) => { await use(new R2RApi(api)); }, a2r: async ({ page }, use) => { await use(new A2RUi(page)); }, a2rapi: async ({ api }, use) => { await use(new A2RApi(api)); }, exp: async ({ page }, use) => { await use(new EXPUi(page)); }, expapi: async ({ api }, use) => { await use(new EXPApi(api)); }, scm: async ({ page }, use) => { await use(new SCMUi(page)); }, scmapi: async ({ api }, use) => { await use(new SCMApi(api)); }, p2m: async ({ page }, use) => { await use(new P2MUi(page)); }, p2mapi: async ({ api }, use) => { await use(new P2MApi(api)); }, ppm: async ({ page }, use) => { await use(new PPMUi(page)); }, ppmapi: async ({ api }, use) => { await use(new PPMApi(api)); }, scp: async ({ page }, use) => { await use(new SCPUi(page)); }, scpapi: async ({ api }, use) => { await use(new SCPApi(api)); }, hcm: async ({ page }, use) => { await use(new HCMUi(page)); }, hcmapi: async ({ api }, use) => { await use(new HCMApi(api)); }, cx: async ({ page }, use) => { await use(new CXUi(page)); }, cxapi: async ({ api }, use) => { await use(new CXApi(api)); }, resetMock: [async ({ api }, use) => { await api.reset(); await use(); }, { auto: true }], // Scenario-level caption for the live view (status.json): start and result of each test. No-op when the env is unset. liveStatus: [async ({}, use, testInfo) => { const done = liveViewDir() ? beginLiveStatus(testInfo) : null; await use(); if (done) done(); }, { auto: true }], }); export { expect };