@essential-apps/shopify-test-runner 1.0.12 → 1.0.13

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 (96) hide show
  1. package/dist/lib/guestVnc.d.ts +31 -0
  2. package/dist/lib/guestVnc.d.ts.map +1 -0
  3. package/dist/lib/guestVnc.js +111 -0
  4. package/dist/lib/guestVnc.js.map +1 -0
  5. package/dist/probes/runProbe.js +0 -0
  6. package/dist/scripts/addStore.js +0 -0
  7. package/dist/scripts/buildImage.d.ts +3 -0
  8. package/dist/scripts/buildImage.d.ts.map +1 -0
  9. package/dist/scripts/{buildDockerImage.js → buildImage.js} +12 -10
  10. package/dist/scripts/buildImage.js.map +1 -0
  11. package/dist/scripts/captureAuth.js +0 -0
  12. package/dist/scripts/captureContracts.js +0 -0
  13. package/dist/scripts/captureRestContracts.js +0 -0
  14. package/dist/scripts/captureSharedContracts.d.ts +3 -0
  15. package/dist/scripts/captureSharedContracts.d.ts.map +1 -0
  16. package/dist/scripts/captureSharedContracts.js +209 -0
  17. package/dist/scripts/captureSharedContracts.js.map +1 -0
  18. package/dist/scripts/checkOperationCoverage.js +0 -0
  19. package/dist/scripts/cleanupStores.js +0 -0
  20. package/dist/scripts/createStores.js +0 -0
  21. package/dist/scripts/deployAppVersion.js +0 -0
  22. package/dist/scripts/devOnlineBackend.js +0 -0
  23. package/dist/scripts/installApp.js +0 -0
  24. package/dist/scripts/listStores.js +0 -0
  25. package/dist/scripts/runOffline.js +78 -1
  26. package/dist/scripts/runOffline.js.map +1 -1
  27. package/dist/scripts/runOfflineFullTests.js +49 -21
  28. package/dist/scripts/runOfflineFullTests.js.map +1 -1
  29. package/dist/scripts/runTests.js +0 -0
  30. package/dist/scripts/runVm.js +0 -0
  31. package/dist/scripts/runVmAuth.js +0 -0
  32. package/dist/scripts/setupTestDb.js +0 -0
  33. package/dist/scripts/verifyContracts.js +20 -29
  34. package/dist/scripts/verifyContracts.js.map +1 -1
  35. package/dist/scripts/verifyRestContracts.js +17 -30
  36. package/dist/scripts/verifyRestContracts.js.map +1 -1
  37. package/package.json +11 -9
  38. package/src/lib/guestVnc.ts +147 -0
  39. package/src/scripts/{buildDockerImage.ts → buildImage.ts} +11 -9
  40. package/src/scripts/captureSharedContracts.ts +228 -0
  41. package/src/scripts/runOffline.ts +82 -1
  42. package/src/scripts/runOfflineFullTests.ts +56 -21
  43. package/src/scripts/verifyContracts.ts +22 -38
  44. package/src/scripts/verifyRestContracts.ts +23 -42
  45. package/dist/edge/nodeShim.d.ts +0 -2
  46. package/dist/edge/nodeShim.d.ts.map +0 -1
  47. package/dist/edge/nodeShim.js +0 -217
  48. package/dist/edge/nodeShim.js.map +0 -1
  49. package/dist/scripts/_probeSourceUrl.d.ts +0 -3
  50. package/dist/scripts/_probeSourceUrl.d.ts.map +0 -1
  51. package/dist/scripts/_probeSourceUrl.js +0 -119
  52. package/dist/scripts/_probeSourceUrl.js.map +0 -1
  53. package/dist/scripts/buildDockerImage.d.ts +0 -3
  54. package/dist/scripts/buildDockerImage.d.ts.map +0 -1
  55. package/dist/scripts/buildDockerImage.js.map +0 -1
  56. package/dist/scripts/devE2eBackend.d.ts +0 -3
  57. package/dist/scripts/devE2eBackend.d.ts.map +0 -1
  58. package/dist/scripts/devE2eBackend.js +0 -117
  59. package/dist/scripts/devE2eBackend.js.map +0 -1
  60. package/dist/scripts/runDocker.d.ts +0 -3
  61. package/dist/scripts/runDocker.d.ts.map +0 -1
  62. package/dist/scripts/runDocker.js +0 -88
  63. package/dist/scripts/runDocker.js.map +0 -1
  64. package/dist/scripts/runDockerAuth.d.ts +0 -3
  65. package/dist/scripts/runDockerAuth.d.ts.map +0 -1
  66. package/dist/scripts/runDockerAuth.js +0 -108
  67. package/dist/scripts/runDockerAuth.js.map +0 -1
  68. package/dist/scripts/runDockerOffline.d.ts +0 -3
  69. package/dist/scripts/runDockerOffline.d.ts.map +0 -1
  70. package/dist/scripts/runDockerOffline.js +0 -129
  71. package/dist/scripts/runDockerOffline.js.map +0 -1
  72. package/dist/scripts/runDockerOfflineExplore.d.ts +0 -3
  73. package/dist/scripts/runDockerOfflineExplore.d.ts.map +0 -1
  74. package/dist/scripts/runDockerOfflineExplore.js +0 -116
  75. package/dist/scripts/runDockerOfflineExplore.js.map +0 -1
  76. package/dist/scripts/runIsolatedDockerOffline.d.ts +0 -3
  77. package/dist/scripts/runIsolatedDockerOffline.d.ts.map +0 -1
  78. package/dist/scripts/runIsolatedDockerOffline.js +0 -351
  79. package/dist/scripts/runIsolatedDockerOffline.js.map +0 -1
  80. package/dist/scripts/runOfflineE2e.d.ts +0 -3
  81. package/dist/scripts/runOfflineE2e.d.ts.map +0 -1
  82. package/dist/scripts/runOfflineE2e.js +0 -408
  83. package/dist/scripts/runOfflineE2e.js.map +0 -1
  84. package/dist/scripts/runSupermachine.d.ts +0 -3
  85. package/dist/scripts/runSupermachine.d.ts.map +0 -1
  86. package/dist/scripts/runSupermachine.js +0 -474
  87. package/dist/scripts/runSupermachine.js.map +0 -1
  88. package/dist/scripts/runSupermachineAuth.d.ts +0 -3
  89. package/dist/scripts/runSupermachineAuth.d.ts.map +0 -1
  90. package/dist/scripts/runSupermachineAuth.js +0 -454
  91. package/dist/scripts/runSupermachineAuth.js.map +0 -1
  92. package/dist/vite/offlineConfig.d.ts +0 -34
  93. package/dist/vite/offlineConfig.d.ts.map +0 -1
  94. package/dist/vite/offlineConfig.js +0 -61
  95. package/dist/vite/offlineConfig.js.map +0 -1
  96. package/src/scripts/runDockerAuth.ts +0 -120
@@ -0,0 +1,31 @@
1
+ /** Minimal structural view of the VM handle this helper needs. */
2
+ export interface VncCapableVm {
3
+ exec(opts: {
4
+ argv: string[];
5
+ timeoutMs?: number;
6
+ }): Promise<{
7
+ exitCode: number;
8
+ stdout: Buffer;
9
+ stderr: Buffer;
10
+ }>;
11
+ exposeTcp(hostPort: number, guestPort: number): Promise<unknown>;
12
+ }
13
+ export declare const DEFAULT_VNC_PORT = 5900;
14
+ export interface ExposeGuestVncOptions {
15
+ /** VNC auth password. Default: TEST_ONLINE_VNC_PASSWORD ?? 'test'. */
16
+ vncPassword?: string;
17
+ /** Host+guest VNC port. Default: 5900. */
18
+ port?: number;
19
+ /** Xvfb virtual screen geometry. Default: '1600x1000x24'. */
20
+ screen?: string;
21
+ /** Log prefix, e.g. '[runOffline]'. Default: '[guestVnc]'. */
22
+ logPrefix?: string;
23
+ }
24
+ /**
25
+ * Start x11vnc in the guest, bridge it to the host, and (on macOS)
26
+ * open Screen Sharing. Throws if Xvfb or x11vnc fail to come up.
27
+ *
28
+ * @returns the forwarder handle (keep it referenced; close on exit).
29
+ */
30
+ export declare function exposeGuestVnc(vm: VncCapableVm, opts?: ExposeGuestVncOptions): Promise<unknown>;
31
+ //# sourceMappingURL=guestVnc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guestVnc.d.ts","sourceRoot":"","sources":["../../src/lib/guestVnc.ts"],"names":[],"mappings":"AAuBA,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAClE;AAED,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,YAAY,EAChB,IAAI,GAAE,qBAA0B,GAC/B,OAAO,CAAC,OAAO,CAAC,CA4FlB"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Expose a guest VM's Xvfb display over VNC to the host.
3
+ *
4
+ * Shared by the interactive VM flows that need a developer to *see*
5
+ * what a headed Chromium is doing inside the microVM:
6
+ * - `runVmAuth.ts` — one-time Shopify login capture.
7
+ * - `runOffline.ts` (explore mode) — click through the offline mock
8
+ * stack (admin app + storefront) by hand.
9
+ *
10
+ * The sequence (extracted so both flows share one implementation):
11
+ * 1. (Re)start Xvfb :99 with access control off, then x11vnc bound
12
+ * to 0.0.0.0:5900 inside the guest.
13
+ * 2. Forward host 127.0.0.1:5900 → guest :5900 via `vm.exposeTcp`.
14
+ * 3. On macOS, open Screen Sharing at vnc://localhost:5900 with the
15
+ * password prefilled. Elsewhere, print connect instructions.
16
+ *
17
+ * Returns the TCP forwarder handle so the caller can keep it alive
18
+ * for the session and close it on teardown.
19
+ */
20
+ import { spawn as nodeSpawn } from 'node:child_process';
21
+ import { platform as osPlatform } from 'node:os';
22
+ import { setTimeout as sleep } from 'node:timers/promises';
23
+ export const DEFAULT_VNC_PORT = 5900;
24
+ /**
25
+ * Start x11vnc in the guest, bridge it to the host, and (on macOS)
26
+ * open Screen Sharing. Throws if Xvfb or x11vnc fail to come up.
27
+ *
28
+ * @returns the forwarder handle (keep it referenced; close on exit).
29
+ */
30
+ export async function exposeGuestVnc(vm, opts = {}) {
31
+ const vncPassword = opts.vncPassword ?? process.env['TEST_ONLINE_VNC_PASSWORD'] ?? 'test';
32
+ const port = opts.port ?? DEFAULT_VNC_PORT;
33
+ const screen = opts.screen ?? '1600x1000x24';
34
+ const log = opts.logPrefix ?? '[guestVnc]';
35
+ // 1) (Re)start Xvfb :99 + x11vnc inside the guest. We restart Xvfb
36
+ // with -ac (access control off) so x11vnc — launched from this
37
+ // fresh exec shell, without the entrypoint's Xauthority — can
38
+ // attach without a cookie. Background via shell `&` + nohup so
39
+ // both survive this exec returning.
40
+ console.error(`${log} starting x11vnc on guest :${port}…`);
41
+ const vncStart = await vm.exec({
42
+ argv: [
43
+ 'bash',
44
+ '-c',
45
+ `
46
+ # No set -e: pkill/rm of absent things exit nonzero legitimately.
47
+ # Match Xvfb by exact name (-x), NOT -f: -f matches this script's
48
+ # own argv (the heredoc contains "Xvfb") and would kill our shell.
49
+ echo "[xvfb] restarting Xvfb :99 ${screen} -ac …"
50
+ pkill -x Xvfb 2>/dev/null || true
51
+ rm -f /tmp/.X11-unix/X99 /tmp/.X99-lock
52
+ sleep 0.3
53
+ nohup Xvfb :99 -screen 0 ${screen} -nolisten tcp -ac \
54
+ >/var/log/xvfb.log 2>&1 &
55
+ for _ in $(seq 1 50); do
56
+ [ -e /tmp/.X11-unix/X99 ] && break
57
+ sleep 0.1
58
+ done
59
+ if [ ! -e /tmp/.X11-unix/X99 ]; then
60
+ echo "[xvfb] FAILED to bind /tmp/.X11-unix/X99 within 5s"
61
+ cat /var/log/xvfb.log
62
+ exit 1
63
+ fi
64
+ echo "[xvfb] up."
65
+
66
+ mkdir -p /root/.vnc
67
+ x11vnc -storepasswd "${vncPassword}" /root/.vnc/passwd >/dev/null 2>&1
68
+ echo "[x11vnc] starting on :${port}…"
69
+ nohup x11vnc -display :99 -forever -shared \
70
+ -rfbauth /root/.vnc/passwd -rfbport ${port} -quiet \
71
+ >/var/log/x11vnc.log 2>&1 &
72
+ echo "[x11vnc] pid $!"
73
+ # Confirm the listener bound. netstat (net-tools) is in the image;
74
+ # bash /dev/tcp is unreliable on jammy (device sometimes disabled).
75
+ for _ in $(seq 1 30); do
76
+ if netstat -ltn 2>/dev/null | grep -q ":${port} "; then
77
+ exit 0
78
+ fi
79
+ sleep 0.1
80
+ done
81
+ echo "x11vnc didn't bind :${port} within 3s"
82
+ netstat -ltn 2>&1 || echo "(netstat unavailable)"
83
+ cat /var/log/x11vnc.log
84
+ exit 1
85
+ `,
86
+ ],
87
+ timeoutMs: 15_000,
88
+ });
89
+ if (vncStart.exitCode !== 0) {
90
+ console.error(`${log} x11vnc failed:`, vncStart.stdout.toString(), vncStart.stderr.toString());
91
+ throw new Error('x11vnc startup failed');
92
+ }
93
+ // 2) Bridge host 127.0.0.1:port → guest :port.
94
+ const forwarder = await vm.exposeTcp(port, port);
95
+ console.error(`${log} forwarding host 127.0.0.1:${port} → guest :${port}`);
96
+ // 3) Open a viewer (macOS Screen Sharing), password prefilled.
97
+ if (osPlatform() === 'darwin') {
98
+ // Tiny delay so the accept loop is warm before the client dials,
99
+ // else Screen Sharing intermittently shows "connection refused".
100
+ await sleep(500);
101
+ const vncUrl = `vnc://:${encodeURIComponent(vncPassword)}@localhost:${port}`;
102
+ console.error(`${log} opening macOS Screen Sharing → vnc://localhost:${port} (password prefilled)`);
103
+ console.error(`${log} (if nothing opens: open '${vncUrl}')`);
104
+ nodeSpawn('open', [vncUrl], { stdio: 'ignore', detached: true }).unref();
105
+ }
106
+ else {
107
+ console.error(`${log} connect any VNC viewer to localhost:${port} (password: ${vncPassword}).`);
108
+ }
109
+ return forwarder;
110
+ }
111
+ //# sourceMappingURL=guestVnc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guestVnc.js","sourceRoot":"","sources":["../../src/lib/guestVnc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAW3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAarC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,EAAgB,EAChB,OAA8B,EAAE;IAEhC,MAAM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CAAC;QAC9B,iEAAiE;QACjE,iEAAiE;QACjE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,UAAU,kBAAkB,CAAC,WAAW,CAAC,cAAc,IAAI,EAAE,CAAC;QAC7E,OAAO,CAAC,KAAK,CACX,GAAG,GAAG,mDAAmD,IAAI,uBAAuB,CACrF,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,6BAA6B,MAAM,IAAI,CAAC,CAAC;QAC7D,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAC3E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CACX,GAAG,GAAG,wCAAwC,IAAI,eAAe,WAAW,IAAI,CACjF,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=buildImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildImage.d.ts","sourceRoot":"","sources":["../../src/scripts/buildImage.ts"],"names":[],"mappings":""}
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Build the canonical `shopify-test` image from the Dockerfile
4
- * bundled in this package. Run from the shopify-test workspace
5
- * root:
3
+ * Build the canonical `shopify-test` VM image via Apple's `container
4
+ * build` (NOT docker we don't use docker for any test path). The
5
+ * image spec is the bundled `docker/Dockerfile`; Dockerfile syntax is
6
+ * what `container build` consumes, and the directory name is
7
+ * historical. supermachine restores microVMs from the built image.
6
8
  *
7
- * npm run docker:build
9
+ * Run directly:
8
10
  *
9
- * Or directly:
11
+ * node --import tsx packages/runner/src/scripts/buildImage.ts
10
12
  *
11
- * node --import tsx packages/runner/src/scripts/buildDockerImage.ts
13
+ * or via the exposed bin `shopify-test-build-image`.
12
14
  *
13
15
  * The image is amd64-only (Rosetta on Apple Silicon) — see
14
16
  * docker/README.md for why.
@@ -20,7 +22,7 @@ import { fileURLToPath } from 'node:url';
20
22
  // Mirrors the npm scope (`@essential-apps/shopify-test`) so anyone
21
23
  // inspecting `container images` sees the same name they `npm install`.
22
24
  const DEFAULT_TAG = 'essential-apps/shopify-test:latest';
23
- function dockerContextDir() {
25
+ function imageContextDir() {
24
26
  // This file lives at packages/runner/src/scripts/ (or dist/scripts/
25
27
  // after build). Walk up + sideways to docker/.
26
28
  const here = dirname(fileURLToPath(import.meta.url));
@@ -38,9 +40,9 @@ function dockerContextDir() {
38
40
  }
39
41
  async function main() {
40
42
  const tag = process.env['SHOPIFY_TEST_IMAGE_TAG'] ?? DEFAULT_TAG;
41
- const context = dockerContextDir();
43
+ const context = imageContextDir();
42
44
  console.log('────────────────────────────────────────────────────────────');
43
- console.log(' shopify-test docker image build');
45
+ console.log(' shopify-test VM image build (Apple `container build`)');
44
46
  console.log('────────────────────────────────────────────────────────────');
45
47
  console.log(` Tag : ${tag}`);
46
48
  console.log(` Context : ${context}`);
@@ -57,4 +59,4 @@ main().catch((err) => {
57
59
  console.error(err);
58
60
  process.exit(1);
59
61
  });
60
- //# sourceMappingURL=buildDockerImage.js.map
62
+ //# sourceMappingURL=buildImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildImage.js","sourceRoot":"","sources":["../../src/scripts/buildImage.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,mEAAmE;AACnE,uEAAuE;AACvE,MAAM,WAAW,GAAG,oCAAoC,CAA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AAC;IACjE,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=captureSharedContracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureSharedContracts.d.ts","sourceRoot":"","sources":["../../src/scripts/captureSharedContracts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,209 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Regenerate the SHARED contract goldens in
4
+ * `@essential-apps/shopify-test-contracts/fixtures` from the in-process
5
+ * offline mock — the "replayable-variable capture" generator.
6
+ *
7
+ * Why this exists (the design the centralization landed on):
8
+ * A verify golden must be *mock-replayable* — `verify-contracts`
9
+ * replays its `source` + `variables` against the offline mock and
10
+ * asserts the response matches. A conformance capture (scrubbed LIVE
11
+ * variables like `ownerId: <NUMERIC_ID>`, a richer field selection)
12
+ * is NOT replayable: the mock can't resolve the placeholders. So the
13
+ * two are different artifacts.
14
+ *
15
+ * The clean split:
16
+ * - The verify golden is captured FROM THE MOCK with deterministic
17
+ * seed variables — replayable by construction. That's this script.
18
+ * - `@essential-apps/shopify-test-conformance` separately CERTIFIES
19
+ * the mock matches live Shopify (schema SDL + shape diffs). A
20
+ * golden that's mock-replayable AND mock-certified-vs-live is
21
+ * trustworthy end to end.
22
+ *
23
+ * This script keeps each golden's `operationName` / `source` /
24
+ * `variables` (so the *request* contract is stable) and refreshes only
25
+ * the `response` to the current mock output. Idempotent: unchanged
26
+ * responses aren't rewritten.
27
+ *
28
+ * node --import tsx packages/runner/src/scripts/captureSharedContracts.ts
29
+ * # or the bin: shopify-test-capture-shared-contracts
30
+ */
31
+ import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
32
+ import { resolve } from 'node:path';
33
+ import { createAdminApi, createStorefrontApi, } from '@essential-apps/shopify-test-shopify-api';
34
+ import { ShopState } from '@essential-apps/shopify-test-storefront';
35
+ import { fixturesDir, } from '@essential-apps/shopify-test-contracts/operation-contract';
36
+ import { normaliseResponse } from '../contracts/normalize.js';
37
+ const ADMIN_API_VERSION = '2025-07';
38
+ /**
39
+ * Structural equality under the same normalisation `verify` applies
40
+ * (gids → `<ID>`, timestamps → `<DATETIME>`, …). We rewrite a golden
41
+ * only on genuine structural drift — not when a volatile-but-equivalent
42
+ * value (a fresh timestamp/id) changed — so the generator is idempotent.
43
+ */
44
+ function sameShape(a, b) {
45
+ return (JSON.stringify(normaliseResponse(a)) === JSON.stringify(normaliseResponse(b)));
46
+ }
47
+ /**
48
+ * Deterministic GraphQL seed. MUST stay in lockstep with
49
+ * `verifyContracts.ts` / `captureContracts.ts` `buildSeededState` — the
50
+ * goldens are replayed against this exact state at verify time.
51
+ */
52
+ function buildGraphqlState() {
53
+ const state = new ShopState({
54
+ shop: {
55
+ domain: 'test-shop.myshopify.com',
56
+ permanent_domain: 'test-shop.myshopify.com',
57
+ },
58
+ });
59
+ state.addProduct({
60
+ id: 900_000_001,
61
+ handle: 'sample-product',
62
+ title: 'Sample Product',
63
+ description: 'Used by contract capture as a deterministic fixture.',
64
+ price: 1000,
65
+ vendor: 'Sample Vendor',
66
+ type: 'Sample',
67
+ variants: [
68
+ {
69
+ id: 900_010_001,
70
+ title: 'Default Title',
71
+ price: 1000,
72
+ available: true,
73
+ sku: 'SAMPLE-1',
74
+ inventory_quantity: 100,
75
+ selected_options: ['Default Title'],
76
+ },
77
+ ],
78
+ tags: [],
79
+ });
80
+ state.addCollection({
81
+ id: 900_020_001,
82
+ handle: 'sample-collection',
83
+ title: 'Sample Collection',
84
+ productHandles: ['sample-product'],
85
+ });
86
+ return state;
87
+ }
88
+ /** REST seed — matches `verifyRestContracts.ts` `buildSeededState`. */
89
+ function buildRestState() {
90
+ return new ShopState({
91
+ shop: {
92
+ domain: 'test-shop.myshopify.com',
93
+ permanent_domain: 'test-shop.myshopify.com',
94
+ },
95
+ });
96
+ }
97
+ function fillPath(template, params) {
98
+ return template.replace(/\{([^}]+)\}/g, (_, key) => {
99
+ if (!(key in params)) {
100
+ throw new Error(`path template references {${key}} but no value provided`);
101
+ }
102
+ return encodeURIComponent(params[key] ?? '');
103
+ });
104
+ }
105
+ function appendQuery(path, query) {
106
+ if (!query || Object.keys(query).length === 0)
107
+ return path;
108
+ const params = new URLSearchParams();
109
+ for (const [k, v] of Object.entries(query))
110
+ params.set(k, v);
111
+ return `${path}${path.includes('?') ? '&' : '?'}${params.toString()}`;
112
+ }
113
+ /** Flat `<op>.json` goldens only (skip manifests + store-keyed captures). */
114
+ function flatGoldens(dir) {
115
+ let entries;
116
+ try {
117
+ entries = readdirSync(dir);
118
+ }
119
+ catch {
120
+ return [];
121
+ }
122
+ return entries.filter((f) => f.endsWith('.json') &&
123
+ !f.endsWith('.manifest.json') &&
124
+ !f.slice(0, -'.json'.length).includes('.'));
125
+ }
126
+ async function regenGraphql(api) {
127
+ const dir = resolve(fixturesDir(), api);
128
+ const state = buildGraphqlState();
129
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Hono types are loose
130
+ const app = api === 'admin' ? createAdminApi({ state }) : createStorefrontApi({ state });
131
+ const endpoint = api === 'admin'
132
+ ? '/admin/api/2025-07/graphql.json'
133
+ : '/api/2025-07/graphql.json';
134
+ let changed = 0;
135
+ for (const f of flatGoldens(dir)) {
136
+ const p = resolve(dir, f);
137
+ const g = JSON.parse(readFileSync(p, 'utf8'));
138
+ if (g.warning)
139
+ continue;
140
+ const resp = await app.request(endpoint, {
141
+ method: 'POST',
142
+ headers: {
143
+ 'Content-Type': 'application/json',
144
+ 'X-Shopify-Access-Token': 'mock-access-token',
145
+ },
146
+ body: JSON.stringify({ query: g.source, variables: g.variables }),
147
+ });
148
+ const actual = await resp.json();
149
+ if (!sameShape(g.response, actual)) {
150
+ g.response = actual;
151
+ writeFileSync(p, JSON.stringify(g, null, 2) + '\n');
152
+ console.log(` updated ${api}/${f}`);
153
+ changed++;
154
+ }
155
+ }
156
+ return changed;
157
+ }
158
+ async function regenRest() {
159
+ const dir = resolve(fixturesDir(), 'admin-rest');
160
+ const state = buildRestState();
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Hono types are loose
162
+ const app = createAdminApi({ state });
163
+ let changed = 0;
164
+ for (const f of flatGoldens(dir)) {
165
+ const p = resolve(dir, f);
166
+ const c = JSON.parse(readFileSync(p, 'utf8'));
167
+ if (c.warning)
168
+ continue;
169
+ const finalPath = appendQuery(fillPath(c.path, { version: ADMIN_API_VERSION, ...(c.pathParams ?? {}) }), c.query);
170
+ const init = {
171
+ method: c.method,
172
+ headers: {
173
+ 'Content-Type': 'application/json',
174
+ 'X-Shopify-Access-Token': 'mock-access-token',
175
+ },
176
+ };
177
+ if (c.body !== undefined)
178
+ init.body = JSON.stringify(c.body);
179
+ const resp = await app.request(finalPath, init);
180
+ let body = null;
181
+ try {
182
+ body = await resp.json();
183
+ }
184
+ catch {
185
+ /* empty / non-JSON */
186
+ }
187
+ const next = { status: resp.status, body };
188
+ if (c.response.status !== next.status || !sameShape(c.response.body, next.body)) {
189
+ c.response = next;
190
+ writeFileSync(p, JSON.stringify(c, null, 2) + '\n');
191
+ console.log(` updated admin-rest/${f}`);
192
+ changed++;
193
+ }
194
+ }
195
+ return changed;
196
+ }
197
+ async function main() {
198
+ console.log('[capture-shared-contracts] regenerating shared goldens from the offline mock…');
199
+ let total = 0;
200
+ total += await regenGraphql('admin');
201
+ total += await regenGraphql('storefront');
202
+ total += await regenRest();
203
+ console.log(`[capture-shared-contracts] done — ${total} golden(s) refreshed.`);
204
+ }
205
+ main().catch((err) => {
206
+ console.error(err);
207
+ process.exit(1);
208
+ });
209
+ //# sourceMappingURL=captureSharedContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureSharedContracts.js","sourceRoot":"","sources":["../../src/scripts/captureSharedContracts.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,mBAAmB,GACpB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EACL,WAAW,GAGZ,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,SAAS,SAAS,CAAC,CAAU,EAAE,CAAU;IACvC,OAAO,CACL,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAC9E,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB;IACxB,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC;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"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -56,6 +56,7 @@ import { dirname, resolve } from 'node:path';
56
56
  import { fileURLToPath } from 'node:url';
57
57
  import { pickApp, prepareOciArchive, envFileArgs, computeBuildHash } from '@essential-apps/shopify-test-core';
58
58
  import { buildExtensions } from '../lib/buildExtensions.js';
59
+ import { exposeGuestVnc } from '../lib/guestVnc.js';
59
60
  const repoRoot = process.cwd();
60
61
  function readAppName() {
61
62
  const pkgPath = resolve(repoRoot, 'package.json');
@@ -293,6 +294,25 @@ async function main() {
293
294
  }
294
295
  })();
295
296
  const runtimeTag = `sm${runtimeVersion.replace(/[^0-9a-z]+/gi, '')}`;
297
+ // Fold THIS runner package's own version into the snapshot key. The
298
+ // warm snapshot bakes the in-VM `npm install` (which installs the
299
+ // orchestrator + fixtures this same shopify-test version ships). Those
300
+ // run INSIDE the VM, so a version bump that changes orchestrator/
301
+ // fixture behaviour (e.g. screen-video support) would otherwise
302
+ // warm-restore a STALE in-VM install — the consumer updates the
303
+ // package but keeps running the old in-VM code until they manually
304
+ // `rm -rf ~/.cache/<app>-test`. Keying on the runner version makes a
305
+ // bump auto-rebake (cold install of the new version) — same
306
+ // no-manual-bust philosophy as manifestHash + runtimeTag.
307
+ const runnerVersion = (() => {
308
+ try {
309
+ return createRequire(import.meta.url)('../../package.json').version;
310
+ }
311
+ catch {
312
+ return 'unknown';
313
+ }
314
+ })();
315
+ const runnerTag = `r${runnerVersion.replace(/[^0-9a-z]+/gi, '')}`;
296
316
  // Scope the snapshot to the consuming app. supermachine keys WARM
297
317
  // snapshots by (image + warmupTag), but the image is shared across
298
318
  // apps and the rest of the tag is identical for any two apps vendoring
@@ -302,7 +322,7 @@ async function main() {
302
322
  // identity (observed: essential-upsell booting with essential-seo's
303
323
  // DB). The cache paths are already appName-namespaced; this aligns the
304
324
  // snapshot key with them.
305
- const warmupTag = `offline-v13-${appName}-${runtimeTag}-${manifestHash}`;
325
+ const warmupTag = `offline-v13-${appName}-${runtimeTag}-${runnerTag}-${manifestHash}`;
306
326
  // Dynamic import — @supermachine/core is heavy and only needed
307
327
  // when actually running tests, not for `--help` etc.
308
328
  const { Image } = await import('@supermachine/core');
@@ -455,6 +475,15 @@ async function main() {
455
475
  // orchestrator's Xvfb startup + the offlineFullStack screen-video
456
476
  // fixture).
457
477
  'TEST_OFFLINE_VIDEO',
478
+ // Offline runs headed-under-Xvfb by default; opt out to headless.
479
+ 'TEST_OFFLINE_HEADLESS',
480
+ // Interactive explore mode: orchestrator skips Playwright and
481
+ // instead opens a headed Chromium (admin + storefront tabs) on
482
+ // the guest Xvfb display, which we surface over VNC (see the
483
+ // explore branch below).
484
+ 'TEST_OFFLINE_EXPLORE',
485
+ 'TEST_OFFLINE_EXPLORE_URL',
486
+ 'TEST_OFFLINE_EXPLORE_NO_DEVTOOLS',
458
487
  'CI',
459
488
  'DEBUG',
460
489
  ]) {
@@ -524,6 +553,54 @@ async function main() {
524
553
  // mismatch unless we tell it exactly which .so.node to dlopen.
525
554
  forwardEnv['PRISMA_QUERY_ENGINE_LIBRARY'] =
526
555
  '/workspace/node_modules/.prisma/client/libquery_engine-linux-arm64-openssl-3.0.x.so.node';
556
+ // ── Explore mode (interactive, VNC) ───────────────────────────
557
+ // `TEST_OFFLINE_EXPLORE=true` boots the full offline mock stack
558
+ // and hands the developer a real browser inside the VM instead of
559
+ // running Playwright. We surface the guest's Xvfb display over VNC
560
+ // (supermachine `vm.exposeTcp`, NOT docker --publish) so they can
561
+ // click through the admin app + storefront against the mock stack.
562
+ // The orchestrator opens both tabs (see runOfflineFullTests explore
563
+ // branch) and holds until the browser window is closed / Ctrl-C.
564
+ if (process.env['TEST_OFFLINE_EXPLORE'] === 'true') {
565
+ let forwarder;
566
+ try {
567
+ forwarder = (await exposeGuestVnc(vm, {
568
+ logPrefix: '[runOffline]',
569
+ }));
570
+ console.error('[runOffline] launching explore session…');
571
+ const exploreProc = await vm.spawn({
572
+ argv: ['sh', '-c', `
573
+ cd /workspace
574
+ export PATH=/workspace/node_modules/.bin:$PATH
575
+ export DISPLAY=:99
576
+ node ${envFileArgs(repoRoot)} node_modules/@essential-apps/shopify-test-runner/dist/scripts/runOfflineFullTests.js
577
+ `],
578
+ env: forwardEnv,
579
+ });
580
+ // Stream guest output verbatim with NO stall/hard timeout — an
581
+ // explore session legitimately sits idle for as long as the
582
+ // developer is poking around. It ends when they close the
583
+ // browser (orchestrator exits) or Ctrl-C here.
584
+ const pump = (async () => {
585
+ while (true) {
586
+ const out = await exploreProc.readStdout(64 * 1024);
587
+ if (out.length === 0) {
588
+ await new Promise((r) => setTimeout(r, 200));
589
+ continue;
590
+ }
591
+ process.stdout.write(out);
592
+ }
593
+ })();
594
+ pump.catch(() => { });
595
+ const wait = await exploreProc.wait();
596
+ process.exitCode = wait.exitCode ?? 0;
597
+ return;
598
+ }
599
+ finally {
600
+ if (forwarder?.stop)
601
+ await Promise.resolve(forwarder.stop()).catch(() => { });
602
+ }
603
+ }
527
604
  // Optional --grep forwarding for fast iteration on a single
528
605
  // scenario or spec without writing a one-off bench script.
529
606
  const grep = process.env['PLAYWRIGHT_GREP'];