Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Ensure community node install button tracks user agreement #6976

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
:class="[$style.checkbox, checkboxWarning ? $style.error : '', 'mt-l']"
:disabled="loading"
@update:modelValue="onCheckboxChecked"
data-test-id="user-agreement-checkbox"
>
<n8n-text>
{{ $locale.baseText('settings.communityNodes.installModal.checkbox.label') }} </n8n-text
Expand All @@ -74,7 +75,7 @@
<template #footer>
<n8n-button
:loading="loading"
:disabled="packageName === '' || loading"
:disabled="!userAgreed || packageName === '' || loading"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be great to add some tests here for this fix

:label="
loading
? $locale.baseText('settings.communityNodes.installModal.installButton.label.loading')
Expand All @@ -83,6 +84,7 @@
size="large"
float="right"
@click="onInstallClick"
data-test-id="install-community-package-button"
/>
</template>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { createComponentRenderer } from '@/__tests__/render';
import CommunityPackageInstallModal from '../CommunityPackageInstallModal.vue';
import { createTestingPinia } from '@pinia/testing';
import { COMMUNITY_PACKAGE_INSTALL_MODAL_KEY, STORES } from '@/constants';
import userEvent from '@testing-library/user-event';
import { retry } from '@/__tests__/utils';

const renderComponent = createComponentRenderer(CommunityPackageInstallModal, {
props: {
appendToBody: false,
},
data() {
return {
packageName: 'n8n-nodes-hello',
};
},
pinia: createTestingPinia({
initialState: {
[STORES.UI]: {
modals: {
[COMMUNITY_PACKAGE_INSTALL_MODAL_KEY]: { open: true },
},
},
[STORES.SETTINGS]: {
settings: {
templates: {
host: '',
},
},
},
},
}),
});

describe('CommunityPackageInstallModal', () => {
it('should disable install button until user agrees', async () => {
const wrapper = renderComponent();

await retry(() =>
expect(wrapper.container.querySelector('.modal-content')).toBeInTheDocument(),
);

const installButton = wrapper.getByTestId('install-community-package-button');

expect(installButton).toBeDisabled();

await userEvent.click(wrapper.getByTestId('user-agreement-checkbox'));

expect(installButton).toBeEnabled();

await userEvent.click(wrapper.getByTestId('user-agreement-checkbox'));

expect(installButton).toBeDisabled();
});
});
Loading