返回 DeepSeek-Reasonix
model-application.mjs
根目录 / desktop / frontend / bench / model-application.mjs
1 import assert from "node:assert/strict";
2 import path from "node:path";
3 import os from "node:os";
4 import { fileURLToPath } from "node:url";
5 import { createServer } from "vite";
6 const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
7 process.env.PLAYWRIGHT_BROWSERS_PATH = path.join(root, ".pw-browsers");
8 const { chromium } = await import("playwright");
9 const server = await createServer({ root, logLevel: "error", server: { host: "127.0.0.1", port: 0 } });
10 await server.listen();
11 const browser = await chromium.launch({ headless: true });
12 const page = await browser.newPage({ viewport: { width: 1000, height: 720 } });
13 const errors = [];
14 page.on("pageerror", error => errors.push(error.message));
15 try {
16 await page.goto(server.resolvedUrls.local[0] + "bench/model-application.html");
17 await page.getByRole("alert").waitFor();
18 assert.equal(await page.getByRole("textbox").inputValue(), "Keep my unsent message and attachment");
19 await page.getByRole("button", { name: /current settings/i }).click();
20 const choice = await page.evaluate(() => window.modelApplicationFixture.calls[0][0]);
21 assert.equal(choice.mode, "applied_once");
22 assert.equal(choice.expectedRuntimeIdentity, "runtime");
23 await page.getByRole("button", { name: /blocking jobs/i }).click();
24 await page.getByRole("checkbox").first().check();
25 await page.screenshot({ path: path.join(os.tmpdir(), "reasonix-model-application.png") });
26 await page.getByRole("button", { name: /stop selected/i }).click();
27 await page.getByRole("alert").waitFor({ state: "detached" });
28 const result = await page.evaluate(() => window.modelApplicationFixture);
29 assert.deepEqual(result.calls[1][2], ["task-1"]);
30 assert.equal(result.sends, 1, "applying settings must not resend the draft");
31 assert.equal(await page.getByRole("textbox").inputValue(), "Keep my unsent message and attachment");
32 assert.equal(await page.getByTestId("attachment").textContent(), "fixture.txt");
33 assert.deepEqual(errors, []);
34 console.log("PASS browser: one-submit choice, selected cancellation, preserved draft/attachment, no automatic resend");
35 } finally { await browser.close(); await server.close(); }
36
36 lines Plain Text