- replace (page, context, helpers) signature with async (context) => {}
- add ScriptContext interface exposing page, browser, env, getEnv,
getCredential, getStepOutput, runSnippet, dumpDom, log/warn/error
- rename getEnvUrl to getEnv throughout service and docs
- fix step ordering: normalizeStepOrder and run step rows are now 1-based
- migrate existing DB rows (scenario_steps, scenario_run_steps) +1
- update all tests and stored snippet/step code in DB to new API
2.4 KiB
2.4 KiB
Scenario execution
When a scenario run is created, the server creates one ScenarioRunStep per scenario step.
- Step runs are ordered by
step.order. - First step run starts as
pending; the rest start aswaiting. - Scheduler tick (
@Interval(1000)) picks pending runs and processes steps in order. - Steps in the same run share one Playwright browser/context/page.
Execution model
Current scheduler behavior is exec-centric:
execCodeis required for a step to pass.validateCodeis optional and runs afterexecCode.- Legacy step type metadata may still appear in MCP payloads, but run execution is not branched by step type.
Script runtime
execCode and validateCode execute as async JavaScript with:
page: PlaywrightPagecontext: PlaywrightBrowserContexthelpers: utility objectconsole: proxied to run logs (log,warn,error, etc.)
validateCode additionally receives result, which is the value returned by execCode.
Available helpers
helpers.dumpDom(selector?): simplified DOM snapshothelpers.log(...args),helpers.warn(...args),helpers.error(...args): structured step logshelpers.getStepOutput(order): prior step output by absolute order (0,1, ...) or relative (-1previous step)helpers.getCredential(alias): credential payload assigned to the scenario aliashelpers.env: shallow copy of environment URL maphelpers.getEnv(key): required environment value lookup (throws if missing)helpers.runSnippet(name, ...args): execute stored snippet code in the same page/context/helpers scope
Validation contract
validateCode may return:
return { success: true, description: 'ok' };
// or
return false;
Interpretation:
- Boolean:
true= pass,false= fail - Object:
successcontrols pass/fail;descriptionis persisted as step description
On validation failure, the step fails and the run is marked fail.
Statuses
Run status:
pendingin_progresspassfail
Run-step status:
waitingpendingin_progresspassfailcancelled
Example workflow
- Create environment
- Create credentials and snippets (optional but common)
- Create scenario
- Add ordered steps (
execCode, optionalvalidateCode) - Assign credentials to scenario aliases when needed
- Run scenario
- Wait for run completion and inspect run logs/outputs