diff --git a/tests/e2e/connection-reviews.spec.ts b/tests/e2e/connection-reviews.spec.ts index e8f85b67175..a2e68a5511d 100644 --- a/tests/e2e/connection-reviews.spec.ts +++ b/tests/e2e/connection-reviews.spec.ts @@ -115,15 +115,19 @@ for (const journey of [ "Use connection-reviews.config.ts for controlled server restart", ); let suppressReviewEvents = journey === "decline"; + let initialSnapshotReturned = false; if (journey === "decline") { // Reproduce a review arriving between the initial fetch and subscription: // return an empty first snapshot and drop its live creation notification. - const initialSnapshots = new Set(); - await page.route("**/api/issues/*/interactions", async (route) => { - const url = route.request().url(); - if (route.request().method() === "GET" && !initialSnapshots.has(url)) { - initialSnapshots.add(url); - await route.fulfill({ json: [] }); + await page.route(/\/api\/issues\/[^/?]+\/(?:interactions|chat-bootstrap)(?:\?.*)?$/, async (route) => { + const url = new URL(route.request().url()); + if (route.request().method() === "GET" && !initialSnapshotReturned) { + initialSnapshotReturned = true; + if (url.pathname.endsWith("/chat-bootstrap")) { + const response = await route.fetch(); + const snapshot = await response.json() as Json; + await route.fulfill({ response, json: { ...snapshot, interactions: [] } }); + } else await route.fulfill({ json: [] }); } else await route.continue(); }); await page.routeWebSocket("**/api/companies/*/events/ws", (socket) => { @@ -218,6 +222,7 @@ for (const journey of [ await expect( page.getByRole("button", { name: "Approve & run", exact: true }), ).toBeVisible({ timeout: 45_000 }); + if (journey === "decline") expect(initialSnapshotReturned).toBe(true); suppressReviewEvents = false; const originatingReviews = await json>(await request.get(`/api/issues/${issue.id}/interactions`)); const originatingReview = originatingReviews[0];