From c50ad9fcc90562f69b56bcc7e8149d381d558518 Mon Sep 17 00:00:00 2001 From: wangtiance Date: Tue, 1 Dec 2026 19:55:29 +0800 Subject: [PATCH 1/2] [test] Lay out the first and last frame fixtures before connecting --- .../browser/first_last_frame_connections.mjs | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/tests/browser/first_last_frame_connections.mjs b/tests/browser/first_last_frame_connections.mjs index 7cf2f7195..06dd43211 100644 --- a/tests/browser/first_last_frame_connections.mjs +++ b/tests/browser/first_last_frame_connections.mjs @@ -120,27 +120,42 @@ try { "first-last mode saved", ); - // Lay the nodes out, then drag A → video and B → video on the canvas. const node = (id) => page.locator(`.react-flow__node[data-id="${id}"]`); - const place = async (id, x, y) => { - const box = await node(id).boundingBox(); - await page.mouse.move(box.x + box.width / 2, box.y + 12); - await page.mouse.down(); - await page.mouse.move(x, y, { steps: 10 }); - await page.mouse.up(); - }; - await page.keyboard.press("Escape"); - await place(images[0], 300, 300); - await place(images[1], 300, 750); - await place(videoId, 1050, 520); + const session = await page.evaluate(() => sessionStorage.getItem("opendirector.session.v1")); + assert.ok(session, "The browser must own the project edit session"); + const layout = await snapshot(); + const positions = new Map([ + [images[0], { x: 0, y: 0 }], + [images[1], { x: 0, y: 400 }], + [videoId, { x: 540, y: 180 }], + ]); + const moved = await page.request.post(`${api}/api/creation/projects/${projectId}/commands`, { + headers: { ...headers, "X-OpenDirector-Session": session }, + data: { + projectId, + commandId: crypto.randomUUID(), + type: "canvas.move", + expectedVersions: layout.canvasItems.map(({ id, revision }) => ({ + objectType: "canvas_item", id, revision, + })), + payload: { + items: [...positions].map(([itemId, position]) => ({ itemId, position })), + }, + }, + }); + assert.ok(moved.ok(), await moved.text()); + const receipt = await moved.json(); + assert.equal(receipt.status, "applied", JSON.stringify(receipt)); + await page.reload(); + await page.getByText("已保存到本机", { exact: true }).waitFor(); + await page.locator(".cw-workspace").focus(); + await page.keyboard.press("Shift+1"); for (const source of images) { - const box = await node(source).boundingBox(); - await page.mouse.move(box.x + box.width + 7, box.y + box.height / 2); - const port = page.getByRole("button", { - name: "添加下游参考节点", - exact: true, - }); - await port.waitFor(); + await node(source).hover(); + const port = page.locator( + `.cw-node-reference-port[data-reference-source="${source}"][data-side="right"]`, + ); + await port.hover(); const from = await port.boundingBox(); const to = await node(videoId).boundingBox(); await page.mouse.move(from.x + from.width / 2, from.y + from.height / 2); From 68a119a2ec23eea00f7eb54d19861eaf6eb643a8 Mon Sep 17 00:00:00 2001 From: wangtiance Date: Tue, 1 Dec 2026 19:57:26 +0800 Subject: [PATCH 2/2] [test] Count view writes in the node history check --- tests/browser/node_versions.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/browser/node_versions.mjs b/tests/browser/node_versions.mjs index fe16f5d20..ef47d7ef1 100644 --- a/tests/browser/node_versions.mjs +++ b/tests/browser/node_versions.mjs @@ -199,7 +199,7 @@ try { }); window.historyReadCheck = { release, - views: 0, + viewWrites: 0, finished: false, restore: () => { client.batch = batch; @@ -220,9 +220,9 @@ try { await gate; return batch(...args); }; - client.view = async (...args) => { - window.historyReadCheck.views++; - return view(...args); + client.view = async (value) => { + if (value) window.historyReadCheck.viewWrites++; + return view(value); }; }, fixture.id); await renameTarget("历史图片(待保存)"); @@ -241,7 +241,7 @@ try { assert.equal(await dialog.count(), 0); await target.getByRole("button", { name: "历史版本,共 2 个" }).click(); await dialog.locator(".cw-version-prompt").first().waitFor(); - assert.equal(await page.evaluate(() => window.historyReadCheck.views), 0); + assert.equal(await page.evaluate(() => window.historyReadCheck.viewWrites), 0); await page.evaluate(() => window.historyReadCheck.restore()); assert.equal(