diff --git a/docs/development/lessons.md b/docs/development/lessons.md index 7d48a1fa3..906dded6b 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -55,6 +55,11 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **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. +## Canvas media readiness depends on the viewport + +- Browser checks that inspect a canvas image or video after reopening a project or placing a result should bring the target node into view first. +- The subject-library and video-review checks in Nightly run 45572808123 reached their persisted-state assertions before the lazy previews were ready. After fitting the canvas, wait for the target image to load or the video to load metadata, then verify the dimensions or duration. [Nightly run 45572808123](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/45572808123/job/139063347523) + ## 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/default_entry.mjs b/tests/browser/default_entry.mjs index 6b10b32d1..8a204e3c4 100644 --- a/tests/browser/default_entry.mjs +++ b/tests/browser/default_entry.mjs @@ -105,16 +105,18 @@ try { } await page.getByRole("button", { name: "切换项目", exact: true }).click(); await page.getByText(/使用旧格式/).waitFor(); - // The current project's check shares the trailing slot with its row actions - // button, which covers it while the row is hovered. + // On hover the new-tab shortcut takes the checkmark's trailing slot. const currentRow = page .locator(".cw-project-row:has(.cw-project-check)") .first(); const checkBox = await currentRow.locator(".cw-project-check").boundingBox(); const moreBox = await currentRow.locator(".cw-project-more").boundingBox(); - assert.ok(checkBox && moreBox); - assert.equal(Math.round(checkBox.x), Math.round(moreBox.x)); - assert.equal(Math.round(checkBox.width), Math.round(moreBox.width)); + const openTab = currentRow.locator(".cw-project-open-tab"); + const openTabBox = await openTab.boundingBox(); + assert.ok(checkBox && moreBox && openTabBox); + assert.equal(Math.round(checkBox.x), Math.round(openTabBox.x)); + assert.equal(Math.round(checkBox.width), Math.round(openTabBox.width)); + assert.ok(Math.round(moreBox.x + moreBox.width) <= Math.round(openTabBox.x)); await currentRow.hover(); await page.waitForTimeout(250); assert.equal( @@ -129,6 +131,10 @@ try { .evaluate((element) => getComputedStyle(element).opacity), "1", ); + assert.equal( + await openTab.evaluate((element) => getComputedStyle(element).opacity), + "1", + ); assert.equal( await page.getByRole("menuitem", { name: old.name, exact: true }).count(), 0, diff --git a/tests/browser/generation_feedback.mjs b/tests/browser/generation_feedback.mjs index 22b563fa4..9e48d923d 100644 --- a/tests/browser/generation_feedback.mjs +++ b/tests/browser/generation_feedback.mjs @@ -147,7 +147,11 @@ try { dark, light, enabled: [...element.querySelectorAll("button:enabled")] - .filter((button) => button.getClientRects().length) + .filter( + (button) => + button.getClientRects().length && + button.getAttribute("aria-disabled") !== "true", + ) .map((button) => button.getAttribute("aria-label")), }; }); @@ -155,6 +159,12 @@ try { assert.equal(locked.dark, "rgb(125, 130, 145)"); assert.equal(locked.light, "rgb(123, 130, 144)"); assert.deepEqual(locked.enabled, ["取消生成"]); + assert.equal( + await dock + .getByRole("button", { name: "提示词优化", exact: true }) + .isDisabled(), + true, + ); assert.equal((await state()).jobs.length, 0); hold.release(); await until(async () => (await state()).jobs.length === 1); diff --git a/tests/browser/subject_library.mjs b/tests/browser/subject_library.mjs index 902e3cf8a..a99855f61 100644 --- a/tests/browser/subject_library.mjs +++ b/tests/browser/subject_library.mjs @@ -615,12 +615,14 @@ try { .durationSeconds, 15, ); - assert.equal( - await node(fixture.blank) - .locator(".cw-subject-main img") - .evaluate((img) => img.complete && img.naturalWidth > 0), - true, - ); + await page.locator(".cw-workspace").focus(); + await page.keyboard.press("Shift+1"); + await page.waitForFunction((id) => { + const img = document.querySelector( + `.react-flow__node[data-id="${id}"] .cw-subject-main img`, + ); + return img?.complete && img.naturalWidth > 0; + }, fixture.blank); console.log( JSON.stringify({ mode: "unified", diff --git a/tests/browser/video_review_regressions.mjs b/tests/browser/video_review_regressions.mjs index 99f235a01..76d4a6eea 100644 --- a/tests/browser/video_review_regressions.mjs +++ b/tests/browser/video_review_regressions.mjs @@ -449,6 +449,11 @@ try { ); assert.ok(task.outputs[0].durationMs > 0); assert.equal(task.modelConfigIds["video.first_frame"], config.id); + await page + .locator(`.react-flow__node[data-id="${task.canvas.targetNodeId}"]`) + .waitFor(); + await page.locator(".cw-workspace").focus(); + await page.keyboard.press("Shift+1"); await page.waitForFunction((id) => { const video = document.querySelector( `.react-flow__node[data-id="${id}"] video.cw-video-preview`, @@ -459,8 +464,6 @@ try { video.duration > 0 ); }, task.canvas.targetNodeId); - await page.locator(".cw-workspace").focus(); - await page.keyboard.press("Shift+1"); assert.deepEqual(errors, []); if (process.env.CREATION_SCREENSHOTS) { await mkdir(process.env.CREATION_SCREENSHOTS, { recursive: true });