mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-17 13:04:02 +00:00
- Drop orders routes, API, MSW, and e2e; users-only CRUD template - Port HTTP refresh, hooks, RouteError, and core e2e to basic - Lingui extract --clean in script; refresh catalogs - Update add-resource docs, cursor rule, and optimization spec Made-with: Cursor
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { loginAsAdmin } from "./helpers";
|
|
|
|
const expiredAuthStorage = () =>
|
|
JSON.stringify({
|
|
state: {
|
|
tokens: {
|
|
accessToken: "__EXPIRED_ACCESS__",
|
|
refreshToken: "mock-refresh-token",
|
|
},
|
|
isAuthenticated: true,
|
|
},
|
|
version: 0,
|
|
});
|
|
|
|
test.describe("Auth refresh", () => {
|
|
test.describe.configure({ retries: 2 });
|
|
|
|
test("401 on list triggers refresh then succeeds", async ({ page }) => {
|
|
await loginAsAdmin(page);
|
|
|
|
await page.evaluate((payload) => {
|
|
localStorage.setItem("auth-storage", payload);
|
|
}, expiredAuthStorage());
|
|
|
|
await page.reload({ waitUntil: "load" });
|
|
|
|
const usersListOk = page.waitForResponse(
|
|
(res) => res.url().includes("/api/users") && res.request().method() === "GET" && res.ok(),
|
|
{ timeout: 60_000 },
|
|
);
|
|
await page.goto("/users", { waitUntil: "domcontentloaded" });
|
|
await usersListOk;
|
|
|
|
await expect(page).toHaveURL(/\/users(\/|\?|$)/);
|
|
const thead = page.locator(".ant-table-thead");
|
|
await expect(thead.getByText(/Username|用户名/)).toBeVisible({ timeout: 30_000 });
|
|
});
|
|
});
|