mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
test(editor): Move test utils to the proper place (#5975)
This commit is contained in:
parent
0b48088296
commit
dc0055fc5c
|
@ -1,3 +1,5 @@
|
||||||
|
import { ISettingsState, UserManagementAuthenticationMethod } from '@/Interface';
|
||||||
|
|
||||||
export const retry = (assertion: () => any, { interval = 20, timeout = 200 } = {}) => {
|
export const retry = (assertion: () => any, { interval = 20, timeout = 200 } = {}) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
@ -15,3 +17,106 @@ export const retry = (assertion: () => any, { interval = 20, timeout = 200 } = {
|
||||||
tryAgain();
|
tryAgain();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const waitAllPromises = () => new Promise((resolve) => setTimeout(resolve));
|
||||||
|
|
||||||
|
export const SETTINGS_STORE_DEFAULT_STATE: ISettingsState = {
|
||||||
|
settings: {
|
||||||
|
userActivationSurveyEnabled: false,
|
||||||
|
allowedModules: {},
|
||||||
|
communityNodesEnabled: false,
|
||||||
|
defaultLocale: '',
|
||||||
|
endpointWebhook: '',
|
||||||
|
endpointWebhookTest: '',
|
||||||
|
enterprise: {
|
||||||
|
advancedExecutionFilters: false,
|
||||||
|
sharing: false,
|
||||||
|
ldap: false,
|
||||||
|
saml: false,
|
||||||
|
logStreaming: false,
|
||||||
|
},
|
||||||
|
executionMode: '',
|
||||||
|
executionTimeout: 0,
|
||||||
|
hideUsagePage: false,
|
||||||
|
hiringBannerEnabled: false,
|
||||||
|
instanceId: '',
|
||||||
|
isNpmAvailable: false,
|
||||||
|
license: { environment: 'production' },
|
||||||
|
logLevel: 'info',
|
||||||
|
maxExecutionTimeout: 0,
|
||||||
|
oauthCallbackUrls: { oauth1: '', oauth2: '' },
|
||||||
|
onboardingCallPromptEnabled: false,
|
||||||
|
personalizationSurveyEnabled: false,
|
||||||
|
posthog: {
|
||||||
|
apiHost: '',
|
||||||
|
apiKey: '',
|
||||||
|
autocapture: false,
|
||||||
|
debug: false,
|
||||||
|
disableSessionRecording: false,
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
|
||||||
|
pushBackend: 'sse',
|
||||||
|
saveDataErrorExecution: '',
|
||||||
|
saveDataSuccessExecution: '',
|
||||||
|
saveManualExecutions: false,
|
||||||
|
sso: {
|
||||||
|
ldap: { loginEnabled: false, loginLabel: '' },
|
||||||
|
saml: { loginEnabled: false, loginLabel: '' },
|
||||||
|
},
|
||||||
|
telemetry: { enabled: false },
|
||||||
|
templates: { enabled: false, host: '' },
|
||||||
|
timezone: '',
|
||||||
|
urlBaseEditor: '',
|
||||||
|
urlBaseWebhook: '',
|
||||||
|
userManagement: {
|
||||||
|
enabled: false,
|
||||||
|
smtpSetup: false,
|
||||||
|
authenticationMethod: UserManagementAuthenticationMethod.Email,
|
||||||
|
},
|
||||||
|
versionCli: '',
|
||||||
|
versionNotifications: {
|
||||||
|
enabled: false,
|
||||||
|
endpoint: '',
|
||||||
|
infoUrl: '',
|
||||||
|
},
|
||||||
|
workflowCallerPolicyDefaultOption: 'any',
|
||||||
|
workflowTagsDisabled: false,
|
||||||
|
deployment: {
|
||||||
|
type: 'default',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
promptsData: {
|
||||||
|
message: '',
|
||||||
|
title: '',
|
||||||
|
showContactPrompt: false,
|
||||||
|
showValueSurvey: false,
|
||||||
|
},
|
||||||
|
userManagement: {
|
||||||
|
enabled: false,
|
||||||
|
showSetupOnFirstLoad: false,
|
||||||
|
smtpSetup: false,
|
||||||
|
authenticationMethod: UserManagementAuthenticationMethod.Email,
|
||||||
|
},
|
||||||
|
templatesEndpointHealthy: false,
|
||||||
|
api: {
|
||||||
|
enabled: false,
|
||||||
|
latestVersion: 0,
|
||||||
|
path: '/',
|
||||||
|
swaggerUi: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ldap: {
|
||||||
|
loginLabel: '',
|
||||||
|
loginEnabled: false,
|
||||||
|
},
|
||||||
|
saml: {
|
||||||
|
loginLabel: '',
|
||||||
|
loginEnabled: false,
|
||||||
|
},
|
||||||
|
onboardingCallPromptEnabled: false,
|
||||||
|
saveDataErrorExecution: 'all',
|
||||||
|
saveDataSuccessExecution: 'all',
|
||||||
|
saveManualExecutions: false,
|
||||||
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { showMessage } from '@/mixins/showMessage';
|
||||||
import { i18nInstance } from '@/plugins/i18n';
|
import { i18nInstance } from '@/plugins/i18n';
|
||||||
import type { IWorkflowShortResponse } from '@/Interface';
|
import type { IWorkflowShortResponse } from '@/Interface';
|
||||||
import type { IExecutionsSummary } from 'n8n-workflow';
|
import type { IExecutionsSummary } from 'n8n-workflow';
|
||||||
import { waitAllPromises } from '@/utils/testUtils';
|
import { waitAllPromises } from '@/__tests__/utils';
|
||||||
|
|
||||||
const workflowDataFactory = (): IWorkflowShortResponse => ({
|
const workflowDataFactory = (): IWorkflowShortResponse => ({
|
||||||
createdAt: faker.date.past().toDateString(),
|
createdAt: faker.date.past().toDateString(),
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { merge } from 'lodash-es';
|
||||||
import SSOLogin from '@/components/SSOLogin.vue';
|
import SSOLogin from '@/components/SSOLogin.vue';
|
||||||
import { STORES } from '@/constants';
|
import { STORES } from '@/constants';
|
||||||
import { useSSOStore } from '@/stores/sso';
|
import { useSSOStore } from '@/stores/sso';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/utils/testUtils';
|
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||||
import { afterEach } from 'vitest';
|
import { afterEach } from 'vitest';
|
||||||
|
|
||||||
let pinia: ReturnType<typeof createTestingPinia>;
|
let pinia: ReturnType<typeof createTestingPinia>;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { useSettingsStore } from '@/stores/settings';
|
||||||
import { useSSOStore } from '@/stores/sso';
|
import { useSSOStore } from '@/stores/sso';
|
||||||
import { merge } from 'lodash-es';
|
import { merge } from 'lodash-es';
|
||||||
import { IN8nUISettings } from '@/Interface';
|
import { IN8nUISettings } from '@/Interface';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/utils/testUtils';
|
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||||
|
|
||||||
let ssoStore: ReturnType<typeof useSSOStore>;
|
let ssoStore: ReturnType<typeof useSSOStore>;
|
||||||
let settingsStore: ReturnType<typeof useSettingsStore>;
|
let settingsStore: ReturnType<typeof useSettingsStore>;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { useSSOStore } from '@/stores/sso';
|
||||||
import { IN8nUISettings, IUser } from '@/Interface';
|
import { IN8nUISettings, IUser } from '@/Interface';
|
||||||
import { routes } from '@/router';
|
import { routes } from '@/router';
|
||||||
import { VIEWS } from '@/constants';
|
import { VIEWS } from '@/constants';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/utils/testUtils';
|
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: IN8nUISettings = SETTINGS_STORE_DEFAULT_STATE.settings;
|
const DEFAULT_SETTINGS: IN8nUISettings = SETTINGS_STORE_DEFAULT_STATE.settings;
|
||||||
|
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
import { ISettingsState, UserManagementAuthenticationMethod } from '@/Interface';
|
|
||||||
|
|
||||||
export const waitAllPromises = () => new Promise((resolve) => setTimeout(resolve));
|
|
||||||
|
|
||||||
export const SETTINGS_STORE_DEFAULT_STATE: ISettingsState = {
|
|
||||||
settings: {
|
|
||||||
allowedModules: {},
|
|
||||||
communityNodesEnabled: false,
|
|
||||||
defaultLocale: '',
|
|
||||||
endpointWebhook: '',
|
|
||||||
endpointWebhookTest: '',
|
|
||||||
enterprise: {
|
|
||||||
advancedExecutionFilters: false,
|
|
||||||
sharing: false,
|
|
||||||
ldap: false,
|
|
||||||
saml: false,
|
|
||||||
logStreaming: false,
|
|
||||||
},
|
|
||||||
executionMode: '',
|
|
||||||
executionTimeout: 0,
|
|
||||||
hideUsagePage: false,
|
|
||||||
hiringBannerEnabled: false,
|
|
||||||
instanceId: '',
|
|
||||||
isNpmAvailable: false,
|
|
||||||
license: { environment: 'production' },
|
|
||||||
logLevel: 'info',
|
|
||||||
maxExecutionTimeout: 0,
|
|
||||||
oauthCallbackUrls: { oauth1: '', oauth2: '' },
|
|
||||||
onboardingCallPromptEnabled: false,
|
|
||||||
personalizationSurveyEnabled: false,
|
|
||||||
posthog: {
|
|
||||||
apiHost: '',
|
|
||||||
apiKey: '',
|
|
||||||
autocapture: false,
|
|
||||||
debug: false,
|
|
||||||
disableSessionRecording: false,
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
|
|
||||||
pushBackend: 'sse',
|
|
||||||
saveDataErrorExecution: '',
|
|
||||||
saveDataSuccessExecution: '',
|
|
||||||
saveManualExecutions: false,
|
|
||||||
sso: {
|
|
||||||
ldap: { loginEnabled: false, loginLabel: '' },
|
|
||||||
saml: { loginEnabled: false, loginLabel: '' },
|
|
||||||
},
|
|
||||||
telemetry: { enabled: false },
|
|
||||||
templates: { enabled: false, host: '' },
|
|
||||||
timezone: '',
|
|
||||||
urlBaseEditor: '',
|
|
||||||
urlBaseWebhook: '',
|
|
||||||
userManagement: {
|
|
||||||
enabled: false,
|
|
||||||
smtpSetup: false,
|
|
||||||
authenticationMethod: UserManagementAuthenticationMethod.Email,
|
|
||||||
},
|
|
||||||
versionCli: '',
|
|
||||||
versionNotifications: {
|
|
||||||
enabled: false,
|
|
||||||
endpoint: '',
|
|
||||||
infoUrl: '',
|
|
||||||
},
|
|
||||||
workflowCallerPolicyDefaultOption: 'any',
|
|
||||||
workflowTagsDisabled: false,
|
|
||||||
deployment: {
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
promptsData: {
|
|
||||||
message: '',
|
|
||||||
title: '',
|
|
||||||
showContactPrompt: false,
|
|
||||||
showValueSurvey: false,
|
|
||||||
},
|
|
||||||
userManagement: {
|
|
||||||
enabled: false,
|
|
||||||
showSetupOnFirstLoad: false,
|
|
||||||
smtpSetup: false,
|
|
||||||
authenticationMethod: UserManagementAuthenticationMethod.Email,
|
|
||||||
},
|
|
||||||
templatesEndpointHealthy: false,
|
|
||||||
api: {
|
|
||||||
enabled: false,
|
|
||||||
latestVersion: 0,
|
|
||||||
path: '/',
|
|
||||||
swaggerUi: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ldap: {
|
|
||||||
loginLabel: '',
|
|
||||||
loginEnabled: false,
|
|
||||||
},
|
|
||||||
saml: {
|
|
||||||
loginLabel: '',
|
|
||||||
loginEnabled: false,
|
|
||||||
},
|
|
||||||
onboardingCallPromptEnabled: false,
|
|
||||||
saveDataErrorExecution: 'all',
|
|
||||||
saveDataSuccessExecution: 'all',
|
|
||||||
saveManualExecutions: false,
|
|
||||||
};
|
|
|
@ -7,7 +7,7 @@ import { merge } from 'lodash-es';
|
||||||
import SamlOnboarding from '@/views/SamlOnboarding.vue';
|
import SamlOnboarding from '@/views/SamlOnboarding.vue';
|
||||||
import { useSSOStore } from '@/stores/sso';
|
import { useSSOStore } from '@/stores/sso';
|
||||||
import { STORES } from '@/constants';
|
import { STORES } from '@/constants';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/utils/testUtils';
|
import { SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils';
|
||||||
import { i18nInstance } from '@/plugins/i18n';
|
import { i18nInstance } from '@/plugins/i18n';
|
||||||
|
|
||||||
vi.mock('vue-router/composables', () => {
|
vi.mock('vue-router/composables', () => {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { faker } from '@faker-js/faker';
|
||||||
import SettingsSso from '@/views/SettingsSso.vue';
|
import SettingsSso from '@/views/SettingsSso.vue';
|
||||||
import { useSSOStore } from '@/stores/sso';
|
import { useSSOStore } from '@/stores/sso';
|
||||||
import { STORES } from '@/constants';
|
import { STORES } from '@/constants';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/utils/testUtils';
|
import { SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils';
|
||||||
import { i18nInstance } from '@/plugins/i18n';
|
import { i18nInstance } from '@/plugins/i18n';
|
||||||
import { SamlPreferences, SamlPreferencesExtractedData } from '@/Interface';
|
import { SamlPreferences, SamlPreferencesExtractedData } from '@/Interface';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue