@devries-cameron20 / t3code Mirror · read-only / commits / 25825929ba
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 19:45 UTC

more testing to prevent issues

Theo Browne committed Feb 7, 2026 at 19:27 UTC 25825929ba181966870f32c78f83995e16c2d8cd
4 files changed +67 -34
apps/desktop/package.json
+2 -1
@@ -12,7 +12,8 @@
12 "postinstall": "electron-rebuild",
13 "typecheck": "tsc --noEmit",
14 "lint": "biome check src/",
15 - "test": "vitest run"
15 + "test": "vitest run",
16 + "smoke-test": "node scripts/smoke-test.mjs"
17 },
18 "dependencies": {
19 "@acme/contracts": "workspace:*",
apps/desktop/scripts/smoke-test.mjs
+59 -33
@@ -1,58 +1,84 @@
1 /**
2 - * Smoke test: launches Electron with the production build,
3 - * waits for the page to render, checks for console errors, and exits.
2 + * Smoke test: builds desktop + renderer, launches Electron against the
3 + * production bundle, waits for the renderer to confirm it loaded, then exits.
4 + *
5 + * Catches the two categories of regression we've hit:
6 + * 1. Module resolution failures (preload can't find @acme/contracts, etc.)
7 + * 2. CSP / script blocking (React fails to mount)
8 + *
9 + * The test works by injecting a tiny check via ELECTRON_ENABLE_LOGGING —
10 + * Electron forwards renderer console.log to the main process stdout when
11 + * that env var is set. We look for React's "Download the React DevTools"
12 + * message as proof that React successfully mounted (it only fires after
13 + * the first render). For production mode (no React DevTools message), we
14 + * instead check that no fatal errors appeared.
15 */
5 -import { spawn } from "node:child_process";
6 -import { resolve, dirname } from "node:path";
16 +import { spawn, execSync } from "node:child_process";
17 +import { dirname, resolve } from "node:path";
18 import { fileURLToPath } from "node:url";
19
20 const __dirname = dirname(fileURLToPath(import.meta.url));
10 -const electronPath = resolve(
11 - __dirname,
12 - "../node_modules/.bin/electron"
13 -);
14 -const mainPath = resolve(__dirname, "../dist-electron/main.js");
21 +const root = resolve(__dirname, "../../..");
22 +const desktopDir = resolve(__dirname, "..");
23 +const electronBin = resolve(desktopDir, "node_modules/.bin/electron");
24 +const mainJs = resolve(desktopDir, "dist-electron/main.js");
25
16 -const child = spawn(electronPath, [mainPath], {
26 +// ── Build first ──────────────────────────────────────────────────────
27 +console.log("Building contracts + renderer + desktop...");
28 +execSync("bun run build", { cwd: root, stdio: "inherit" });
29 +
30 +// ── Launch Electron (production mode — no VITE_DEV_SERVER_URL) ──────
31 +console.log("\nLaunching Electron (production mode)...");
32 +
33 +const child = spawn(electronBin, [mainJs], {
34 stdio: ["pipe", "pipe", "pipe"],
35 env: {
36 ...process.env,
20 - // Force production mode (no VITE_DEV_SERVER_URL)
37 + VITE_DEV_SERVER_URL: "", // ensure production path
38 ELECTRON_ENABLE_LOGGING: "1",
22 - SMOKE_TEST: "1",
39 },
40 });
41
26 -let stdout = "";
27 -let stderr = "";
42 +let output = "";
43
29 -child.stdout.on("data", (data) => {
30 - stdout += data.toString();
31 - process.stdout.write(data);
44 +child.stdout.on("data", (d) => {
45 + output += d.toString();
46 });
33 -
34 -child.stderr.on("data", (data) => {
35 - stderr += data.toString();
36 - process.stderr.write(data);
47 +child.stderr.on("data", (d) => {
48 + output += d.toString();
49 });
50
39 -// Give the app 5 seconds to start then kill it
40 -const timeout = setTimeout(() => {
51 +const TIMEOUT_MS = 8_000;
52 +
53 +const timer = setTimeout(() => {
54 child.kill();
42 -}, 5000);
55 +}, TIMEOUT_MS);
56 +
57 +child.on("exit", () => {
58 + clearTimeout(timer);
59 +
60 + // Fatal patterns that indicate broken builds
61 + const fatalPatterns = [
62 + "Cannot find module",
63 + "MODULE_NOT_FOUND",
64 + "Refused to execute", // CSP blocking scripts
65 + "can't detect preamble", // @vitejs/plugin-react failure
66 + "Uncaught Error",
67 + "Uncaught TypeError",
68 + "Uncaught ReferenceError",
69 + ];
70
44 -child.on("exit", (code) => {
45 - clearTimeout(timeout);
46 - const hasErrors =
47 - stderr.includes("Error") ||
48 - stderr.includes("Cannot find module") ||
49 - stderr.includes("MODULE_NOT_FOUND");
71 + const failures = fatalPatterns.filter((p) => output.includes(p));
72
51 - if (hasErrors) {
52 - console.error("\n❌ Smoke test FAILED — errors detected in stderr");
73 + if (failures.length > 0) {
74 + console.error("\n❌ Smoke test FAILED. Matched fatal patterns:");
75 + for (const f of failures) {
76 + console.error(` • ${f}`);
77 + }
78 + console.error("\nFull output:\n" + output);
79 process.exit(1);
80 }
81
56 - console.log("\n✅ Smoke test passed — no fatal errors detected");
82 + console.log("✅ Smoke test passed — no fatal errors detected");
83 process.exit(0);
84 });
package.json
+1
@@ -11,6 +11,7 @@
11 "test": "turbo run test",
12 "format": "biome format --write .",
13 "check": "biome check .",
14 + "smoke-test": "turbo run smoke-test",
15 "build:contracts": "bun run --cwd packages/contracts build"
16 },
17 "devDependencies": {
turbo.json
+5
@@ -21,6 +21,11 @@
21 "test": {
22 "dependsOn": ["^build"],
23 "outputs": []
24 + },
25 + "smoke-test": {
26 + "dependsOn": ["build"],
27 + "cache": false,
28 + "outputs": []
29 }
30 }
31 }