feat: unify scope settings and catalog table interactions
Deploy production / deploy (push) Successful in 54s

This commit is contained in:
yuxuanhui
2026-09-12 12:11:53 +08:00
parent 9dee2de039
commit 8981c24fda
29 changed files with 2521 additions and 796 deletions
+174 -9
View File
@@ -129,16 +129,23 @@ test("在线字段跨页多选直接准备,本地只展示完整同步字段",
).toHaveAttribute("aria-selected", "true");
await page.getByRole("tab", { name: "worldquant接口", exact: true }).click();
const online = page.getByRole("tabpanel", { name: "worldquant接口" });
await online
.getByRole("button", { name: "筛选字段目录", exact: true })
.click();
await expect(
online.getByRole("button", { name: "查询", exact: true }),
page.getByRole("button", { name: "查询", exact: true }),
).toBeDisabled();
await expect(
online.getByText("请输入关键词、数据集或其他筛选条件,然后点击查询。"),
).toBeVisible();
expect(queries).toEqual([]);
await online.getByLabel("字段数据集").fill("TEST_FIN");
if (!(await page.getByRole("form", { name: "字段目录筛选条件" }).isVisible()))
await online
.getByRole("button", { name: "筛选字段目录", exact: true })
.click();
await page.getByLabel("字段数据集").fill("TEST_FIN");
expect(queries).toEqual([]);
await online.getByRole("button", { name: "查询", exact: true }).click();
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect(online.getByText("TEST_FIN_001", { exact: true })).toBeVisible();
await online
.getByRole("row")
@@ -166,8 +173,11 @@ test("在线字段跨页多选直接准备,本地只展示完整同步字段",
await page.getByRole("tab", { name: "本地同步", exact: true }).click();
const local = page.getByRole("tabpanel", { name: "本地同步" });
// Other browser tests share this isolated server, so verify the unsynced dataset explicitly.
await local.getByLabel("字段数据集").fill("TEST_NEWS");
await local.getByRole("button", { name: "查询", exact: true }).click();
await local
.getByRole("button", { name: "筛选字段目录", exact: true })
.click();
await page.getByLabel("字段数据集").fill("TEST_NEWS");
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect(local.getByText("共 0 个字段", { exact: true })).toBeVisible();
await page.screenshot({
path: "test-results/preparations-fields.png",
@@ -239,19 +249,174 @@ test("目录表格保持紧凑行高、截断和固定分页", async ({ page })
await page.screenshot({ path: "test-results/field-table-layout-narrow.png" });
await page.getByRole("tab", { name: "worldquant接口", exact: true }).click();
const online = page.getByRole("tabpanel", { name: "worldquant接口" });
await online.getByLabel("字段数据集").fill("TEST_FIN");
await online.getByRole("button", { name: "查询", exact: true }).click();
if (!(await page.getByRole("form", { name: "字段目录筛选条件" }).isVisible()))
await online
.getByRole("button", { name: "筛选字段目录", exact: true })
.click();
await page.getByLabel("字段数据集").fill("TEST_FIN");
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect(online.getByText("TEST_FIN_001", { exact: true })).toBeVisible();
let queries = 0;
page.on("request", (req) => {
if (req.url().includes("/catalog/worldquant/fields")) queries++;
});
await online.getByRole("button", { name: "重置", exact: true }).click();
await online
.getByRole("button", { name: "筛选字段目录", exact: true })
.click();
await page.getByRole("button", { name: "重置", exact: true }).click();
await online
.getByRole("button", { name: "筛选字段目录", exact: true })
.click();
await expect(
online.getByRole("button", { name: "查询", exact: true }),
page.getByRole("button", { name: "查询", exact: true }),
).toBeDisabled();
await expect(online.getByText("TEST_FIN_001", { exact: true })).toHaveCount(
0,
);
expect(queries).toBe(0);
});
async function selectToolbarOption(page: Page, label: string, value: string) {
const control = page.getByRole("combobox", { name: label, exact: true });
await control.click();
const popup = page.locator(
`[id="${await control.getAttribute("aria-controls")}"]`,
);
await popup
.getByRole("option")
.filter({ hasText: new RegExp(`^${value}$`) })
.click();
await expect(control).toContainText(value);
await expect(popup).not.toBeVisible();
}
test("共用工具栏延迟应用筛选、保存列设置并发送服务端排序", async ({ page }) => {
await setup(page);
await sync(page, null);
await sync(page, "TEST_FIN");
await page.reload();
await expect(
page.getByRole("row").filter({ hasText: "TEST 财务报表" }),
).toBeVisible();
const requests: string[] = [];
page.on("request", (req) => {
if (
req.url().includes("/catalog/datasets?") ||
req.url().includes("/catalog/fields?") ||
req.url().includes("/data-preparations?")
)
requests.push(req.url());
});
await page.getByRole("button", { name: "筛选数据目录", exact: true }).click();
const filter = page.getByRole("form", { name: "数据目录筛选条件" });
await filter.getByLabel("搜索数据集").fill("TEST_FIN");
expect(requests.some((url) => url.includes("q=TEST_FIN"))).toBe(false);
await filter.getByRole("button", { name: "查询", exact: true }).click();
await expect
.poll(() =>
requests.some((url) => new URL(url).searchParams.get("q") === "TEST_FIN"),
)
.toBe(true);
await page.getByRole("button", { name: "显示列设置", exact: true }).click();
await page
.locator(".catalog-column-panel .semi-checkbox")
.filter({ hasText: "价值评分" })
.click();
await expect(
page.getByRole("checkbox", { name: "价值评分", exact: true }),
).not.toBeChecked();
await page.keyboard.press("Escape");
await expect(
page.getByRole("columnheader", { name: "价值评分", exact: true }),
).toHaveCount(0);
await page.reload();
await expect(
page.getByRole("row").filter({ hasText: "TEST 财务报表" }),
).toBeVisible();
await expect(
page.getByRole("columnheader", { name: "价值评分", exact: true }),
).toHaveCount(0);
await page.getByRole("button", { name: "排序设置", exact: true }).click();
await selectToolbarOption(page, "排序字段", "字段数");
await selectToolbarOption(page, "排序方向", "降序");
await expect
.poll(() =>
requests.some(
(url) =>
url.includes("sort=field_count") && url.includes("direction=desc"),
),
)
.toBe(true);
await page.screenshot({ path: "test-results/catalog-sort-popover.png" });
await page.keyboard.press("Escape");
await page
.getByRole("navigation", { name: "主导航" })
.getByRole("button", { name: "字段目录", exact: true })
.click();
const local = page.getByRole("tabpanel", { name: "本地同步" });
await expect(local.getByText("TEST_FIN_001", { exact: true })).toBeVisible();
await local.locator(".semi-page-item").filter({ hasText: /^2$/ }).click();
await expect
.poll(() =>
requests.some(
(url) => url.includes("/catalog/fields?") && url.includes("offset=25"),
),
)
.toBe(true);
await local.getByRole("button", { name: "排序设置", exact: true }).click();
await selectToolbarOption(page, "排序方向", "降序");
await expect
.poll(() =>
requests.some(
(url) =>
url.includes("/catalog/fields?") &&
url.includes("direction=desc") &&
url.includes("offset=0"),
),
)
.toBe(true);
await page.keyboard.press("Escape");
await page.getByRole("tab", { name: "worldquant接口", exact: true }).click();
await expect(
page
.getByRole("tabpanel", { name: "worldquant接口" })
.getByRole("button", { name: "排序设置", exact: true }),
).toBeDisabled();
await page
.getByRole("navigation", { name: "主导航" })
.getByRole("button", { name: "数据准备", exact: true })
.click();
await page.getByRole("button", { name: "筛选数据准备", exact: true }).click();
await page.getByLabel("搜索准备集合").fill("toolbar-preparation");
await page
.locator(".catalog-filter-panel .semi-checkbox")
.filter({ hasText: "按范围筛选" })
.click();
await page.getByRole("button", { name: "更改组合", exact: true }).click();
await selectToolbarOption(page, "Region", "USA");
await page.getByRole("button", { name: "应用组合", exact: true }).click();
await expect(
page.getByRole("form", { name: "数据准备筛选条件" }),
).toBeVisible();
expect(requests.some((url) => url.includes("q=toolbar-preparation"))).toBe(
false,
);
await page.screenshot({
path: "test-results/preparation-filter-popover.png",
});
await page.getByRole("button", { name: "查询", exact: true }).click();
await expect
.poll(() => requests.some((url) => url.includes("q=toolbar-preparation")))
.toBe(true);
await page.getByRole("button", { name: "排序设置", exact: true }).click();
await selectToolbarOption(page, "排序字段", "集合名称");
await expect
.poll(() =>
requests.some(
(url) =>
url.includes("/data-preparations?") && url.includes("sort=name"),
),
)
.toBe(true);
});