mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 09:02:11 +03:00
Electron Package Smoke — a packaging defect that had been hidden behind another
packaging defect for nine days. Once the loginHeaderCapture fix let the main process
start, the server underneath died on 'Cannot find module next': resources/app/server.js
shipped without resources/app/node_modules.
electron-builder discards the ROOT node_modules in code, not by configuration —
app-builder-lib/out/util/filter.js:42 has a hard-coded `if (relative === "node_modules")
return false` that runs before any filter pattern. The second extraResources entry
pointing INTO ../.build/electron-standalone/node_modules is what sidesteps it, because
those relative paths are never equal to "node_modules". #10325 removed that entry as an
apparent duplicate and flipped the test to assert "exactly once", freezing the
regression as if it were the contract. Restored, and the unit guard now pins both
entries — proven by mutation: reverting package.json to the post-#10325 shape fails the
guard 3/4, restoring it passes 4/4.
group-b-quota-plans-config — the assertion was impossible to satisfy on ANY route, and
the page was never broken. layout.tsx hands the whole message catalogue to
NextIntlClientProvider, React serialises that prop into the RSC payload, and en.json
carries "Internal Server Error" twice, so page.content() always contains it: probing
/dashboard, /dashboard/costs, /dashboard/settings and /login showed the string present
with every page rendering fine, and a pageerror probe on the failing run captured zero
client exceptions. This is the same trap that killed the sibling not.toContain("500")
in fc77100c3f ("raw HTML is unreliable") — that one was removed, this one was kept.
Now asserts on rendered text, which still catches a real error boundary. The pageerror
capture stays: the CI failure carried no stack trace, which is why it was misread twice.
Integration — 10 of the 14 shard-2 reds, all sibling-test gaps behind security fixes:
monitoring health now takes a Request and requires management auth (GHSA-mvf8-qc78-5mxm);
the OAuth import routes moved to requireManagementAuth (GHSA-mg76) — the test accepts
both guard shapes and gained a stronger anchor that every exported handler awaits a
guard on its own request, mutation-verified; skill tool names are derived from
encodeSkillToolName() and the fake upstream now returns the encoded name so
decodeSkillToolName() is exercised too; previous_response_id now fails closed (#10262);
proxy_logs persist as an async batch (#11182) so the test flushes first;
providerQuotaOverrides joined GET /api/resilience (#9871); the reasoning fixture used a
model that stopped being thinking-incompatible, replaced and pinned with a premise
assert so it cannot rot silently again.
A vacuous assert.ok(true, "all 10 streams completed without hanging") was replaced with
real anchors — content must arrive on every stream and the active Timeout count must not
grow.
Four are deliberately left red rather than aligned, each now tracked: #11551 (the
/v1/models after() wiring is dead — the route passes a third argument to a two-parameter
function and catalogCache never imports after, so the #8728 contract is unimplemented),
#11552 (~27% of requests emit an extra discarded upstream call; the delivered
distribution is exactly 0.70, so weighted routing is correct and the waste is the real
finding), the fixed-account combo pin (aligning it would destroy the per-step attribution
the test exists for), and the web_search fallback already tracked as #11524.
Package Artifact — the provenance stamp I added last round used git rev-parse HEAD, which
under pull_request is the ephemeral merge commit and therefore never an ancestor of the
release branch. Now takes the PR head sha.
Refs #10692
134 lines
5.4 KiB
TypeScript
134 lines
5.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import test from "node:test";
|
|
import { pruneElectronRuntimeDocs } from "../../scripts/build/electronRuntimeDocs.mjs";
|
|
|
|
const ROOT = join(import.meta.dirname, "..", "..");
|
|
|
|
// The SECOND entry looks like a redundant duplicate of the first — it is not, and
|
|
// removing it ships a desktop app that cannot boot.
|
|
//
|
|
// electron-builder's file matcher hard-codes an exclusion of the source root's
|
|
// `node_modules` directory for extraResources/extraFiles, BEFORE any `filter`
|
|
// pattern is consulted (app-builder-lib/out/util/filter.js: `if (relative ===
|
|
// "node_modules") return false`). So `{ from: ".build/electron-standalone", to:
|
|
// "app", filter: ["**/*"] }` copies server.js, server-ws.mjs and every NESTED
|
|
// node_modules, but silently drops `.build/electron-standalone/node_modules` —
|
|
// the tree that holds `next`, `better-sqlite3` and the whole server closure.
|
|
//
|
|
// Pointing a second matcher AT the node_modules directory sidesteps the check
|
|
// (its relative paths never equal "node_modules") and is the only way to get that
|
|
// tree into `resources/app/node_modules`, which main.js also puts on the server's
|
|
// NODE_PATH.
|
|
//
|
|
// Regression history: #10325 "de-duplicated" the two entries into one on
|
|
// 2026-08-16; the packaged app then died on `Cannot find module 'next'` at
|
|
// resources/app/server.js. It went unnoticed for nine days because the Electron
|
|
// Package Smoke was already red on an earlier defect (lib/loginHeaderCapture.js
|
|
// missing from build.files since #9984), so the main process never got far enough
|
|
// to spawn the server.
|
|
test("electron build copies the standalone runtime AND its root node_modules into resources/app", () => {
|
|
const electronPackage = JSON.parse(readFileSync(join(ROOT, "electron", "package.json"), "utf8"));
|
|
|
|
const extraResources = electronPackage.build?.extraResources;
|
|
assert.ok(Array.isArray(extraResources), "electron build.extraResources must be an array");
|
|
|
|
const appResources = extraResources.filter(
|
|
(resource) => resource?.to === "app" || resource?.to?.startsWith("app/")
|
|
);
|
|
|
|
assert.deepEqual(appResources, [
|
|
{
|
|
from: "../.build/electron-standalone",
|
|
to: "app",
|
|
filter: ["**/*", "node_modules/**/*"],
|
|
},
|
|
{
|
|
from: "../.build/electron-standalone/node_modules",
|
|
to: "app/node_modules",
|
|
filter: ["**/*"],
|
|
},
|
|
]);
|
|
});
|
|
|
|
test("electron standalone assembly normalizes Turbopack hashed external imports", () => {
|
|
const prepareScript = readFileSync(
|
|
join(ROOT, "scripts", "build", "prepare-electron-standalone.mjs"),
|
|
"utf8"
|
|
);
|
|
|
|
assert.match(
|
|
prepareScript,
|
|
/assembleStandalone\(\{[\s\S]*?patchTurbopackChunks:\s*true,[\s\S]*?\}\);/,
|
|
"Electron packages must strip Turbopack's hashed external package names before bundling"
|
|
);
|
|
});
|
|
|
|
test("electron docs manifest prunes authoring payloads without removing runtime docs", () => {
|
|
const bundleRoot = mkdtempSync(join(tmpdir(), "omniroute-electron-docs-"));
|
|
const files = new Map([
|
|
["docs/openapi.yaml", "openapi: 3.1.0"],
|
|
["docs/guides/CODEX-CLI-CONFIGURATION.md", "# Codex CLI"],
|
|
["docs/i18n/ko/docs/guides/ELECTRON_GUIDE.md", "# Electron"],
|
|
["docs/i18n/ko/CHANGELOG.md", "translated release history"],
|
|
["docs/i18n/fr/CHANGELOG.md", "historique traduit"],
|
|
["docs/research/desktop-notes.md", "authoring notes"],
|
|
["docs/superpowers/plans/desktop-plan.md", "implementation plan"],
|
|
]);
|
|
|
|
try {
|
|
for (const [relativePath, content] of files) {
|
|
const absolutePath = join(bundleRoot, relativePath);
|
|
mkdirSync(join(absolutePath, ".."), { recursive: true });
|
|
writeFileSync(absolutePath, content);
|
|
}
|
|
|
|
const result = pruneElectronRuntimeDocs(bundleRoot);
|
|
|
|
assert.deepEqual(result.removedPaths, [
|
|
"docs/i18n/fr/CHANGELOG.md",
|
|
"docs/i18n/ko/CHANGELOG.md",
|
|
"docs/research",
|
|
"docs/superpowers",
|
|
]);
|
|
assert.equal(result.removedFiles, 4);
|
|
assert.equal(
|
|
result.removedBytes,
|
|
Buffer.byteLength("translated release history") +
|
|
Buffer.byteLength("historique traduit") +
|
|
Buffer.byteLength("authoring notes") +
|
|
Buffer.byteLength("implementation plan")
|
|
);
|
|
|
|
assert.equal(existsSync(join(bundleRoot, "docs/openapi.yaml")), true);
|
|
assert.equal(existsSync(join(bundleRoot, "docs/guides/CODEX-CLI-CONFIGURATION.md")), true);
|
|
assert.equal(existsSync(join(bundleRoot, "docs/i18n/ko/docs/guides/ELECTRON_GUIDE.md")), true);
|
|
assert.equal(existsSync(join(bundleRoot, "docs/i18n/ko/CHANGELOG.md")), false);
|
|
assert.equal(existsSync(join(bundleRoot, "docs/research")), false);
|
|
assert.equal(existsSync(join(bundleRoot, "docs/superpowers")), false);
|
|
|
|
assert.deepEqual(pruneElectronRuntimeDocs(bundleRoot), {
|
|
removedFiles: 0,
|
|
removedBytes: 0,
|
|
removedPaths: [],
|
|
});
|
|
} finally {
|
|
rmSync(bundleRoot, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("electron bundle preparation applies the runtime docs manifest to its staging tree", () => {
|
|
const prepareScript = readFileSync(
|
|
join(ROOT, "scripts", "build", "prepare-electron-standalone.mjs"),
|
|
"utf8"
|
|
);
|
|
|
|
assert.match(
|
|
prepareScript,
|
|
/pruneElectronRuntimeDocs\(ELECTRON_STANDALONE_DIR\)/,
|
|
"Electron staging must prune authoring docs before electron-builder copies the bundle"
|
|
);
|
|
});
|