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
1 change: 1 addition & 0 deletions docs/development/lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u

- 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)
- [Nightly run 46322961844](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/46322961844/job/141535114491) reached a subject image fingerprint check after the element mounted but before its source was ready. Wait for a nonempty source and decode before reading bytes. The same run's history dialog test intercepted a save on a clean canvas. Make a real edit before testing the pending or failed save states, since the save queue skips unchanged content.

## Browser clock pauses must precede short-lived observations

Expand Down
14 changes: 11 additions & 3 deletions tests/browser/node_versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ try {
await page.getByText("已保存到本机", { exact: true }).waitFor();
const source = page.locator(`.react-flow__node[data-id="${fixture.source}"]`);
const target = page.locator(`.react-flow__node[data-id="${fixture.target}"]`);
const renameTarget = async (name) => {
await target.locator(".cw-node-title").dblclick();
const title = target.locator(".cw-node-title-input");
await title.fill(name);
await title.press("Enter");
await target.getByText(name, { exact: true }).waitFor();
};
await source.getByRole("button", { name: "历史版本,共 2 个" }).waitFor();
await page.evaluate(async (id) => {
const client = (
Expand All @@ -190,8 +197,7 @@ try {
projection.save = save;
},
};
// Opening history flushes through projection.save. A clean canvas never
// reaches batch, so hold the flush the dialog actually awaits.
// Hold the dirty document save that history preparation must await.
projection.save = async (...args) => {
await gate;
try {
Expand All @@ -209,6 +215,7 @@ try {
return view(...args);
};
}, fixture.id);
await renameTarget("历史图片(待保存)");
await target.getByRole("button", { name: "历史版本,共 2 个" }).click();
const dialog = page.getByRole("dialog", { name: "节点历史版本" });
await dialog.waitFor({ timeout: 1500 });
Expand Down Expand Up @@ -807,11 +814,12 @@ try {
window.restoreHistoryBatch = () => {
projection.save = save;
};
// A clean canvas does not call batch. The dialog awaits this flush.
// The dialog must surface a failure while saving a real edit.
projection.save = async () => {
throw new Error("模拟草稿保存失败");
};
}, fixture.id);
await renameTarget("历史图片(重试保存)");
await target.getByRole("button", { name: "历史版本,共 3 个" }).click();
await dialog
.getByRole("alert")
Expand Down
12 changes: 7 additions & 5 deletions tests/browser/subject_node_media.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,14 @@ try {
});
}
const target = node(fixture.images[0]);
const mainBefore = await target
.locator(".cw-subject-main img")
.getAttribute("src");
const mainImage = target.locator('.cw-subject-main img[src]:not([src=""])');
const mainBefore = await mainImage.getAttribute("src");
const mainFingerprint = () =>
target.locator(".cw-subject-main img").evaluate(async (element) => {
const bytes = await (await fetch(element.src)).arrayBuffer();
mainImage.evaluate(async (element) => {
await element.decode();
const response = await fetch(element.currentSrc);
if (!response.ok) throw new Error(`Main subject image read failed: ${response.status}`);
const bytes = await response.arrayBuffer();
return Array.from(
new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)),
).join(",");
Expand Down
Loading