feat: unify backtest table controls and add refresh action
Deploy production / deploy (push) Successful in 53s

This commit is contained in:
yuxuanhui
2026-09-12 13:29:00 +08:00
parent ed349693db
commit 8206b36cd2
8 changed files with 453 additions and 142 deletions
+101
View File
@@ -188,9 +188,110 @@ test("MCP direct batch appears through its run link and source filter", async ({
.getByRole("heading")
.getByRole("button")
.click();
await page.getByRole("button", { name: "筛选回测研究", exact: true }).click();
await page.getByText("全部研究来源", { exact: true }).click();
await page.getByRole("option", { name: /MCP 研究/ }).click();
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect(
page.getByRole("button", { name: "MCP 浏览器留痕", exact: true }),
).toBeVisible();
});
test("backtest toolbar filters, sorts, refreshes and preserves compact layout", async ({
page,
}) => {
await login(page);
let revision = 1;
const requests: URL[] = [];
await page.route("**/api/v1/backtests/runs?*", async (route) => {
const url = new URL(route.request().url());
requests.push(url);
const offset = Number(url.searchParams.get("offset") || 0);
const limit = Number(url.searchParams.get("limit") || 25);
await route.fulfill({
json: {
total: 60,
limit,
offset,
items: Array.from({ length: Math.min(limit, 60 - offset) }, (_, i) => ({
backtest_run_id: `run-${offset + i}`,
name: `工具栏验收-${revision}-${offset + i} ` + "长名称".repeat(20),
source: { kind: "manual" },
status: "running",
total: 8,
counts: { persistence: { saved: 2 }, platform: { failed: 0 } },
created_at: "2026-09-12T10:00:00Z",
})),
},
});
});
await page.reload();
const table = page.locator(".backtest-page .workspace-table");
await expect(
table.getByRole("row").filter({ hasText: "工具栏验收-1-0" }),
).toBeVisible();
revision = 2;
await page.getByRole("button", { name: "刷新回测", exact: true }).click();
await expect(
table.getByRole("row").filter({ hasText: "工具栏验收-2-0" }),
).toBeVisible();
await page.getByRole("button", { name: "筛选回测研究", exact: true }).click();
await page.getByLabel("回测名称筛选").fill("test-filter");
expect(
requests.some((url) => url.searchParams.get("q") === "test-filter"),
).toBe(false);
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect
.poll(() =>
requests.some((url) => url.searchParams.get("q") === "test-filter"),
)
.toBe(true);
await page.getByRole("button", { name: "显示列设置", exact: true }).click();
await page
.locator(".catalog-column-panel .semi-checkbox")
.filter({ hasText: "失败" })
.click();
await page.keyboard.press("Escape");
await expect(
table.getByRole("columnheader", { name: "失败", exact: true }),
).toHaveCount(0);
await page
.locator(".backtest-page .semi-page-item")
.filter({ hasText: /^2$/ })
.click();
await expect
.poll(() => requests.some((url) => url.searchParams.get("offset") === "25"))
.toBe(true);
await page.getByRole("button", { name: "排序设置", exact: true }).click();
await page.getByRole("combobox", { name: "排序字段", exact: true }).click();
await page
.getByRole("option")
.filter({ hasText: /^名称$/ })
.click();
await expect
.poll(() =>
requests.some(
(url) =>
url.searchParams.get("sort") === "name" &&
url.searchParams.get("offset") === "0",
),
)
.toBe(true);
await page.keyboard.press("Escape");
for (const width of [1440, 850]) {
await page.setViewportSize({ width, height: 900 });
const row = table.locator("tbody tr.semi-table-row").first();
await expect(row).toBeVisible();
expect(await row.evaluate((el) => el.getBoundingClientRect().height)).toBe(
40,
);
const footer = await page
.locator(".backtest-page .workspace-table-footer")
.boundingBox();
expect(footer!.y + footer!.height).toBeLessThanOrEqual(900);
expect(footer!.y + footer!.height).toBeGreaterThan(860);
await page.screenshot({
path: `../output/playwright/backtest-toolbar-${width}.png`,
});
}
});