tftsr-devops_investigation/tests/unit/history.test.tsx
Shaun Arman 4c4ca40146 fix: UI contrast issues and ARM64 build failure
**UI Fixes (TDD approach - tests first, then implementation):**
- Resolution steps: improved text contrast (text-foreground vs muted)
- DocEditor preview: added text-foreground class for readability
- History page: fixed domain display (category field) with better contrast
- Audit Log: added expandable rows with View/Hide buttons to show transmitted data
- Dashboard & buttons: already had proper contrast with outline variant
- Export document: fixed missing title/content parameters in command signature

**Tests Added (13 new tests, all passing):**
- tests/unit/resolution.test.tsx - resolution steps contrast
- tests/unit/docEditor.test.tsx - preview mode and export buttons
- tests/unit/exportDocument.test.ts - export parameters validation
- tests/unit/history.test.tsx - domain display and filtering
- tests/unit/dashboard.test.tsx - refresh button visibility
- tests/unit/auditLog.test.tsx - data visibility and expandable rows
- tests/unit/setup.ts - added @testing-library/jest-dom matchers

**CI Fix:**
- Removed platform label from ARM64 build step (native agent, old Docker)

**Test Results:**
- Frontend: 38/38 passing 
- Backend: 64/64 passing 
- TypeScript: no errors 

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-03 08:05:58 -05:00

99 lines
2.4 KiB
TypeScript

import { describe, it, expect, beforeEach, vi } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import History from "@/pages/History";
import { useHistoryStore } from "@/stores/historyStore";
import type { IssueSummary } from "@/lib/tauriCommands";
vi.mock("@/stores/historyStore");
const mockIssues: IssueSummary[] = [
{
id: "issue-1",
title: "Test Issue 1",
severity: "P3",
status: "open",
category: "linux",
created_at: "2026-01-01",
updated_at: "2026-01-01",
log_count: 1,
step_count: 2,
},
{
id: "issue-2",
title: "Test Issue 2",
severity: "P1",
status: "resolved",
category: "kubernetes",
created_at: "2026-01-02",
updated_at: "2026-01-02",
log_count: 0,
step_count: 3,
},
];
describe("History Page", () => {
beforeEach(() => {
vi.mocked(useHistoryStore).mockReturnValue({
issues: mockIssues,
isLoading: false,
error: null,
searchQuery: "",
loadIssues: vi.fn(),
searchIssues: vi.fn(),
setSearchQuery: vi.fn(),
});
});
it("displays domain column in table", () => {
render(
<MemoryRouter>
<History />
</MemoryRouter>
);
// Check that Domain header exists
const domainHeader = screen.getByText("Domain");
expect(domainHeader).toBeInTheDocument();
// Check that domain values are displayed
expect(screen.getByText("linux")).toBeInTheDocument();
expect(screen.getByText("kubernetes")).toBeInTheDocument();
});
it("domain filter is functional", () => {
const mockLoadIssues = vi.fn();
vi.mocked(useHistoryStore).mockReturnValue({
issues: mockIssues,
isLoading: false,
error: null,
searchQuery: "",
loadIssues: mockLoadIssues,
searchIssues: vi.fn(),
setSearchQuery: vi.fn(),
});
render(
<MemoryRouter>
<History />
</MemoryRouter>
);
// Find domain filter dropdown button
const domainFilter = screen.getByRole("button", { name: /All Domains/i });
expect(domainFilter).toBeInTheDocument();
});
it("search button is visible and readable", () => {
render(
<MemoryRouter>
<History />
</MemoryRouter>
);
const searchButton = screen.getByRole("button", { name: /search/i });
expect(searchButton).toBeInTheDocument();
expect(searchButton.className).toContain("outline");
});
});