Files
fusion/packages/dashboard/app/components/__tests__/ReportActionMenu.test.tsx
gsxdsm 2a2b157cb9 FN-8585: fix dashboard composer test source reads
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>
2026-07-25 06:22:23 -07:00

49 lines
2.5 KiB
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { ReportActionMenu } from "../ReportActionMenu";
import { readAppFile } from "../../test/cssFixture";
describe("ReportActionMenu", () => {
it("defines the portal stacking contract instead of relying on an undefined z-index", () => {
const styles = readAppFile("styles.css");
const menuStyles = readAppFile("components/ReportActionMenu.css");
expect(styles).toMatch(/--z-dropdown:\s*\d+/);
expect(styles).toMatch(/--z-modal:\s*\d+/);
expect(menuStyles).toMatch(/\.report-action-menu__list\s*{[^}]*z-index:\s*var\(--z-dropdown\)/s);
expect(menuStyles).toMatch(/\.report-action-menu__list--portal\s*{[^}]*position:\s*fixed/s);
});
it("uses defined opaque surface tokens for both shared render homes", () => {
const styles = readAppFile("styles.css");
const menuStyles = readAppFile("components/ReportActionMenu.css");
for (const token of ["card", "border", "text", "surface-hover", "space-xs", "space-sm", "space-md", "space-2xl"]) {
expect(styles).toMatch(new RegExp(`--${token}:\\s*[^;]+;`));
}
expect(menuStyles).toMatch(/\.report-action-menu__list\s*{[^}]*background:\s*var\(--card\)/s);
expect(menuStyles).toMatch(/\.report-action-menu__list\s*{[^}]*border:\s*1px solid var\(--border\)/s);
expect(menuStyles).toMatch(/\.report-action-menu__item\s*{[^}]*color:\s*var\(--text\)/s);
expect(menuStyles).toMatch(/\.report-action-menu__item:hover,\s*\.report-action-menu__item:focus-visible\s*{[^}]*background:\s*var\(--surface-hover\)/s);
for (const undefinedToken of ["bg-elevated", "text-primary", "bg-hover", "space-1", "space-2", "space-3", "space-48"]) {
expect(menuStyles).not.toMatch(new RegExp(`var\\(--${undefinedToken}\\)`));
}
});
it("exposes all four guided actions without empty controls", () => {
const onSelect = vi.fn();
render(<ReportActionMenu onSelect={onSelect} />);
fireEvent.click(screen.getByRole("button", { name: "Report" }));
const actions = ["Report bug", "Send feedback", "Share idea", "Get help"];
for (const action of actions) expect(screen.getByRole("menuitem", { name: action })).toBeEnabled();
fireEvent.click(screen.getByRole("menuitem", { name: "Get help" }));
expect(onSelect).toHaveBeenCalledWith("help");
expect(screen.queryByRole("menu")).not.toBeInTheDocument();
});
});