File
Blob: tests/e2e/specs/14-profile-session-rehydration.spec.ts
| 1 | import { test, expect } from "../fixtures/bland-test"; |
| 2 | |
| 3 | test.describe("profile session rehydration", () => { |
| 4 | test("cached profile session renders immediately, shows background refresh UI, and dedupes refresh requests", async ({ |
| 5 | authenticatedPage: { page }, |
| 6 | }) => { |
| 7 | await page.goto("/profile"); |
| 8 | await expect(page.getByRole("heading", { name: "Profile" })).toBeVisible({ timeout: 30_000 }); |
| 9 | |
| 10 | const nameInput = page.locator("#profile-name"); |
| 11 | const initialName = await nameInput.inputValue(); |
| 12 | let refreshCalls = 0; |
| 13 | |
| 14 | await page.route("**/api/v1/auth/refresh", async (route) => { |
| 15 | refreshCalls += 1; |
| 16 | await page.waitForTimeout(1200); |
| 17 | await route.continue(); |
| 18 | }); |
| 19 | |
| 20 | await page.reload(); |
| 21 | |
| 22 | await expect(page.getByRole("heading", { name: "Profile" })).toBeVisible({ timeout: 30_000 }); |
| 23 | await expect(page.getByText("Restoring your session in the background.")).toBeVisible(); |
| 24 | await expect(page.getByText("Restoring your session before profile changes.")).toBeVisible(); |
| 25 | |
| 26 | await nameInput.fill(`${initialName} updated`); |
| 27 | await expect(page.getByRole("button", { name: "Save" })).toBeDisabled(); |
| 28 | |
| 29 | await expect(page.getByText("Restoring your session in the background.")).not.toBeVisible({ timeout: 15_000 }); |
| 30 | await expect(page.getByRole("button", { name: "Save" })).toBeEnabled(); |
| 31 | expect(refreshCalls).toBe(1); |
| 32 | }); |
| 33 | }); |