refactor: unify data preparations and research input snapshots
Deploy production / deploy (push) Successful in 53s
Deploy production / deploy (push) Successful in 53s
This commit is contained in:
+105
-248
@@ -1,14 +1,12 @@
|
||||
import { test, expect, type Page } from "@playwright/test";
|
||||
import { choosePreparation } from "./preparation-helpers";
|
||||
const headers = { "X-WQ-Request": "1" };
|
||||
const scope = {
|
||||
instrument_type: "EQUITY",
|
||||
region: "USA",
|
||||
universe: "TOP3000",
|
||||
delay: 1,
|
||||
};
|
||||
const query = new URLSearchParams(
|
||||
Object.entries(scope).map(([k, v]) => [k, String(v)]),
|
||||
).toString();
|
||||
const headers = { "X-WQ-Request": "1" };
|
||||
async function setup(page: Page) {
|
||||
await page.goto("/#datasets");
|
||||
await page.getByLabel("密码", { exact: true }).fill("browser-test-password");
|
||||
@@ -20,273 +18,132 @@ async function setup(page: Page) {
|
||||
headers,
|
||||
data: { email: "test@example.com", password: "synthetic-only" },
|
||||
});
|
||||
const connect = await (
|
||||
const job = await (
|
||||
await page.request.post("/api/v1/account/connect", { headers })
|
||||
).json();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(
|
||||
await (
|
||||
await page.request.get(`/api/v1/sync-jobs/${connect.id}`)
|
||||
).json()
|
||||
).status,
|
||||
(await (await page.request.get(`/api/v1/sync-jobs/${job.id}`)).json())
|
||||
.status,
|
||||
)
|
||||
.toBe("completed");
|
||||
await page.getByRole("button", { name: "同步目录", exact: true }).click();
|
||||
await page.reload();
|
||||
}
|
||||
async function sync(page: Page, dataset_id: string | null) {
|
||||
const job = await (
|
||||
await page.request.post("/api/v1/catalog/sync-jobs", {
|
||||
headers,
|
||||
data: { scope, dataset_id },
|
||||
})
|
||||
).json();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(await (await page.request.get(`/api/v1/sync-jobs/${job.id}`)).json())
|
||||
.status,
|
||||
)
|
||||
.toBe("completed");
|
||||
}
|
||||
test("数据集完整同步、使用、集合编辑与研究选择", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await setup(page);
|
||||
await sync(page, null);
|
||||
await page.reload();
|
||||
const row = page.getByRole("row").filter({ hasText: "TEST 财务报表" });
|
||||
await expect(
|
||||
row.getByRole("button", { name: "使用", exact: true }),
|
||||
).toBeDisabled();
|
||||
await row.getByRole("button", { name: "同步", exact: true }).click();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(
|
||||
await (
|
||||
await page.request.get(`/api/v1/catalog/datasets?${query}`)
|
||||
await page.request.get(
|
||||
"/api/v1/catalog/datasets/TEST_FIN?region=USA&universe=TOP3000&delay=1",
|
||||
)
|
||||
).json()
|
||||
).total,
|
||||
).complete_count,
|
||||
)
|
||||
.toBe(3);
|
||||
.toBe(123);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "TEST 财务报表", exact: true }),
|
||||
).toBeVisible();
|
||||
}
|
||||
async function openFields(page: Page) {
|
||||
await page
|
||||
.getByRole("row")
|
||||
.filter({ hasText: "TEST 财务报表" })
|
||||
.getByRole("button", { name: "查看字段", exact: true })
|
||||
.click();
|
||||
const sync = page
|
||||
.getByRole("dialog", { name: "数据字段", exact: true })
|
||||
.getByRole("button", { name: "同步全部字段", exact: true });
|
||||
if (await sync.isVisible()) {
|
||||
await sync.click();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(
|
||||
await (
|
||||
await page.request.get(
|
||||
`/api/v1/catalog/datasets/TEST_FIN/fields?${query}`,
|
||||
)
|
||||
).json()
|
||||
).complete_count,
|
||||
)
|
||||
.toBe(123);
|
||||
await page.keyboard.press("Escape");
|
||||
}
|
||||
}
|
||||
|
||||
test("目录筛选、双层详情、完整输入、排除、备注与刷新", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await setup(page);
|
||||
await page.getByLabel("分类", { exact: true }).click();
|
||||
await page.getByRole("option", { name: /基本面/ }).click();
|
||||
await page.getByLabel("子分类", { exact: true }).click();
|
||||
await page.getByRole("option", { name: /财务报表/ }).click();
|
||||
await openFields(page);
|
||||
const fields = page.getByRole("dialog", { name: "数据字段", exact: true });
|
||||
await expect(fields).toBeVisible();
|
||||
await expect(fields).toContainText("全部 123 个字段");
|
||||
expect((await fields.boundingBox())!.width).toBeCloseTo(864, 0);
|
||||
await page.getByLabel("搜索字段").fill("字段 12");
|
||||
await expect(fields.getByRole("button", { name: /TEST 字段/ })).toHaveCount(
|
||||
3,
|
||||
);
|
||||
await page
|
||||
.getByRole("button", { name: "TEST 字段 122", exact: true })
|
||||
.click();
|
||||
const detail = page.getByRole("dialog", { name: "字段详情", exact: true });
|
||||
await expect(detail).toContainText("FUTURE_TYPE");
|
||||
expect((await detail.boundingBox())!.width).toBeCloseTo(864, 0);
|
||||
await page.getByLabel("研究备注", { exact: true }).fill("保留字段研究假设");
|
||||
await page.getByRole("button", { name: "保存备注", exact: true }).click();
|
||||
await expect(page.getByText("研究备注已保存")).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(detail).not.toBeVisible();
|
||||
await expect(page.getByLabel("搜索字段")).toHaveValue("字段 12");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "TEST 字段 122", exact: true }),
|
||||
).toBeFocused();
|
||||
await page
|
||||
.getByRole("button", { name: "用于 Alpha 模板", exact: true })
|
||||
.click();
|
||||
await page.getByRole("button", { name: "保存输入草稿", exact: true }).click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "输入草稿已保存" }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
(
|
||||
await (await page.request.get(`/api/v1/catalog/inputs?${query}`)).json()
|
||||
)[0].field_ids,
|
||||
).toHaveLength(123);
|
||||
await page.keyboard.press("Escape");
|
||||
await page
|
||||
.getByRole("checkbox", { name: "选择TEST 字段 122", exact: true })
|
||||
.press("Space");
|
||||
await page.getByRole("button", { name: "覆盖率排序" }).click();
|
||||
await expect(fields).toContainText("122 / 123 个字段");
|
||||
await page
|
||||
.getByRole("button", { name: "用于 Alpha 模板", exact: true })
|
||||
.click();
|
||||
await page.getByRole("button", { name: "保存输入草稿", exact: true }).click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "输入草稿已保存" }),
|
||||
).toBeVisible();
|
||||
const subset = (
|
||||
await (await page.request.get(`/api/v1/catalog/inputs?${query}`)).json()
|
||||
)[0];
|
||||
expect(subset.field_ids).toHaveLength(122);
|
||||
expect(subset.field_ids).not.toContain("TEST_FIN_122");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.getByRole("button", { name: "恢复全选" }).click();
|
||||
await page
|
||||
.getByRole("checkbox", { name: "选择本数据集全部字段" })
|
||||
.press("Space");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "用于 Alpha 模板", exact: true }),
|
||||
).toBeDisabled();
|
||||
await page.getByRole("button", { name: "恢复全选" }).click();
|
||||
await page
|
||||
.getByRole("button", { name: "TEST 字段 122", exact: true })
|
||||
.click();
|
||||
await expect(page.getByLabel("研究备注", { exact: true })).toHaveValue(
|
||||
"保留字段研究假设",
|
||||
);
|
||||
await page.screenshot({ path: "../output/playwright/dataset-desktop.png" });
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByLabel("分类", { exact: true })).toContainText(
|
||||
"基本面",
|
||||
);
|
||||
await page.reload();
|
||||
await row.getByRole("button", { name: "查看", exact: true }).click();
|
||||
const detail = page.getByRole("dialog", {
|
||||
name: "TEST 财务报表",
|
||||
exact: true,
|
||||
});
|
||||
await expect(detail).toContainText("TEST_FIN_001");
|
||||
await detail.getByLabel("研究备注").fill("验证备注");
|
||||
await detail.getByRole("button", { name: "保存备注", exact: true }).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await row.getByRole("button", { name: "使用", exact: true }).click();
|
||||
await page.getByRole("link", { name: "打开数据准备" }).click();
|
||||
const prep = page.getByRole("dialog", { name: "数据准备详情", exact: true });
|
||||
await expect(prep).toContainText("123 字段 / 1 数据集");
|
||||
await prep.getByLabel("集合名称", { exact: true }).fill("浏览器准备集合");
|
||||
await prep.getByRole("button", { name: "保存名称和备注" }).click();
|
||||
await expect(prep).toContainText("v2");
|
||||
await prep
|
||||
.getByRole("row")
|
||||
.filter({ hasText: "TEST_FIN_000" })
|
||||
.locator("span.semi-checkbox")
|
||||
.click();
|
||||
await prep.getByRole("button", { name: "移除所选字段" }).click();
|
||||
await expect(prep).toContainText("122 字段");
|
||||
await page.keyboard.press("Escape");
|
||||
await page
|
||||
.getByRole("navigation", { name: "主导航" })
|
||||
.getByRole("button", { name: "特征工程", exact: true })
|
||||
.click();
|
||||
await page.getByRole("button", { name: "新建特征方案", exact: true }).click();
|
||||
await choosePreparation(page, "浏览器准备集合", "选择特征数据准备");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "已保存输入 (2)" }),
|
||||
page.locator("p").filter({ hasText: /浏览器准备集合 ·.*122 字段/ }),
|
||||
).toBeVisible();
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test("窄屏抽屉、键盘隔离和研究范围切换", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
test("在线字段跨页多选直接准备,本地只展示完整同步字段", async ({ page }) => {
|
||||
await setup(page);
|
||||
await openFields(page);
|
||||
const fields = page.getByRole("dialog", { name: "数据字段", exact: true });
|
||||
await expect(fields).toBeVisible();
|
||||
expect((await fields.boundingBox())!.width).toBeCloseTo(234, 0);
|
||||
await page
|
||||
.getByRole("button", { name: "TEST 字段 000", exact: true })
|
||||
.getByRole("navigation", { name: "主导航" })
|
||||
.getByRole("button", { name: "字段目录", exact: true })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByRole("dialog", { name: "字段详情", exact: true }),
|
||||
).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(fields).toBeVisible();
|
||||
expect(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
).toBe(true);
|
||||
await page.screenshot({ path: "../output/playwright/dataset-mobile.png" });
|
||||
await page.keyboard.press("Escape");
|
||||
await page.getByLabel("Region", { exact: true }).click();
|
||||
await page.getByRole("option", { name: /CHN/ }).click();
|
||||
await expect(page.getByLabel("Universe", { exact: true })).toContainText(
|
||||
"TOP2000",
|
||||
);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "用于 Alpha 模板", exact: true }),
|
||||
).toBeDisabled();
|
||||
});
|
||||
|
||||
test("非首页排除、聊天暂存详情、遮罩逐层关闭和多尺寸", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await setup(page);
|
||||
await openFields(page);
|
||||
const fields = page.getByRole("dialog", { name: "数据字段", exact: true });
|
||||
await fields.getByRole("button", { name: "Next", exact: true }).click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "TEST 字段 025", exact: true }),
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByRole("checkbox", { name: "选择TEST 字段 025", exact: true })
|
||||
.press("Space");
|
||||
await page.getByLabel("搜索字段").fill("字段 12");
|
||||
await expect(fields).toContainText("122 / 123 个字段");
|
||||
await page.getByLabel("字段类型", { exact: true }).click();
|
||||
await page.getByRole("option", { name: /VECTOR/ }).click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "TEST 字段 120", exact: true }),
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByRole("button", { name: "TEST 字段 120", exact: true })
|
||||
const online = page.getByRole("tabpanel", { name: "worldquant接口" });
|
||||
await expect(online.getByText("TEST_FIN_001", { exact: true })).toBeVisible();
|
||||
await online
|
||||
.getByRole("row")
|
||||
.filter({ hasText: "TEST_FIN_001" })
|
||||
.locator("span.semi-checkbox")
|
||||
.click();
|
||||
await page.getByLabel("研究备注", { exact: true }).fill("未保存草稿需要恢复");
|
||||
await page
|
||||
.getByRole("dialog", { name: "字段详情", exact: true })
|
||||
.getByRole("button", { name: "AI 助手", exact: true })
|
||||
await online.locator(".semi-page-item").filter({ hasText: /^2$/ }).click();
|
||||
await online
|
||||
.getByRole("row")
|
||||
.filter({ hasText: "TEST_FIN_025" })
|
||||
.locator("span.semi-checkbox")
|
||||
.click();
|
||||
await expect(fields).not.toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByLabel("研究备注", { exact: true })).toHaveValue(
|
||||
"未保存草稿需要恢复",
|
||||
);
|
||||
for (const width of [850, 390, 1920]) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await expect(
|
||||
page.getByRole("button", { name: "关闭详情", exact: true }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await page.mouse.click(10, 400);
|
||||
await expect(
|
||||
page.getByRole("dialog", { name: "字段详情", exact: true }),
|
||||
).not.toBeVisible();
|
||||
await expect(fields).toBeVisible();
|
||||
await expect(fields).toContainText("122 / 123 个字段");
|
||||
await page.mouse.click(10, 400);
|
||||
await expect(fields).not.toBeVisible();
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test("平台选项失败可重试,地区联动限制 Delay 和 Universe", async ({ page }) => {
|
||||
await setup(page);
|
||||
await page.getByLabel("Delay", { exact: true }).click();
|
||||
await page.getByRole("option", { name: /Delay 0/ }).click();
|
||||
await page.getByLabel("Region", { exact: true }).click();
|
||||
await page.getByRole("option", { name: /IND/ }).click();
|
||||
await expect(page.getByLabel("Universe", { exact: true })).toContainText(
|
||||
"TOP500",
|
||||
);
|
||||
await expect(page.getByLabel("Delay", { exact: true })).toContainText(
|
||||
"Delay 1",
|
||||
);
|
||||
await page.getByLabel("Delay", { exact: true }).click();
|
||||
await expect(page.getByRole("option", { name: /Delay 0/ })).toHaveCount(0);
|
||||
await page.keyboard.press("Escape");
|
||||
await page.route("**/api/v1/catalog/scopes", (route) =>
|
||||
route.fulfill({
|
||||
status: 502,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ detail: "测试平台选项不可用" }),
|
||||
}),
|
||||
);
|
||||
await page.getByRole("button", { name: "Alpha 管理", exact: true }).click();
|
||||
await page.getByRole("button", { name: "数据目录", exact: true }).click();
|
||||
await expect(page.getByText("测试平台选项不可用")).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "同步目录", exact: true }),
|
||||
).toBeDisabled();
|
||||
await page.unroute("**/api/v1/catalog/scopes");
|
||||
await page.getByRole("button", { name: "重试获取选项" }).click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "同步目录", exact: true }),
|
||||
).toBeEnabled();
|
||||
await expect(online.getByText(/已选 2 个字段/)).toBeVisible();
|
||||
await online
|
||||
.getByRole("button", { name: "加入数据准备", exact: true })
|
||||
.click();
|
||||
const add = page.getByRole("dialog", { name: "加入数据准备", exact: true });
|
||||
await add.getByLabel("新集合名称").fill("在线选取集合");
|
||||
await add.getByRole("button", { name: "新建集合并加入" }).click();
|
||||
await expect(add).not.toBeVisible();
|
||||
const collections = await (
|
||||
await page.request.get("/api/v1/data-preparations?q=在线选取集合")
|
||||
).json();
|
||||
expect(collections.items[0].field_count).toBe(2);
|
||||
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 expect(local.getByText("共 0 个字段", { exact: true })).toBeVisible();
|
||||
await page.screenshot({
|
||||
path: "test-results/preparations-fields.png",
|
||||
fullPage: true,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
export async function choosePreparation(
|
||||
page: Page,
|
||||
name: string,
|
||||
label = "选择研究数据准备",
|
||||
) {
|
||||
await page.getByRole("button", { name: label, exact: true }).click();
|
||||
const picker = page.getByRole("dialog", {
|
||||
name: "选择数据准备集合",
|
||||
exact: true,
|
||||
});
|
||||
await picker.getByLabel("搜索数据准备集合").fill(name);
|
||||
await picker
|
||||
.getByRole("row")
|
||||
.filter({ hasText: name })
|
||||
.first()
|
||||
.locator("span.semi-checkbox")
|
||||
.click();
|
||||
await picker.getByRole("button", { name: "选择", exact: true }).click();
|
||||
await expect(picker).not.toBeVisible();
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { choosePreparation } from "./preparation-helpers";
|
||||
import { expect, test } from "@playwright/test";
|
||||
const headers = { "X-WQ-Request": "1" };
|
||||
const scope = {
|
||||
@@ -71,13 +72,12 @@ test("native QuantFlow canvas saves versions, branches and restores artifacts",
|
||||
await page.request.get(`/api/v1/catalog/datasets/TEST_FIN/fields?${params}`)
|
||||
).json();
|
||||
const fixed = await (
|
||||
await page.request.post("/api/v1/catalog/inputs", {
|
||||
await page.request.post("/api/v1/data-preparations/from-dataset", {
|
||||
headers,
|
||||
data: {
|
||||
scope,
|
||||
dataset_id: "TEST_FIN",
|
||||
collection_version: fields.collection_version,
|
||||
selection: "all",
|
||||
},
|
||||
})
|
||||
).json();
|
||||
@@ -175,11 +175,7 @@ test("native QuantFlow canvas saves versions, branches and restores artifacts",
|
||||
.getByRole("button", { name: "启动已保存流程", exact: true })
|
||||
.click();
|
||||
await page.getByLabel("自动研究假设").fill("画布条件分支与固定版本");
|
||||
await page.getByRole("combobox", { name: "自动研究固定输入" }).click();
|
||||
await page
|
||||
.getByRole("option")
|
||||
.filter({ hasText: fixed.id.slice(0, 8) })
|
||||
.click();
|
||||
await choosePreparation(page, fixed.name, "选择研究数据准备");
|
||||
await page.getByLabel("自动研究假设").click();
|
||||
for (const [label, value] of [
|
||||
["最大轮数", "1"],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { choosePreparation } from "./preparation-helpers";
|
||||
import { expect, test } from "@playwright/test";
|
||||
const headers = { "X-WQ-Request": "1" };
|
||||
const scope = {
|
||||
@@ -71,13 +72,12 @@ test("finite pipeline confirms scope and budget, executes native steps and resto
|
||||
await page.request.get(`/api/v1/catalog/datasets/TEST_FIN/fields?${params}`)
|
||||
).json();
|
||||
const fixed = await (
|
||||
await page.request.post("/api/v1/catalog/inputs", {
|
||||
await page.request.post("/api/v1/data-preparations/from-dataset", {
|
||||
headers,
|
||||
data: {
|
||||
scope,
|
||||
dataset_id: "TEST_FIN",
|
||||
collection_version: fields.collection_version,
|
||||
selection: "all",
|
||||
},
|
||||
})
|
||||
).json();
|
||||
@@ -97,11 +97,7 @@ test("finite pipeline confirms scope and budget, executes native steps and resto
|
||||
await page.getByRole("button", { name: "新建自动研究", exact: true }).click();
|
||||
await page.getByLabel("自动研究名称").fill("浏览器有限研究");
|
||||
await page.getByLabel("自动研究假设").fill("研究排名稳定性");
|
||||
await page.getByRole("combobox", { name: "自动研究固定输入" }).click();
|
||||
await page
|
||||
.getByRole("option")
|
||||
.filter({ hasText: fixed.id.slice(0, 8) })
|
||||
.click();
|
||||
await choosePreparation(page, fixed.name, "选择研究数据准备");
|
||||
await page.getByLabel("自动研究名称").click();
|
||||
for (const [label, value] of [
|
||||
["最大轮数", "1"],
|
||||
|
||||
@@ -68,17 +68,27 @@ test("fixed input, AI approval, backtest and research source remain connected",
|
||||
const fields = await (
|
||||
await page.request.get(`/api/v1/catalog/datasets/TEST_FIN/fields?${params}`)
|
||||
).json();
|
||||
const saved = await page.request.post("/api/v1/catalog/inputs", {
|
||||
headers,
|
||||
data: {
|
||||
scope,
|
||||
dataset_id: "TEST_FIN",
|
||||
collection_version: fields.collection_version,
|
||||
selection: "all",
|
||||
const saved = await page.request.post(
|
||||
"/api/v1/data-preparations/from-dataset",
|
||||
{
|
||||
headers,
|
||||
data: {
|
||||
scope,
|
||||
dataset_id: "TEST_FIN",
|
||||
collection_version: fields.collection_version,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
expect(saved.status()).toBe(201);
|
||||
const input = await saved.json();
|
||||
const preparation = await saved.json();
|
||||
const input = (
|
||||
await (
|
||||
await page.request.post("/api/v1/data-preparations/freeze", {
|
||||
headers,
|
||||
data: { items: [{ id: preparation.id, version: preparation.version }] },
|
||||
})
|
||||
).json()
|
||||
).items[0];
|
||||
const conversation = await (
|
||||
await page.request.post("/api/v1/ai/conversations", { headers })
|
||||
).json();
|
||||
@@ -96,7 +106,7 @@ test("fixed input, AI approval, backtest and research source remain connected",
|
||||
page: "datasets",
|
||||
catalog_scope: scope,
|
||||
dataset_id: "TEST_FIN",
|
||||
template_input_id: input.id,
|
||||
input_snapshot_id: input.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -130,17 +140,10 @@ test("fixed input, AI approval, backtest and research source remain connected",
|
||||
.click();
|
||||
await expect(chat).not.toBeVisible();
|
||||
const inputSheet = page.getByRole("dialog", {
|
||||
name: "模板输入草稿",
|
||||
name: "研究输入快照",
|
||||
exact: true,
|
||||
});
|
||||
await expect(
|
||||
inputSheet.getByRole("heading", { name: "输入草稿已保存", exact: true }),
|
||||
).toBeVisible();
|
||||
await inputSheet
|
||||
.getByRole("button", { name: "用此输入研究", exact: true })
|
||||
.click();
|
||||
await expect(
|
||||
chat.locator(".research-ai-reference").filter({ hasText: "固定输入" }),
|
||||
).toContainText(input.id);
|
||||
await expect(inputSheet).toContainText("TEST_FIN_001");
|
||||
await expect(inputSheet).toContainText("TEST_FIN");
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { choosePreparation } from "./preparation-helpers";
|
||||
import { expect, test } from "@playwright/test";
|
||||
const headers = { "X-WQ-Request": "1" };
|
||||
const scope = {
|
||||
@@ -50,13 +51,12 @@ test("feature conversion, saved views and immutable evaluations", async ({
|
||||
await page.request.get(`/api/v1/catalog/datasets/TEST_FIN/fields?${params}`)
|
||||
).json();
|
||||
const fixed = await (
|
||||
await page.request.post("/api/v1/catalog/inputs", {
|
||||
await page.request.post("/api/v1/data-preparations/from-dataset", {
|
||||
headers,
|
||||
data: {
|
||||
scope,
|
||||
dataset_id: "TEST_FIN",
|
||||
collection_version: fields.collection_version,
|
||||
selection: "all",
|
||||
},
|
||||
})
|
||||
).json();
|
||||
@@ -67,11 +67,7 @@ test("feature conversion, saved views and immutable evaluations", async ({
|
||||
await page
|
||||
.getByLabel("特征经济假设", { exact: true })
|
||||
.fill("排名可降低异常值影响");
|
||||
await page.getByRole("combobox", { name: "特征固定输入" }).click();
|
||||
await page
|
||||
.getByRole("option")
|
||||
.filter({ hasText: fixed.id.slice(0, 8) })
|
||||
.click();
|
||||
await choosePreparation(page, fixed.name, "选择特征数据准备");
|
||||
await page.getByLabel("特征方案名称", { exact: true }).click();
|
||||
await page.getByRole("button", { name: "添加处理步骤" }).click();
|
||||
await page.getByLabel("步骤 1 名称").fill("横截面排名");
|
||||
@@ -95,9 +91,12 @@ test("feature conversion, saved views and immutable evaluations", async ({
|
||||
"/api/v1/research/assets?kind=template&q=特征转换模板",
|
||||
)
|
||||
).json();
|
||||
expect(templates.items[0].provenance.feature.content.input_ids).toEqual([
|
||||
fixed.id,
|
||||
]);
|
||||
const snapshot = await (
|
||||
await page.request.get(
|
||||
`/api/v1/research/input-snapshots/${templates.items[0].provenance.feature.content.input_ids[0]}`,
|
||||
)
|
||||
).json();
|
||||
expect(snapshot.preparation_id).toBe(fixed.id);
|
||||
await page.keyboard.press("Escape");
|
||||
await page.getByRole("button", { name: "Alpha 管理", exact: true }).click();
|
||||
await page.getByRole("button", { name: "保存为新视图" }).click();
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import { choosePreparation } from "./preparation-helpers";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// UI contract fixtures: no external model call or simulation is started by these tests.
|
||||
const fixed = {
|
||||
id: "semi-fixed-input",
|
||||
dataset_id: "TEST_FIN",
|
||||
name: "Semi 准备集合",
|
||||
note: "",
|
||||
version: 1,
|
||||
field_count: 1,
|
||||
dataset_count: 1,
|
||||
dataset_ids: ["TEST_FIN"],
|
||||
fields: [],
|
||||
preparation_ref: { id: "semi-fixed-input", version: 1 },
|
||||
field_ids: ["TEST_FIN_001"],
|
||||
field_types: { TEST_FIN_001: "MATRIX" },
|
||||
collection_version: "fixed-v1",
|
||||
@@ -20,8 +28,19 @@ for (const mode of ["templates", "variants", "features"] as const) {
|
||||
}) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
await page.route("**/api/v1/research/inputs", (route) =>
|
||||
route.fulfill({ json: { items: [fixed] } }),
|
||||
await page.route("**/api/v1/data-preparations?*", (route) =>
|
||||
route.fulfill({
|
||||
json: { items: [fixed], total: 1, limit: 25, offset: 0 },
|
||||
}),
|
||||
);
|
||||
await page.route(
|
||||
"**/api/v1/data-preparations/semi-fixed-input/selection?*",
|
||||
(route) => route.fulfill({ json: fixed }),
|
||||
);
|
||||
await page.route(
|
||||
"**/api/v1/research/input-snapshots/semi-fixed-input",
|
||||
(route) =>
|
||||
route.fulfill({ json: { ...fixed, preparation_ref: undefined } }),
|
||||
);
|
||||
await page.route(
|
||||
"**/api/v1/research/assets/semi-generated/versions",
|
||||
@@ -49,23 +68,18 @@ for (const mode of ["templates", "variants", "features"] as const) {
|
||||
exact: true,
|
||||
});
|
||||
await expect(generate).toBeDisabled();
|
||||
await sheet
|
||||
.getByRole("combobox", {
|
||||
name: feature ? "特征固定输入" : "固定研究输入",
|
||||
exact: true,
|
||||
})
|
||||
.click();
|
||||
await page
|
||||
.getByRole("option")
|
||||
.filter({ hasText: fixed.id.slice(0, 8) })
|
||||
.click();
|
||||
await choosePreparation(
|
||||
page,
|
||||
fixed.name,
|
||||
feature ? "选择特征数据准备" : "选择数据准备",
|
||||
);
|
||||
await input.click();
|
||||
if (mode === "variants")
|
||||
await sheet.getByLabel("种子 Alpha", { exact: true }).fill("TEST0001");
|
||||
const hypothesis = "检验 <收益> 与规模\n第二轮保留原始假设";
|
||||
await input.fill(hypothesis);
|
||||
await expect(
|
||||
sheet.locator(".research-ai-reference").filter({ hasText: fixed.id }),
|
||||
sheet.locator("p").filter({ hasText: /Semi 准备集合 ·/ }),
|
||||
).toBeVisible();
|
||||
let release!: () => void;
|
||||
const pending = new Promise<void>((resolve) => {
|
||||
@@ -117,7 +131,8 @@ for (const mode of ["templates", "variants", "features"] as const) {
|
||||
.poll(() => requestBody)
|
||||
.toMatchObject({
|
||||
hypothesis,
|
||||
input_ids: [fixed.id],
|
||||
input_ids: [],
|
||||
preparation_refs: [fixed.preparation_ref],
|
||||
method: feature
|
||||
? "feature"
|
||||
: mode === "variants"
|
||||
|
||||
Reference in New Issue
Block a user