From a83fdd93eb1ad55015c7bf26d42a5956c9c27c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 18 Aug 2023 17:23:24 +0200 Subject: [PATCH 1/3] fix(editor): Ensure community node install button tracks user agreement --- .../editor-ui/src/components/CommunityPackageInstallModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor-ui/src/components/CommunityPackageInstallModal.vue b/packages/editor-ui/src/components/CommunityPackageInstallModal.vue index 66bf8470c0fed..63ee3aef416f4 100644 --- a/packages/editor-ui/src/components/CommunityPackageInstallModal.vue +++ b/packages/editor-ui/src/components/CommunityPackageInstallModal.vue @@ -74,7 +74,7 @@ diff --git a/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts b/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts new file mode 100644 index 0000000000000..ceb329e6b19a3 --- /dev/null +++ b/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts @@ -0,0 +1,43 @@ +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, { + 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(); + }); +}); From 602239551db6b62f45d8ce91f4e9434d7d4f718b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 22 Aug 2023 15:26:33 +0200 Subject: [PATCH 3/3] Fix test --- .../__tests__/CommunityPackageInstallModal.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts b/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts index ceb329e6b19a3..4e21495287efe 100644 --- a/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts +++ b/packages/editor-ui/src/components/__tests__/CommunityPackageInstallModal.spec.ts @@ -6,6 +6,14 @@ 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]: { @@ -39,5 +47,9 @@ describe('CommunityPackageInstallModal', () => { await userEvent.click(wrapper.getByTestId('user-agreement-checkbox')); expect(installButton).toBeEnabled(); + + await userEvent.click(wrapper.getByTestId('user-agreement-checkbox')); + + expect(installButton).toBeDisabled(); }); });