mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix: fixed remaining unit tests
This commit is contained in:
parent
48ecfd3d32
commit
38fe111709
|
@ -8,7 +8,7 @@ import ExecutionsList from '@/components/ExecutionsList.vue';
|
||||||
import type { IWorkflowDb } from '@/Interface';
|
import type { IWorkflowDb } from '@/Interface';
|
||||||
import type { IExecutionsSummary } from 'n8n-workflow';
|
import type { IExecutionsSummary } from 'n8n-workflow';
|
||||||
import { retry, SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils';
|
import { retry, SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils';
|
||||||
import { useWorkflowsStore } from '@/stores';
|
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||||
import { RenderOptions, createComponentRenderer } from '@/__tests__/render';
|
import { RenderOptions, createComponentRenderer } from '@/__tests__/render';
|
||||||
|
|
||||||
let pinia: ReturnType<typeof createTestingPinia>;
|
let pinia: ReturnType<typeof createTestingPinia>;
|
||||||
|
|
|
@ -54,7 +54,6 @@ describe('VariablesRow', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
|
||||||
expect(wrapper.container.querySelectorAll('td')).toHaveLength(4);
|
expect(wrapper.container.querySelectorAll('td')).toHaveLength(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,8 +88,6 @@ describe('VariablesRow', () => {
|
||||||
expect(wrapper.getByTestId('variable-row-value-input').querySelector('input')).toHaveValue(
|
expect(wrapper.getByTestId('variable-row-value-input').querySelector('input')).toHaveValue(
|
||||||
environmentVariable.value,
|
environmentVariable.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show cancel and save buttons in edit mode', async () => {
|
it('should show cancel and save buttons in edit mode', async () => {
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
// Vitest Snapshot v1
|
|
||||||
|
|
||||||
exports[`VariablesRow > should render correctly 1`] = `
|
|
||||||
"<tr class=\\"variablesRow\\" data-test-id=\\"variables-row\\">
|
|
||||||
<td class=\\"variables-key-column\\">
|
|
||||||
<div><span>key</span></div>
|
|
||||||
</td>
|
|
||||||
<td class=\\"variables-value-column\\">
|
|
||||||
<div><span>value</span></div>
|
|
||||||
</td>
|
|
||||||
<td class=\\"variables-usage-column\\">
|
|
||||||
<div><span class=\\"usageSyntax el-tooltip__trigger el-tooltip__trigger\\">$vars.key</span>
|
|
||||||
<!--teleport start-->
|
|
||||||
<!--teleport end-->
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class=\\"buttons hoverButtons\\">
|
|
||||||
<div class=\\"el-tooltip__trigger\\"><button class=\\"button button tertiary medium disabled mr-xs mr-xs\\" disabled=\\"\\" aria-disabled=\\"true\\" aria-live=\\"polite\\" data-test-id=\\"variable-row-edit-button\\">
|
|
||||||
<!--v-if--><span>Edit</span>
|
|
||||||
</button></div>
|
|
||||||
<!--teleport start-->
|
|
||||||
<!--teleport end-->
|
|
||||||
<div class=\\"el-tooltip__trigger\\"><button class=\\"button button tertiary medium disabled\\" disabled=\\"\\" aria-disabled=\\"true\\" aria-live=\\"polite\\" data-test-id=\\"variable-row-delete-button\\">
|
|
||||||
<!--v-if--><span>Delete</span>
|
|
||||||
</button></div>
|
|
||||||
<!--teleport start-->
|
|
||||||
<!--teleport end-->
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`VariablesRow > should show key and value inputs in edit mode 1`] = `
|
|
||||||
"<tr class=\\"variablesRow\\" data-test-id=\\"variables-row\\">
|
|
||||||
<td class=\\"variables-key-column\\">
|
|
||||||
<div>
|
|
||||||
<div class=\\"container\\" data-test-id=\\"variable-row-key-input\\">
|
|
||||||
<!--v-if-->
|
|
||||||
<div class=\\"\\">
|
|
||||||
<div class=\\"el-input el-input--large n8n-input\\">
|
|
||||||
<!-- input -->
|
|
||||||
<!-- prepend slot -->
|
|
||||||
<!--v-if-->
|
|
||||||
<div class=\\"el-input__wrapper is-focus\\">
|
|
||||||
<!-- prefix slot -->
|
|
||||||
<!--v-if--><input class=\\"el-input__inner\\" autocomplete=\\"off\\" name=\\"key\\" rows=\\"2\\" maxlength=\\"Infinity\\" title=\\"\\" type=\\"text\\" tabindex=\\"0\\" placeholder=\\"Enter a name\\" id=\\"el-id-5581-7\\"><!-- suffix slot -->
|
|
||||||
<!--v-if-->
|
|
||||||
</div><!-- append slot -->
|
|
||||||
<!--v-if-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--v-if-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class=\\"variables-value-column\\">
|
|
||||||
<div>
|
|
||||||
<div class=\\"container\\" data-test-id=\\"variable-row-value-input\\">
|
|
||||||
<!--v-if-->
|
|
||||||
<div class=\\"\\">
|
|
||||||
<div class=\\"el-input el-input--large n8n-input\\">
|
|
||||||
<!-- input -->
|
|
||||||
<!-- prepend slot -->
|
|
||||||
<!--v-if-->
|
|
||||||
<div class=\\"el-input__wrapper\\">
|
|
||||||
<!-- prefix slot -->
|
|
||||||
<!--v-if--><input class=\\"el-input__inner\\" autocomplete=\\"off\\" name=\\"value\\" rows=\\"2\\" maxlength=\\"Infinity\\" title=\\"\\" type=\\"text\\" tabindex=\\"0\\" placeholder=\\"Enter a value\\" id=\\"el-id-5581-8\\"><!-- suffix slot -->
|
|
||||||
<!--v-if-->
|
|
||||||
</div><!-- append slot -->
|
|
||||||
<!--v-if-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--v-if-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class=\\"variables-usage-column\\">
|
|
||||||
<div><span class=\\"usageSyntax el-tooltip__trigger el-tooltip__trigger\\">$vars.key</span>
|
|
||||||
<!--teleport start-->
|
|
||||||
<!--teleport end-->
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class=\\"buttons\\"><button class=\\"button button tertiary medium mr-xs mr-xs\\" aria-live=\\"polite\\" data-test-id=\\"variable-row-cancel-button\\">
|
|
||||||
<!--v-if--><span>Cancel</span>
|
|
||||||
</button><button class=\\"button button primary medium\\" aria-live=\\"polite\\" data-test-id=\\"variable-row-save-button\\">
|
|
||||||
<!--v-if--><span>Save</span>
|
|
||||||
</button></div>
|
|
||||||
</td>
|
|
||||||
</tr>"
|
|
||||||
`;
|
|
|
@ -55,7 +55,7 @@ import type { BaseTextKey } from '@/plugins/i18n';
|
||||||
import { i18n as locale } from '@/plugins/i18n';
|
import { i18n as locale } from '@/plugins/i18n';
|
||||||
import type { Modals, NewCredentialsModal } from '@/Interface';
|
import type { Modals, NewCredentialsModal } from '@/Interface';
|
||||||
import { useTelemetryStore } from '@/stores/telemetry.store';
|
import { useTelemetryStore } from '@/stores/telemetry.store';
|
||||||
import { getStyleTokenValue } from '@/utils';
|
import { getStyleTokenValue } from '@/utils/htmlUtils';
|
||||||
import { dismissBannerPermanently } from '@/api/ui';
|
import { dismissBannerPermanently } from '@/api/ui';
|
||||||
import type { Banners } from 'n8n-workflow';
|
import type { Banners } from 'n8n-workflow';
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import { beforeAll } from 'vitest';
|
import { beforeAll } from 'vitest';
|
||||||
import { setActivePinia, createPinia } from 'pinia';
|
import { setActivePinia, createPinia } from 'pinia';
|
||||||
import { merge } from 'lodash-es';
|
import { merge } from 'lodash-es';
|
||||||
import { isAuthorized } from '@/utils';
|
import { isAuthorized, ROLE } from '@/utils';
|
||||||
import { useSettingsStore, useSSOStore } from '@/stores';
|
import { useSettingsStore } from '@/stores/settings.store';
|
||||||
|
import { useSSOStore } from '@/stores/sso.store';
|
||||||
import type { IUser } from '@/Interface';
|
import type { IUser } from '@/Interface';
|
||||||
import { routes } from '@/router';
|
|
||||||
import { VIEWS } from '@/constants';
|
import { VIEWS } from '@/constants';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||||
import type { IN8nUISettings } from 'n8n-workflow';
|
import type { IN8nUISettings } from 'n8n-workflow';
|
||||||
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: IN8nUISettings = SETTINGS_STORE_DEFAULT_STATE.settings;
|
const DEFAULT_SETTINGS: IN8nUISettings = SETTINGS_STORE_DEFAULT_STATE.settings;
|
||||||
|
|
||||||
|
@ -30,15 +31,24 @@ describe('userUtils', () => {
|
||||||
|
|
||||||
describe('isAuthorized', () => {
|
describe('isAuthorized', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
setActivePinia(createPinia());
|
setActivePinia(createTestingPinia());
|
||||||
settingsStore = useSettingsStore();
|
settingsStore = useSettingsStore();
|
||||||
ssoStore = useSSOStore();
|
ssoStore = useSSOStore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @TODO Move to routes tests in the future
|
||||||
it('should check SSO settings route permissions', () => {
|
it('should check SSO settings route permissions', () => {
|
||||||
const ssoSettingsPermissions = routes
|
const ssoSettingsPermissions = {
|
||||||
.find((route) => route.path.startsWith('/settings'))
|
allow: {
|
||||||
?.children?.find((route) => route.name === VIEWS.SSO_SETTINGS)?.meta?.permissions;
|
role: [ROLE.Owner],
|
||||||
|
},
|
||||||
|
deny: {
|
||||||
|
shouldDeny: () => {
|
||||||
|
const settingsStore = useSettingsStore();
|
||||||
|
return settingsStore.isDesktopDeployment;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const user: IUser = merge({}, DEFAULT_USER, {
|
const user: IUser = merge({}, DEFAULT_USER, {
|
||||||
isDefaultUser: false,
|
isDefaultUser: false,
|
||||||
|
|
|
@ -118,23 +118,6 @@ export default mergeConfig(
|
||||||
}),
|
}),
|
||||||
defineVitestConfig({
|
defineVitestConfig({
|
||||||
test: {
|
test: {
|
||||||
include: [
|
|
||||||
// 'src/components/__tests__/SQLEditor.test.ts',
|
|
||||||
// 'src/components/__tests__/BannersStack.test.ts',
|
|
||||||
// 'src/components/__tests__/ExecutionFilter.test.ts',
|
|
||||||
// 'src/components/__tests__/ExecutionsList.test.ts',
|
|
||||||
// 'src/components/__tests__/MainSidebarSourceControl.test.ts',
|
|
||||||
// 'src/components/__tests__/PersonalizationModal.spec.ts',
|
|
||||||
// 'src/components/__tests__/ResourceMapper.test.ts',
|
|
||||||
// 'src/components/__tests__/RunData.test.ts',
|
|
||||||
// 'src/components/__tests__/RunDataJson.test.ts',
|
|
||||||
// 'src/components/__tests__/RunDataSchema.test.ts',
|
|
||||||
// 'src/components/__tests__/SQLEditor.test.ts',
|
|
||||||
// 'src/components/__tests__/VariablesRow.spec.ts',
|
|
||||||
'src/components/Node/**/*.test.ts',
|
|
||||||
'src/views/**/*.test.ts',
|
|
||||||
'src/views/**/*.spec.ts',
|
|
||||||
],
|
|
||||||
globals: true,
|
globals: true,
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
setupFiles: ['./src/__tests__/setup.ts'],
|
setupFiles: ['./src/__tests__/setup.ts'],
|
||||||
|
|
Loading…
Reference in a new issue