Files
fusion/plugins/fusion-plugin-reports/vitest.config.ts
Phil Larson 920d68e10f fix(dashboard): expose column roles to browser bundle (#3151)
## Summary
- export the browser-safe `@fusion/core/column-roles` subpath
- keep Vite/Vitest aliases ahead of broad `@fusion/core` aliases
- restore production dashboard builds after task undo classification
adopted shared column-role helpers

## Test plan
- `node scripts/check-no-node-only-core-imports-in-dashboard.mjs`
- `FUSION_DASHBOARD_DEEP=1 pnpm --filter @fusion/dashboard exec vitest
run app/utils/__tests__/taskRevert.test.ts --pool=threads
--maxWorkers=1`
- `pnpm --filter @fusion/core typecheck`
- `pnpm --filter @fusion/dashboard typecheck`
- `CI=true pnpm check:changesets`
- `pnpm build`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
  * Fixed dashboard build compatibility for browser-based environments.
* Improved reliability when importing column role functionality across
supported application components.

* **Refactor**
* Made column role utilities available through a dedicated browser-safe
entry point.

* **Chores**
* Updated development and test configurations to consistently resolve
the new entry point.
* Documented the browser-safe module classification and recorded the
release patch.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-31 06:46:19 -07:00

89 lines
4.0 KiB
TypeScript

import { defineConfig } from "vitest/config";
import { fileURLToPath } from "node:url";
import { computeMaxWorkers } from "../../packages/core/src/__test-utils__/vitest-workers";
const maxWorkers = computeMaxWorkers();
const coreSetup = fileURLToPath(
new URL("../../packages/core/src/__test-utils__/vitest-setup.ts", import.meta.url),
);
const dashboardSetup = fileURLToPath(
new URL("./src/dashboard/test-setup.ts", import.meta.url),
);
/*
FNXC:ReportsTests 2026-06-25-16:30:
The SQLite-to-PostgreSQL cutover (feature delete-sqlite-runtime-final, PHASE A)
quarantines plugin test files that construct a SQLite-backed store (new TaskStore(...,
{inMemoryDb: true}) / new Database(...)). The SQLite runtime code is being deleted
in this feature. Per the AGENTS.md flaky-test deletion ratchet, these tests are
quarantined on sight. Mirrored in scripts/lib/test-quarantine.json.
*/
const quarantinedReportsTests = [
];
export default defineConfig({
resolve: {
alias: {
/*
FNXC:VitestAliases 2026-07-30-13:10:
Must precede the broader `@fusion/core` alias: Vite string aliases match by PREFIX, so that key
rewrites this subpath to `index.ts/task-delete-attribution` and resolution fails. Reached here
transitively — this project aliases `@fusion/dashboard`, and `app/api/client.ts` imports the
browser-safe delete-attribution leaf.
*/
"@fusion/core/column-roles": fileURLToPath(new URL("../../packages/core/src/column-roles.ts", import.meta.url)),
"@fusion/core/task-delete-attribution": fileURLToPath(new URL("../../packages/core/src/task-delete-attribution.ts", import.meta.url)),
"@fusion/core": fileURLToPath(new URL("../../packages/core/src/index.ts", import.meta.url)),
// FNXC:Clipboard 2026-07-12-00:00: The reports plugin imports the dashboard clipboard helper through its package subpath export; keep this exact alias ahead of the package root alias so vitest does not collapse the subpath to src/index.ts.
"@fusion/dashboard/app/utils/copyToClipboard": fileURLToPath(new URL("../../packages/dashboard/app/utils/copyToClipboard.ts", import.meta.url)),
"@fusion/dashboard": fileURLToPath(new URL("../../packages/dashboard/src/index.ts", import.meta.url)),
"@fusion/plugin-sdk": fileURLToPath(new URL("../../packages/plugin-sdk/src/index.ts", import.meta.url)),
},
},
test: {
// coreSetup runs for all projects via extends: true inheritance
setupFiles: [coreSetup],
globalSetup: [fileURLToPath(new URL("../../packages/core/src/__test-utils__/vitest-teardown.ts", import.meta.url))],
pool: "threads",
maxWorkers,
minWorkers: 1,
/*
FNXC:PluginPgTestTimeout 2026-07-23-22:15:
The shared PG test harness (packages/core/src/__test-utils__/pg-test-harness.ts) pays its
golden-schema-template cold start inside the FIRST pg test of a vitest invocation, which is
budgeted for the 15s testTimeout its home package (@fusion/core) configures. Plugin packages
ran at vitest's 5s default, so the whatsapp-chat persistence.pg.test.ts timed out on loaded
CI runners (full-suite shard 4, 2026-07-24). Align every pg-harness-consuming plugin with
core's budget.
*/
testTimeout: 15_000,
projects: [
{
extends: true,
test: {
name: "reports-dashboard",
environment: "jsdom",
include: ["src/dashboard/**/__tests__/**/*.test.{ts,tsx}", "src/dashboard/**/*.test.{ts,tsx}"],
// coreSetup is inherited from root via extends: true.
// Only add dashboardSetup which is jsdom-specific.
setupFiles: [dashboardSetup],
},
},
{
extends: true,
test: {
name: "reports-node",
environment: "node",
include: ["src/**/__tests__/**/*.test.{ts,tsx}", "src/**/*.test.{ts,tsx}"],
exclude: [
"src/dashboard/**/__tests__/**/*.test.{ts,tsx}",
"src/dashboard/**/*.test.{ts,tsx}",
...quarantinedReportsTests,
],
},
},
],
},
});