mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-25 11:31:38 -08:00
fix(editor): Hide credential’s modal menu when the credential is managed (no-changelog) (#12471)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
This commit is contained in:
parent
06c9473210
commit
f609371257
|
@ -1106,7 +1106,7 @@ function resetCredentialData(): void {
|
|||
</template>
|
||||
<template #content>
|
||||
<div :class="$style.container" data-test-id="credential-edit-dialog">
|
||||
<div :class="$style.sidebar">
|
||||
<div v-if="!isEditingManagedCredential" :class="$style.sidebar">
|
||||
<n8n-menu
|
||||
mode="tabs"
|
||||
:items="sidebarItems"
|
||||
|
|
|
@ -3,6 +3,8 @@ import CredentialEdit from '@/components/CredentialEdit/CredentialEdit.vue';
|
|||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { CREDENTIAL_EDIT_MODAL_KEY, STORES } from '@/constants';
|
||||
import { cleanupAppModals, createAppModals, retry } from '@/__tests__/utils';
|
||||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import type { ICredentialsResponse } from '@/Interface';
|
||||
|
||||
vi.mock('@/permissions', () => ({
|
||||
getResourcePermissions: vi.fn(() => ({
|
||||
|
@ -23,6 +25,10 @@ const renderComponent = createComponentRenderer(CredentialEdit, {
|
|||
},
|
||||
[STORES.SETTINGS]: {
|
||||
settings: {
|
||||
enterprise: {
|
||||
sharing: true,
|
||||
externalSecrets: false,
|
||||
},
|
||||
templates: {
|
||||
host: '',
|
||||
},
|
||||
|
@ -67,4 +73,54 @@ describe('CredentialEdit', () => {
|
|||
});
|
||||
await retry(() => expect(queryByTestId('credential-save-button')).not.toBeInTheDocument());
|
||||
});
|
||||
|
||||
test('hides menu item when credential is managed', async () => {
|
||||
const credentialsStore = useCredentialsStore();
|
||||
|
||||
credentialsStore.state.credentials = {
|
||||
'123': {
|
||||
isManaged: false,
|
||||
} as ICredentialsResponse,
|
||||
};
|
||||
|
||||
const { queryByText } = renderComponent({
|
||||
props: {
|
||||
activeId: '123', // credentialId will be set to this value in edit mode
|
||||
isTesting: false,
|
||||
isSaving: false,
|
||||
hasUnsavedChanges: false,
|
||||
modalName: CREDENTIAL_EDIT_MODAL_KEY,
|
||||
mode: 'edit',
|
||||
},
|
||||
});
|
||||
|
||||
await retry(() => expect(queryByText('Details')).toBeInTheDocument());
|
||||
await retry(() => expect(queryByText('Connection')).toBeInTheDocument());
|
||||
await retry(() => expect(queryByText('Sharing')).toBeInTheDocument());
|
||||
});
|
||||
|
||||
test('shows menu item when credential is not managed', async () => {
|
||||
const credentialsStore = useCredentialsStore();
|
||||
|
||||
credentialsStore.state.credentials = {
|
||||
'123': {
|
||||
isManaged: true,
|
||||
} as ICredentialsResponse,
|
||||
};
|
||||
|
||||
const { queryByText } = renderComponent({
|
||||
props: {
|
||||
activeId: '123', // credentialId will be set to this value in edit mode
|
||||
isTesting: false,
|
||||
isSaving: false,
|
||||
hasUnsavedChanges: false,
|
||||
modalName: CREDENTIAL_EDIT_MODAL_KEY,
|
||||
mode: 'edit',
|
||||
},
|
||||
});
|
||||
|
||||
await retry(() => expect(queryByText('Details')).not.toBeInTheDocument());
|
||||
await retry(() => expect(queryByText('Connection')).not.toBeInTheDocument());
|
||||
await retry(() => expect(queryByText('Sharing')).not.toBeInTheDocument());
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue