fix(e2e): simplify impersonation mocks - remove dead POST/dev-session mock, use broader portal/me pattern
The POST /api/portal/dev-session mock is dead code in impersonation tests since the fixture seeds devUser.type=staff, which skips that code path. Removed it to eliminate potential interference. Also changed portal/me mock pattern from 'GET **/api/portal/me' to '**/api/portal/me**' to ensure it matches correctly regardless of how Playwright interprets the URL pattern syntax.
This commit is contained in:
committed by
GitHub
parent
1eb274198c
commit
50f3c961ff
@@ -19,6 +19,7 @@ const MOCK_SESSION = {
|
|||||||
|
|
||||||
test.describe("ImpersonationBanner", () => {
|
test.describe("ImpersonationBanner", () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Impersonation session endpoints
|
||||||
await page.route("**/api/impersonation/sessions/session-1", (route) =>
|
await page.route("**/api/impersonation/sessions/session-1", (route) =>
|
||||||
route.fulfill({ json: MOCK_SESSION })
|
route.fulfill({ json: MOCK_SESSION })
|
||||||
);
|
);
|
||||||
@@ -31,23 +32,8 @@ test.describe("ImpersonationBanner", () => {
|
|||||||
await page.route("**/api/impersonation/sessions/session-1/audit-log", (route) =>
|
await page.route("**/api/impersonation/sessions/session-1/audit-log", (route) =>
|
||||||
route.fulfill({ json: { logs: [] } })
|
route.fulfill({ json: { logs: [] } })
|
||||||
);
|
);
|
||||||
// Portal session endpoint: CustomerPortal.tsx expects a FLAT ImpersonationSession object
|
// Portal profile endpoint used during impersonation
|
||||||
await page.route("POST **/api/portal/dev-session", (route) =>
|
await page.route("**/api/portal/me**", (route) =>
|
||||||
route.fulfill({
|
|
||||||
json: {
|
|
||||||
id: "session-1",
|
|
||||||
staffId: "staff-1",
|
|
||||||
clientId: "client-1",
|
|
||||||
reason: null,
|
|
||||||
status: "active",
|
|
||||||
startedAt: new Date().toISOString(),
|
|
||||||
endedAt: null,
|
|
||||||
expiresAt: new Date(Date.now() + 3600000).toISOString(),
|
|
||||||
createdAt: new Date().toISOString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
await page.route("GET **/api/portal/me", (route) =>
|
|
||||||
route.fulfill({ json: { id: "client-1", name: "Carol Client", email: "carol@test.com" } })
|
route.fulfill({ json: { id: "client-1", name: "Carol Client", email: "carol@test.com" } })
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user