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
4 changes: 4 additions & 0 deletions docs/development/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ node tests/browser/mp4_export.mjs # 合成 MP4(WebCodecs + 软件
node tests/browser/new_image_node_outputs.mjs # 新建图片节点采用所选适配器的比例与尺寸
```

历史版本预览回归([#393](https://github.com/ThinkFlowLab/OpenDirector/issues/393))沿用上述隔离服务:运行 `node tests/browser/node_versions.mjs`;设置 `HISTORY_PREVIEW_PROBE=delay` 会延迟目标缩略图一秒,完整旅程应通过。设置 `HISTORY_PREVIEW_PROBE=missing` 会注入缩略图 404,预期脚本失败并输出 `History preview unavailable`、目标资产 ID、HTTP 状态和媒体提示;它是故障诊断检查,不是成功旅程。清除变量后恢复正常运行。布局断言必须等待预期资产的图片加载成功,不能以提示词出现代替预览就绪。

History preview regression ([#393](https://github.com/ThinkFlowLab/OpenDirector/issues/393)): run `node tests/browser/node_versions.mjs` against the isolated services above. `HISTORY_PREVIEW_PROBE=delay` delays the target thumbnail by one second; the complete journey must pass. `HISTORY_PREVIEW_PROBE=missing` injects a thumbnail 404; the script must fail with `History preview unavailable`, the target asset ID, HTTP status and media message. This is an expected-failure diagnostic probe. Unset the variable for the normal journey. Measure layout only after the expected asset's image has loaded successfully; prompt readiness does not establish media readiness.

`mp4_export.mjs` 以 640x360 渲染:没有 GPU 的无头浏览器只在该尺寸暴露 H.264
编码能力,1080p 导出仍需在桌面浏览器人工验收。

Expand Down
46 changes: 43 additions & 3 deletions tests/browser/node_versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,29 @@ try {
target: target.id,
originalAsset: old.id,
newAsset: written.assetId,
previewAsset: client.snapshot.jobs[0].asset.assetId,
};
});
await page.unroute(bootstrap);
const previewResponses = [];
page.on("response", response => {
if (response.url().includes(`/assets/${fixture.previewAsset}/thumbnail`))
previewResponses.push({ url: response.url(), status: response.status() });
});
// Optional fault probes exercise the same wait and diagnostic as the journey.
const previewProbe = process.env.HISTORY_PREVIEW_PROBE;
if (previewProbe) {
assert.ok(["delay", "missing"].includes(previewProbe));
await page.route(`**/assets/${fixture.previewAsset}/thumbnail`, async route => {
if (previewProbe === "missing")
await route.fulfill({ status: 404, contentType: "application/json",
body: JSON.stringify({ detail: "History preview probe missing" }) });
else {
await new Promise(resolve => setTimeout(resolve, 1000));
await route.continue();
}
});
}
await page.goto(`${base}/ai-tool/ai-canvas/${fixture.id}`);
await page.getByText("已保存到本机", { exact: true }).waitFor();
const source = page.locator(`.react-flow__node[data-id="${fixture.source}"]`);
Expand Down Expand Up @@ -242,9 +262,29 @@ try {
assert.equal(fixedBounds.width, 560);
assert.equal(fixedBounds.height, 210);

const layout = await dialog
.locator(".cw-version-details")
.first()
const details = dialog.locator(
`.cw-version-entry[data-version-asset-id="${generatedAssets[0]}"] .cw-version-details`,
);
try {
await details.locator("img").waitFor({ state: "visible", timeout: 10000 });
await page.waitForFunction(assetId => {
const image = document.querySelector(
`.cw-version-entry[data-version-asset-id="${assetId}"] .cw-version-details img`,
);
return image instanceof HTMLImageElement && image.complete &&
image.naturalWidth > 0 && image.naturalHeight > 0;
}, generatedAssets[0], { timeout: 10000 });
} catch (error) {
throw new Error(`History preview unavailable: ${JSON.stringify({
assetId: generatedAssets[0], responses: previewResponses,
media: await details.locator(".cw-version-media").allTextContents(),
images: await details.locator("img").evaluateAll(images => images.map(image => ({
src: image.currentSrc || image.src, complete: image.complete,
width: image.naturalWidth, height: image.naturalHeight,
}))),
})}`, { cause: error });
}
const layout = await details
.evaluate((element) => {
const preview = element.children[0].getBoundingClientRect();
const composer = element.children[1].getBoundingClientRect();
Expand Down
Loading