refactor(editor): Remove i18n and toast usage from setting store (no-changelog) (#16721)

This commit is contained in:
Alex Grozav
2025-06-26 12:24:52 +03:00
committed by GitHub
parent 901e034196
commit a7e9cc0896
3 changed files with 35 additions and 20 deletions

View File

@@ -18,9 +18,10 @@ import { EnterpriseEditionFeature } from '@/constants';
import { useUIStore } from '@/stores/ui.store';
const showMessage = vi.fn();
const showToast = vi.fn();
vi.mock('@/composables/useToast', () => ({
useToast: () => ({ showMessage }),
useToast: () => ({ showMessage, showToast }),
}));
vi.mock('@/stores/users.store', () => ({
@@ -90,6 +91,23 @@ describe('Init', () => {
expect(settingsStoreSpy).toHaveBeenCalledTimes(1);
});
it('should throw an error if settings initialization fails', async () => {
const error = new Error('Settings initialization failed');
vi.spyOn(settingsStore, 'initialize').mockImplementation(() => {
throw error;
});
await initializeCore();
expect(showToast).toHaveBeenCalledWith(
expect.objectContaining({
title: 'Error connecting to n8n',
type: 'error',
}),
);
});
it('should initialize authentication hooks', async () => {
const registerLoginHookSpy = vi.spyOn(usersStore, 'registerLoginHook');
const registerLogoutHookSpy = vi.spyOn(usersStore, 'registerLogoutHook');