返回 DeepSeek-Reasonix
trash-lifecycle.mjs
根目录 / desktop / frontend / bench / trash-lifecycle.mjs
1 // Run against a local Vite server. The real React surface uses a deterministic
2 // host fixture; Go tests separately exercise the same RPC admission invariants.
3 import assert from "node:assert/strict";
4 import { chromium } from "playwright";
5 const browser = await chromium.launch({ headless: true });
6 try {
7 const page = await browser.newPage();
8 const openDelete = async () => {
9 await page.locator(".archived-sessions__open").click();
10 await page.getByRole("button", { name: "Conversation actions" }).click();
11 await page.getByRole("menuitem", { name: "Permanently delete" }).click();
12 };
13 const errors = [];
14 page.on("pageerror", error => errors.push(error.message));
15 const url = process.env.REASONIX_TRASH_BROWSER_URL || "http://127.0.0.1:4771/bench/trash-lifecycle.html";
16 await page.goto(url);
17 await openDelete();
18 await page.getByRole("dialog").waitFor();
19 await page.evaluate(() => window.trashFixture.changeTarget());
20 await page.getByRole("button", { name: "Permanently delete", exact: true }).click();
21 await page.getByRole("alert").filter({ hasText: "changed state" }).waitFor();
22 assert.equal(await page.evaluate(() => window.trashFixture.requests[0].expectedGeneration), 7);
23 assert.equal(await page.getByRole("button", { name: "Retry failed items" }).count(), 0);
24
25 await page.reload();
26 await page.locator(".archived-sessions__open").click();
27 await page.evaluate(() => window.trashFixture.invalidatePreview());
28 await page.locator(".archived-sessions__preview").waitFor({ state: "detached" });
29 await page.evaluate(() => window.trashFixture.finishPreview());
30 assert.equal(await page.getByText("late fixture history").count(), 0);
31
32 await page.reload();
33 await openDelete();
34 await page.evaluate(() => { window.trashFixture.changeOther(); window.trashFixture.loseResult(); });
35 await page.getByRole("button", { name: "Permanently delete", exact: true }).click();
36 await page.getByRole("button", { name: "Retry failed items" }).waitFor();
37 await page.evaluate(() => window.trashFixture.changeOther());
38 await page.getByRole("button", { name: "Retry failed items" }).click();
39 await page.waitForFunction(() => window.trashFixture.requests.length === 2);
40 const requests = await page.evaluate(() => window.trashFixture.requests);
41 assert.deepEqual(requests[0], requests[1]);
42 assert.equal(requests[1].expectedGeneration, 7);
43 await page.waitForFunction(() => document.querySelector('[role="status"]')?.textContent?.includes("1"));
44 assert.deepEqual(errors, []);
45 console.log("PASS Chromium confirmation snapshot, conflict guidance, preview invalidation, unchanged retry after refresh");
46 } finally { await browser.close(); }
47
47 lines Plain Text