open-design/tools/dev/tests/diagnostics.test.ts
marco 5dd70b5016
Some checks failed
ci / Validate workspace (push) Successful in 12m32s
landing-page-ci / Validate landing page (push) Successful in 9m41s
landing-page-deploy / Deploy landing page (push) Failing after 5m23s
github-metrics / Generate repository metrics SVG (push) Failing after 2m3s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 11s
Initial import: open-design source for helix-mind.ai distribution
This repository contains the open-design daemon CLI source code, built
and packaged at https://helix-mind.ai/cli/open-design/latest.tgz for use
by the HelixMind /design slash command.

Licenses: Apache-2.0 (root) + MIT (skills/*)
2026-05-06 20:50:24 +02:00

68 lines
2.9 KiB
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import {
appendStartupLogDiagnostics,
createStartupLogDiagnostics,
detectLogDiagnostics,
} from "../src/diagnostics.js";
describe("tools-dev diagnostics", () => {
it("detects native addon ABI mismatches", () => {
const diagnostics = detectLogDiagnostics([
"Error: The module '/repo/node_modules/better-sqlite3/build/Release/better_sqlite3.node'",
"was compiled against a different Node.js version using",
"NODE_MODULE_VERSION 127. This version of Node.js requires",
"NODE_MODULE_VERSION 137. Please try re-compiling or re-installing",
]);
assert.equal(diagnostics.length, 1);
assert.match(diagnostics[0].message, /native Node addon ABI mismatch/);
assert.match(diagnostics[0].recommendation, /rebuild better-sqlite3 --pending/);
assert.match(diagnostics[0].recommendation, /pnpm install/);
});
it("detects missing Next.js package resolution during web startup", () => {
const diagnostics = detectLogDiagnostics([
"Turbopack build failed with 1 errors:",
"./apps/web/app",
"Error: Next.js inferred your workspace root, but it may not be correct.",
"We couldn't find the Next.js package (next/package.json) from the project directory: /repo/apps/web/app",
]);
assert.equal(diagnostics.length, 1);
assert.match(diagnostics[0].message, /Next\.js package is not resolvable/);
assert.match(diagnostics[0].recommendation, /apps\/web\/node_modules\/next/);
assert.match(diagnostics[0].recommendation, /pnpm install --frozen-lockfile/);
});
it("detects missing Next.js package resolution when details change", () => {
const diagnostics = detectLogDiagnostics([
"Error: We couldn't find the Next.js package from the project directory: /repo/apps/web/app",
]);
assert.equal(diagnostics.length, 1);
assert.match(diagnostics[0].message, /Next\.js package is not resolvable/);
});
it("does not report diagnostics for unrelated logs", () => {
assert.deepEqual(detectLogDiagnostics(["daemon booting", "ready"]), []);
});
it("appends log tails and recommendations to startup timeout errors", () => {
const error = appendStartupLogDiagnostics(
new Error("daemon did not expose status in time"),
"daemon",
createStartupLogDiagnostics("/tmp/daemon.log", [
"better_sqlite3.node was compiled against a different Node.js version using",
"NODE_MODULE_VERSION 127. This version of Node.js requires NODE_MODULE_VERSION 137.",
]),
);
assert.match(error.message, /daemon did not expose status in time/);
assert.match(error.message, /daemon log tail \(\/tmp\/daemon\.log\)/);
assert.match(error.message, /better_sqlite3\.node/);
assert.match(error.message, /pnpm --filter @open-design\/daemon rebuild better-sqlite3 --pending/);
});
});