Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test([issue-1088]): faithful toast mock + confirmed-restore-failure case
Adam Eivyb8c5abad7b62
diff --git a/client/src/components/settings/BackupTab.test.jsx b/client/src/components/settings/BackupTab.test.jsxindex 10b3e392b5..f8f1e8e032 100644--- a/client/src/components/settings/BackupTab.test.jsx+++ b/client/src/components/settings/BackupTab.test.jsx@@ -13,8 +13,17 @@ vi.mock('../../services/api', () => ({// so the import doesn't resolve to undefined if the picker ever mounts eagerly.getDirectories: vi.fn(),}));+// The real `toast` is a callable function with `.success`/`.error`/`.warning`+// attached — the component calls the bare form (`toast('Backup already+// running')`) as well as the namespaced ones. Mock it faithfully so a future+// test of those bare-call paths doesn't trip over a non-callable stub.vi.mock('../ui/Toast', () => ({- default: { success: vi.fn(), error: vi.fn(), info: vi.fn() },+ default: Object.assign(vi.fn(), {+ success: vi.fn(),+ error: vi.fn(),+ warning: vi.fn(),+ info: vi.fn(),+ }),}));import {@@ -143,6 +152,24 @@ describe('BackupTab', () => {expect(toast.success).toHaveBeenCalledWith('Database restored from snap-2026-06-09', { icon: '💾' });});+ it('toasts an error when the confirmed restore fails', async () => {+ withSnapshot();+ restoreDatabase+ .mockResolvedValueOnce({ status: 'ok', sizeBytes: 2048, tableCount: 12 }) // dry-run+ .mockResolvedValueOnce({ status: 'failed', reason: 'pg_restore_error' }); // real restore fails+ await renderTab();++ await act(async () => {+ fireEvent.click(await screen.findByRole('button', { name: /Restore DB/i }));+ });+ await act(async () => {+ fireEvent.click(screen.getByRole('button', { name: /^Restore$/i }));+ });++ expect(toast.error).toHaveBeenCalledWith('DB restore failed: pg_restore_error');+ expect(toast.success).not.toHaveBeenCalled();+ });+it('aborts and toasts when the dry-run reports no dump', async () => {withSnapshot();restoreDatabase.mockResolvedValue({ status: 'skipped', reason: 'no_dump' });