refactor(editor): Move user login and logout side effects into hooks (no-changelog) (#16663)

This commit is contained in:
Alex Grozav
2025-06-25 13:00:52 +03:00
committed by GitHub
parent 6fa4a3eaa1
commit de0293595c
5 changed files with 91 additions and 45 deletions

View File

@@ -24,7 +24,11 @@ vi.mock('@/composables/useToast', () => ({
}));
vi.mock('@/stores/users.store', () => ({
useUsersStore: vi.fn().mockReturnValue({ initialize: vi.fn() }),
useUsersStore: vi.fn().mockReturnValue({
initialize: vi.fn(),
registerLoginHook: vi.fn(),
registerLogoutHook: vi.fn(),
}),
}));
vi.mock('@n8n/stores/useRootStore', () => ({
@@ -86,6 +90,16 @@ describe('Init', () => {
expect(settingsStoreSpy).toHaveBeenCalledTimes(1);
});
it('should initialize authentication hooks', async () => {
const registerLoginHookSpy = vi.spyOn(usersStore, 'registerLoginHook');
const registerLogoutHookSpy = vi.spyOn(usersStore, 'registerLogoutHook');
await initializeCore();
expect(registerLoginHookSpy).toHaveBeenCalled();
expect(registerLogoutHookSpy).toHaveBeenCalled();
});
it('should initialize ssoStore with settings SSO configuration', async () => {
const saml = { loginEnabled: true, loginLabel: '' };
const ldap = { loginEnabled: false, loginLabel: '' };