tftsr-devops_investigation/tests/unit/resolution.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

72 lines
2.1 KiB
TypeScript

import { describe, it, expect, beforeEach, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { MemoryRouter, Route, Routes } from "react-router-dom";
import Resolution from "@/pages/Resolution";
import * as tauriCommands from "@/lib/tauriCommands";
vi.mock("@/lib/tauriCommands");
const mockIssueDetail = {
issue: {
id: "test-id",
title: "Test Issue",
description: "Test Description",
severity: "P3",
status: "open",
category: "linux",
source: "manual",
created_at: "2026-01-01",
updated_at: "2026-01-01",
assigned_to: "",
tags: "[]",
},
log_files: [],
resolution_steps: [
{
id: "step-1",
issue_id: "test-id",
step_order: 1,
why_question: "Why did the service crash?",
answer: "Out of memory",
evidence: "dmesg shows OOM killer",
created_at: "2026-01-01",
},
],
conversations: [],
};
describe("Resolution Page", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(tauriCommands.getIssueCmd).mockResolvedValue(mockIssueDetail);
});
it("renders resolution steps with readable text", async () => {
render(
<MemoryRouter initialEntries={["/issue/test-id/resolution"]}>
<Routes>
<Route path="/issue/:id/resolution" element={<Resolution />} />
</Routes>
</MemoryRouter>
);
const question = await screen.findByText("Why did the service crash?");
const answer = await screen.findByText("Out of memory");
const evidence = await screen.findByText("dmesg shows OOM killer");
// Check that text has proper contrast classes
expect(question).toBeInTheDocument();
expect(answer).toBeInTheDocument();
expect(evidence).toBeInTheDocument();
// Check for readable color classes (not muted-foreground which is too dark)
const questionParent = question.closest("p");
const answerParent = answer.closest("p");
const evidenceParent = evidence.closest("p");
expect(questionParent?.className).toContain("text-foreground");
expect(answerParent?.className).toMatch(/text-foreground/);
expect(evidenceParent?.className).toMatch(/text-foreground/);
});
});