feat(scenarios): add step title, scenario credentials, and environment context in executor

- add nullable title column to scenario steps; exposed in create/edit forms and step table
- add scenario-credential join (many-to-many with CredentialEntity) with CRUD endpoints
- expose environment URLs in code executor helpers via helpers.env and helpers.getEnvUrl()
- resolve and cache environment per run from the login step's environmentName in scheduler
- add section spacing and step table title column to ScenarioDetailPage
This commit is contained in:
ars9 committed 2026-04-09 23:37:21 +03:00
1 parent 1f3a604940
commit 1efbbb38a3
34 files changed
+1362 -14

No files matched your search

@@ -7,6 +7,7 @@ import { TraceLogger } from "../common/trace-logger";
import { parse } from "acorn";
import type { Page, BrowserContext } from "playwright";
import { dumpDom } from "./dom-helpers";
import type { EnvironmentUrls } from "../environment/environment.entity";
export interface ExecResult {
result: unknown;
@@ -47,6 +48,8 @@ export class CodeExecutorService {
code: string,
log?: ScriptLogger,
getStepOutput?: (order: number) => Promise<unknown>,
credentials?: Record<string, unknown>,
environment?: EnvironmentUrls | null,
): Promise<ExecResult> {
const scriptLog: ScriptLogger =
log ?? ((level, msg) => this.logger[level](msg));
@@ -55,6 +58,9 @@ export class CodeExecutorService {
.map((a) => (typeof a === "object" ? JSON.stringify(a) : String(a)))
.join(" ");
const credMap: Record<string, unknown> = credentials ?? {};
const envUrls: EnvironmentUrls = environment ?? {};
try {
const pageHelpers = {
dumpDom: (selector?: string) => dumpDom(page, selector),
@@ -62,6 +68,26 @@ export class CodeExecutorService {
warn: (...args: unknown[]) => scriptLog("warn", toStr(args)),
error: (...args: unknown[]) => scriptLog("error", toStr(args)),
getStepOutput: getStepOutput ?? (() => Promise.resolve(null)),
getCredential: (alias: string): unknown => {
if (!(alias in credMap)) {
throw new Error(
`Credential alias "${alias}" not found in this scenario`,
);
}
return credMap[alias];
},
/** All URLs defined for the current environment (may be empty if no environment is set). */
env: { ...envUrls },
/** Returns the URL for the given key, or throws if it is not defined. */
getEnvUrl: (key: string): string => {
const value = envUrls[key];
if (value == null) {
throw new Error(
`Environment URL "${key}" is not defined for this environment`,
);
}
return value;
},
};
const fakeConsole = {