openpetswithchatandmcp/apps/desktop/scripts/run-tests.mjs
2026-06-19 21:05:28 +00:00

184 lines
7.7 KiB
JavaScript

#!/usr/bin/env node
/**
* Desktop test runner
* Runs preload checks, builds and runs behavior tests, contract tests, then remaining dist checks.
*/
import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const rootDir = join(__dirname, "..");
const preloadChecks = [
"control-center-preload.cjs",
"familiar-preload.cjs",
"plugin-sdk-preload.cjs",
"panel-preload.cjs",
"plugin-command-form-preload.cjs",
"prompt-window-preload.cjs",
];
const behaviorTests = [
".test-dist/tests/lease-manager.test.js",
".test-dist/tests/custom-familiar-name.test.js",
".test-dist/tests/internal-ui-route-conformance.test.js",
".test-dist/tests/control-center-ipc-route-seams.test.js",
".test-dist/tests/familiar-window-render.test.js",
".test-dist/tests/familiar-window-content.test.js",
".test-dist/tests/familiar-window-layout.test.js",
".test-dist/tests/familiar-window-renderer-bridge.test.js",
".test-dist/tests/local-ipc-socket.test.js",
".test-dist/tests/prompt-window-render.test.js",
".test-dist/tests/prompt-window-render-seams.test.js",
".test-dist/tests/prompt-window-render-script-sections.test.js",
".test-dist/tests/familiar-window-interactions.test.js",
".test-dist/tests/familiar-window-mouse-interop-runtime.test.js",
".test-dist/tests/familiar-window-plugin-menu.test.js",
".test-dist/tests/settings-view-tabs.test.js",
".test-dist/tests/settings-view-state.test.js",
".test-dist/tests/settings-view-action-seams.test.js",
".test-dist/tests/settings-view-state-actions-split.test.js",
".test-dist/tests/control-center-state-validation.test.js",
".test-dist/tests/settings-openapi-group-provider.test.js",
".test-dist/tests/settings-tts-group-split.test.js",
".test-dist/tests/default-familiar-external-show.test.js",
".test-dist/tests/default-familiar-controller-bubbles.test.js",
".test-dist/tests/default-familiar-controller-motion.test.js",
".test-dist/tests/default-familiar-controller-display-support.test.js",
".test-dist/tests/default-familiar-controller-window.test.js",
".test-dist/tests/app-state-preferences.test.js",
".test-dist/tests/app-state-analytics.test.js",
".test-dist/tests/app-state-familiar-records.test.js",
".test-dist/tests/app-state-normalization.test.js",
".test-dist/tests/app-state-storage.test.js",
".test-dist/tests/onboarding-state.test.js",
".test-dist/tests/update-version.test.js",
".test-dist/tests/reaction-animation-mapping.test.js",
".test-dist/tests/openapi-chat-settings.test.js",
".test-dist/tests/openapi-chat-prompt-flows.test.js",
".test-dist/tests/openapi-chat-prompt-plain-flow.test.js",
".test-dist/tests/openapi-chat-provider.test.js",
".test-dist/tests/openapi-chat-tool-loop.test.js",
".test-dist/tests/openapi-chat-request-helpers.test.js",
".test-dist/tests/openapi-chat-conversation-store.test.js",
".test-dist/tests/openapi-chat-config-store.test.js",
".test-dist/tests/catalog-surfaceable.test.js",
".test-dist/tests/zip-safety.test.js",
".test-dist/tests/tts-engine.test.js",
".test-dist/tests/codex-familiars.test.js",
".test-dist/tests/catalog-remote-seams.test.js",
".test-dist/tests/claude-memory.test.js",
".test-dist/tests/prompt-memory-extraction.test.js",
".test-dist/tests/familiaros-memory-search.test.js",
".test-dist/tests/knowledge-store-core-seam.test.js",
".test-dist/tests/knowledge-store.test.js",
".test-dist/tests/control-center-service-barrels.test.js",
".test-dist/tests/mcp-toolkit-installer-seams.test.js",
".test-dist/tests/mcp-toolkit-catalog.test.js",
".test-dist/tests/integrations-view-toolkit-split.test.js",
".test-dist/tests/integrations-view-agent-sections.test.js",
".test-dist/tests/integrations-view-detail-dialog.test.js",
".test-dist/tests/integrations-view-state.test.js",
".test-dist/tests/familiars-view-detail-dialog.test.js",
".test-dist/tests/familiars-view-state.test.js",
".test-dist/tests/agent-setup-actions.test.js",
".test-dist/tests/agent-setup-actions-tooling.test.js",
".test-dist/tests/agent-setup-claude-status.test.js",
".test-dist/tests/agent-setup-command-runner.test.js",
".test-dist/tests/agent-setup-command-context.test.js",
".test-dist/tests/agent-setup-support.test.js",
".test-dist/tests/plugin-config.test.js",
".test-dist/tests/plugin-sdk-bridge.test.js",
".test-dist/tests/plugin-sdk-api-builder.test.js",
".test-dist/tests/plugin-sdk-api-builder-platform.test.js",
".test-dist/tests/plugin-sdk-api-builder-platform-files.test.js",
".test-dist/tests/plugin-sdk-bridge-runtime-state.test.js",
".test-dist/tests/plugin-sdk-bubble-validation.test.js",
".test-dist/tests/plugin-sdk-command-validation.test.js",
".test-dist/tests/plugin-sdk-runtime-helpers.test.js",
".test-dist/tests/plugin-sdk-storage-stores.test.js",
".test-dist/tests/plugin-sdk-surface-boundaries.test.js",
".test-dist/tests/plugin-state.test.js",
".test-dist/tests/plugin-runtime.test.js",
".test-dist/tests/plugin-catalog-validation.test.js",
".test-dist/tests/plugin-package.test.js",
".test-dist/tests/plugin-js-host-sdk-dispatch.test.js",
".test-dist/tests/plugin-service-app.test.js",
".test-dist/tests/plugin-service-actions.test.js",
".test-dist/tests/plugin-service.test.js",
".test-dist/tests/plugin-service-bundled-support.test.js",
".test-dist/tests/plugin-service-catalog-support.test.js",
".test-dist/tests/plugin-service-support.test.js",
".test-dist/tests/plugin-service-dialog-support.test.js",
".test-dist/tests/plugin-service-local-support.test.js",
".test-dist/tests/plugin-service-ui-helpers.test.js",
".test-dist/tests/plugin-manifest-validation-seams.test.js",
".test-dist/tests/plugin-manifest-shape-validation.test.js",
".test-dist/tests/plugins-view-config-list-editor.test.js",
".test-dist/tests/plugins-view-config-fields.test.js",
".test-dist/tests/plugin-ui-static.test.js",
".test-dist/tests/plugin-user-sound-store.test.js",
".test-dist/tests/plugin-bridge-fuzz.test.js",
".test-dist/tests/shared-ui-split.test.js",
];
const contractTests = [
".test-dist/contracts/local-ipc-protocol.contract.js",
".test-dist/contracts/catalog-fixture.contract.js",
".test-dist/contracts/plugin-manifest.contract.js",
];
const distChecks = [
"dist/check-opencode-desktop-setup.js",
"dist/check-cursor-desktop.js",
"dist/check-packaging-contract.js",
];
function run(command, args = [], options = {}) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, {
stdio: "inherit",
cwd: rootDir,
env: { ...process.env, FAMILIAROS_DESKTOP_ROOT: rootDir },
...options,
});
child.on("close", (code) => {
if (code !== 0) {
reject(new Error(`Command failed with exit code ${code}: ${command} ${args.join(" ")}`));
} else {
resolve();
}
});
child.on("error", reject);
});
}
async function main() {
// 1. Preload syntax checks
console.log("\n[1/5] Checking preload syntax...");
for (const preload of preloadChecks) await run("node", ["--check", preload]);
// 2. Build tests
console.log("\n[2/5] Building tests...");
await run("pnpm", ["test:build"]);
// 3. Run behavior tests
console.log("\n[3/5] Running behavior tests...");
for (const test of behaviorTests) await run("node", [test]);
// 4. Run contract tests
console.log("\n[4/5] Running contract tests...");
for (const test of contractTests) await run("node", [test]);
// 5. Run remaining dist checks
console.log("\n[5/5] Running dist checks...");
for (const check of distChecks) {
await run("node", [check]);
}
console.log("\n✓ All tests passed!");
}
main().catch((err) => {
console.error("\n✗ Test suite failed:", err.message);
process.exit(1);
});