feat(scenario): export scenarios as standalone playwright e2e test projects

- Added E2eExportService to package scenarios as plug-and-play zip archives
  containing package.json, playwright.config.ts, test.spec.ts, .env, credentials.json,
  snippets, and referenced scenario files
- Only bundles credentials, snippets, and files actually referenced (directly or
  transitively) by the scenario's steps, reducing archive size
- Exported test runs entirely offline using a context shim that mirrors liqa's API
  (page, getCredential, runSnippet, getScenarioFiles, downloadFile, assert, etc.)
- Added GET /scenarios/:id/export-e2e HTTP endpoint and export_e2e_test MCP tool
- Added getUsedSnippets() endpoint to list snippets referenced by a scenario
- Added "Used Snippets" section on scenario detail page
- Added archiver@^7.0.1 dependency for zip archive creation
- Bumped version to 1.11.0
This commit is contained in:
ars9 committed 2026-09-16 12:33:16 +03:00
1 parent 385f51f3ba
commit 1eea4eb8d8
14 files changed
+1348 -11

No files matched your search

+32 -1
View File
@@ -28,11 +28,15 @@ import { ExportEntity } from "./dto/scenario-export.dto";
import { UpdateScenarioStepDto } from "./dto/update-scenario-step.dto";
import { UpdateScenarioDto } from "./dto/update-scenario.dto";
import { ScenarioService } from "./scenario.service";
import { E2eExportService } from "./e2e-export.service";
@ApiTags("scenarios")
@Controller("scenarios")
export class ScenarioController {
constructor(private readonly scenarioService: ScenarioService) {}
constructor(
private readonly scenarioService: ScenarioService,
private readonly e2eExportService: E2eExportService,
) {}
// ── Scenarios ─────────────────────────────────────────────────────────────
@@ -130,6 +134,23 @@ export class ScenarioController {
return parts.join("\n");
}
@Get(":id/export-e2e")
@ApiOperation({
summary: "Export a scenario as a standalone, plug-and-play Playwright e2e test (zip)",
})
@ApiResponse({ status: 200, description: "Zip archive" })
@ApiResponse({ status: 404, description: "Scenario not found" })
async exportE2eTest(
@Param("id", ParseUUIDPipe) id: string,
@Res() res: Response,
) {
const { filename, buffer } = await this.e2eExportService.buildE2eTestPackage(id);
res.setHeader("Content-Type", "application/zip");
res.setHeader("Content-Disposition", `attachment; filename="${filename}"`);
res.setHeader("Content-Length", buffer.length);
res.send(buffer);
}
// ── Steps ─────────────────────────────────────────────────────────────────
@Post(":id/steps")
@@ -178,6 +199,16 @@ export class ScenarioController {
return this.scenarioService.removeStep(id, stepId);
}
@Get(":id/used-snippets")
@ApiOperation({
summary: "List snippets referenced (directly or transitively) by this scenario's steps",
})
@ApiResponse({ status: 200 })
@ApiResponse({ status: 404, description: "Scenario not found" })
getUsedSnippets(@Param("id", ParseUUIDPipe) id: string) {
return this.scenarioService.getUsedSnippets(id);
}
// ── Credentials ───────────────────────────────────────────────────────────
@Get(":id/credentials")