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:
48
packages/editor-ui/src/stores/__tests__/sso.test.ts
Normal file
48
packages/editor-ui/src/stores/__tests__/sso.test.ts
Normal 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);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -75,6 +75,7 @@ export const useSSOStore = defineStore('sso', () => {
|
||||
setLoading,
|
||||
isSamlLoginEnabled,
|
||||
isEnterpriseSamlEnabled,
|
||||
isDefaultAuthenticationSaml,
|
||||
showSsoLoginButton,
|
||||
getSSORedirectUrl,
|
||||
getSamlMetadata,
|
||||
|
||||
Reference in New Issue
Block a user