Skip to content

Commit 2759378

Browse files
loganjLarry
andcommitted
test(desktop): bind workflow message owner and settled geometry
Keep the outgoing trigger input separate from the new message textarea, sample match controls together after inspector settlement, and verify the persisted original trigger and step text before reopen. Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <[email protected]>
1 parent 3825f89 commit 2759378

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

‎desktop/tests/e2e/workflow-local-controls.spec.ts‎

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ async function addMessageStep(
6363
) {
6464
await dialog.getByRole("button", { name: "Add step", exact: true }).click();
6565
await page.getByRole("menuitem", { name: "Send Message" }).click();
66-
await dialog.getByLabel("Message text").fill("Workflow notification");
66+
// The outgoing trigger input has the same label during inspector exit.
67+
const message = dialog.locator("textarea#wf-step-0-text");
68+
await expect(message).toBeVisible();
69+
await message.fill("Workflow notification");
6770
}
6871

6972
async function createEnabled(
@@ -288,9 +291,30 @@ test("round-trips and reopens structured message-text conditions", async ({
288291
await openTriggerInspector(dialog);
289292
const matchControls = dialog.getByRole("group", { name: "Match" });
290293
const operatorButtons = matchControls.getByRole("button");
291-
const firstOperatorBox = await operatorButtons.nth(0).boundingBox();
292-
const secondOperatorBox = await operatorButtons.nth(1).boundingBox();
293-
const thirdOperatorBox = await operatorButtons.nth(2).boundingBox();
294+
// Motion updates inspector geometry in JS; sample all boxes in the same frame.
295+
const boxes = await operatorButtons.evaluateAll(async (buttons) => {
296+
if (buttons.length < 3) throw new Error("Missing workflow match operators");
297+
const inspector = buttons[0].closest(
298+
'[data-testid="workflow-node-inspector"]',
299+
);
300+
if (!inspector) throw new Error("Missing workflow inspector");
301+
let previous = "";
302+
let stable = 0;
303+
for (let frame = 0; frame < 120; frame++) {
304+
await new Promise(requestAnimationFrame);
305+
const boxes = buttons
306+
.slice(0, 3)
307+
.map((button) => button.getBoundingClientRect().toJSON());
308+
const style = getComputedStyle(inspector);
309+
const sample = { boxes, width: style.width, transform: style.transform };
310+
const current = JSON.stringify(sample);
311+
stable = current === previous ? stable + 1 : 0;
312+
if (stable >= 2) return boxes;
313+
previous = current;
314+
}
315+
throw new Error("Workflow inspector geometry did not settle");
316+
});
317+
const [firstOperatorBox, secondOperatorBox, thirdOperatorBox] = boxes;
294318
expect(firstOperatorBox).not.toBeNull();
295319
expect(secondOperatorBox).not.toBeNull();
296320
expect(thirdOperatorBox).not.toBeNull();
@@ -315,6 +339,17 @@ test("round-trips and reopens structured message-text conditions", async ({
315339

316340
await addMessageStep(page, dialog);
317341
await createEnabled(page, dialog);
342+
const savedYaml = await page.evaluate(() => {
343+
const call = [...(window.__BUZZ_E2E_COMMAND_PAYLOADS__ ?? [])]
344+
.reverse()
345+
.find((candidate) => candidate.command === "create_workflow");
346+
return (call?.payload as { yamlDefinition?: string } | undefined)
347+
?.yamlDefinition;
348+
});
349+
const saved = parseYaml(savedYaml ?? "");
350+
expect(saved.name).toBe(name);
351+
expect(saved.trigger.filter).toBe(expression);
352+
expect(saved.steps[0].text).toBe("Workflow notification");
318353
const reopened = await reopenWorkflow(page, name);
319354
await openTriggerInspector(reopened);
320355
await expect(

0 commit comments

Comments
 (0)