mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 16:44:07 -08:00
remove unnecessary code from credentials view
This commit is contained in:
parent
aa9343001a
commit
a0ea4897d8
|
@ -6,10 +6,14 @@ import { useUIStore } from '@/stores/ui.store';
|
|||
import { mockedStore } from '@/__tests__/utils';
|
||||
import { waitFor, within, fireEvent } from '@testing-library/vue';
|
||||
import { CREDENTIAL_SELECT_MODAL_KEY, STORES } from '@/constants';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { useProjectsStore } from '@/stores/projects.store';
|
||||
import type { Project } from '@/types/projects.types';
|
||||
import { useRouter } from 'vue-router';
|
||||
vi.mock('@/composables/useGlobalEntityCreation', () => ({
|
||||
useGlobalEntityCreation: () => ({
|
||||
menu: [],
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('vue-router', async () => {
|
||||
const actual = await vi.importActual('vue-router');
|
||||
|
@ -96,28 +100,6 @@ describe('CredentialsView', () => {
|
|||
renderComponent({ props: { credentialId: 'create' } });
|
||||
expect(uiStore.openModal).toHaveBeenCalledWith(CREDENTIAL_SELECT_MODAL_KEY);
|
||||
});
|
||||
|
||||
it('should update credentialId route param to create', async () => {
|
||||
const projectsStore = mockedStore(useProjectsStore);
|
||||
projectsStore.isProjectHome = false;
|
||||
projectsStore.currentProject = { scopes: ['credential:create'] } as Project;
|
||||
const credentialsStore = mockedStore(useCredentialsStore);
|
||||
credentialsStore.allCredentials = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'test',
|
||||
type: 'test',
|
||||
createdAt: '2021-05-05T00:00:00Z',
|
||||
updatedAt: '2021-05-05T00:00:00Z',
|
||||
},
|
||||
];
|
||||
const { getByTestId } = renderComponent();
|
||||
|
||||
await userEvent.click(getByTestId('resources-list-add'));
|
||||
await waitFor(() =>
|
||||
expect(router.replace).toHaveBeenCalledWith({ params: { credentialId: 'create' } }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('open existing credential', () => {
|
||||
|
|
|
@ -26,7 +26,7 @@ import { getResourcePermissions } from '@/permissions';
|
|||
import { useDocumentTitle } from '@/composables/useDocumentTitle';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
import { N8nButton, N8nInputLabel, N8nSelect, N8nOption } from 'n8n-design-system';
|
||||
import { N8nInputLabel, N8nSelect, N8nOption } from 'n8n-design-system';
|
||||
|
||||
const props = defineProps<{
|
||||
credentialId?: string;
|
||||
|
@ -192,19 +192,6 @@ onMounted(() => {
|
|||
<template #header>
|
||||
<ProjectTabs />
|
||||
</template>
|
||||
<template #add-button="{ disabled }">
|
||||
<div>
|
||||
<N8nButton
|
||||
size="large"
|
||||
block
|
||||
:disabled="disabled"
|
||||
data-test-id="resources-list-add"
|
||||
@click="addCredential"
|
||||
>
|
||||
{{ addCredentialButtonText }}
|
||||
</N8nButton>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ data }">
|
||||
<CredentialCard
|
||||
data-test-id="resources-list-item"
|
||||
|
|
Loading…
Reference in a new issue