From 353a325e4cfaba27ee0520cef47d2e176d7d84a5 Mon Sep 17 00:00:00 2001 From: wangtiance Date: Tue, 24 Nov 2026 11:22:27 +0800 Subject: [PATCH] [test] Stabilize nightly extended browser scenarios ## summary Scope the empty video catalog to the composer test page and verify asset library multi-selection, batch import, and subject-slot selection. --- docs/development/lessons.md | 2 ++ tests/browser/composer_configure_model.mjs | 40 +++++++++++++++------ tests/browser/manifest.json | 2 +- tests/browser/subject_library.mjs | 41 +++++++++++++++++----- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/docs/development/lessons.md b/docs/development/lessons.md index 02d65b52f..dd79f0e29 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -51,6 +51,8 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **Fixture-mode follow-up:** [PR #266 review](https://github.com/ThinkFlowLab/OpenDirector/pull/266#issuecomment-6906025718) found browser workflows passing with local HTTP-generation fixtures but failing before business assertions under nightly's generic provider. Declare the required fixture modes in the manifest and check the running API and web proxy before executing each fixture lane. Reproduce the workflow's service commands and script grouping; separately correct local startup commands do not validate CI wiring. - **Save-observation follow-up:** [Issue #300](https://github.com/ThinkFlowLab/OpenDirector/issues/300) reproduced a stale saved label satisfying a browser wait before the edited text binding was committed. `asset.writeText` had succeeded, but the `creation.batch` containing `canvas.materialize` was still in flight; its later applied receipt installed the binding and the content was `AB`. Wait for the specific persisted binding, settings or position before asserting a save, retain the content check, and bound and release test gates even on failure. A visible saved label alone does not identify which edit was acknowledged. +- **Shared model catalog follow-up:** [Nightly run 45309310680](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/45309310680/job/138160760923) reached the empty-video-selector test after an earlier script saved a video model. A new page still reads the shared server's catalog. For a UI test of an empty category, scope that catalog response to the test page and verify the flow with a model already present on the shared server. + ## Browser clock pauses must precede short-lived observations - **Trigger:** Freezing browser time to inspect a short-lived response in both languages. diff --git a/tests/browser/composer_configure_model.mjs b/tests/browser/composer_configure_model.mjs index 8d8893872..1aa6ac3ac 100644 --- a/tests/browser/composer_configure_model.mjs +++ b/tests/browser/composer_configure_model.mjs @@ -20,14 +20,8 @@ async function call(path, body) { } assert.equal((await call("/api/creation-test-health")).isolated, true); const configs = await call("/api/model-configs"); -const list = Array.isArray(configs) ? configs : (configs.models ?? configs.items ?? []); assert.equal( - list.some((item) => item.kind === "video"), - false, - "needs a fixture API without a video model", -); -assert.equal( - list.some((item) => item.kind === "image"), + configs.some((item) => item.kind === "image"), true, "needs a fixture API with an image model", ); @@ -44,9 +38,22 @@ try { locale: "zh-CN", viewport: { width: 1600, height: 1000 }, }); - await page.addInitScript(() => - localStorage.setItem("opendirector.modelSetup.v1", "dismissed"), - ); + await page.addInitScript(() => { + localStorage.setItem("opendirector.modelSetup.v1", "dismissed"); + localStorage.setItem("opendirector.locale.v1", "zh-CN"); + }); + // The shared fixture may already contain video models from other tests. + // Scope the empty video catalog to this page and keep the real image models. + await page.route("**/api/model-configs", async (route) => { + if (route.request().method() !== "GET") return route.fallback(); + const response = await route.fetch(); + if (!response.ok()) return route.fulfill({ response }); + const models = await response.json(); + await route.fulfill({ + response, + json: models.filter((item) => item.kind !== "video"), + }); + }); page.setDefaultTimeout(15000); const errors = []; const generation = []; @@ -56,7 +63,18 @@ try { generation.push(request.url()); }); await page.goto(`${base}/ai-tool/ai-canvas/${projectId}`); - await page.getByText("已保存到本机", { exact: true }).waitFor(); + await page + .getByText("已保存到本机", { exact: true }) + .waitFor() + .catch(async (error) => { + console.error( + "Canvas did not open", + page.url(), + errors, + await page.locator("body").innerText(), + ); + throw error; + }); const rail = page.getByRole("toolbar", { name: "画布创作工具" }); // Another category being configured must not hide the action. diff --git a/tests/browser/manifest.json b/tests/browser/manifest.json index da72ffc51..3246bf356 100644 --- a/tests/browser/manifest.json +++ b/tests/browser/manifest.json @@ -192,7 +192,7 @@ "lanes": [ "extended" ], - "note": "Needs a fixture API without a video model; opens model settings from the empty selector and keeps the draft." + "note": "Filters video models from this page's fixture catalog and verifies the empty selector opens settings without losing the draft." }, { "file": "composer_duration.mjs", diff --git a/tests/browser/subject_library.mjs b/tests/browser/subject_library.mjs index d32a7a523..902e3cf8a 100644 --- a/tests/browser/subject_library.mjs +++ b/tests/browser/subject_library.mjs @@ -35,7 +35,10 @@ const browser = await chromium.launch({ }); const page = await browser.newPage({ locale: "zh-CN", viewport: { width: 1500, height: 1050 } }); // Skip the first-run model setup welcome; it covers the canvas. -await page.addInitScript(() => localStorage.setItem("opendirector.modelSetup.v1", "dismissed")); +await page.addInitScript(() => { + localStorage.setItem("opendirector.modelSetup.v1", "dismissed"); + localStorage.setItem("opendirector.locale.v1", "zh-CN"); +}); page.setDefaultTimeout(15000); const errors = []; page.on("pageerror", (error) => errors.push(error.message)); @@ -427,7 +430,8 @@ try { const targetBefore = state.nodes.find((item) => item.id === fixture.blank); assert.equal(targetBefore.data.title, "Blank destination"); assert.equal(targetBefore.data.subject.main.kind, "image"); - // The global library always creates a node, even when a populated subject is selected. + // Each selected asset creates its own node, even with a populated subject selected. + const beforeAssetImport = new Set(state.nodes.map((item) => item.id)); await openLibrary(); assert.equal( await library @@ -445,14 +449,25 @@ try { await check(library, pictureB.name).click(); assert.equal( await check(library, pictureA.name).getAttribute("aria-checked"), - "false", + "true", + ); + assert.equal( + await check(library, pictureB.name).getAttribute("aria-checked"), + "true", ); await library .getByRole("button", { name: "导入画布", exact: true }) .click(); await library.waitFor({ state: "hidden" }); state = await waitForSaved( - (state) => state.nodes.length === fixture.originalCount + 1, + (state) => state.nodes.length === fixture.originalCount + 2, + ); + const importedAssets = state.nodes.filter( + (item) => !beforeAssetImport.has(item.id), + ); + assert.deepEqual( + importedAssets.map((item) => item.data.title).sort(), + [pictureA.name, pictureB.name].sort(), ); assert.deepEqual( state.nodes.find((item) => item.id === fixture.blank).data.subject, @@ -461,16 +476,25 @@ try { await openLibrary("subjects"); await check(library, fixture.title).click(); await check(library, fixture.videoTitle).click(); + assert.equal( + await check(library, fixture.title).getAttribute("aria-checked"), + "true", + ); + await check(library, fixture.title).click(); assert.equal( await check(library, fixture.title).getAttribute("aria-checked"), "false", ); + assert.equal( + await check(library, fixture.videoTitle).getAttribute("aria-checked"), + "true", + ); await library .getByRole("button", { name: "导入画布", exact: true }) .click(); await library.waitFor({ state: "hidden" }); await waitForSaved( - (state) => state.nodes.length === fixture.originalCount + 2, + (state) => state.nodes.length === fixture.originalCount + 3, ); // Whole-subject replacement clears old assembly and remains one undo step. await openSubject(fixture.images[1]); @@ -528,7 +552,7 @@ try { state.nodes.find((item) => item.id === fixture.blank).data.subject .auxiliaries.length === 2, ); - assert.equal(state.nodes.length, fixture.originalCount + 2); + assert.equal(state.nodes.length, fixture.originalCount + 3); // Voice slot allows 15s and blocks 16s; it keeps the image and auxiliary slots. await node(fixture.blank) .getByRole("button", { name: "添加主体声音", exact: true }) @@ -566,7 +590,7 @@ try { .click(); await library.waitFor({ state: "hidden" }); await waitForSaved( - (state) => state.nodes.length === fixture.originalCount + 3, + (state) => state.nodes.length === fixture.originalCount + 4, ); // Library deletion does not break already imported owned media or provenance. const subjects = await ( @@ -584,7 +608,7 @@ try { await page.reload(); await page.getByText("已保存到本机", { exact: true }).waitFor(); state = await waitForSaved( - (state) => state.nodes.length === fixture.originalCount + 3, + (state) => state.nodes.length === fixture.originalCount + 4, ); assert.equal( state.nodes.find((item) => item.id === fixture.blank).data.subject.voice @@ -603,6 +627,7 @@ try { independentSelector: true, entryTabs: true, singleSelection: true, + globalMultiSelection: true, globalCreateOnly: true, fullCanvasSubject: true, voice15Accepted16Rejected: true,