Skip to content
53 changes: 34 additions & 19 deletions tests/browser/first_last_frame_connections.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,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);
Expand Down
6 changes: 3 additions & 3 deletions tests/browser/node_versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ try {
});
window.historyReadCheck = {
release,
views: 0,
viewWrites: 0,
finished: false,
restore: () => {
client.batch = batch;
Expand All @@ -221,7 +221,7 @@ try {
return batch(...args);
};
client.view = async (...args) => {
if (args[0]) window.historyReadCheck.views++;
if (args[0]) window.historyReadCheck.viewWrites++;
return view(...args);
};
}, fixture.id);
Expand All @@ -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(
Expand Down
Loading