feat: 收口 Rust Web 3000 主链
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
const assert = require("node:assert");
|
||||
const { chromium } = require("playwright");
|
||||
const { fetchWithTimeout } = require("./task114-rust-web-gateway-entry-smoke.js");
|
||||
const { createTempDocument, ensureAuthenticated, openDocument } = require("./tree-shell-smoke-helpers");
|
||||
|
||||
const BASE_URL = (process.env.MNOTE_UI_BASE_URL || "http://127.0.0.1:3000").replace(/\/+$/, "");
|
||||
const UI_TIMEOUT_MS = Number(process.env.MNOTE_SMOKE_UI_TIMEOUT_MS || 30_000);
|
||||
@@ -36,13 +37,17 @@ async function main() {
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 960 } });
|
||||
const page = await context.newPage();
|
||||
let seed = null;
|
||||
let created = null;
|
||||
|
||||
try {
|
||||
const response = await page.goto(`${BASE_URL}/`, { waitUntil: "domcontentloaded", timeout: UI_TIMEOUT_MS });
|
||||
await ensureAuthenticated(page, context.request);
|
||||
seed = await createTempDocument(context.request, null);
|
||||
const targetUrl = await openDocument(page, seed.workspaceId, seed.documentId);
|
||||
const response = await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: UI_TIMEOUT_MS });
|
||||
assert(response, "根页没有返回响应");
|
||||
assert.equal(response.status(), 200, `根页状态码异常: ${response.status()}`);
|
||||
assert.equal(response.headers()["x-mnote-web-owner"], "mnote-web", "根页必须由 mnote-web 拥有");
|
||||
assert.equal(response.headers()["x-mnote-web-owner"], "mnote-web", "文档页必须由 mnote-web 拥有");
|
||||
|
||||
const createButton = page.getByTestId("wolai-sidebar-create-page").first();
|
||||
await createButton.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
|
||||
@@ -59,7 +64,7 @@ async function main() {
|
||||
assert(workspaceId, "新建后 URL 缺少 workspaceId");
|
||||
created = { documentId, workspaceId };
|
||||
|
||||
await page.locator('[data-testid="mnote-leptos-tiptap-island-editor-root"]').waitFor({
|
||||
await page.locator('[data-testid="mnote-leptos-tiptap-island-editor-root"][data-pane-role="primary"]').waitFor({
|
||||
state: "visible",
|
||||
timeout: UI_TIMEOUT_MS,
|
||||
});
|
||||
@@ -90,6 +95,12 @@ async function main() {
|
||||
`清理 UI 新建页面 ${created.documentId}`,
|
||||
).catch(() => undefined);
|
||||
}
|
||||
if (seed?.documentId && seed?.workspaceId) {
|
||||
await postTreeCommand(
|
||||
{ action: "purge", workspaceId: seed.workspaceId, documentId: seed.documentId },
|
||||
`清理种子页面 ${seed.documentId}`,
|
||||
).catch(() => undefined);
|
||||
}
|
||||
await page.close().catch(() => undefined);
|
||||
await context.close().catch(() => undefined);
|
||||
await browser.close().catch(() => undefined);
|
||||
|
||||
Reference in New Issue
Block a user