From dd6127e986b0ad6b6d3fb9b5da0ff764aa042cd9 Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 26 Oct 2026 17:05:20 +0100 Subject: [PATCH 1/6] feat(core): add scenario pacing, step dwellMs and fill typingDelayMs Scenarios may set pacing.stepDwellMs, pacing.endHoldMs and pacing.typingDelayMs (defaults 1000/3500/80 ms); any step may override its dwell with dwellMs and a fill its typing speed with typingDelayMs. The timeline records each event's dwell and the run's end hold. --- packages/core/schemas/fragment.schema.json | 90 +++++++ packages/core/schemas/scenario.schema.json | 298 +++++++++++++++++++++ packages/core/src/scenario.ts | 49 +++- packages/core/src/step.ts | 14 + packages/core/src/timeline.ts | 5 + packages/core/test/scenario.spec.ts | 69 ++++- 6 files changed, 523 insertions(+), 2 deletions(-) diff --git a/packages/core/schemas/fragment.schema.json b/packages/core/schemas/fragment.schema.json index 669c0841..edcbbd99 100644 --- a/packages/core/schemas/fragment.schema.json +++ b/packages/core/schemas/fragment.schema.json @@ -84,6 +84,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -227,6 +233,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -357,6 +369,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -480,6 +498,12 @@ "required": ["env"], "additionalProperties": false }, + "typingDelayMs": { + "description": "Milliseconds between two typed characters of this fill; overrides pacing.typingDelayMs.", + "type": "integer", + "minimum": 0, + "maximum": 500 + }, "caption": { "type": "string", "maxLength": 120 @@ -493,6 +517,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -626,6 +656,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "option"], @@ -748,6 +784,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -881,6 +923,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "key"], @@ -1091,6 +1139,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -1221,6 +1275,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -1360,6 +1420,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "text"], @@ -1397,6 +1463,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], @@ -1439,6 +1511,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "title"], @@ -1469,6 +1547,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "ms"], @@ -1506,6 +1590,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], diff --git a/packages/core/schemas/scenario.schema.json b/packages/core/schemas/scenario.schema.json index 0d1324da..7e827485 100644 --- a/packages/core/schemas/scenario.schema.json +++ b/packages/core/schemas/scenario.schema.json @@ -73,6 +73,34 @@ } } }, + "pacing": { + "type": "object", + "properties": { + "stepDwellMs": { + "default": 1000, + "description": "Milliseconds the recording stays on the result of each visible step (navigate, click, hover, fill, select, press, scroll, assertVisible, assertText) before the next one. A step overrides it with dwellMs; 0 turns it off.", + "type": "integer", + "minimum": 0, + "maximum": 10000 + }, + "endHoldMs": { + "default": 3500, + "description": "Milliseconds the recording holds the final frame after the last step of a successful run. 0 ends the video at the last step.", + "type": "integer", + "minimum": 0, + "maximum": 10000 + }, + "typingDelayMs": { + "default": 80, + "description": "Milliseconds between two typed characters of a fill. A fill overrides it with typingDelayMs.", + "type": "integer", + "minimum": 0, + "maximum": 500 + } + }, + "additionalProperties": false, + "description": "How fast the recording plays. Every field has a default; setup and off-camera steps are not paced." + }, "setup": { "description": "Steps that run off camera before the recording starts, such as signing in: an include of a fragment, or plain steps. The recording starts in the same browser storage (cookies, localStorage), on the page setup ended on.", "minItems": 1, @@ -109,6 +137,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -244,6 +278,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -374,6 +414,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -497,6 +543,12 @@ "required": ["env"], "additionalProperties": false }, + "typingDelayMs": { + "description": "Milliseconds between two typed characters of this fill; overrides pacing.typingDelayMs.", + "type": "integer", + "minimum": 0, + "maximum": 500 + }, "caption": { "type": "string", "maxLength": 120 @@ -510,6 +562,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -643,6 +701,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "option"], @@ -765,6 +829,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -890,6 +960,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "key"], @@ -1092,6 +1168,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -1222,6 +1304,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -1353,6 +1441,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "text"], @@ -1382,6 +1476,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], @@ -1416,6 +1516,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "title"], @@ -1446,6 +1552,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "ms"], @@ -1475,6 +1587,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], @@ -1550,6 +1668,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -1685,6 +1809,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -1815,6 +1945,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -1938,6 +2074,12 @@ "required": ["env"], "additionalProperties": false }, + "typingDelayMs": { + "description": "Milliseconds between two typed characters of this fill; overrides pacing.typingDelayMs.", + "type": "integer", + "minimum": 0, + "maximum": 500 + }, "caption": { "type": "string", "maxLength": 120 @@ -1951,6 +2093,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -2084,6 +2232,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "option"], @@ -2206,6 +2360,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -2331,6 +2491,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "key"], @@ -2533,6 +2699,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -2663,6 +2835,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -2794,6 +2972,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "text"], @@ -2823,6 +3007,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], @@ -2857,6 +3047,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "title"], @@ -2887,6 +3083,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "ms"], @@ -2916,6 +3118,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], @@ -2988,6 +3196,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -3131,6 +3345,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -3261,6 +3481,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -3384,6 +3610,12 @@ "required": ["env"], "additionalProperties": false }, + "typingDelayMs": { + "description": "Milliseconds between two typed characters of this fill; overrides pacing.typingDelayMs.", + "type": "integer", + "minimum": 0, + "maximum": 500 + }, "caption": { "type": "string", "maxLength": 120 @@ -3397,6 +3629,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -3530,6 +3768,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "option"], @@ -3652,6 +3896,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -3785,6 +4035,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "key"], @@ -3995,6 +4251,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action"], @@ -4125,6 +4387,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target"], @@ -4264,6 +4532,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "target", "text"], @@ -4301,6 +4575,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], @@ -4343,6 +4623,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "title"], @@ -4373,6 +4659,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "ms"], @@ -4410,6 +4702,12 @@ "record": { "description": "false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.", "type": "boolean" + }, + "dwellMs": { + "description": "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + "type": "integer", + "minimum": 0, + "maximum": 10000 } }, "required": ["action", "name"], diff --git a/packages/core/src/scenario.ts b/packages/core/src/scenario.ts index 7838f580..ebeb7320 100644 --- a/packages/core/src/scenario.ts +++ b/packages/core/src/scenario.ts @@ -5,7 +5,13 @@ import { NonEmptyStringSchema, ViewportSchema, } from './common.ts'; -import { DataKeySchema, ScenarioStepSchema, SetupStepSchema } from './step.ts'; +import { + DataKeySchema, + DwellMsSchema, + ScenarioStepSchema, + SetupStepSchema, + TypingDelayMsSchema, +} from './step.ts'; /** One item of a data list: the fields a `repeat` substitutes. */ export const DataItemSchema = z.record( @@ -39,6 +45,46 @@ export const DEFAULT_VIEWPORTS: Record< phone: { width: 412, height: 914 }, }; +/** How fast the recorded steps play when a scenario sets no `pacing` (C-203). */ +export const DEFAULT_PACING = { + stepDwellMs: 1_000, + endHoldMs: 3_500, + typingDelayMs: 80, +} as const; + +/** + * How fast a recording plays (C-203): a pause after each visible step, a hold + * on the final frame, and the typing speed. Setup and off-camera steps are not + * paced. + */ +export const PacingSchema = z + .strictObject({ + stepDwellMs: DwellMsSchema.default(DEFAULT_PACING.stepDwellMs).meta({ + description: + 'Milliseconds the recording stays on the result of each visible step (navigate, click, hover, fill, select, press, scroll, assertVisible, assertText) before the next one. A step overrides it with dwellMs; 0 turns it off.', + }), + endHoldMs: DwellMsSchema.default(DEFAULT_PACING.endHoldMs).meta({ + description: + 'Milliseconds the recording holds the final frame after the last step of a successful run. 0 ends the video at the last step.', + }), + typingDelayMs: TypingDelayMsSchema.default( + DEFAULT_PACING.typingDelayMs, + ).meta({ + description: + 'Milliseconds between two typed characters of a fill. A fill overrides it with typingDelayMs.', + }), + }) + .meta({ + description: + 'How fast the recording plays. Every field has a default; setup and off-camera steps are not paced.', + }); +export type Pacing = z.infer; + +/** The scenario's pacing with every default filled in. */ +export function resolvePacing(pacing: Partial | undefined): Pacing { + return { ...DEFAULT_PACING, ...pacing }; +} + /** A scenario file, `demoflow/**\/*.demo.json` (ADR-0003). */ export const ScenarioSchema = z .strictObject({ @@ -54,6 +100,7 @@ export const ScenarioSchema = z }), viewport: ViewportSchema.optional(), data: ScenarioDataSchema.optional(), + pacing: PacingSchema.optional(), setup: z .array(SetupStepSchema) .min(1, 'expected at least one step') diff --git a/packages/core/src/step.ts b/packages/core/src/step.ts index b2de845d..89edefd8 100644 --- a/packages/core/src/step.ts +++ b/packages/core/src/step.ts @@ -38,11 +38,21 @@ export const RecordSchema = z.boolean().optional().meta({ 'false runs the step off camera: before the recording starts, in the same browser storage (cookies, localStorage). Only the opening steps of a scenario may be off camera; the video starts on the first recorded step.', }); +/** How long the video stays on a step's result before the next step (C-203). */ +export const DwellMsSchema = z.number().int().min(0).max(10_000); + +/** How long a `fill` waits between two typed characters (C-203). */ +export const TypingDelayMsSchema = z.number().int().min(0).max(500); + /** Fields every step may carry. */ const common = { caption: z.string().max(120).optional(), timeoutMs: z.number().int().min(100).max(60_000).default(10_000), record: RecordSchema, + dwellMs: DwellMsSchema.optional().meta({ + description: + "Milliseconds the recording stays on this step's result before the next step starts; overrides pacing.stepDwellMs. 0 turns the dwell off. Ignored off camera.", + }), }; /** @@ -228,6 +238,10 @@ function stepSchema(mode: M) { ...zoom, value: z.string().optional(), valueFrom: z.strictObject({ env: EnvNameSchema }).optional(), + typingDelayMs: TypingDelayMsSchema.optional().meta({ + description: + 'Milliseconds between two typed characters of this fill; overrides pacing.typingDelayMs.', + }), }) .superRefine(exactlyOne(fillKeys)) .meta(exactlyOneJsonSchema(fillKeys)), diff --git a/packages/core/src/timeline.ts b/packages/core/src/timeline.ts index f18e61f8..97e2d323 100644 --- a/packages/core/src/timeline.ts +++ b/packages/core/src/timeline.ts @@ -187,6 +187,8 @@ export const TimelineEventSchema = z // The step's `zoom`, verbatim: the renderer resolves `true` (ADR-0012). zoom: ZoomSchema.optional(), error: z.strictObject({ message: z.string() }).optional(), + // The pause the engine recorded after `endMs`, before the next step (C-203). + dwellMs: msSchema.optional(), // Only on a masked `fill`: when its field was on the page (ADR-0004; #18). maskVisibility: MaskVisibilitySchema.optional(), }) @@ -246,6 +248,9 @@ export const TimelineSchema = z maskedElements: z.array(MaskedElementSchema).optional(), // Scenes and captions the page set, by engine time; omitted when none was (#201). annotations: AnnotationsSchema.optional(), + // How long the engine kept recording after the last event of a successful + // run (C-203); absent in older timelines, which the renderer gives a 1 s tail. + endHoldMs: msSchema.optional(), }) .refine( (timeline) => { diff --git a/packages/core/test/scenario.spec.ts b/packages/core/test/scenario.spec.ts index bc45a617..e22e4cad 100644 --- a/packages/core/test/scenario.spec.ts +++ b/packages/core/test/scenario.spec.ts @@ -1,5 +1,10 @@ import { describe, expect, it } from 'vitest'; -import { type Issue, parseScenario, type StepAction } from '../src/index.ts'; +import { + type Issue, + parseScenario, + resolvePacing, + type StepAction, +} from '../src/index.ts'; function scenario(...steps: unknown[]) { return { schemaVersion: 1, name: 'Demo', steps }; @@ -612,3 +617,65 @@ describe('parseScenario — scenario', () => { ]); }); }); + +describe('parseScenario — pacing', () => { + const click = { action: 'click', target }; + + it('leaves pacing to the defaults when the scenario sets none', () => { + const result = parseScenario(scenario(click)); + if (!result.ok) throw new Error('expected the scenario to parse'); + expect(result.value.pacing).toBeUndefined(); + expect(resolvePacing(result.value.pacing)).toEqual({ + stepDwellMs: 1_000, + endHoldMs: 3_500, + typingDelayMs: 80, + }); + }); + + it('fills in the fields a partial pacing leaves out', () => { + const result = parseScenario({ + ...scenario(click), + pacing: { endHoldMs: 0 }, + }); + expect(result).toMatchObject({ + ok: true, + value: { + pacing: { stepDwellMs: 1_000, endHoldMs: 0, typingDelayMs: 80 }, + }, + }); + }); + + it('accepts a dwell on any step and a typing delay on a fill', () => { + const result = parseScenario( + scenario( + { ...click, dwellMs: 0 }, + { action: 'marker', title: 'Intro', dwellMs: 2_000 }, + { action: 'fill', target, value: 'Ada', typingDelayMs: 120 }, + ), + ); + expect(result).toMatchObject({ + ok: true, + value: { + steps: [{ dwellMs: 0 }, { dwellMs: 2_000 }, { typingDelayMs: 120 }], + }, + }); + }); + + it('rejects out-of-range and misplaced pacing', () => { + expect( + errorsOf({ ...scenario(click), pacing: { stepDwellMs: -1 } }), + ).toEqual([expect.objectContaining({ path: 'pacing.stepDwellMs' })]); + expect( + errorsOf({ ...scenario(click), pacing: { endHoldMs: 10_001 } }), + ).toEqual([expect.objectContaining({ path: 'pacing.endHoldMs' })]); + expect( + errorsOf({ ...scenario(click), pacing: { typingDelayMs: 1.5 } }), + ).toEqual([expect.objectContaining({ path: 'pacing.typingDelayMs' })]); + expect(errorsOf({ ...scenario(click), pacing: { speed: 2 } })).toEqual([ + expect.objectContaining({ path: 'pacing.speed' }), + ]); + expect(errorsOf(scenario({ ...click, typingDelayMs: 50 }))).toEqual([ + expect.objectContaining({ path: 'steps[0].typingDelayMs' }), + ]); + }); +}); From 6ee01a96dc9aef00481dacc5461cf74cf46cb51d Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 26 Oct 2026 17:05:25 +0100 Subject: [PATCH 2/6] feat(engine): dwell after each visible step and hold the final frame Recorded on-camera steps now wait stepDwellMs after a visible action, the run holds endHoldMs before the video stops, and typing defaults to 80 ms per character. Setup steps, check runs and failed runs are not slowed down. --- packages/engine/src/capture/observer.ts | 3 + packages/engine/src/execute/actions.ts | 16 +- packages/engine/src/execute/observer.ts | 2 + packages/engine/src/execute/pacing.ts | 46 +++ packages/engine/src/run.ts | 52 +++- packages/engine/test/execute/pacing.spec.ts | 293 ++++++++++++++++++++ packages/engine/test/execute/scenario.ts | 7 +- 7 files changed, 409 insertions(+), 10 deletions(-) create mode 100644 packages/engine/src/execute/pacing.ts create mode 100644 packages/engine/test/execute/pacing.spec.ts diff --git a/packages/engine/src/capture/observer.ts b/packages/engine/src/capture/observer.ts index 93503159..63db0049 100644 --- a/packages/engine/src/capture/observer.ts +++ b/packages/engine/src/capture/observer.ts @@ -79,6 +79,9 @@ export function createCaptureObserver(options: CaptureOptions): EngineObserver { ...(outcome.annotations === undefined ? {} : { annotations: outcome.annotations }), + ...(outcome.endHoldMs === undefined + ? {} + : { endHoldMs: outcome.endHoldMs }), }); await writeJson(path.join(runDir, RUN_FILES.timeline), timeline); } diff --git a/packages/engine/src/execute/actions.ts b/packages/engine/src/execute/actions.ts index 88ddb66a..719ca6f2 100644 --- a/packages/engine/src/execute/actions.ts +++ b/packages/engine/src/execute/actions.ts @@ -1,6 +1,7 @@ import { setTimeout as sleep } from 'node:timers/promises'; import { type Box, + DEFAULT_PACING, type Locator, MASKED_VALUE, type Step, @@ -19,8 +20,8 @@ import { } from './readiness.ts'; import { waitForReady } from './ready.ts'; -/** Spec 3: the recording shows typing, one character every 35 ms. */ -export const TYPING_DELAY_MS = 35; +/** The recording shows typing, one character every 80 ms unless the scenario's pacing says otherwise (C-203). */ +export const TYPING_DELAY_MS = DEFAULT_PACING.typingDelayMs; /** A scroll waits on animation frames; this bounds one wait if the page stops producing them. */ const SCROLL_FRAME_FALLBACK_MS = 100; @@ -55,6 +56,8 @@ export interface StepContext { /** Where the real pointer is; actions that move it update it. */ pointer: Point; observers: readonly EngineObserver[]; + /** Milliseconds between two characters a `fill` types. */ + typingDelayMs: number; } /** The fields of a step's timeline event the action itself knows. */ @@ -130,7 +133,7 @@ export async function runAction( if (!masked) { await target.fill('', { timeout: step.timeoutMs }); const box = await measure(target); - await type(target, value, step.timeoutMs); + await type(target, value, step.timeoutMs, ctx.typingDelayMs); return { ...withBox(box), value }; } // #42: a failure part-way leaves typed characters on screen, so the @@ -139,7 +142,7 @@ export async function runAction( try { await target.fill('', { timeout: step.timeoutMs }); box = await measure(target); - await type(target, value, step.timeoutMs); + await type(target, value, step.timeoutMs, ctx.typingDelayMs); } catch (error) { box ??= await measure(target); throw maskedFailure(error, withBox(box)); @@ -207,10 +210,11 @@ async function type( target: PlaywrightLocator, value: string, timeoutMs: number, + delayMs: number, ): Promise { await target.pressSequentially(value, { - delay: TYPING_DELAY_MS, - timeout: timeoutMs + value.length * TYPING_DELAY_MS, + delay: delayMs, + timeout: timeoutMs + value.length * delayMs, }); } diff --git a/packages/engine/src/execute/observer.ts b/packages/engine/src/execute/observer.ts index e5cc739f..38c5816d 100644 --- a/packages/engine/src/execute/observer.ts +++ b/packages/engine/src/execute/observer.ts @@ -33,6 +33,8 @@ export interface RunOutcome { maskedElements?: MaskedElement[]; /** Scenes and captions the page set through `window.demoflow` (#201); absent when none. */ annotations?: Annotation[]; + /** How long the recording held the final frame after the last step (C-203); only on a recorded run that passed. */ + endHoldMs?: number; /** The absolute path of the raw recording, when the browser was started. */ videoPath?: string; } diff --git a/packages/engine/src/execute/pacing.ts b/packages/engine/src/execute/pacing.ts new file mode 100644 index 00000000..99daacc1 --- /dev/null +++ b/packages/engine/src/execute/pacing.ts @@ -0,0 +1,46 @@ +import type { Pacing, Step, StepAction } from '@demoflow/core'; + +/** Steps whose result the viewer sees: the default dwell follows them (C-203). */ +export const DWELL_ACTIONS: ReadonlySet = new Set([ + 'navigate', + 'click', + 'hover', + 'fill', + 'select', + 'press', + 'scroll', + 'assertVisible', + 'assertText', +]); + +/** How one step is paced. */ +export interface StepPace { + /** Slept after the step succeeds, before the next one starts. */ + dwellMs: number; + /** Between two characters a `fill` types. */ + typingDelayMs: number; +} + +export interface PaceMode { + /** The step is on camera: off-camera steps (setup) are never slowed down. */ + onCamera: boolean; + /** The run records a video; a check run (ADR-0021) has nothing to watch. */ + recording: boolean; + /** The last step: the end hold follows it instead of the default dwell. */ + last: boolean; +} + +/** + * The pace of one step (C-203). A step's own `dwellMs` and `typingDelayMs` + * win over the scenario's pacing; off camera only an explicit typing delay + * applies, and nothing dwells. + */ +export function stepPace(step: Step, pacing: Pacing, mode: PaceMode): StepPace { + const ownTyping = step.action === 'fill' ? step.typingDelayMs : undefined; + const typingDelayMs = ownTyping ?? (mode.onCamera ? pacing.typingDelayMs : 0); + if (!mode.onCamera || !mode.recording) return { dwellMs: 0, typingDelayMs }; + const dwellMs = + step.dwellMs ?? + (mode.last || !DWELL_ACTIONS.has(step.action) ? 0 : pacing.stepDwellMs); + return { dwellMs, typingDelayMs }; +} diff --git a/packages/engine/src/run.ts b/packages/engine/src/run.ts index a5ffecdd..32e8624a 100644 --- a/packages/engine/src/run.ts +++ b/packages/engine/src/run.ts @@ -1,4 +1,5 @@ import { mkdir } from 'node:fs/promises'; +import { setTimeout as sleep } from 'node:timers/promises'; import { type Annotation, deriveRunStatus, @@ -7,6 +8,8 @@ import { type MaskedElement, type Navigation, offCameraSteps, + type Pacing, + resolvePacing, type Scenario, type Stage, type Stages, @@ -32,6 +35,7 @@ import { MarkedMasks } from './execute/marked-masks.ts'; import { MaskTracker } from './execute/mask.ts'; import { NavigationRecorder } from './execute/navigations.ts'; import type { EngineObserver, RunOutcome } from './execute/observer.ts'; +import { stepPace } from './execute/pacing.ts'; import { installPageScripts } from './execute/page-scripts.ts'; import { type Point, viewportCentre } from './execute/pointer.ts'; import { @@ -90,6 +94,7 @@ export async function runScenario( const stages = pendingStages(); const recording = recordingOptions(scenario, options.runDir); const baseUrl = scenario.baseUrl ?? options.baseUrl; + const pacing = resolvePacing(scenario.pacing); await mkdir(options.runDir, { recursive: true }); await emit('onRunStarted', { @@ -139,10 +144,14 @@ export async function runScenario( session: Session, range: { from: number; to: number }, events: TimelineEvent[], + onCamera: boolean, ): Promise => executeSteps({ steps, ...range, + pacing, + onCamera, + recording: record, page: session.page, clock: session.clock, baseUrl, @@ -169,7 +178,12 @@ export async function runScenario( }), }); const offEvents: TimelineEvent[] = []; - const failure = await execute(off, { from: 0, to: hidden }, offEvents); + const failure = await execute( + off, + { from: 0, to: hidden }, + offEvents, + false, + ); if (failure === undefined) { start = { storageState: await off.context.storageState(), @@ -215,7 +229,13 @@ export async function runScenario( session, { from: hidden, to: steps.length }, events, + true, ); + // The final frame stays on screen before the video stops (C-203); a failed + // run ends at the failure, and a check has nothing to watch. + const endHoldMs = + record && failure === undefined ? pacing.endHoldMs : undefined; + if (endHoldMs !== undefined && endHoldMs > 0) await sleep(endHoldMs); // Before the context closes: a document's clock exchange may still be running on it. const maskedElements = await marked.list(); @@ -255,6 +275,7 @@ export async function runScenario( navigations: navigations.list(), maskedElements, annotations: annotations.list(), + endHoldMs, }); await emit('onRunFinished', { outcome, video }); return outcome; @@ -340,6 +361,11 @@ interface ExecuteInput { steps: readonly ExpandedStep[]; from: number; to: number; + pacing: Pacing; + /** Off-camera steps (ADR-0018) are not paced. */ + onCamera: boolean; + /** Whether the run records a video: a check run does not dwell. */ + recording: boolean; page: Page; clock: Clock; baseUrl: string | undefined; @@ -378,8 +404,14 @@ async function executeSteps(input: ExecuteInput): Promise { input.annotations.stepStarted(startMs); await emit('onStepStarted', { stepIndex, step, startMs }); + const pace = stepPace(step, input.pacing, { + onCamera: input.onCamera, + recording: input.recording, + last: stepIndex === input.to - 1, + }); const ctx = { page: input.page, + typingDelayMs: pace.typingDelayMs, stepIndex, baseUrl: input.baseUrl, guard: input.guard, @@ -425,6 +457,10 @@ async function executeSteps(input: ExecuteInput): Promise { ...(failure === undefined ? {} : failure.detail), ...(step.caption === undefined ? {} : { caption: step.caption }), ...('zoom' in step && step.zoom !== undefined ? { zoom: step.zoom } : {}), + // A failed step does not dwell: the run stops there. + ...(failure === undefined && pace.dwellMs > 0 + ? { dwellMs: pace.dwellMs } + : {}), }; if (failure !== undefined && failure.stage === 'execution') { event.error = { message: scrub(failure.message) }; @@ -450,6 +486,8 @@ async function executeSteps(input: ExecuteInput): Promise { origin: step.origin, }; } + // The viewer sees the step's result before the next step starts (C-203). + if (event.dwellMs !== undefined) await sleep(event.dwellMs); } return undefined; } @@ -528,10 +566,17 @@ function conclude( navigations?: Navigation[]; maskedElements?: MaskedElement[]; annotations?: Annotation[]; + endHoldMs?: number | undefined; } = {}, ): RunOutcome { - const { videoPath, syncMark, navigations, maskedElements, annotations } = - recorded; + const { + videoPath, + syncMark, + navigations, + maskedElements, + annotations, + endHoldMs, + } = recorded; const warnings: string[] = []; return { startedAt, @@ -551,6 +596,7 @@ function conclude( ? {} : { annotations }), ...(videoPath === undefined ? {} : { videoPath }), + ...(endHoldMs === undefined ? {} : { endHoldMs }), }; } diff --git a/packages/engine/test/execute/pacing.spec.ts b/packages/engine/test/execute/pacing.spec.ts new file mode 100644 index 00000000..5901511c --- /dev/null +++ b/packages/engine/test/execute/pacing.spec.ts @@ -0,0 +1,293 @@ +import { mkdtemp, rm } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import path from 'node:path'; +import { + DEFAULT_PACING, + resolvePacing, + type Step, + type StepInput, + StepSchema, +} from '@demoflow/core'; +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; +import { stepPace } from '../../src/execute/pacing.ts'; +import { + type EngineObserver, + type RunOptions, + runScenario, +} from '../../src/index.ts'; +import { + type FixtureServer, + SIGN_IN_PATH, + startFixtureServer, +} from './fixture-server.ts'; +import { scenario } from './scenario.ts'; + +function step(input: StepInput): Step { + return StepSchema.parse(input); +} + +const onCamera = { onCamera: true, recording: true, last: false }; +const defaults = resolvePacing(undefined); + +describe('stepPace', () => { + it('dwells after a visible step and types at the default speed', () => { + expect(defaults).toEqual({ + stepDwellMs: 1_000, + endHoldMs: 3_500, + typingDelayMs: 80, + }); + for (const input of [ + { action: 'navigate', path: '/' }, + { action: 'click', target: { text: 'Go' } }, + { action: 'fill', target: { label: 'Name' }, value: 'Ada' }, + { action: 'select', target: { label: 'Size' }, option: 'L' }, + { action: 'press', key: 'Enter' }, + { action: 'assertVisible', target: { text: 'Done' } }, + ] as const) { + expect(stepPace(step(input), defaults, onCamera)).toEqual({ + dwellMs: 1_000, + typingDelayMs: 80, + }); + } + }); + + it('does not dwell after a step with nothing new to see', () => { + for (const input of [ + { action: 'wait', ms: 500 }, + { action: 'marker', title: 'Scene' }, + { action: 'waitFor', target: { text: 'Done' } }, + { action: 'waitForReady', name: 'list' }, + { action: 'screenshot', name: 'shot' }, + ] as const) { + expect(stepPace(step(input), defaults, onCamera).dwellMs).toBe(0); + } + }); + + it('takes the scenario pacing, and a step overrides it', () => { + const pacing = resolvePacing({ stepDwellMs: 300, typingDelayMs: 20 }); + expect(pacing.endHoldMs).toBe(DEFAULT_PACING.endHoldMs); + const fill = { + action: 'fill', + target: { label: 'Name' }, + value: 'Ada', + } as const; + expect(stepPace(step(fill), pacing, onCamera)).toEqual({ + dwellMs: 300, + typingDelayMs: 20, + }); + expect( + stepPace( + step({ ...fill, dwellMs: 2_000, typingDelayMs: 150 }), + pacing, + onCamera, + ), + ).toEqual({ dwellMs: 2_000, typingDelayMs: 150 }); + // 0 turns the dwell off; a marker may ask for one. + expect(stepPace(step({ ...fill, dwellMs: 0 }), pacing, onCamera)).toEqual({ + dwellMs: 0, + typingDelayMs: 20, + }); + expect( + stepPace( + step({ action: 'marker', title: 'Scene', dwellMs: 800 }), + pacing, + onCamera, + ).dwellMs, + ).toBe(800); + }); + + it('leaves the default dwell off the last step: the end hold follows it', () => { + const click = step({ action: 'click', target: { text: 'Go' } }); + const last = { ...onCamera, last: true }; + expect(stepPace(click, defaults, last).dwellMs).toBe(0); + expect( + stepPace({ ...click, dwellMs: 500 } as Step, defaults, last).dwellMs, + ).toBe(500); + }); + + it('does not slow down off-camera steps or a check run', () => { + const fill = step({ + action: 'fill', + target: { label: 'Name' }, + value: 'Ada', + dwellMs: 2_000, + }); + expect(stepPace(fill, defaults, { ...onCamera, onCamera: false })).toEqual({ + dwellMs: 0, + typingDelayMs: 0, + }); + expect( + stepPace({ ...fill, typingDelayMs: 50 } as Step, defaults, { + ...onCamera, + onCamera: false, + }).typingDelayMs, + ).toBe(50); + expect(stepPace(fill, defaults, { ...onCamera, recording: false })).toEqual( + { dwellMs: 0, typingDelayMs: 80 }, + ); + }); +}); + +let fixture: FixtureServer; +const runDirs: string[] = []; + +beforeAll(async () => { + fixture = await startFixtureServer(); +}); + +afterAll(async () => { + await fixture.close(); + await Promise.all( + runDirs.map((dir) => rm(dir, { recursive: true, force: true })), + ); +}); + +async function options(extra: Partial = {}): Promise { + const runDir = await mkdtemp(path.join(tmpdir(), 'demoflow-engine-')); + runDirs.push(runDir); + return { + runDir, + baseUrl: fixture.origin, + allowedOrigins: [fixture.origin], + env: {}, + ...extra, + }; +} + +/** When the last step finished and when the run did, in wall-clock ms. */ +function endWatch(): { + observer: EngineObserver; + times: { lastStepMs?: number; finishedMs?: number }; +} { + const times: { lastStepMs?: number; finishedMs?: number } = {}; + return { + times, + observer: { + onStepFinished() { + times.lastStepMs = Date.now(); + }, + onRunFinished() { + times.finishedMs = Date.now(); + }, + }, + }; +} + +const fillPassword = { + action: 'fill', + target: { label: 'Password' }, + value: 'abc', +} as const; + +describe('a paced run', () => { + it('dwells after each visible step, then holds the final frame', async () => { + const { observer, times } = endWatch(); + const outcome = await runScenario( + scenario( + [ + { action: 'navigate', path: '/login' }, + fillPassword, + { action: 'wait', ms: 200 }, + { ...fillPassword, dwellMs: 0 }, + { action: 'marker', title: 'Done' }, + ], + { pacing: { stepDwellMs: 400, endHoldMs: 700, typingDelayMs: 50 } }, + ), + await options({ observers: [observer] }), + ); + expect(outcome.stages.execution.status).toBe('passed'); + const [navigate, fill, wait, refill, marker] = outcome.events; + expect(navigate?.dwellMs).toBe(400); + expect(fill?.dwellMs).toBe(400); + expect(wait?.dwellMs).toBeUndefined(); + expect(refill?.dwellMs).toBeUndefined(); + expect(marker?.dwellMs).toBeUndefined(); + // The next step starts after the dwell, and an explicit wait adds to it. + expect( + (fill?.startMs ?? 0) - (navigate?.endMs ?? 0), + ).toBeGreaterThanOrEqual(400); + expect((refill?.startMs ?? 0) - (fill?.endMs ?? 0)).toBeGreaterThanOrEqual( + 600, + ); + // Three characters at 50 ms: two gaps between them at least. + expect((fill?.endMs ?? 0) - (fill?.startMs ?? 0)).toBeGreaterThanOrEqual( + 100, + ); + expect(outcome.endHoldMs).toBe(700); + expect( + (times.finishedMs ?? 0) - (times.lastStepMs ?? 0), + ).toBeGreaterThanOrEqual(700); + }); + + it('does not slow down setup steps', async () => { + // Wall-clock ms between the end of setup step 0 and the start of step 1. + let finished0: number | undefined; + let gapMs: number | undefined; + const observer: EngineObserver = { + onStepFinished({ stepIndex }) { + if (stepIndex === 0) finished0 = Date.now(); + }, + onStepStarted({ stepIndex }) { + if (stepIndex === 1 && finished0 !== undefined) { + gapMs = Date.now() - finished0; + } + }, + }; + const outcome = await runScenario( + scenario([fillPassword], { + setup: [ + { action: 'navigate', path: SIGN_IN_PATH }, + { action: 'navigate', path: '/login' }, + ], + pacing: { stepDwellMs: 5_000, endHoldMs: 0 }, + }), + await options({ observers: [observer] }), + ); + expect(outcome.stages.execution.status).toBe('passed'); + expect(gapMs).toBeDefined(); + expect(gapMs ?? Infinity).toBeLessThan(2_000); + expect(outcome.endHoldMs).toBe(0); + }); + + it('neither dwells nor holds in a check run', async () => { + const outcome = await runScenario( + scenario([{ action: 'navigate', path: '/login' }, fillPassword], { + pacing: { stepDwellMs: 5_000, endHoldMs: 5_000 }, + }), + await options({ record: false }), + ); + expect(outcome.stages.execution.status).toBe('passed'); + expect(outcome.events.every((event) => event.dwellMs === undefined)).toBe( + true, + ); + expect(outcome.endHoldMs).toBeUndefined(); + // A 5 s dwell and a 5 s hold would take 10 s. + expect( + Date.parse(outcome.finishedAt) - Date.parse(outcome.startedAt), + ).toBeLessThan(8_000); + }); + + it('does not hold the end of a failed run', async () => { + const { observer, times } = endWatch(); + const outcome = await runScenario( + scenario( + [ + { action: 'navigate', path: '/login' }, + { + action: 'click', + target: { role: 'button', name: 'No such button' }, + timeoutMs: 300, + }, + ], + { pacing: { stepDwellMs: 0, endHoldMs: 5_000 } }, + ), + await options({ observers: [observer] }), + ); + expect(outcome.status).toBe('failed'); + expect(outcome.events.at(-1)?.dwellMs).toBeUndefined(); + expect(outcome.endHoldMs).toBeUndefined(); + expect((times.finishedMs ?? 0) - (times.lastStepMs ?? 0)).toBeLessThan( + 5_000, + ); + }); +}); diff --git a/packages/engine/test/execute/scenario.ts b/packages/engine/test/execute/scenario.ts index 0cf68453..84c0af5a 100644 --- a/packages/engine/test/execute/scenario.ts +++ b/packages/engine/test/execute/scenario.ts @@ -5,7 +5,10 @@ import { type ScenarioStepInput, } from '@demoflow/core'; -/** An inline scenario, validated and with defaults applied. */ +/** + * An inline scenario, validated and with defaults applied. It does not dwell + * or hold the end unless `pacing` says so (C-203), to keep the suite fast. + */ export function scenario( steps: ScenarioStepInput[], extra: { @@ -13,12 +16,14 @@ export function scenario( viewport?: { width: number; height: number }; data?: ScenarioInput['data']; setup?: ScenarioInput['setup']; + pacing?: ScenarioInput['pacing']; } = {}, ): Scenario { const parsed = parseScenario({ schemaVersion: 1, name: 'inline', viewport: { width: 1280, height: 720 }, + pacing: { stepDwellMs: 0, endHoldMs: 0 }, ...extra, steps, }); From 4bc31d10cd4a2ccbab85533181258f27dfdc36b9 Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 26 Oct 2026 17:05:27 +0100 Subject: [PATCH 3/6] feat(renderer): keep step dwells and the end hold at real speed The idle trim no longer compresses a dwell or the end hold the engine recorded, and a timeline's endHoldMs replaces the fixed 1 s tail. Document pacing in the scenario reference. --- apps/web/src/app/docs/scenarios/page.mdx | 45 ++++++++++++++++++++++-- packages/renderer/src/plan/plan.ts | 22 ++++++++++-- packages/renderer/test/plan/plan.spec.ts | 36 ++++++++++++++++++- 3 files changed, 98 insertions(+), 5 deletions(-) diff --git a/apps/web/src/app/docs/scenarios/page.mdx b/apps/web/src/app/docs/scenarios/page.mdx index df816888..ca92f61d 100644 --- a/apps/web/src/app/docs/scenarios/page.mdx +++ b/apps/web/src/app/docs/scenarios/page.mdx @@ -74,14 +74,15 @@ whole string instead of a part of it. ## Steps Every step has an `action`. Every step may also carry a `caption`, a -`timeoutMs` and `"record": false` (see [Off-camera steps](#off-camera-steps)). +`timeoutMs`, a `dwellMs` (see [Pacing](#pacing)) and `"record": false` (see +[Off-camera steps](#off-camera-steps)). | Action | What it does | Fields | |---|---|---| | `navigate` | Opens a page. | exactly one of `path` (starts with a single `/`) or `url` | | `waitFor` | Waits for an element. | `target`, `state` (`visible` by default, or `hidden`) | | `click` | Clicks an element. | `target` | -| `fill` | Types into a field. | `target`, exactly one of `value` or `valueFrom` | +| `fill` | Types into a field. | `target`, exactly one of `value` or `valueFrom`; optional `typingDelayMs` | | `select` | Picks an option of a select. | `target`, `option` | | `hover` | Moves the pointer over an element. | `target` | | `press` | Presses a key or a chord, such as `Enter` or `Control+a`. | `key`, optional `target` | @@ -128,6 +129,46 @@ steps that have a target, `waitFor` for a hidden element excepted, and on } ``` +### Pacing + +A recording plays slowly enough to follow. After each visible step +(`navigate`, `click`, `hover`, `fill`, `select`, `press`, `scroll`, +`assertVisible`, `assertText`) the video stays on the result for a moment +before the next step. After the last step of a successful run it holds the +final frame, so the result of the demo stays on screen. A `fill` types one +character at a time. + +The top-level `pacing` object sets these for the whole scenario. Every field is +optional and has a default: + +| Field | Default | Range | What it does | +|---|---|---|---| +| `stepDwellMs` | 1000 | 0 to 10000 | Pause after each visible step. `0` turns it off. | +| `endHoldMs` | 3500 | 0 to 10000 | Hold on the final frame after the last step. `0` ends the video at the last step. | +| `typingDelayMs` | 80 | 0 to 500 | Pause between two typed characters of a `fill`. | + +A step overrides the scenario's pacing for itself: `dwellMs` (0 to 10000) on +any step, and `typingDelayMs` (0 to 500) on a `fill`. A `dwellMs` also adds a +pause after a step that has none by default, such as a `marker`. The last step +does not dwell unless it sets `dwellMs`; the end hold follows it. + +```json +{ + "pacing": { "stepDwellMs": 700, "endHoldMs": 5000, "typingDelayMs": 60 }, + "steps": [ + { "action": "fill", "target": { "label": "Title" }, "value": "Hello", "typingDelayMs": 120 }, + { "action": "click", "target": { "role": "button", "name": "Publish" }, "dwellMs": 2000 }, + { "action": "assertVisible", "target": { "text": "Hello" } } + ] +} +``` + +A `wait` still pauses on top of the dwell. Pacing never slows down +[setup and off-camera steps](#off-camera-steps), and a check run +(`demoflow run --check`) neither dwells nor holds the end. The renderer keeps the +dwells and the end hold at real speed: only other frozen stretches, such as a +long `wait`, are shortened. + ### Scene markers A `marker` with `kind: "scene"` starts a new scene. It gets a scene card in the diff --git a/packages/renderer/src/plan/plan.ts b/packages/renderer/src/plan/plan.ts index ff6879e3..08ac83b7 100644 --- a/packages/renderer/src/plan/plan.ts +++ b/packages/renderer/src/plan/plan.ts @@ -87,7 +87,7 @@ const TIMING = { maskLeadMs: 200, /** Masks end this late, for the same reason: an early end leaks, a late one is safe (#48). */ maskTrailMs: 200, - /** A successful run keeps this much video after its last event. */ + /** A successful run keeps this much video after its last event, when its timeline names no `endHoldMs`. */ tailMs: 1_000, /** A target box fills at most this share of the zoomed view. */ targetFill: 0.9, @@ -218,12 +218,16 @@ export function planRender( ? undefined : events.find((event) => event.stepIndex === failure.stepIndex); const lastEvent = events.at(-1); + // The engine's end hold (C-203) follows the last event's own dwell. + const holdFromMs = + lastEvent === undefined ? 0 : lastEvent.endMs + (lastEvent.dwellMs ?? 0); + const endHoldMs = timeline.endHoldMs ?? TIMING.tailMs; const sourceEndMs = failure !== undefined ? toSource(failedEvent?.endMs ?? lastEvent?.endMs ?? source.durationMs) : lastEvent === undefined ? source.durationMs - : toSource(lastEvent.endMs + TIMING.tailMs); + : toSource(holdFromMs + endHoldMs); const active: Interval[] = events .filter((event) => ACTIVE.has(event.action)) @@ -231,6 +235,20 @@ export function planRender( startMs: toSource(event.startMs), endMs: toSource(event.endMs), })); + // A dwell and the end hold are there to be watched: the idle trim never cuts them (C-203). + for (const event of events) { + if (event.dwellMs === undefined) continue; + active.push({ + startMs: toSource(event.endMs), + endMs: toSource(event.endMs + event.dwellMs), + }); + } + if (timeline.endHoldMs !== undefined && lastEvent !== undefined) { + active.push({ + startMs: toSource(holdFromMs), + endMs: toSource(holdFromMs + timeline.endHoldMs), + }); + } const idle = idleStretches(source.freezes, active, thresholdMs, sourceEndMs); // Page time: the map before cards. Overlays are planned in it, then moved // past the cards, so no lead or trail is ever measured across a card. diff --git a/packages/renderer/test/plan/plan.spec.ts b/packages/renderer/test/plan/plan.spec.ts index 3687b6cd..a95a2e0c 100644 --- a/packages/renderer/test/plan/plan.spec.ts +++ b/packages/renderer/test/plan/plan.spec.ts @@ -78,15 +78,17 @@ function plan( failed?: Parameters[0]; maskedElements?: MaskedElement[]; annotations?: Annotation[]; + endHoldMs?: number; } = {}, ): RenderPlan { - const { failed, maskedElements, annotations, ...rest } = options; + const { failed, maskedElements, annotations, endHoldMs, ...rest } = options; return planRender( { timeline: { ...timeline(events), ...(maskedElements === undefined ? {} : { maskedElements }), ...(annotations === undefined ? {} : { annotations }), + ...(endHoldMs === undefined ? {} : { endHoldMs }), }, result: result(failed), source: { @@ -254,6 +256,38 @@ describe('time map', () => { expect(source).toBe(8000); }); + it('keeps a frozen dwell at real speed, and still compresses a wait (C-203)', () => { + const rendered = plan( + [ + { ...click(0, 1000, { x: 300, y: 200 }), dwellMs: 1500 }, + event({ action: 'wait', startMs: 2500, endMs: 5000 }), + click(5000, 5600, { x: 900, y: 500 }), + ], + [{ startMs: 1000, endMs: 5000 }], + ); + // The dwell plays 1:1; only the wait after it is compressed. + expect(toOutputMs(rendered.timeMap, 2500)).toBe(2500); + expect(toOutputMs(rendered.timeMap, 5000)).toBe(2900); + }); + + it("ends a passed run at the engine's end hold, after the last dwell (C-203)", () => { + const rendered = plan( + [{ ...click(0, 1000, { x: 300, y: 200 }), dwellMs: 500 }], + // The page is frozen from the click on: dwell and hold are kept whole. + [{ startMs: 1000, endMs: 20_000 }], + { endHoldMs: 3500 }, + ); + expect(rendered.durationMs).toBe(1000 + 500 + 3500); + expect(toOutputMs(rendered.timeMap, 5000)).toBe(5000); + }); + + it('ends at the last event when the end hold is 0', () => { + const rendered = plan([click(0, 1000, { x: 300, y: 200 })], [], { + endHoldMs: 0, + }); + expect(rendered.durationMs).toBe(1000); + }); + it('applies the clock offset: source = timeline + offsetMs', () => { const rendered = plan([click(1000, 2000, { x: 300, y: 200 })], [], { offsetMs: -100, From a03671bce01187e40885a75879117b66045c894d Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 26 Oct 2026 17:38:34 +0100 Subject: [PATCH 4/6] test(renderer): record fixture runs at the timing the plan tests expect Recorded fixture scenarios now get the default pacing; the renderer's real-run tests pin no dwell, a 1 s end hold and 35 ms typing unless a scenario sets its own pacing. --- packages/renderer/test/plan/fixture-runs.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/renderer/test/plan/fixture-runs.ts b/packages/renderer/test/plan/fixture-runs.ts index 303e2296..7b1fff50 100644 --- a/packages/renderer/test/plan/fixture-runs.ts +++ b/packages/renderer/test/plan/fixture-runs.ts @@ -60,6 +60,17 @@ export async function recordFixtureRun( ); } +/** + * The pacing these runs record with unless the scenario sets its own: no + * dwell, a 1 s end hold and 35 ms typing, the timing the plan tests were + * written against. Pacing itself is tested in the engine and in `plan.spec.ts`. + */ +const TEST_PACING = { + stepDwellMs: 0, + endHoldMs: 1_000, + typingDelayMs: 35, +} as const; + /** * Records a scenario given inline — validated as a scenario file is — against * the fixture, into `/`, and returns that run directory. @@ -70,7 +81,11 @@ export async function recordInlineRun( parentDir: string, observers: readonly EngineObserver[] = [], ): Promise { - const parsed = parseScenario(input); + const parsed = parseScenario( + typeof input === 'object' && input !== null && !('pacing' in input) + ? { ...input, pacing: TEST_PACING } + : input, + ); if (!parsed.ok) throw new Error(JSON.stringify(parsed.errors)); const runDir = path.join(parentDir, name); From 0f3d6e1d7dd3c2b5ad90835228ec9847c80abe48 Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 26 Oct 2026 18:14:11 +0100 Subject: [PATCH 5/6] test(fixture): pace the five-customer repeat lightly With the default pacing the 26-step repeat takes about 30 s more; the CLI test checks iteration tagging, not pacing. The scenario now sets its own pacing, which also exercises the field through the CLI. --- apps/fixture/demoflow/customers-repeat.demo.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/fixture/demoflow/customers-repeat.demo.json b/apps/fixture/demoflow/customers-repeat.demo.json index 020edbf9..03ccc40e 100644 --- a/apps/fixture/demoflow/customers-repeat.demo.json +++ b/apps/fixture/demoflow/customers-repeat.demo.json @@ -12,6 +12,7 @@ { "name": "Ken Thompson", "email": "ken@example.com" } ] }, + "pacing": { "stepDwellMs": 250, "endHoldMs": 1000, "typingDelayMs": 20 }, "steps": [ { "action": "navigate", "path": "/customers" }, { From 6495e8ac8e91a8d98cf7a5c624e70c15cd921e17 Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 26 Oct 2026 20:00:57 +0100 Subject: [PATCH 6/6] Format the engine pacing test as Biome prints it --- packages/engine/test/execute/pacing.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/engine/test/execute/pacing.spec.ts b/packages/engine/test/execute/pacing.spec.ts index e456ea90..057ed432 100644 --- a/packages/engine/test/execute/pacing.spec.ts +++ b/packages/engine/test/execute/pacing.spec.ts @@ -122,9 +122,9 @@ describe('stepPace', () => { ).toBe(50); // A check run adds no default dwell; a step's own hold still applies. const plain = { ...fill, hold: undefined } as Step; - expect(stepPace(plain, defaults, { ...onCamera, recording: false })).toEqual( - { dwellMs: 0, typingDelayMs: 80 }, - ); + expect( + stepPace(plain, defaults, { ...onCamera, recording: false }), + ).toEqual({ dwellMs: 0, typingDelayMs: 80 }); }); });