Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/development/lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 29 additions & 11 deletions tests/browser/composer_configure_model.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
Expand All @@ -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 = [];
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/browser/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 33 additions & 8 deletions tests/browser/subject_library.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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]);
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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 (
Expand All @@ -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
Expand All @@ -603,6 +627,7 @@ try {
independentSelector: true,
entryTabs: true,
singleSelection: true,
globalMultiSelection: true,
globalCreateOnly: true,
fullCanvasSubject: true,
voice15Accepted16Rejected: true,
Expand Down
Loading