Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
1dfaa59
docs(09): smart discuss context
therealbrad Mar 18, 2026
19f6355
fix(09): revise plans based on checker feedback
therealbrad Mar 18, 2026
687ff43
fix(09): revise plans based on checker feedback - add SAML test, docu…
therealbrad Mar 18, 2026
6423631
docs(09): create phase 9 plans — auth E2E and API tests
therealbrad Mar 18, 2026
51ce32f
feat(09-04): add API token authentication E2E tests
therealbrad Mar 19, 2026
c8c7718
docs(09-04): complete API token authentication E2E test plan
therealbrad Mar 19, 2026
68fda5e
feat(09-01): add sign-in and sign-out E2E tests
therealbrad Mar 19, 2026
c146177
feat(09-01): add sign-up and email verification E2E tests
therealbrad Mar 19, 2026
21b0049
docs(09-01): complete sign-in/sign-out and email verification E2E tes…
therealbrad Mar 19, 2026
e5bc6fc
test(09-03): add signin and signup page component tests
therealbrad Mar 19, 2026
1cdb0f7
test(09-03): add 2FA setup and verify page component tests
therealbrad Mar 19, 2026
521b6e1
docs(09-03): complete auth page component tests plan
therealbrad Mar 19, 2026
b1e9240
feat(09-02): add 2FA E2E tests for voluntary setup, TOTP login, backu…
therealbrad Mar 19, 2026
3cc317e
feat(09-02): add SSO OAuth/SAML, magic link, and password change E2E …
therealbrad Mar 19, 2026
2fe9e0c
docs(09-02): complete advanced auth E2E tests plan
therealbrad Mar 19, 2026
0c21afd
docs(phase-09): complete phase execution
therealbrad Mar 19, 2026
ac091db
docs(10): smart discuss context — gap-fill approach for repository E2E
therealbrad Mar 19, 2026
8b5141f
docs(10-test-case-repository-e2e-tests): create phase plan
therealbrad Mar 19, 2026
3acc632
feat(10-02): add shared steps management E2E tests
therealbrad Mar 19, 2026
6f367c6
docs(10-02): complete shared steps management E2E tests plan
therealbrad Mar 19, 2026
927b0bb
feat(10-01): add edit and delete test case E2E tests
therealbrad Mar 19, 2026
b5834bd
feat(10-01): add move test case to folder E2E test
therealbrad Mar 19, 2026
b4f8233
docs(10-01): complete test case edit/delete and folder move E2E tests…
therealbrad Mar 19, 2026
5b7f3a3
docs(phase-10): complete phase execution
therealbrad Mar 19, 2026
59bc368
docs(11): smart discuss context — repository component and hook tests
therealbrad Mar 19, 2026
34083c3
docs(11): create phase plan for repository components and hooks tests
therealbrad Mar 19, 2026
92c44a3
test(11-01): add StepsForm and FieldValueRenderer component tests
therealbrad Mar 19, 2026
4c025c2
test(11-02): add Cases table component tests
therealbrad Mar 19, 2026
b79203d
test(11-02): add useRepositoryCasesWithLastResult hook tests
therealbrad Mar 19, 2026
1e8be4d
test(11-01): add BreadcrumbComponent and TreeView component tests
therealbrad Mar 19, 2026
2d14588
docs(11-02): complete repository cases and hook tests plan
therealbrad Mar 19, 2026
0cc6144
docs(11-01): complete repository sub-component tests plan
therealbrad Mar 19, 2026
88420fb
docs(phase-11): complete phase execution
therealbrad Mar 19, 2026
ef2c153
docs(12): smart discuss context — test execution E2E tests
therealbrad Mar 19, 2026
9ba61ed
docs(12-test-execution-e2e-tests): create phase plan
therealbrad Mar 19, 2026
8ecbab3
feat(12-02): add bulk status, completion, and multi-config E2E tests
therealbrad Mar 19, 2026
c22061a
feat(12-02): add JUnit XML import E2E tests (RUN-06)
therealbrad Mar 19, 2026
5343f05
docs(12-02): complete bulk ops, completion, JUnit import E2E plan
therealbrad Mar 19, 2026
bf290d1
feat(12-01): add test run creation wizard E2E tests
therealbrad Mar 19, 2026
8e9b710
feat(12-01): add test case execution E2E tests and fix wizard folder …
therealbrad Mar 19, 2026
693cdaf
docs(12-01): complete test execution E2E plan
therealbrad Mar 19, 2026
e8344db
docs(phase-12): complete phase execution
therealbrad Mar 19, 2026
a286d09
docs(13): smart discuss context — run components + sessions
therealbrad Mar 19, 2026
1ff3416
docs(13): create phase plan
therealbrad Mar 19, 2026
46e6564
feat(13-02): add session lifecycle E2E spec
therealbrad Mar 19, 2026
9c32a16
test(13-01): add Vitest tests for TestRunCaseDetails and TestResultHi…
therealbrad Mar 19, 2026
6b05e94
test(13-01): add Vitest tests for MagicSelectButton and MagicSelectDi…
therealbrad Mar 19, 2026
0abc13f
docs(13-02): complete session lifecycle E2E plan
therealbrad Mar 19, 2026
87c90fa
docs(13-01): complete run components unit test plan
therealbrad Mar 19, 2026
084463c
test(13-03): add SessionResultForm and SessionResultsList component t…
therealbrad Mar 19, 2026
91b0001
test(13-03): add session hooks integration tests and verify existing …
therealbrad Mar 19, 2026
375b643
docs(13-03): complete session component and hook tests plan
therealbrad Mar 19, 2026
8c77a11
docs(phase-13): complete phase execution
therealbrad Mar 19, 2026
2364661
docs(14): smart discuss context — project management tests
therealbrad Mar 19, 2026
b63844a
docs(14): create phase plan for project management E2E and components
therealbrad Mar 19, 2026
226b2be
feat(14-02): add milestone CRUD E2E tests (PROJ-03)
therealbrad Mar 19, 2026
1ac45e2
feat(14-02): add project documentation editor E2E tests (PROJ-04)
therealbrad Mar 19, 2026
42360cb
feat(14-01): add project creation wizard and overview dashboard E2E t…
therealbrad Mar 19, 2026
0543c4e
test(14-03): add ProjectCard, ProjectMenu, and ProjectQuickSelector c…
therealbrad Mar 19, 2026
7f2f5d5
docs(14-02): complete milestone CRUD and documentation E2E plan
therealbrad Mar 19, 2026
b33c4da
feat(14-01): add project settings and member management E2E tests
therealbrad Mar 19, 2026
f8b1b3c
test(14-03): add MilestoneItemCard tests and extend useProjectPermiss…
therealbrad Mar 19, 2026
13b3f5b
docs(14-01): complete project management E2E tests plan
therealbrad Mar 19, 2026
f12e690
docs(14-03): complete project component tests plan
therealbrad Mar 19, 2026
017e52b
docs(phase-14): complete phase execution
therealbrad Mar 19, 2026
5ab53f9
docs(15): smart discuss context — AI feature E2E and API tests
therealbrad Mar 19, 2026
2a46e00
docs(15): create phase plan
therealbrad Mar 19, 2026
5cff9d8
feat(15-02): add API tests for LLM and auto-tag endpoints
therealbrad Mar 19, 2026
de4a21f
docs(15-02): complete LLM and auto-tag API tests plan
therealbrad Mar 19, 2026
fa927eb
feat(15-01): add AI test case generation and auto-tag E2E tests
therealbrad Mar 19, 2026
6e65342
feat(15-01): add magic select, QuickScript, and writing assistant E2E…
therealbrad Mar 19, 2026
40d7d36
docs(15-01): complete AI feature E2E tests plan
therealbrad Mar 19, 2026
d7dc328
docs(phase-15): complete phase execution
therealbrad Mar 19, 2026
147a7da
docs(16): smart discuss context — AI component tests
therealbrad Mar 19, 2026
cd96337
docs(16-ai-component-tests): create phase plan
therealbrad Mar 19, 2026
e645e98
test(16-02): add ExportPreviewPane component tests
therealbrad Mar 19, 2026
ac497c3
test(16-02): add QuickScriptModal component tests
therealbrad Mar 19, 2026
5dd7efd
docs(16-02): complete QuickScript dialog component tests plan
therealbrad Mar 19, 2026
ed62c83
test(16-01): add AutoTagProgress and TagChip component tests
therealbrad Mar 19, 2026
73e1847
test(16-01): add AutoTagWizardDialog and AutoTagReviewDialog componen…
therealbrad Mar 19, 2026
18a0424
docs(16-01): complete AutoTag component tests plan
therealbrad Mar 19, 2026
ae03eeb
docs(phase-16): complete phase execution
therealbrad Mar 19, 2026
e7bc9e6
docs(17): smart discuss context — administration E2E tests
therealbrad Mar 19, 2026
e9c49bc
docs(17): create phase plan for administration E2E tests
therealbrad Mar 19, 2026
821049d
feat(17-01): Add user management gap and group management E2E tests
therealbrad Mar 19, 2026
ebbdab6
feat(17-01): Add role management E2E tests
therealbrad Mar 19, 2026
c489f19
docs(17-01): complete administration E2E tests plan
therealbrad Mar 19, 2026
55e010b
feat(17-04): add Elasticsearch admin and LLM integration management E…
therealbrad Mar 19, 2026
2b589a5
feat(17-04): add app config management E2E tests
therealbrad Mar 19, 2026
c72d27a
docs(17-04): complete Elasticsearch, LLM, and app config admin E2E te…
therealbrad Mar 19, 2026
b35f197
test(17-02): add SSO provider and workflow management E2E tests
therealbrad Mar 19, 2026
a052008
test(17-02): add status management E2E tests
therealbrad Mar 19, 2026
2d4c2e8
feat(17-03): add configuration management E2E tests
therealbrad Mar 19, 2026
510e1ab
feat(17-03): add audit log management E2E tests
therealbrad Mar 19, 2026
8b0af9b
docs(17-03): complete configuration and audit log E2E tests plan
therealbrad Mar 19, 2026
4f856be
docs(phase-17): complete phase execution
therealbrad Mar 19, 2026
1436923
docs(18): smart discuss context — admin component tests
therealbrad Mar 19, 2026
762aeaa
docs(18): create phase plan
therealbrad Mar 19, 2026
7346554
test(18-01): add QueueManagement and ElasticsearchAdmin component tests
therealbrad Mar 19, 2026
13b660f
test(18-01): add AuditLogDetailModal component tests
therealbrad Mar 19, 2026
6f0152e
docs(18-01): complete administration component tests plan
therealbrad Mar 19, 2026
47e1121
test(18-02): add EditUserModal and EditGroupModal component tests
therealbrad Mar 19, 2026
5abae40
test(18-02): add EditRoleModal permissions matrix component tests
therealbrad Mar 19, 2026
80b8026
docs(18-02): complete EditUser, EditGroup, and EditRoles component te…
therealbrad Mar 19, 2026
dd350f6
docs(phase-18): complete phase execution
therealbrad Mar 19, 2026
fa4e7b2
docs(19): smart discuss context — reporting E2E and component tests
therealbrad Mar 19, 2026
ace3890
docs(19): create phase plan for reporting E2E and component tests
therealbrad Mar 19, 2026
f7b5436
test(19-02): add component tests for ReportRenderer, DrillDownDrawer,…
therealbrad Mar 19, 2026
96a91df
test(19-02): add component tests for ShareDialog, PasswordGate, and S…
therealbrad Mar 19, 2026
652a228
feat(19-03): add component tests for ReportChart dispatcher, ReportBa…
therealbrad Mar 19, 2026
bbd0de1
docs(19-02): complete report and share component tests plan
therealbrad Mar 19, 2026
9c485fa
test(19-01): add report builder multi-type E2E tests (RPT-01, RPT-02)
therealbrad Mar 19, 2026
ccf3f7c
test(19-01): add drill-down and forecasting E2E tests (RPT-03, RPT-05)
therealbrad Mar 19, 2026
0c6789f
docs(19-01): complete reporting E2E tests plan summary and state update
therealbrad Mar 19, 2026
0834d3d
feat(19-03): add component tests for ReportSunburstChart, FlakyTestsB…
therealbrad Mar 19, 2026
8264a7c
docs(19-03): complete data visualization chart component tests plan
therealbrad Mar 19, 2026
7f71cc2
docs(phase-19): complete phase execution
therealbrad Mar 19, 2026
bd13653
docs(20): smart discuss context — search E2E and component tests
therealbrad Mar 19, 2026
64e7492
docs(20): create phase plan for search E2E and component tests
therealbrad Mar 19, 2026
7df67a8
test(20-02): add GlobalSearchSheet component tests
therealbrad Mar 19, 2026
21c0820
test(20-02): add FacetedSearchFilters component tests
therealbrad Mar 19, 2026
02ed807
docs(20-02): complete search component tests plan
therealbrad Mar 19, 2026
584afa3
feat(20-01): add global search E2E tests (Cmd+K, results, navigation,…
therealbrad Mar 19, 2026
4e7a700
feat(20-01): add faceted search filter E2E tests; fix parallel unique…
therealbrad Mar 19, 2026
587ed9e
docs(20-01): complete global search and faceted filter E2E tests plan
therealbrad Mar 19, 2026
42b07a3
docs(phase-20): complete phase execution
therealbrad Mar 19, 2026
25d6c8f
docs(21): smart discuss context — integrations tests
therealbrad Mar 19, 2026
5169de7
docs(21): create phase plan
therealbrad Mar 19, 2026
449047a
test(21-03): API route unit tests for create-issue and search endpoints
therealbrad Mar 19, 2026
ca1a751
test(21-03): API route unit tests for test-connection and sync endpoints
therealbrad Mar 19, 2026
3ea93f4
docs(21-03): complete integration API route tests plan
therealbrad Mar 19, 2026
4b8fec7
feat(21-01): add E2E tests for integration setup and project linking
therealbrad Mar 19, 2026
95d279c
feat(21-01): add E2E tests for issue operations and fix link/unlink r…
therealbrad Mar 19, 2026
bb770d9
test(21-02): issue management component tests
therealbrad Mar 19, 2026
45d7f51
test(21-02): integration config form component tests
therealbrad Mar 19, 2026
d2632c6
docs(21-01): complete integration setup and issue operations E2E test…
therealbrad Mar 19, 2026
eeefaf1
docs(21-02): complete integration component tests plan
therealbrad Mar 19, 2026
842fbab
docs(phase-21): complete phase execution
therealbrad Mar 19, 2026
41fc677
docs(22): smart discuss context — custom API route tests
therealbrad Mar 19, 2026
ba375ca
docs(22): create phase plan for custom API route tests
therealbrad Mar 19, 2026
ae0342d
feat(22-02): add milestone endpoint route tests (CAPI-04)
therealbrad Mar 19, 2026
aabc96c
test(22-03): add main report builder and drill-down route tests
therealbrad Mar 19, 2026
272a26d
test(22-04): add admin endpoint route tests (CAPI-07)
therealbrad Mar 19, 2026
2c354a2
feat(22-05): add file upload and download endpoint route tests (CAPI-09)
therealbrad Mar 19, 2026
23aa4e8
test(22-03): add pre-built report endpoint route tests
therealbrad Mar 19, 2026
debca3e
feat(22-02): add share link endpoint route tests (CAPI-05)
therealbrad Mar 19, 2026
4c0b6aa
test(22-01): add project endpoint and session summary route tests
therealbrad Mar 19, 2026
698d97f
test(22-04): add search and aggregation endpoint route tests (CAPI-08)
therealbrad Mar 19, 2026
e9ec2d4
docs(22-02): complete milestone and share link route tests plan
therealbrad Mar 19, 2026
dfbfa0c
docs(22-03): complete report builder route tests plan
therealbrad Mar 19, 2026
4a6edb4
feat(22-05): add health, metadata, and docs endpoint route tests (CAP…
therealbrad Mar 19, 2026
baf4d95
docs(22-04): complete admin and search route tests plan
therealbrad Mar 19, 2026
1b7f013
docs(22-05): complete upload/download and infrastructure endpoint rou…
therealbrad Mar 19, 2026
3ca9667
test(22-01): add test run endpoint route tests
therealbrad Mar 19, 2026
f371c3f
docs(22-01): complete custom API route tests plan
therealbrad Mar 19, 2026
4fe2eca
docs(phase-22): complete phase execution
therealbrad Mar 19, 2026
f05892b
docs(23): smart discuss context — general component tests
therealbrad Mar 19, 2026
385041a
docs(23-general-components): create phase plan
therealbrad Mar 19, 2026
66fed26
feat(23-03): add ImageWithResize extension tests
therealbrad Mar 19, 2026
fd9337b
test(23-02): add comment system component tests
therealbrad Mar 19, 2026
768fff4
feat(23-03): add DnD preview and DraggableCaseFields tests
therealbrad Mar 19, 2026
4e566d7
docs(23-03): complete TipTap and DnD component tests plan
therealbrad Mar 19, 2026
b21a2f0
test(23-02): add attachment and onboarding component tests
therealbrad Mar 19, 2026
e27a24b
docs(23-02): complete comment, attachment, and onboarding tests plan
therealbrad Mar 19, 2026
328936e
test(23-01): add Header and DataTable component tests
therealbrad Mar 19, 2026
3361d19
test(23-01): add form select component tests (ConfigurationSelect, Fo…
therealbrad Mar 19, 2026
9b9f88d
docs(23-01): complete Header, DataTable, and form select component te…
therealbrad Mar 19, 2026
ba736e5
docs(phase-23): complete phase execution
therealbrad Mar 19, 2026
09f4760
docs(24): smart discuss context — hooks, notifications, workers
therealbrad Mar 19, 2026
7766259
docs(24): create phase plan for hooks, notifications, and workers
therealbrad Mar 19, 2026
d116479
test(24-02): add ZenStack hook shape verification tests
therealbrad Mar 19, 2026
b94e36d
test(24-02): add useAutoTagJob integration hook lifecycle tests
therealbrad Mar 19, 2026
16d67a0
test(24-04): add emailWorker unit tests
therealbrad Mar 19, 2026
28728c8
test(24-03): gap-fill NotificationContent component tests
therealbrad Mar 19, 2026
7c3f1c6
test(24-03): extend NotificationService dispatch API tests
therealbrad Mar 19, 2026
0f7f74b
docs(24-02): complete hooks-notifications-and-workers plan 02
therealbrad Mar 19, 2026
0fa2779
docs(24-03): complete notification test gap-fill plan
therealbrad Mar 19, 2026
2b4c133
test(24-04): add repoCacheWorker and autoTagWorker unit tests
therealbrad Mar 19, 2026
5475dea
docs(24-04): complete worker unit tests plan
therealbrad Mar 19, 2026
72867e4
test(24-01): add tests for UI state and utility hooks
therealbrad Mar 19, 2026
96b274c
test(24-01): add tests for auth and interaction hooks
therealbrad Mar 19, 2026
baa3318
docs(24-01): complete hook unit tests plan
therealbrad Mar 19, 2026
fa571ed
docs(phase-24): complete final phase execution
therealbrad Mar 19, 2026
480cdcd
docs: v2.0 milestone audit — tech_debt (no blockers)
therealbrad Mar 19, 2026
4f62729
docs: mark all 89 requirements as complete in REQUIREMENTS.md
therealbrad Mar 19, 2026
6c84c1f
tests: add LLM integration functionality to ApiHelper and related tests
therealbrad Mar 19, 2026
0b4eaf5
chore: remove outdated planning documents
therealbrad Mar 19, 2026
a75658b
Modify gitgnore
therealbrad Mar 19, 2026
4f2fe1b
enhancement(emailWorker): export processor and startWorker functions
therealbrad Mar 19, 2026
36557da
chore: update ESLint configuration and improve test file implementations
therealbrad Mar 20, 2026
afee0dc
test: enhance test coverage and improve stability in various components
therealbrad Mar 20, 2026
db4801f
test: add mock for useFindUniqueProjects in QuickScriptModal tests
therealbrad Mar 20, 2026
04b56a1
fix: update milestone completion handling and improve test stability
therealbrad Mar 20, 2026
ce02a7b
refactor: improve pagination and search filter tests for stability an…
therealbrad Mar 20, 2026
465d539
refactor: enhance milestone CRUD and project creation wizard tests fo…
therealbrad Mar 20, 2026
53391ab
refactor: update folder selection logic in AI tests for clarity and r…
therealbrad Mar 20, 2026
2f9bb03
refactor: improve folder edit test for better reliability and clarity
therealbrad Mar 20, 2026
cda9603
update tests to be more resilient
therealbrad Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ testplanit/backups/*
*cases/*
**/.planning/*
demo/
.planning/**
.planning/**
204 changes: 204 additions & 0 deletions testplanit/app/[locale]/admin/audit-logs/AuditLogDetailModal.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, test, vi } from "vitest";

import type { ExtendedAuditLog } from "./columns";
import { AuditLogDetailModal } from "./AuditLogDetailModal";

// Mock next-intl
vi.mock("next-intl", () => ({
useTranslations: (namespace?: string) => (key: string) =>
namespace ? `${namespace}.${key}` : key,
}));

// Mock next-auth/react
vi.mock("next-auth/react", () => ({
useSession: () => ({
data: {
user: {
preferences: {
timezone: "Etc/UTC",
dateFormat: "MM-dd-yyyy",
},
},
},
}),
}));

// Mock DateFormatter to avoid date formatting complexity
vi.mock("@/components/DateFormatter", () => ({
DateFormatter: ({ date }: { date: Date | string }) => (
<span data-testid="date-formatter">{String(date)}</span>
),
}));

const baseLog: ExtendedAuditLog = {
id: "log-001",
action: "CREATE" as any,
entityType: "TestCase",
entityId: "abc-123",
entityName: "My Test",
userId: "user-001",
userName: "Admin User",
userEmail: "admin@test.com",
timestamp: new Date("2024-01-15T10:00:00Z"),
changes: null,
metadata: null,
projectId: null,
project: null,
};

describe("AuditLogDetailModal", () => {
test("renders nothing when log is null", () => {
const { container } = render(
<AuditLogDetailModal log={null} open={true} onClose={vi.fn()} />
);
expect(container.firstChild).toBeNull();
});

test("renders basic info for a log entry", () => {
render(
<AuditLogDetailModal log={baseLog} open={true} onClose={vi.fn()} />
);

// Entity type
expect(screen.getByText("TestCase")).toBeInTheDocument();

// Entity ID
expect(screen.getByText("abc-123")).toBeInTheDocument();

// Entity name
expect(screen.getByText("My Test")).toBeInTheDocument();

// User name
expect(screen.getByText("Admin User")).toBeInTheDocument();

// User email
expect(screen.getByText("admin@test.com")).toBeInTheDocument();
});

test("renders action badge with CREATE text", () => {
render(
<AuditLogDetailModal log={baseLog} open={true} onClose={vi.fn()} />
);

// The action badge shows action.replace(/_/g, " ") = "CREATE"
expect(screen.getByText("CREATE")).toBeInTheDocument();
});

test("renders changes section with old and new values", () => {
const logWithChanges: ExtendedAuditLog = {
...baseLog,
changes: {
name: { old: "Old Name", new: "New Name" },
} as any,
};

render(
<AuditLogDetailModal log={logWithChanges} open={true} onClose={vi.fn()} />
);

// Changes section header
expect(screen.getByText("admin.auditLogs.changes")).toBeInTheDocument();

// Field name
expect(screen.getByText("name")).toBeInTheDocument();

// Old and new value labels
expect(screen.getByText(/admin\.auditLogs\.oldValue/)).toBeInTheDocument();
expect(screen.getByText(/admin\.auditLogs\.newValue/)).toBeInTheDocument();

// Old and new values rendered in pre elements
expect(screen.getByText("Old Name")).toBeInTheDocument();
expect(screen.getByText("New Name")).toBeInTheDocument();
});

test("renders metadata section as JSON", () => {
const logWithMetadata: ExtendedAuditLog = {
...baseLog,
metadata: {
ipAddress: "1.2.3.4",
userAgent: "Mozilla/5.0",
} as any,
};

render(
<AuditLogDetailModal log={logWithMetadata} open={true} onClose={vi.fn()} />
);

// Metadata section header
expect(screen.getByText("admin.auditLogs.metadata")).toBeInTheDocument();

// Metadata content rendered in pre block
expect(screen.getByText(/1\.2\.3\.4/)).toBeInTheDocument();
expect(screen.getByText(/Mozilla\/5\.0/)).toBeInTheDocument();
});

test("hides changes section when changes is null", () => {
const logNullChanges: ExtendedAuditLog = {
...baseLog,
changes: null,
};

render(
<AuditLogDetailModal log={logNullChanges} open={true} onClose={vi.fn()} />
);

// Changes section should NOT be present
expect(screen.queryByText("admin.auditLogs.changes")).not.toBeInTheDocument();
});

test("hides changes section when changes is empty object", () => {
const logEmptyChanges: ExtendedAuditLog = {
...baseLog,
changes: {} as any,
};

render(
<AuditLogDetailModal log={logEmptyChanges} open={true} onClose={vi.fn()} />
);

// Changes section should NOT be present (Object.keys(changes).length === 0)
expect(screen.queryByText("admin.auditLogs.changes")).not.toBeInTheDocument();
});

test("renders project name when project is present", () => {
const logWithProject: ExtendedAuditLog = {
...baseLog,
projectId: 1,
project: { name: "My Project" },
};

render(
<AuditLogDetailModal log={logWithProject} open={true} onClose={vi.fn()} />
);

expect(screen.getByText("My Project")).toBeInTheDocument();
});

test("calls onClose when dialog close is triggered", async () => {
const user = userEvent.setup();
const onClose = vi.fn();

render(
<AuditLogDetailModal log={baseLog} open={true} onClose={onClose} />
);

// Radix Dialog close button (aria-label="Close")
const closeButton = screen.getByRole("button", { name: /close/i });
await user.click(closeButton);

await waitFor(() => {
expect(onClose).toHaveBeenCalled();
});
});

test("renders date formatter for the log timestamp", () => {
render(
<AuditLogDetailModal log={baseLog} open={true} onClose={vi.fn()} />
);

// DateFormatter should be rendered (mocked to show the date string)
expect(screen.getByTestId("date-formatter")).toBeInTheDocument();
});
});
Loading
Loading