refactor(code-executor): migrate user scripts to single context argument
- 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
This commit is contained in:
@@ -216,7 +216,7 @@ describe("ScenarioController", () => {
|
||||
.expect(201);
|
||||
|
||||
expect(res.body.id).toBeDefined();
|
||||
expect(res.body.order).toBe(0);
|
||||
expect(res.body.order).toBe(1);
|
||||
});
|
||||
|
||||
it("creates a step without execCode", async () => {
|
||||
@@ -274,7 +274,7 @@ describe("ScenarioController", () => {
|
||||
.expect(200);
|
||||
|
||||
const orders = res.body.steps.map((s: { order: number }) => s.order);
|
||||
expect(orders).toEqual([0, 1, 2]);
|
||||
expect(orders).toEqual([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -573,7 +573,7 @@ describe("ScenarioController", () => {
|
||||
expect(res.body.name).toBe("imported scenario");
|
||||
expect(res.body.steps).toHaveLength(3);
|
||||
expect(res.body.steps.map((s: { order: number }) => s.order)).toEqual([
|
||||
0, 1, 2,
|
||||
1, 2, 3,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -689,7 +689,7 @@ describe("ScenarioController", () => {
|
||||
.expect(200);
|
||||
|
||||
const orders = res.body.stepRuns.map((s: { order: number }) => s.order);
|
||||
expect(orders).toEqual([0, 1, 2]);
|
||||
expect(orders).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it("returns 404 for unknown run", async () => {
|
||||
|
||||
Reference in New Issue
Block a user