Stabilize dashboard composer tests when Vitest launches from the workspace root. - Resolve dashboard test source fixtures relative to the app directory. - Migrate affected component tests away from cwd-relative CSS reads. - Enforce the fixture convention in test hooks and document it. Files changed: docs/testing.md | 4 +++ package.json | 6 ++-- .../__tests__/AuthTokenRecoveryDialog.test.tsx | 3 +- .../components/__tests__/ChatView.mobile.test.tsx | 5 +-- .../__tests__/EngineControlMenu.test.tsx | 11 ++---- .../components/__tests__/FloatingWindow.test.tsx | 5 +-- .../app/components/__tests__/ListView.test.tsx | 5 +-- .../__tests__/MissionInterviewModal.test.tsx | 3 +- .../app/components/__tests__/MobileNavBar.test.tsx | 3 +- .../app/components/__tests__/NewTaskModal.test.tsx | 3 +- .../__tests__/PlanningModeModal.initial.test.tsx | 3 +- .../PlanningModeModal.ui-interactions.test.tsx | 7 ++-- .../components/__tests__/PrCreateModal.test.tsx | 3 +- .../__tests__/QuickChat.persist.test.tsx | 3 +- .../components/__tests__/QuickEntryBox.test.tsx | 3 +- .../components/__tests__/ReportActionMenu.test.tsx | 9 ++--- .../app/components/__tests__/ReportModal.test.tsx | 3 +- .../__tests__/ShadcnColorPicker.test.tsx | 3 +- .../components/__tests__/TerminalModal.test.tsx | 3 +- .../components/__tests__/ThemeDropdown.test.tsx | 9 ++--- .../__tests__/WorkflowNodeEditor.test.tsx | 5 +-- .../WorkflowOptionalStepsDropdown.test.tsx | 3 +- .../components/__tests__/WorkflowSwitcher.test.tsx | 5 +-- .../app/components/__tests__/board-mobile.test.tsx | 4 +-- .../__tests__/CommandCenterControls.test.tsx | 6 ++-- .../__tests__/SystemControlsArea.test.tsx | 5 +-- .../__tests__/SystemStatsArea.test.tsx | 3 +- .../command-center/areas/__tests__/areas.test.tsx | 3 +- .../__tests__/KeyboardShortcutsSection.test.tsx | 3 +- .../app/test/__tests__/cssFixture.test.ts | 35 +++++++++++++++++++ packages/dashboard/app/test/cssFixture.ts | 12 +++++++ .../check-no-cwd-relative-dashboard-test-reads.mjs | 39 ++++++++++++++++++++++ 32 files changed, 162 insertions(+), 55 deletions(-) Fusion-Task-Id: FN-8585 Fusion-Task-Lineage: 83a35fb6-a29d-4e97-b282-1054c68b8cc9 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { isAbsolute, resolve } from "node:path";
|
|
import { tmpdir } from "node:os";
|
|
import { loadComponentCss, readAppFile } from "../cssFixture";
|
|
|
|
const repoRoot = resolve(__dirname, "../../../../../");
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
describe("cssFixture source readers", () => {
|
|
it.each([repoRoot, tmpdir()])("resolves app files when cwd is %s", (cwd) => {
|
|
// Vitest worker threads cannot call chdir, so emulate the changed process
|
|
// cwd at the public process boundary while exercising the resolver.
|
|
vi.spyOn(process, "cwd").mockReturnValue(cwd);
|
|
|
|
expect(readAppFile("styles.css")).toContain("--space-");
|
|
expect(loadComponentCss("QuickEntryBox.css")).toContain(".quick-entry-box");
|
|
expect(readAppFile("components/command-center/areas/SystemStatsArea.css")).toContain(".cc-");
|
|
expect(readAppFile("components/PlanningModeModal.tsx")).toContain("PlanningModeModal");
|
|
});
|
|
|
|
it("surfaces missing files as absolute-path ENOENT errors", () => {
|
|
try {
|
|
readAppFile("components/not-a-dashboard-source-file.css");
|
|
throw new Error("Expected readAppFile to throw");
|
|
} catch (error) {
|
|
const fileError = error as NodeJS.ErrnoException;
|
|
expect(fileError.code).toBe("ENOENT");
|
|
expect(fileError.path).toBeDefined();
|
|
expect(isAbsolute(fileError.path!)).toBe(true);
|
|
}
|
|
});
|
|
});
|