Files
worldquant-alpha-system/frontend/tests/submission-blocked.spec.ts
T

47 lines
2.2 KiB
TypeScript
Raw Normal View History

import { expect, test } from "@playwright/test";
test("fixed blocked tab retains its scope through filtering, reset and saved views", async ({
page,
}) => {
let params = new URLSearchParams();
await page.route(/\/api\/v1\/alphas\?/, async (route) => {
params = new URL(route.request().url()).searchParams;
await route.fulfill({
json: { items: [], total: 0, limit: 25, offset: 0 },
});
});
await page.goto("/#alphas");
await page.getByLabel("密码", { exact: true }).fill("browser-test-password");
await page.getByRole("button", { name: "进入工作空间" }).click();
const blocked = page.getByRole("tab", { name: "提交受阻", exact: true });
await blocked.click();
await expect.poll(() => params.get("submission_blocked")).toBe("true");
expect(params.get("submission")).toBe("UNSUBMITTED");
await page.getByRole("button", { name: "筛选 Alpha", exact: true }).click();
await page
.getByRole("textbox", { name: "搜索 Alpha", exact: true })
.fill("candidate");
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect.poll(() => params.get("q")).toBe("candidate");
expect(params.get("submission_blocked")).toBe("true");
await page.getByRole("button", { name: "保存为新视图", exact: true }).click();
await page
.getByRole("textbox", { name: "视图名称", exact: true })
.fill("受阻候选");
await page.getByRole("button", { name: "保存视图", exact: true }).click();
const saved = page.getByRole("tab", { name: "受阻候选" });
await expect(saved).toBeVisible();
await page.getByRole("tab", { name: "已提交", exact: true }).click();
await expect.poll(() => params.get("submission")).toBe("SUBMITTED");
expect(params.has("submission_blocked")).toBe(false);
await saved.click();
await expect.poll(() => params.get("submission_blocked")).toBe("true");
expect(params.get("q")).toBe("candidate");
await blocked.click();
await page.getByRole("button", { name: "筛选 Alpha", exact: true }).click();
await page.getByRole("button", { name: "重置", exact: true }).click();
await expect.poll(() => params.has("q")).toBe(false);
expect(params.get("submission_blocked")).toBe("true");
await expect(blocked).toHaveAttribute("aria-selected", "true");
});