@solidxai/core 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/run-tests.command.d.ts +37 -0
- package/dist/commands/run-tests.command.d.ts.map +1 -0
- package/dist/commands/run-tests.command.js +345 -0
- package/dist/commands/run-tests.command.js.map +1 -0
- package/dist/commands/test-data.command.d.ts +6 -6
- package/dist/commands/test-data.command.d.ts.map +1 -1
- package/dist/commands/test-data.command.js +25 -25
- package/dist/commands/test-data.command.js.map +1 -1
- package/dist/commands/test.command.d.ts +5 -0
- package/dist/commands/test.command.d.ts.map +1 -0
- package/dist/commands/test.command.js +26 -0
- package/dist/commands/test.command.js.map +1 -0
- package/dist/controllers/service.controller.d.ts +0 -9
- package/dist/controllers/service.controller.d.ts.map +1 -1
- package/dist/controllers/service.controller.js +0 -45
- package/dist/controllers/service.controller.js.map +1 -1
- package/dist/dtos/basic-filters.dto.d.ts.map +1 -1
- package/dist/dtos/basic-filters.dto.js.map +1 -1
- package/dist/dtos/create-user.dto.d.ts +1 -0
- package/dist/dtos/create-user.dto.d.ts.map +1 -1
- package/dist/dtos/create-user.dto.js +2 -1
- package/dist/dtos/create-user.dto.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +1 -20
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/module-test-data.service.d.ts.map +1 -1
- package/dist/seeders/module-test-data.service.js +3 -3
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts +2 -0
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +18 -2
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/queues/common.d.ts +3 -0
- package/dist/services/queues/common.d.ts.map +1 -0
- package/dist/services/queues/common.js +39 -0
- package/dist/services/queues/common.js.map +1 -0
- package/dist/services/queues/database-publisher.service.d.ts.map +1 -1
- package/dist/services/queues/database-publisher.service.js +3 -1
- package/dist/services/queues/database-publisher.service.js.map +1 -1
- package/dist/services/queues/database-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/database-subscriber.service.js +5 -2
- package/dist/services/queues/database-subscriber.service.js.map +1 -1
- package/dist/services/queues/rabbitmq-publisher.service.d.ts.map +1 -1
- package/dist/services/queues/rabbitmq-publisher.service.js +13 -6
- package/dist/services/queues/rabbitmq-publisher.service.js.map +1 -1
- package/dist/services/queues/rabbitmq-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/rabbitmq-subscriber.service.js +9 -5
- package/dist/services/queues/rabbitmq-subscriber.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +4 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/testing/__examples__/register-example-specs.d.ts +3 -0
- package/dist/testing/__examples__/register-example-specs.d.ts.map +1 -0
- package/dist/testing/__examples__/register-example-specs.js +8 -0
- package/dist/testing/__examples__/register-example-specs.js.map +1 -0
- package/dist/testing/__examples__/specs/custom-health.spec.d.ts +17 -0
- package/dist/testing/__examples__/specs/custom-health.spec.d.ts.map +1 -0
- package/dist/testing/__examples__/specs/custom-health.spec.js +30 -0
- package/dist/testing/__examples__/specs/custom-health.spec.js.map +1 -0
- package/dist/testing/adapters/api/api-adapter.d.ts +9 -0
- package/dist/testing/adapters/api/api-adapter.d.ts.map +1 -0
- package/dist/testing/adapters/api/api-adapter.js +76 -0
- package/dist/testing/adapters/api/api-adapter.js.map +1 -0
- package/dist/testing/adapters/api/api.types.d.ts +14 -0
- package/dist/testing/adapters/api/api.types.d.ts.map +1 -0
- package/dist/testing/adapters/api/api.types.js +3 -0
- package/dist/testing/adapters/api/api.types.js.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +14 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.js +47 -0
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -0
- package/dist/testing/adapters/ui/ui.types.d.ts +5 -0
- package/dist/testing/adapters/ui/ui.types.d.ts.map +1 -0
- package/dist/testing/adapters/ui/ui.types.js +3 -0
- package/dist/testing/adapters/ui/ui.types.js.map +1 -0
- package/dist/testing/contracts/runtime-context.types.d.ts +35 -0
- package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -0
- package/dist/testing/contracts/runtime-context.types.js +3 -0
- package/dist/testing/contracts/runtime-context.types.js.map +1 -0
- package/dist/testing/contracts/test-spec.types.d.ts +21 -0
- package/dist/testing/contracts/test-spec.types.d.ts.map +1 -0
- package/dist/testing/contracts/test-spec.types.js +3 -0
- package/dist/testing/contracts/test-spec.types.js.map +1 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts +41 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -0
- package/dist/testing/contracts/testing-metadata.types.js +3 -0
- package/dist/testing/contracts/testing-metadata.types.js.map +1 -0
- package/dist/testing/core/interpolation.d.ts +4 -0
- package/dist/testing/core/interpolation.d.ts.map +1 -0
- package/dist/testing/core/interpolation.js +180 -0
- package/dist/testing/core/interpolation.js.map +1 -0
- package/dist/testing/core/normalize-steps.d.ts +7 -0
- package/dist/testing/core/normalize-steps.d.ts.map +1 -0
- package/dist/testing/core/normalize-steps.js +20 -0
- package/dist/testing/core/normalize-steps.js.map +1 -0
- package/dist/testing/core/resource-store.d.ts +8 -0
- package/dist/testing/core/resource-store.d.ts.map +1 -0
- package/dist/testing/core/resource-store.js +41 -0
- package/dist/testing/core/resource-store.js.map +1 -0
- package/dist/testing/core/spec-registry.d.ts +10 -0
- package/dist/testing/core/spec-registry.d.ts.map +1 -0
- package/dist/testing/core/spec-registry.js +32 -0
- package/dist/testing/core/spec-registry.js.map +1 -0
- package/dist/testing/core/step-registry.d.ts +10 -0
- package/dist/testing/core/step-registry.d.ts.map +1 -0
- package/dist/testing/core/step-registry.js +26 -0
- package/dist/testing/core/step-registry.js.map +1 -0
- package/dist/testing/core/testing-engine.d.ts +14 -0
- package/dist/testing/core/testing-engine.d.ts.map +1 -0
- package/dist/testing/core/testing-engine.js +97 -0
- package/dist/testing/core/testing-engine.js.map +1 -0
- package/dist/testing/core/timeout.d.ts +2 -0
- package/dist/testing/core/timeout.d.ts.map +1 -0
- package/dist/testing/core/timeout.js +18 -0
- package/dist/testing/core/timeout.js.map +1 -0
- package/dist/testing/reporter/attachments.d.ts +4 -0
- package/dist/testing/reporter/attachments.d.ts.map +1 -0
- package/dist/testing/reporter/attachments.js +25 -0
- package/dist/testing/reporter/attachments.js.map +1 -0
- package/dist/testing/reporter/console-reporter.d.ts +45 -0
- package/dist/testing/reporter/console-reporter.d.ts.map +1 -0
- package/dist/testing/reporter/console-reporter.js +189 -0
- package/dist/testing/reporter/console-reporter.js.map +1 -0
- package/dist/testing/reporter/reporter.types.d.ts +37 -0
- package/dist/testing/reporter/reporter.types.d.ts.map +1 -0
- package/dist/testing/reporter/reporter.types.js +3 -0
- package/dist/testing/reporter/reporter.types.js.map +1 -0
- package/dist/testing/runner/lifecycle.d.ts +9 -0
- package/dist/testing/runner/lifecycle.d.ts.map +1 -0
- package/dist/testing/runner/lifecycle.js +33 -0
- package/dist/testing/runner/lifecycle.js.map +1 -0
- package/dist/testing/runner/run-from-metadata.d.ts +24 -0
- package/dist/testing/runner/run-from-metadata.d.ts.map +1 -0
- package/dist/testing/runner/run-from-metadata.js +70 -0
- package/dist/testing/runner/run-from-metadata.js.map +1 -0
- package/dist/testing/runner/scenario-filter.d.ts +9 -0
- package/dist/testing/runner/scenario-filter.d.ts.map +1 -0
- package/dist/testing/runner/scenario-filter.js +22 -0
- package/dist/testing/runner/scenario-filter.js.map +1 -0
- package/dist/testing/steps/api/auth.step.d.ts +3 -0
- package/dist/testing/steps/api/auth.step.d.ts.map +1 -0
- package/dist/testing/steps/api/auth.step.js +38 -0
- package/dist/testing/steps/api/auth.step.js.map +1 -0
- package/dist/testing/steps/api/index.d.ts +3 -0
- package/dist/testing/steps/api/index.d.ts.map +1 -0
- package/dist/testing/steps/api/index.js +10 -0
- package/dist/testing/steps/api/index.js.map +1 -0
- package/dist/testing/steps/api/request.step.d.ts +3 -0
- package/dist/testing/steps/api/request.step.d.ts.map +1 -0
- package/dist/testing/steps/api/request.step.js +281 -0
- package/dist/testing/steps/api/request.step.js.map +1 -0
- package/dist/testing/steps/assert/http.step.d.ts +3 -0
- package/dist/testing/steps/assert/http.step.d.ts.map +1 -0
- package/dist/testing/steps/assert/http.step.js +27 -0
- package/dist/testing/steps/assert/http.step.js.map +1 -0
- package/dist/testing/steps/assert/index.d.ts +3 -0
- package/dist/testing/steps/assert/index.d.ts.map +1 -0
- package/dist/testing/steps/assert/index.js +12 -0
- package/dist/testing/steps/assert/index.js.map +1 -0
- package/dist/testing/steps/assert/jsonpath.step.d.ts +3 -0
- package/dist/testing/steps/assert/jsonpath.step.d.ts.map +1 -0
- package/dist/testing/steps/assert/jsonpath.step.js +40 -0
- package/dist/testing/steps/assert/jsonpath.step.js.map +1 -0
- package/dist/testing/steps/assert/primitives.step.d.ts +3 -0
- package/dist/testing/steps/assert/primitives.step.d.ts.map +1 -0
- package/dist/testing/steps/assert/primitives.step.js +43 -0
- package/dist/testing/steps/assert/primitives.step.js.map +1 -0
- package/dist/testing/steps/test/index.d.ts +3 -0
- package/dist/testing/steps/test/index.d.ts.map +1 -0
- package/dist/testing/steps/test/index.js +8 -0
- package/dist/testing/steps/test/index.js.map +1 -0
- package/dist/testing/steps/test/test-spec.step.d.ts +3 -0
- package/dist/testing/steps/test/test-spec.step.d.ts.map +1 -0
- package/dist/testing/steps/test/test-spec.step.js +41 -0
- package/dist/testing/steps/test/test-spec.step.js.map +1 -0
- package/dist/testing/steps/ui/actions.step.d.ts +3 -0
- package/dist/testing/steps/ui/actions.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/actions.step.js +31 -0
- package/dist/testing/steps/ui/actions.step.js.map +1 -0
- package/dist/testing/steps/ui/assertions.step.d.ts +3 -0
- package/dist/testing/steps/ui/assertions.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/assertions.step.js +41 -0
- package/dist/testing/steps/ui/assertions.step.js.map +1 -0
- package/dist/testing/steps/ui/form.step.d.ts +3 -0
- package/dist/testing/steps/ui/form.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/form.step.js +34 -0
- package/dist/testing/steps/ui/form.step.js.map +1 -0
- package/dist/testing/steps/ui/index.d.ts +3 -0
- package/dist/testing/steps/ui/index.d.ts.map +1 -0
- package/dist/testing/steps/ui/index.js +14 -0
- package/dist/testing/steps/ui/index.js.map +1 -0
- package/dist/testing/steps/ui/navigation.step.d.ts +3 -0
- package/dist/testing/steps/ui/navigation.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/navigation.step.js +39 -0
- package/dist/testing/steps/ui/navigation.step.js.map +1 -0
- package/dist/testing/steps/util/index.d.ts +3 -0
- package/dist/testing/steps/util/index.d.ts.map +1 -0
- package/dist/testing/steps/util/index.js +12 -0
- package/dist/testing/steps/util/index.js.map +1 -0
- package/dist/testing/steps/util/log.step.d.ts +3 -0
- package/dist/testing/steps/util/log.step.d.ts.map +1 -0
- package/dist/testing/steps/util/log.step.js +18 -0
- package/dist/testing/steps/util/log.step.js.map +1 -0
- package/dist/testing/steps/util/require.step.d.ts +3 -0
- package/dist/testing/steps/util/require.step.d.ts.map +1 -0
- package/dist/testing/steps/util/require.step.js +16 -0
- package/dist/testing/steps/util/require.step.js.map +1 -0
- package/dist/testing/steps/util/sleep.step.d.ts +3 -0
- package/dist/testing/steps/util/sleep.step.d.ts.map +1 -0
- package/dist/testing/steps/util/sleep.step.js +13 -0
- package/dist/testing/steps/util/sleep.step.js.map +1 -0
- package/docs/test-data-workflow.md +51 -11
- package/package.json +4 -2
- package/src/commands/run-tests.command.ts +278 -0
- package/src/commands/test-data.command.ts +26 -26
- package/src/commands/test.command.ts +14 -0
- package/src/controllers/service.controller.ts +58 -59
- package/src/dtos/basic-filters.dto.ts +0 -2
- package/src/dtos/create-user.dto.ts +1 -0
- package/src/index.ts +3 -0
- package/src/seeders/module-metadata-seeder.service.ts +3 -24
- package/src/seeders/module-test-data.service.ts +5 -3
- package/src/services/chatter-message.service.ts +18 -1
- package/src/services/crud.service.ts +1 -0
- package/src/services/queues/common.ts +75 -0
- package/src/services/queues/database-publisher.service.ts +4 -1
- package/src/services/queues/database-subscriber.service.ts +5 -3
- package/src/services/queues/rabbitmq-publisher.service.ts +17 -7
- package/src/services/queues/rabbitmq-subscriber.service.ts +9 -5
- package/src/solid-core.module.ts +4 -0
- package/src/testing/README.md +364 -0
- package/src/testing/__examples__/register-example-specs.ts +6 -0
- package/src/testing/__examples__/specs/custom-health.spec.ts +29 -0
- package/src/testing/__examples__/testing.sample.json +82 -0
- package/src/testing/adapters/api/api-adapter.ts +85 -0
- package/src/testing/adapters/api/api.types.ts +15 -0
- package/src/testing/adapters/ui/playwright-adapter.ts +54 -0
- package/src/testing/adapters/ui/ui.types.ts +4 -0
- package/src/testing/contracts/runtime-context.types.ts +36 -0
- package/src/testing/contracts/test-spec.types.ts +24 -0
- package/src/testing/contracts/testing-metadata.types.ts +46 -0
- package/src/testing/core/interpolation.ts +189 -0
- package/src/testing/core/normalize-steps.ts +21 -0
- package/src/testing/core/resource-store.ts +38 -0
- package/src/testing/core/spec-registry.ts +33 -0
- package/src/testing/core/step-registry.ts +27 -0
- package/src/testing/core/testing-engine.ts +127 -0
- package/src/testing/core/timeout.ts +19 -0
- package/src/testing/reporter/attachments.ts +25 -0
- package/src/testing/reporter/console-reporter.ts +229 -0
- package/src/testing/reporter/reporter.types.ts +36 -0
- package/src/testing/runner/lifecycle.ts +31 -0
- package/src/testing/runner/run-from-metadata.ts +87 -0
- package/src/testing/runner/scenario-filter.ts +33 -0
- package/src/testing/steps/api/auth.step.ts +66 -0
- package/src/testing/steps/api/index.ts +10 -0
- package/src/testing/steps/api/request.step.ts +358 -0
- package/src/testing/steps/assert/http.step.ts +33 -0
- package/src/testing/steps/assert/index.ts +12 -0
- package/src/testing/steps/assert/jsonpath.step.ts +50 -0
- package/src/testing/steps/assert/primitives.step.ts +69 -0
- package/src/testing/steps/test/index.ts +8 -0
- package/src/testing/steps/test/test-spec.step.ts +52 -0
- package/src/testing/steps/ui/actions.step.ts +36 -0
- package/src/testing/steps/ui/assertions.step.ts +54 -0
- package/src/testing/steps/ui/form.step.ts +39 -0
- package/src/testing/steps/ui/index.ts +12 -0
- package/src/testing/steps/ui/navigation.step.ts +53 -0
- package/src/testing/steps/util/index.ts +10 -0
- package/src/testing/steps/util/log.step.ts +19 -0
- package/src/testing/steps/util/require.step.ts +16 -0
- package/src/testing/steps/util/sleep.step.ts +15 -0
- package/tsconfig.json +35 -25
- package/tsconfig.tests.json +14 -0
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Purpose: Basic console reporter implementation.
|
|
2
|
+
|
|
3
|
+
import type { Reporter } from "./reporter.types";
|
|
4
|
+
import type { OpStep } from "../contracts/testing-metadata.types";
|
|
5
|
+
|
|
6
|
+
const INDENT = " ";
|
|
7
|
+
const STEP_INDENT = INDENT;
|
|
8
|
+
const MAX_DETAIL_LEN = 140;
|
|
9
|
+
|
|
10
|
+
function formatError(err: unknown): string {
|
|
11
|
+
if (!err) return "";
|
|
12
|
+
if (err instanceof Error) {
|
|
13
|
+
return err.stack || err.message;
|
|
14
|
+
}
|
|
15
|
+
return String(err);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function indentLines(text: string, indent: string): string {
|
|
19
|
+
return text
|
|
20
|
+
.split("\n")
|
|
21
|
+
.map((line) => (line.length ? `${indent}${line}` : indent))
|
|
22
|
+
.join("\n");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function truncate(value: string, maxLen: number = MAX_DETAIL_LEN): string {
|
|
26
|
+
if (value.length <= maxLen) return value;
|
|
27
|
+
return `${value.slice(0, maxLen - 1)}…`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function formatHttpBody(body: unknown): string {
|
|
31
|
+
if (body === null || body === undefined) return "";
|
|
32
|
+
if (typeof body === "string") {
|
|
33
|
+
const trimmed = body.trim();
|
|
34
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(JSON.parse(trimmed), null, 2);
|
|
37
|
+
} catch {
|
|
38
|
+
return body;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return body;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return JSON.stringify(body, null, 2);
|
|
45
|
+
} catch {
|
|
46
|
+
return String(body);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function withoutQuery(url: string): string {
|
|
51
|
+
const idx = url.indexOf("?");
|
|
52
|
+
return idx === -1 ? url : url.slice(0, idx);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function maskIfSensitive(value: string, hints: string[]): string {
|
|
56
|
+
const lower = hints.join(" ").toLowerCase();
|
|
57
|
+
if (lower.includes("password") || lower.includes("pwd")) {
|
|
58
|
+
return "••••••";
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function stepDetails(step: OpStep): string | undefined {
|
|
64
|
+
const withObj = (step.with ?? {}) as Record<string, any>;
|
|
65
|
+
|
|
66
|
+
switch (step.op) {
|
|
67
|
+
case "api.request": {
|
|
68
|
+
const method = String(withObj.method ?? "").toUpperCase();
|
|
69
|
+
const url = typeof withObj.url === "string" ? withoutQuery(withObj.url) : "";
|
|
70
|
+
if (!method && !url) return undefined;
|
|
71
|
+
return `${method} ${url}`.trim();
|
|
72
|
+
}
|
|
73
|
+
case "api.auth.bearerFromLogin": {
|
|
74
|
+
const url = typeof withObj.url === "string" ? withoutQuery(withObj.url) : "";
|
|
75
|
+
return url ? `url: ${url}` : undefined;
|
|
76
|
+
}
|
|
77
|
+
case "ui.goto": {
|
|
78
|
+
return withObj.url ? `url: ${withObj.url}` : undefined;
|
|
79
|
+
}
|
|
80
|
+
case "ui.click":
|
|
81
|
+
case "ui.expectVisible": {
|
|
82
|
+
return withObj.selector ? `selector: ${withObj.selector}` : undefined;
|
|
83
|
+
}
|
|
84
|
+
case "ui.fill":
|
|
85
|
+
case "ui.select": {
|
|
86
|
+
const selector = withObj.selector ? `selector: ${withObj.selector}` : "";
|
|
87
|
+
const value =
|
|
88
|
+
withObj.value !== undefined
|
|
89
|
+
? `value: ${maskIfSensitive(String(withObj.value), [String(withObj.selector ?? ""), String(step.op)])}`
|
|
90
|
+
: "";
|
|
91
|
+
return [selector, value].filter(Boolean).join(", ") || undefined;
|
|
92
|
+
}
|
|
93
|
+
case "ui.press": {
|
|
94
|
+
const selector = withObj.selector ? `selector: ${withObj.selector}` : "";
|
|
95
|
+
const key = withObj.key ? `key: ${withObj.key}` : "";
|
|
96
|
+
return [selector, key].filter(Boolean).join(", ") || undefined;
|
|
97
|
+
}
|
|
98
|
+
case "ui.expectUrl": {
|
|
99
|
+
const equals = withObj.equals ? `equals: ${withObj.equals}` : "";
|
|
100
|
+
const contains = withObj.contains ? `contains: ${withObj.contains}` : "";
|
|
101
|
+
return [equals, contains].filter(Boolean).join(", ") || undefined;
|
|
102
|
+
}
|
|
103
|
+
case "ui.expectText": {
|
|
104
|
+
const selector = withObj.selector ? `selector: ${withObj.selector}` : "";
|
|
105
|
+
const equals = withObj.equals ? `equals: ${truncate(String(withObj.equals))}` : "";
|
|
106
|
+
const contains = withObj.contains ? `contains: ${truncate(String(withObj.contains))}` : "";
|
|
107
|
+
return [selector, equals, contains].filter(Boolean).join(", ") || undefined;
|
|
108
|
+
}
|
|
109
|
+
case "assert.httpStatus": {
|
|
110
|
+
return withObj.is !== undefined ? `status: ${withObj.is}` : undefined;
|
|
111
|
+
}
|
|
112
|
+
case "assert.jsonPath": {
|
|
113
|
+
const path = withObj.path ? `path: ${withObj.path}` : "";
|
|
114
|
+
const equals = withObj.equals !== undefined ? `equals: ${truncate(String(withObj.equals))}` : "";
|
|
115
|
+
return [path, equals].filter(Boolean).join(", ") || undefined;
|
|
116
|
+
}
|
|
117
|
+
case "assert.contains":
|
|
118
|
+
case "assert.equals":
|
|
119
|
+
case "assert.matches": {
|
|
120
|
+
const expected =
|
|
121
|
+
withObj.expected !== undefined
|
|
122
|
+
? `expected: ${truncate(String(withObj.expected))}`
|
|
123
|
+
: withObj.pattern
|
|
124
|
+
? `pattern: ${truncate(String(withObj.pattern))}`
|
|
125
|
+
: withObj.equals !== undefined
|
|
126
|
+
? `equals: ${truncate(String(withObj.equals))}`
|
|
127
|
+
: "";
|
|
128
|
+
return expected || undefined;
|
|
129
|
+
}
|
|
130
|
+
case "util.sleep": {
|
|
131
|
+
return withObj.ms !== undefined ? `ms: ${withObj.ms}` : undefined;
|
|
132
|
+
}
|
|
133
|
+
case "util.log": {
|
|
134
|
+
return withObj.message ? `message: ${truncate(String(withObj.message))}` : undefined;
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function formatStepLabel(step: OpStep): string {
|
|
142
|
+
const base = step.name ? `${step.op} (${step.name})` : step.op;
|
|
143
|
+
const details = stepDetails(step);
|
|
144
|
+
if (!details) return base;
|
|
145
|
+
return `${base} (${details})`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export class ConsoleReporter implements Reporter {
|
|
149
|
+
onScenarioStart(scenario: { id: string; name?: string }): void {
|
|
150
|
+
const label = scenario.name ? `${scenario.id} (${scenario.name})` : scenario.id;
|
|
151
|
+
console.log(`\n▶ Scenario: ${label}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
onScenarioEnd(
|
|
155
|
+
scenario: { id: string; name?: string },
|
|
156
|
+
result: { ok: boolean; error?: unknown; durationMs: number },
|
|
157
|
+
): void {
|
|
158
|
+
const label = scenario.name ? `${scenario.id} (${scenario.name})` : scenario.id;
|
|
159
|
+
const status = result.ok ? "✔" : "✖";
|
|
160
|
+
console.log(`${status} Scenario: ${label} (${result.durationMs}ms)`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
onStepStart(args: {
|
|
164
|
+
scenarioId: string;
|
|
165
|
+
phase: string;
|
|
166
|
+
step: OpStep;
|
|
167
|
+
}): void {
|
|
168
|
+
const label = formatStepLabel(args.step);
|
|
169
|
+
const phase = args.phase.toUpperCase();
|
|
170
|
+
console.log(`${STEP_INDENT}↳ ${phase} ${label}`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
onStepEnd(args: {
|
|
174
|
+
scenarioId: string;
|
|
175
|
+
phase: string;
|
|
176
|
+
step: OpStep;
|
|
177
|
+
ok: boolean;
|
|
178
|
+
error?: unknown;
|
|
179
|
+
durationMs: number;
|
|
180
|
+
}): void {
|
|
181
|
+
const label = formatStepLabel(args.step);
|
|
182
|
+
const phase = args.phase.toUpperCase();
|
|
183
|
+
const status = args.ok ? "✔" : "✖";
|
|
184
|
+
console.log(
|
|
185
|
+
`${STEP_INDENT}${status} ${phase} ${label} (${args.durationMs}ms)`
|
|
186
|
+
);
|
|
187
|
+
if (!args.ok && args.error) {
|
|
188
|
+
const details = formatError(args.error);
|
|
189
|
+
console.error(indentLines(details, `${STEP_INDENT}${INDENT}`));
|
|
190
|
+
const httpBody = (args.error as any)?.httpResponseBody;
|
|
191
|
+
if (httpBody !== undefined) {
|
|
192
|
+
const formatted = formatHttpBody(httpBody);
|
|
193
|
+
const bodyText = formatted.length ? formatted : "<empty>";
|
|
194
|
+
console.error(
|
|
195
|
+
indentLines(
|
|
196
|
+
`HTTP Response Body:\n${bodyText}`,
|
|
197
|
+
`${STEP_INDENT}${INDENT}`,
|
|
198
|
+
),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
onSpecResult(args: {
|
|
205
|
+
scenarioId: string;
|
|
206
|
+
specId: string;
|
|
207
|
+
stepName?: string;
|
|
208
|
+
result: { ok: boolean; details?: Record<string, any> };
|
|
209
|
+
}): void {
|
|
210
|
+
console.log(`${INDENT}↳ SPEC ${args.specId} ok=${args.result.ok}`);
|
|
211
|
+
if (args.result.details) {
|
|
212
|
+
const details = JSON.stringify(args.result.details, null, 2);
|
|
213
|
+
console.log(indentLines(details, `${INDENT}${INDENT}`));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
attach(args: {
|
|
218
|
+
scenarioId: string;
|
|
219
|
+
name: string;
|
|
220
|
+
contentType: string;
|
|
221
|
+
data: Buffer | string;
|
|
222
|
+
}): void {
|
|
223
|
+
const header = `ATTACH ${args.name} (${args.contentType})`;
|
|
224
|
+
console.log(indentLines(header, `${STEP_INDENT}${INDENT}`));
|
|
225
|
+
const dataText = Buffer.isBuffer(args.data) ? args.data.toString("utf8") : String(args.data ?? "");
|
|
226
|
+
if (!dataText.length) return;
|
|
227
|
+
console.log(indentLines(dataText, `${STEP_INDENT}${INDENT}${INDENT}`));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { StepPhase } from "../contracts/runtime-context.types";
|
|
2
|
+
import type { OpStep, ScenarioSpec } from "../contracts/testing-metadata.types";
|
|
3
|
+
import type { SolidTestSpecResult } from "../contracts/test-spec.types";
|
|
4
|
+
|
|
5
|
+
export interface Reporter {
|
|
6
|
+
onScenarioStart(scenario: ScenarioSpec): void;
|
|
7
|
+
onScenarioEnd(
|
|
8
|
+
scenario: ScenarioSpec,
|
|
9
|
+
result: { ok: boolean; error?: unknown; durationMs: number },
|
|
10
|
+
): void;
|
|
11
|
+
onStepStart(args: {
|
|
12
|
+
scenarioId: string;
|
|
13
|
+
phase: StepPhase;
|
|
14
|
+
step: OpStep;
|
|
15
|
+
}): void;
|
|
16
|
+
onStepEnd(args: {
|
|
17
|
+
scenarioId: string;
|
|
18
|
+
phase: StepPhase;
|
|
19
|
+
step: OpStep;
|
|
20
|
+
ok: boolean;
|
|
21
|
+
error?: unknown;
|
|
22
|
+
durationMs: number;
|
|
23
|
+
}): void;
|
|
24
|
+
onSpecResult?(args: {
|
|
25
|
+
scenarioId: string;
|
|
26
|
+
specId: string;
|
|
27
|
+
stepName?: string;
|
|
28
|
+
result: SolidTestSpecResult;
|
|
29
|
+
}): void;
|
|
30
|
+
attach?(args: {
|
|
31
|
+
scenarioId: string;
|
|
32
|
+
name: string;
|
|
33
|
+
contentType: string;
|
|
34
|
+
data: Buffer | string;
|
|
35
|
+
}): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TestContext } from "../contracts/runtime-context.types";
|
|
2
|
+
import type { OpStep, ScenarioSpec, StepBlock } from "../contracts/testing-metadata.types";
|
|
3
|
+
|
|
4
|
+
type StartedFlag = { value: boolean };
|
|
5
|
+
|
|
6
|
+
function stepsFromBlock(block: StepBlock): OpStep[] {
|
|
7
|
+
if ("given" in block) return [block.given];
|
|
8
|
+
if ("when" in block) return [block.when];
|
|
9
|
+
if ("and" in block) return [block.and];
|
|
10
|
+
if ("then" in block) return Array.isArray(block.then) ? block.then : [block.then];
|
|
11
|
+
return [block];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function scenarioNeedsUi(scenario: ScenarioSpec): boolean {
|
|
15
|
+
if (scenario.type === "ui" || scenario.type === "mixed") return true;
|
|
16
|
+
for (const block of scenario.steps) {
|
|
17
|
+
for (const step of stepsFromBlock(block)) {
|
|
18
|
+
if (step.op.startsWith("ui.")) return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function ensureUiStarted(
|
|
25
|
+
ctxBase: Omit<TestContext, "scenarioId" | "scenarioType" | "params">,
|
|
26
|
+
startedFlag: StartedFlag,
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
if (!ctxBase.ui || startedFlag.value) return;
|
|
29
|
+
await ctxBase.ui.start();
|
|
30
|
+
startedFlag.value = true;
|
|
31
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Reporter } from "../reporter/reporter.types";
|
|
2
|
+
import type { TestingMetadata, TestingDataRecord } from "../contracts/testing-metadata.types";
|
|
3
|
+
import type { ApiAdapterOptions } from "../adapters/api/api.types";
|
|
4
|
+
import type { PlaywrightAdapterOptions } from "../adapters/ui/ui.types";
|
|
5
|
+
import { ApiAdapter } from "../adapters/api/api-adapter";
|
|
6
|
+
import { PlaywrightAdapter } from "../adapters/ui/playwright-adapter";
|
|
7
|
+
import { registerApiSteps } from "../steps/api";
|
|
8
|
+
import { registerUiSteps } from "../steps/ui";
|
|
9
|
+
import { registerAssertSteps } from "../steps/assert";
|
|
10
|
+
import { registerUtilSteps } from "../steps/util";
|
|
11
|
+
import { registerTestSteps } from "../steps/test";
|
|
12
|
+
import { SimpleResourceStore } from "../core/resource-store";
|
|
13
|
+
import { StepRegistry } from "../core/step-registry";
|
|
14
|
+
import { SpecRegistry } from "../core/spec-registry";
|
|
15
|
+
import { TestingEngine } from "../core/testing-engine";
|
|
16
|
+
import { filterScenarios } from "./scenario-filter";
|
|
17
|
+
import { ensureUiStarted, scenarioNeedsUi } from "./lifecycle";
|
|
18
|
+
import { ConsoleReporter } from "../reporter/console-reporter";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function buildTestDataIndex(data?: TestingDataRecord[]): Record<string, Record<string, any>> {
|
|
22
|
+
const index: Record<string, Record<string, any>> = {};
|
|
23
|
+
if (!Array.isArray(data)) return index;
|
|
24
|
+
for (const record of data) {
|
|
25
|
+
if (!record?.modelUserKey || !record?.recUserKeyValue) continue;
|
|
26
|
+
if (!index[record.modelUserKey]) {
|
|
27
|
+
index[record.modelUserKey] = {};
|
|
28
|
+
}
|
|
29
|
+
index[record.modelUserKey][record.recUserKeyValue] = record.data ?? {};
|
|
30
|
+
}
|
|
31
|
+
return index;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type RunnerOptions = {
|
|
35
|
+
metadata: TestingMetadata;
|
|
36
|
+
scenarioIds?: string[];
|
|
37
|
+
includeTags?: string[];
|
|
38
|
+
skipScenarioIds?: string[];
|
|
39
|
+
reporter?: Reporter;
|
|
40
|
+
api?: ApiAdapterOptions;
|
|
41
|
+
ui?: PlaywrightAdapterOptions;
|
|
42
|
+
defaults?: { timeoutMs?: number; retries?: number };
|
|
43
|
+
options?: { printApiLogs?: boolean };
|
|
44
|
+
specs?: (registry: SpecRegistry) => void;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export async function runFromMetadata(opts: RunnerOptions): Promise<void> {
|
|
48
|
+
const registry = new StepRegistry();
|
|
49
|
+
registerApiSteps(registry);
|
|
50
|
+
registerUiSteps(registry);
|
|
51
|
+
registerAssertSteps(registry);
|
|
52
|
+
registerUtilSteps(registry);
|
|
53
|
+
registerTestSteps(registry);
|
|
54
|
+
|
|
55
|
+
const engine = new TestingEngine(registry, opts.defaults);
|
|
56
|
+
const scenarios = filterScenarios(opts.metadata.testing.scenarios, {
|
|
57
|
+
scenarioIds: opts.scenarioIds,
|
|
58
|
+
includeTags: opts.includeTags,
|
|
59
|
+
skipScenarioIds: opts.skipScenarioIds,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const specRegistry = new SpecRegistry();
|
|
63
|
+
const testData = buildTestDataIndex(opts.metadata.testing?.data);
|
|
64
|
+
if (opts.specs) {
|
|
65
|
+
opts.specs(specRegistry);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const resources = new SimpleResourceStore();
|
|
69
|
+
const reporter = opts.reporter ?? new ConsoleReporter();
|
|
70
|
+
const api = new ApiAdapter(opts.api);
|
|
71
|
+
const ui = new PlaywrightAdapter(opts.ui);
|
|
72
|
+
const ctxBase = { resources, reporter, api, ui, specRegistry, testData, options: opts.options };
|
|
73
|
+
const uiStarted = { value: false };
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
for (const scenario of scenarios) {
|
|
77
|
+
if (scenarioNeedsUi(scenario)) {
|
|
78
|
+
await ensureUiStarted(ctxBase, uiStarted);
|
|
79
|
+
}
|
|
80
|
+
await engine.runScenario(scenario, ctxBase);
|
|
81
|
+
}
|
|
82
|
+
} finally {
|
|
83
|
+
if (uiStarted.value) {
|
|
84
|
+
await ui.stop();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ScenarioSpec } from "../contracts/testing-metadata.types";
|
|
2
|
+
|
|
3
|
+
type ScenarioFilterOptions = {
|
|
4
|
+
scenarioIds?: string[];
|
|
5
|
+
includeTags?: string[];
|
|
6
|
+
skipScenarioIds?: string[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function filterScenarios(
|
|
10
|
+
scenarios: ScenarioSpec[],
|
|
11
|
+
opts: ScenarioFilterOptions,
|
|
12
|
+
): ScenarioSpec[] {
|
|
13
|
+
let result = scenarios;
|
|
14
|
+
|
|
15
|
+
if (opts.scenarioIds && opts.scenarioIds.length > 0) {
|
|
16
|
+
const idSet = new Set(opts.scenarioIds);
|
|
17
|
+
result = result.filter((scenario) => idSet.has(scenario.id));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (opts.includeTags && opts.includeTags.length > 0) {
|
|
21
|
+
result = result.filter((scenario) => {
|
|
22
|
+
const tags = scenario.tags ?? [];
|
|
23
|
+
return opts.includeTags!.every((tag) => tags.includes(tag));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (opts.skipScenarioIds && opts.skipScenarioIds.length > 0) {
|
|
28
|
+
const skipSet = new Set(opts.skipScenarioIds);
|
|
29
|
+
result = result.filter((scenario) => !skipSet.has(scenario.id));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Purpose: API auth step registrations.
|
|
2
|
+
|
|
3
|
+
import type { TestContext } from "../../contracts/runtime-context.types";
|
|
4
|
+
import type { OpStep } from "../../contracts/testing-metadata.types";
|
|
5
|
+
import { StepRegistry } from "../../core/step-registry";
|
|
6
|
+
|
|
7
|
+
type BearerFromLoginInput = {
|
|
8
|
+
url: string;
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function registerAuthSteps(registry: StepRegistry): void {
|
|
14
|
+
registry.register(
|
|
15
|
+
"api.auth.bearerFromLogin",
|
|
16
|
+
async (ctx: TestContext, step: OpStep) => {
|
|
17
|
+
if (!ctx.api) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
'Missing API adapter on context for op "api.auth.bearerFromLogin"',
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const input = (step.with ?? {}) as BearerFromLoginInput;
|
|
24
|
+
if (!input.url) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
'Missing "url" in step.with for op "api.auth.bearerFromLogin"',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (!input.username) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
'Missing "username" in step.with for op "api.auth.bearerFromLogin"',
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
if (!input.password) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'Missing "password" in step.with for op "api.auth.bearerFromLogin"',
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const response = await ctx.api.http({
|
|
41
|
+
method: "POST",
|
|
42
|
+
url: input.url,
|
|
43
|
+
json: {
|
|
44
|
+
username: input.username,
|
|
45
|
+
password: input.password,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (response.status < 200 || response.status >= 300) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Login failed with status ${response.status}: ${response.bodyText}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const bodyJson = response.bodyJson as
|
|
56
|
+
| { data?: { accessToken?: unknown }; accessToken?: unknown }
|
|
57
|
+
| undefined;
|
|
58
|
+
const token = bodyJson?.data?.accessToken ?? bodyJson?.accessToken;
|
|
59
|
+
if (typeof token !== "string" || token.length === 0) {
|
|
60
|
+
throw new Error("Missing access token in login response");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return token;
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Purpose: API step registrations.
|
|
2
|
+
|
|
3
|
+
import { StepRegistry } from "../../core/step-registry";
|
|
4
|
+
import { registerAuthSteps } from "./auth.step";
|
|
5
|
+
import { registerApiRequestStep } from "./request.step";
|
|
6
|
+
|
|
7
|
+
export function registerApiSteps(registry: StepRegistry): void {
|
|
8
|
+
registerApiRequestStep(registry);
|
|
9
|
+
registerAuthSteps(registry);
|
|
10
|
+
}
|