test(editor): SSO tests (#5946)

* test(editor): SSO tests

* test(editor): move store tests to __tests__ folder

* test(editor): move tests in a different PR

* test(editor): add SSO tests

* test(editor): add SSO settings page tests

* test(editor): add SSO onboarding page base test

* test(editor): add SSO onboarding page test

* test(editor): fix router spy
This commit is contained in:
Csaba Tuncsik
2023-04-13 16:17:47 +02:00
committed by GitHub
parent 1a8a9f8ddb
commit bc1db5e16a
10 changed files with 475 additions and 79 deletions

View File

@@ -0,0 +1,48 @@
import { createPinia, setActivePinia } from 'pinia';
import { useSettingsStore } from '@/stores/settings';
import { useSSOStore } from '@/stores/sso';
import { merge } from 'lodash-es';
import { IN8nUISettings } from '@/Interface';
import { SETTINGS_STORE_DEFAULT_STATE } from '@/utils/testUtils';
let ssoStore: ReturnType<typeof useSSOStore>;
let settingsStore: ReturnType<typeof useSettingsStore>;
const DEFAULT_SETTINGS: IN8nUISettings = SETTINGS_STORE_DEFAULT_STATE.settings;
describe('SSO store', () => {
beforeEach(() => {
setActivePinia(createPinia());
ssoStore = useSSOStore();
settingsStore = useSettingsStore();
});
test.each([
['saml', true, true, true],
['saml', false, true, false],
['saml', false, false, false],
['saml', true, false, false],
['email', true, true, false],
])(
'should check SSO login button availability when authenticationMethod is %s and enterprise feature is %s and sso login is set to %s',
(authenticationMethod, saml, loginEnabled, expectation) => {
settingsStore.setSettings(
merge({}, DEFAULT_SETTINGS, {
userManagement: {
authenticationMethod,
},
enterprise: {
saml,
},
sso: {
saml: {
loginEnabled,
},
},
}),
);
expect(ssoStore.showSsoLoginButton).toBe(expectation);
},
);
});

View File

@@ -75,6 +75,7 @@ export const useSSOStore = defineStore('sso', () => {
setLoading,
isSamlLoginEnabled,
isEnterpriseSamlEnabled,
isDefaultAuthenticationSaml,
showSsoLoginButton,
getSSORedirectUrl,
getSamlMetadata,