@elench/testkit 0.1.117 → 0.1.119

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.
Files changed (37) hide show
  1. package/README.md +27 -12
  2. package/lib/app/doctor.mjs +11 -113
  3. package/lib/cli/assistant/command-observer.mjs +1 -1
  4. package/lib/cli/assistant/context-pack.mjs +31 -11
  5. package/lib/cli/assistant/state.mjs +2 -0
  6. package/lib/cli/commands/lint.mjs +37 -0
  7. package/lib/cli/entrypoint.mjs +1 -0
  8. package/lib/cli/operations/db/schema/refresh/operation.mjs +4 -2
  9. package/lib/cli/operations/lint/operation.mjs +12 -0
  10. package/lib/cli/renderers/db-schema/text.mjs +3 -0
  11. package/lib/cli/renderers/doctor/text.mjs +5 -0
  12. package/lib/cli/renderers/lint/text.mjs +20 -0
  13. package/lib/config/database.mjs +9 -13
  14. package/lib/config-api/database-steps.mjs +132 -0
  15. package/lib/config-api/index.d.ts +37 -5
  16. package/lib/config-api/index.mjs +123 -12
  17. package/lib/database/fingerprint.mjs +2 -2
  18. package/lib/database/index.mjs +4 -4
  19. package/lib/database/schema-source.mjs +107 -14
  20. package/lib/lint/index.mjs +569 -0
  21. package/lib/repo/state.mjs +164 -0
  22. package/lib/runner/metadata.mjs +11 -24
  23. package/lib/runner/template-steps.mjs +8 -0
  24. package/lib/runner/template.mjs +0 -3
  25. package/lib/runtime/index.d.ts +43 -0
  26. package/lib/runtime/index.mjs +24 -0
  27. package/lib/runtime-src/k6/http-assertions.js +82 -0
  28. package/lib/shared/configured-steps.mjs +16 -0
  29. package/lib/ui/index.d.ts +46 -0
  30. package/lib/ui/index.mjs +11 -0
  31. package/lib/ui/sandbox.mjs +115 -0
  32. package/node_modules/@elench/next-analysis/package.json +1 -1
  33. package/node_modules/@elench/testkit-bridge/package.json +2 -2
  34. package/node_modules/@elench/testkit-protocol/package.json +1 -1
  35. package/node_modules/@elench/ts-analysis/package.json +1 -1
  36. package/package.json +6 -5
  37. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/package.json +1 -1
@@ -0,0 +1,115 @@
1
+ import { expect, request, test as base } from "@playwright/test";
2
+
3
+ export function createUiSandbox(options = {}) {
4
+ const sandboxId = createSandboxId(options);
5
+ return {
6
+ expect,
7
+ test: base.extend({
8
+ testkitSandbox: async ({ page }, use) => {
9
+ await use({
10
+ id: sandboxId,
11
+ backendBaseUrl: resolveBackendBaseUrl(options),
12
+ frontendBaseUrl: resolveFrontendBaseUrl(options),
13
+ page,
14
+ });
15
+ },
16
+ }),
17
+ };
18
+ }
19
+
20
+ export function createSandboxId(options = {}) {
21
+ const prefix =
22
+ String(options.prefix || "ui").replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "ui";
23
+ const worker = process.env.TEST_WORKER_INDEX || process.env.TESTKIT_WORKER_INDEX || "0";
24
+ const run = process.env.TESTKIT_LEASE_ID || process.env.TESTKIT_RUNTIME_ID || process.pid;
25
+ return `${prefix}-${run}-${worker}`;
26
+ }
27
+
28
+ export function resolveFrontendBaseUrl(options = {}) {
29
+ return resolveBaseUrl(
30
+ options.frontendBaseUrl ||
31
+ options.baseUrl ||
32
+ process.env.TESTKIT_FRONTEND_BASE_URL ||
33
+ process.env.BASE_URL
34
+ );
35
+ }
36
+
37
+ export function resolveBackendBaseUrl(options = {}) {
38
+ return resolveBaseUrl(options.backendBaseUrl || process.env.TESTKIT_BACKEND_BASE_URL || process.env.API_BASE_URL);
39
+ }
40
+
41
+ export function assertSafeUiTarget(url, options = {}) {
42
+ const parsed = parseUrl(url);
43
+ if (!parsed) {
44
+ throw new Error(`Invalid UI target URL: ${url}`);
45
+ }
46
+ if (options.allowRemote === true) return parsed.toString().replace(/\/$/, "");
47
+ if (!isLocalHost(parsed.hostname)) {
48
+ throw new Error(`UI target must be local unless allowRemote is true: ${url}`);
49
+ }
50
+ return parsed.toString().replace(/\/$/, "");
51
+ }
52
+
53
+ export function assertSafeUiTargets(urls = [], options = {}) {
54
+ return urls.map((url) => assertSafeUiTarget(url, options));
55
+ }
56
+
57
+ export async function createAuthedApiClient(playwrightRequest = request, options = {}) {
58
+ const baseURL = assertSafeUiTarget(resolveBackendBaseUrl(options), options);
59
+ return playwrightRequest.newContext({
60
+ baseURL,
61
+ extraHTTPHeaders: options.headers || {},
62
+ });
63
+ }
64
+
65
+ export async function waitForUiSettled(page, options = {}) {
66
+ const timeout = options.timeout ?? 5_000;
67
+ await page.waitForLoadState("domcontentloaded", { timeout });
68
+ await waitForAnimationFrames(page, options.frames ?? 2);
69
+ await page.waitForLoadState("networkidle", { timeout }).catch(() => {});
70
+ }
71
+
72
+ export async function waitForAnimationFrames(page, frames = 2) {
73
+ const count = Math.max(1, Number(frames) || 1);
74
+ await page.evaluate(
75
+ (frameCount) =>
76
+ new Promise((resolve) => {
77
+ let remaining = frameCount;
78
+ const tick = () => {
79
+ remaining -= 1;
80
+ if (remaining <= 0) {
81
+ resolve();
82
+ return;
83
+ }
84
+ requestAnimationFrame(tick);
85
+ };
86
+ requestAnimationFrame(tick);
87
+ }),
88
+ count
89
+ );
90
+ }
91
+
92
+ function resolveBaseUrl(value) {
93
+ const normalized = String(value || "").trim();
94
+ if (!normalized) {
95
+ throw new Error("A UI base URL is required");
96
+ }
97
+ return assertSafeUiTarget(normalized);
98
+ }
99
+
100
+ function parseUrl(value) {
101
+ try {
102
+ return new URL(value);
103
+ } catch {
104
+ return null;
105
+ }
106
+ }
107
+
108
+ function isLocalHost(hostname) {
109
+ return (
110
+ hostname === "localhost" ||
111
+ hostname === "127.0.0.1" ||
112
+ hostname === "::1" ||
113
+ hostname.endsWith(".localhost")
114
+ );
115
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/next-analysis",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "SWC-backed Next.js source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-bridge",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "Browser bridge helpers for testkit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "typecheck": "tsc -p tsconfig.json --noEmit"
23
23
  },
24
24
  "dependencies": {
25
- "@elench/testkit-protocol": "0.1.117"
25
+ "@elench/testkit-protocol": "0.1.119"
26
26
  },
27
27
  "private": false
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-protocol",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "Shared browser protocol for testkit bridge and extension consumers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/ts-analysis",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "TypeScript compiler-backed source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "Assistant-first CLI for running, inspecting, and debugging local testkit suites",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -65,6 +65,7 @@
65
65
  "test:database-version:compat": "node scripts/test-database-version-compat.mjs",
66
66
  "test:engine-version:compat": "node scripts/test-engine-version-compat.mjs",
67
67
  "test:live": "node scripts/live-sandbox/harness.mjs",
68
+ "test:live:github": "node scripts/test-live-github-fixture.mjs",
68
69
  "test:live:neon": "node scripts/test-database-version-compat.mjs --neon-only",
69
70
  "test:unit": "npm run build:assistant && npm run build:packages && npm run test:audit && vitest run --config vitest.unit.config.mjs",
70
71
  "test:integration": "npm run build:assistant && npm run build:packages && vitest run test/integration",
@@ -94,10 +95,10 @@
94
95
  },
95
96
  "dependencies": {
96
97
  "@babel/code-frame": "^7.29.0",
97
- "@elench/next-analysis": "0.1.117",
98
- "@elench/testkit-bridge": "0.1.117",
99
- "@elench/testkit-protocol": "0.1.117",
100
- "@elench/ts-analysis": "0.1.117",
98
+ "@elench/next-analysis": "0.1.119",
99
+ "@elench/testkit-bridge": "0.1.119",
100
+ "@elench/testkit-protocol": "0.1.119",
101
+ "@elench/ts-analysis": "0.1.119",
101
102
  "@oclif/core": "^4.10.6",
102
103
  "@playwright/test": "^1.52.0",
103
104
  "esbuild": "^0.25.11",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-protocol",
3
- "version": "0.1.116",
3
+ "version": "0.1.118",
4
4
  "description": "Shared browser protocol for testkit bridge and extension consumers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",