feat(scenarios): export used snippets with a scenario
- list the snippets a scenario uses in the export dialog, checked by default, with the versions the scenario uses - export each selected snippet once per used version (latest and pinned) via the new snippetIds query parameter - resolve used snippets from the exported version's steps - show the scenario version in the export dialog - document the export query parameters - bump version to 1.22.0
This commit is contained in:
1 parent
f43d902297
commit
23fa302b25
13 files changed
+163
-18
No files matched your search
@@ -277,6 +277,47 @@ describe("Versioning", () => {
|
||||
expect(first[first.length - 1]).toMatchObject({ version: 1, steps: [] });
|
||||
});
|
||||
|
||||
it("includes selected used snippets at the versions the scenario uses", async () => {
|
||||
const alias = `exp-snip-${uniq()}`;
|
||||
const sn = await snippetService.create({
|
||||
alias,
|
||||
title: "t",
|
||||
code: "return 'one';",
|
||||
});
|
||||
await snippetService.update(sn.id, { code: "return 'two';" });
|
||||
const other = await snippetService.create({
|
||||
alias: `exp-other-${uniq()}`,
|
||||
title: "t",
|
||||
code: "return 3;",
|
||||
});
|
||||
|
||||
const sc = await scenarioService.create({ name: `exp-sn-${uniq()}` });
|
||||
await scenarioService.createStep(sc.id, {
|
||||
execCode: `await context.runSnippet("${alias}"); await context.runSnippet("${alias}@1"); await context.runSnippet("${alias}"); return context.runSnippet("${other.alias}");`,
|
||||
});
|
||||
|
||||
const withSnippet = await scenarioService.exportScenario(sc.id, {
|
||||
includeEnvironment: false,
|
||||
credentialIds: [],
|
||||
snippetIds: [sn.id],
|
||||
});
|
||||
expect(withSnippet.map((e) => e.kind)).toEqual([
|
||||
"snippet",
|
||||
"snippet",
|
||||
"scenario",
|
||||
]);
|
||||
expect(withSnippet.slice(0, 2)).toMatchObject([
|
||||
{ id: sn.id, version: 2, code: "return 'two';" },
|
||||
{ id: sn.id, version: 1, code: "return 'one';" },
|
||||
]);
|
||||
|
||||
const without = await scenarioService.exportScenario(sc.id, {
|
||||
includeEnvironment: false,
|
||||
credentialIds: [],
|
||||
});
|
||||
expect(without.map((e) => e.kind)).toEqual(["scenario"]);
|
||||
});
|
||||
|
||||
it("restores exact versions by id + version", async () => {
|
||||
const id = crypto.randomUUID();
|
||||
const base = { kind: "scenario" as const, id, name: "imported" };
|
||||
|
||||
Reference in new issue
Block a user