Add favorites feature with toggle filters, group management, color/icon pickers, dashboard widget, and star buttons across containers/docker sections with persistent storage and real-time UI updates
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
This commit is contained in:
@@ -638,3 +638,52 @@ describe('DashboardCore - Constructor', () => {
|
||||
expect(core.apiBase).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
// TESTS: Dashboard UI helpers (main.js) - Ad-Hoc widget regression
|
||||
// ============================================================================
|
||||
|
||||
describe('main.js - Ad-Hoc widget regression', () => {
|
||||
it('computes counters from task log status and shows load more when more items exist locally', async () => {
|
||||
// Minimal DOM for widget
|
||||
document.body.innerHTML = `
|
||||
<div id="adhoc-widget-history"></div>
|
||||
<button id="adhoc-widget-load-more" class="hidden"></button>
|
||||
<div id="adhoc-widget-success"></div>
|
||||
<div id="adhoc-widget-failed"></div>
|
||||
<div id="adhoc-widget-total"></div>
|
||||
<div id="adhoc-widget-count"></div>
|
||||
`;
|
||||
|
||||
// Import side-effects are heavy; instead, instantiate the real DashboardManager by requiring main.js.
|
||||
// main.js defines DashboardManager on the global scope.
|
||||
await import('../../app/main.js');
|
||||
|
||||
// Create instance and stub required methods used by widget
|
||||
const dash = new window.DashboardManager();
|
||||
dash.escapeHtml = (s) => String(s ?? '');
|
||||
dash.formatTimeAgo = () => 'À l\'instant';
|
||||
dash.viewTaskLogContent = vi.fn();
|
||||
dash.showAdHocConsole = vi.fn();
|
||||
|
||||
// Emulate loaded adhoc task logs
|
||||
dash.adhocWidgetLimit = 2;
|
||||
dash.adhocWidgetOffset = 0;
|
||||
dash.adhocWidgetLogs = [
|
||||
{ id: 'l1', status: 'completed', task_name: 'Ad-hoc: docker version', target: 'h1', created_at: new Date().toISOString(), duration_seconds: 1.2 },
|
||||
{ id: 'l2', status: 'failed', task_name: 'Ad-hoc: docker ps', target: 'h2', created_at: new Date().toISOString(), duration_seconds: 2.3 },
|
||||
{ id: 'l3', status: 'completed', task_name: 'Ad-hoc: cat /etc/os-release', target: 'h3', created_at: new Date().toISOString(), duration_seconds: 0.8 },
|
||||
];
|
||||
dash.adhocWidgetTotalCount = 3;
|
||||
dash.adhocWidgetHasMore = false;
|
||||
|
||||
dash.renderAdhocWidget();
|
||||
|
||||
expect(document.getElementById('adhoc-widget-success').textContent).toBe('2');
|
||||
expect(document.getElementById('adhoc-widget-failed').textContent).toBe('1');
|
||||
expect(document.getElementById('adhoc-widget-total').textContent).toBe('3');
|
||||
expect(document.getElementById('adhoc-widget-count').textContent).toContain('3');
|
||||
// Since only 2 are displayed but 3 are loaded, load-more must be visible.
|
||||
expect(document.getElementById('adhoc-widget-load-more').classList.contains('hidden')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user