fix(ui): suppress extension loading toast when all extensions succeed (#11016)

Signed-off-by: Abhijay Jain <Abhijay007j@gmail.com>
This commit is contained in:
Abhijay Jain
2026-08-12 13:50:59 +05:30
committed by GitHub
parent e20cb87875
commit 6aa3ca6b3d
2 changed files with 54 additions and 0 deletions
@@ -0,0 +1,49 @@
import { describe, expect, it, vi, beforeEach } from 'vitest';
import { showExtensionLoadResults } from './extensionErrorUtils';
vi.mock('../toasts', () => ({
toastService: {
error: vi.fn(),
extensionLoading: vi.fn(),
dismiss: vi.fn(),
},
}));
import { toastService } from '../toasts';
describe('showExtensionLoadResults', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('shows nothing when results are empty', () => {
showExtensionLoadResults([]);
expect(toastService.error).not.toHaveBeenCalled();
expect(toastService.extensionLoading).not.toHaveBeenCalled();
});
it('dismisses stale toast when all extensions succeed', () => {
showExtensionLoadResults([
{ name: 'ext-a', success: true },
{ name: 'ext-b', success: true },
]);
expect(toastService.dismiss).toHaveBeenCalledWith('extension-loading');
expect(toastService.error).not.toHaveBeenCalled();
expect(toastService.extensionLoading).not.toHaveBeenCalled();
});
it('shows individual error toast for a single failed extension', () => {
showExtensionLoadResults([{ name: 'ext-a', success: false, error: 'connection refused' }]);
expect(toastService.error).toHaveBeenCalledOnce();
expect(toastService.extensionLoading).not.toHaveBeenCalled();
});
it('shows grouped toast when multiple extensions load and at least one fails', () => {
showExtensionLoadResults([
{ name: 'ext-a', success: true },
{ name: 'ext-b', success: false, error: 'timeout' },
]);
expect(toastService.extensionLoading).toHaveBeenCalledOnce();
expect(toastService.error).not.toHaveBeenCalled();
});
});
@@ -44,6 +44,11 @@ export function showExtensionLoadResults(results: ExtensionLoadResult[] | null |
const failedExtensions = results.filter((r) => !r.success);
if (failedExtensions.length === 0) {
toastService.dismiss('extension-loading');
return;
}
if (results.length === 1 && failedExtensions.length === 1) {
const failed = failedExtensions[0];
const errorMsg = failed.error || 'Unknown error';