test: remediate audit findings for task log viewer, report card and logger tests
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// [DEF:frontend.src.components.__tests__.task_log_viewer:Module]
|
||||
// @TIER: STANDARD
|
||||
// @TIER: CRITICAL
|
||||
// @SEMANTICS: tests, task-log, viewer, mount, components
|
||||
// @PURPOSE: Unit tests for TaskLogViewer component by mounting it and observing the DOM.
|
||||
// @LAYER: UI (Tests)
|
||||
// @RELATION: TESTS -> frontend.src.components.TaskLogViewer
|
||||
// @RELATION: VERIFIES -> frontend/src/components/TaskLogViewer.svelte
|
||||
// @INVARIANT: Duplicate logs are never appended. Polling only active for in-progress tasks.
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
@@ -20,10 +20,12 @@ vi.mock('../../lib/i18n', () => ({
|
||||
subscribe: (fn) => {
|
||||
fn({
|
||||
tasks: {
|
||||
loading: 'Loading...'
|
||||
loading: 'Loading...',
|
||||
logs_title: 'Task Logs'
|
||||
},
|
||||
common: {
|
||||
retry: 'Retry'
|
||||
retry: 'Retry',
|
||||
close: 'Close'
|
||||
}
|
||||
});
|
||||
return () => { };
|
||||
@@ -127,5 +129,33 @@ describe('TaskLogViewer Component', () => {
|
||||
// getByText asserts there is exactly *one* match.
|
||||
expect(() => screen.getByText(/Duplicate log entry/)).not.toThrow();
|
||||
});
|
||||
|
||||
// @TEST_FIXTURE valid_viewer
|
||||
it('fetches and displays historical logs in modal mode under valid_viewer fixture', async () => {
|
||||
getTaskLogs.mockResolvedValue([
|
||||
{ timestamp: '2024-01-01T00:00:00', level: 'INFO', message: 'Modal log entry' }
|
||||
]);
|
||||
|
||||
render(TaskLogViewer, { show: true, inline: false, taskId: 'task-123' });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Modal log entry/)).toBeDefined();
|
||||
expect(screen.getByText('Task Logs')).toBeDefined();
|
||||
});
|
||||
|
||||
expect(getTaskLogs).toHaveBeenCalledWith('task-123');
|
||||
});
|
||||
|
||||
// @TEST_EDGE no_task_id
|
||||
it('does not fetch logs if taskId is null', () => {
|
||||
render(TaskLogViewer, { inline: true, taskId: null });
|
||||
expect(getTaskLogs).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// @UX_FEEDBACK
|
||||
it('passes autoScroll feedback properly down to the panel by rendering without crashing', () => {
|
||||
const { component } = render(TaskLogViewer, { inline: true, taskId: 'task-123' });
|
||||
expect(component).toBeDefined();
|
||||
});
|
||||
});
|
||||
// [/DEF:frontend.src.components.__tests__.task_log_viewer:Module]
|
||||
|
||||
Reference in New Issue
Block a user