fix: allow repeated platform checks and unify Alpha metric formatting
Deploy production / deploy (push) Successful in 54s
Deploy production / deploy (push) Successful in 54s
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import type { Job } from "../src/types";
|
||||
|
||||
test("platform check can repeat after its own description writeback", async ({
|
||||
page,
|
||||
}) => {
|
||||
let snapshot = "a".repeat(64);
|
||||
let descriptions = { regular: "" };
|
||||
let job: Job | null = null;
|
||||
const submitted: string[] = [];
|
||||
await page.route(/\/api\/v1\/sync-jobs$/, (route) =>
|
||||
route.fulfill({ json: job ? [job] : [] }),
|
||||
);
|
||||
await page.route(/\/api\/v1\/alphas\/[^/]+\/submission$/, (route) =>
|
||||
route.fulfill({
|
||||
json: {
|
||||
snapshot,
|
||||
descriptions,
|
||||
sections: {
|
||||
regular: { code: "rank(close)", description: descriptions.regular },
|
||||
},
|
||||
model: "test-model",
|
||||
can_generate: true,
|
||||
can_check: true,
|
||||
job,
|
||||
},
|
||||
}),
|
||||
);
|
||||
await page.route(
|
||||
/\/api\/v1\/alphas\/[^/]+\/submission-check$/,
|
||||
async (route) => {
|
||||
const body = route.request().postDataJSON();
|
||||
expect(body.snapshot).toBe(snapshot);
|
||||
submitted.push(body.snapshot);
|
||||
descriptions = body.descriptions;
|
||||
snapshot = String(submitted.length).repeat(64);
|
||||
job = {
|
||||
id: `repeat-${submitted.length}`,
|
||||
kind: "submission_check",
|
||||
status: "completed",
|
||||
processed: 1,
|
||||
failed: 0,
|
||||
total: 1,
|
||||
error: null,
|
||||
next_retry_at: null,
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
payload: {},
|
||||
checkpoint: { phase: "checked", review_snapshot: snapshot },
|
||||
};
|
||||
await route.fulfill({ status: 202, json: { ...job, status: "queued" } });
|
||||
},
|
||||
);
|
||||
await page.goto("/#alphas");
|
||||
await page.getByLabel("密码", { exact: true }).fill("browser-test-password");
|
||||
await page.getByRole("button", { name: "进入工作空间" }).click();
|
||||
await expect(
|
||||
page.getByRole("tab", { name: "待提交", exact: true }),
|
||||
).toBeVisible();
|
||||
const headers = { "X-WQ-Request": "1" };
|
||||
await page.request.put("/api/v1/account/credentials", {
|
||||
headers,
|
||||
data: { email: "test@example.com", password: "synthetic-password" },
|
||||
});
|
||||
await page.request.post("/api/v1/account/connect", { headers });
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(await (await page.request.get("/api/v1/account")).json())
|
||||
.connection_status,
|
||||
)
|
||||
.toBe("connected");
|
||||
const imported = await (
|
||||
await page.request.post("/api/v1/sync-jobs", {
|
||||
headers,
|
||||
data: { kind: "alpha_refresh", alpha_ids: ["TEST0004"] },
|
||||
})
|
||||
).json();
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
(
|
||||
await (
|
||||
await page.request.get(`/api/v1/sync-jobs/${imported.id}`)
|
||||
).json()
|
||||
).status,
|
||||
)
|
||||
.toBe("completed");
|
||||
await page.reload();
|
||||
await page.locator(".alpha-link").first().click();
|
||||
const sheet = page.locator(".alpha-detail");
|
||||
await sheet.getByRole("tab", { name: "相关性检查", exact: true }).click();
|
||||
const load = sheet.getByRole("button", { name: "载入最新描述", exact: true });
|
||||
const generate = sheet.getByRole("button", {
|
||||
name: "AI 生成 Description",
|
||||
exact: true,
|
||||
});
|
||||
await expect(load).toBeVisible();
|
||||
expect((await load.boundingBox())!.x).toBeLessThan(
|
||||
(await generate.boundingBox())!.x,
|
||||
);
|
||||
const draft = sheet.getByRole("textbox", {
|
||||
name: "regular Description",
|
||||
exact: true,
|
||||
});
|
||||
await draft.fill("A reviewed description for repeat checking.");
|
||||
const check = sheet.getByRole("button", { name: "平台检查", exact: true });
|
||||
for (let i = 1; i <= 2; i++) {
|
||||
await expect(check).toBeEnabled();
|
||||
await check.click();
|
||||
await expect.poll(() => submitted.length).toBe(i);
|
||||
await expect(page.locator(".job-panel")).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.locator(".job-panel")).not.toBeVisible();
|
||||
await expect(check).toBeEnabled();
|
||||
await expect(draft).toHaveValue(
|
||||
"A reviewed description for repeat checking.",
|
||||
);
|
||||
}
|
||||
expect(submitted).toEqual(["a".repeat(64), "1".repeat(64)]);
|
||||
});
|
||||
Reference in New Issue
Block a user