From 02c17fb70f8250987c3100f0f48f1d52993ace45 Mon Sep 17 00:00:00 2001 From: vashjs <86330150+vashjs@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:01:57 +0100 Subject: [PATCH] UIPQB-56 Prevent columns from being reset when query is changed (#69) --- CHANGELOG.md | 1 + .../QueryBuilderModal.test.js | 20 ++++--------------- .../QueryBuilder/TestQuery/TestQuery.js | 8 +++++++- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2e739c..82dc8e16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## (in progress) * [UIPQB-60](https://issues.folio.org/browse/UIPQB-60) 'In' and 'Not In' requests not properly formatted for [Users] "User ID" +* [UIPQB-56](https://issues.folio.org/browse/UIPQB-56) Prevent columns from being reset when query is changed ## [1.0.0](https://github.com/folio-org/ui-plugin-query-builder/tree/v1.0.0) (2023-10-12) diff --git a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.test.js b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.test.js index 8522b6d1..e03e9a9e 100644 --- a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.test.js +++ b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.test.js @@ -52,7 +52,7 @@ const fillFormAndClickTestQuery = async () => { const selectFieldPlaceholder = screen.findByText('ui-plugin-query-builder.control.selection.placeholder'); - await act(async () => userEvent.click(await selectFieldPlaceholder)); + await userEvent.click(await selectFieldPlaceholder); let userFirstNameOption; @@ -77,7 +77,7 @@ const fillFormAndClickTestQuery = async () => { expect(testQuery).toBeEnabled(); }); - await act(async () => userEvent.click(await testQuery)); + userEvent.click(testQuery); }; describe('QueryBuilderModal', () => { @@ -157,30 +157,18 @@ describe('QueryBuilderModal', () => { expect(screen.getByText(/testText/)).toBeVisible(); }); - it.skip('should show progress table when form valid and testQuery button clicked', async () => { + it('should show progress table when form valid and testQuery button clicked', async () => { renderQueryBuilderModal({}); await waitFor(() => { expect(screen.queryByText('LOADING')).not.toBeInTheDocument(); }); - const runQuery = screen.getByRole('button', { name: /ui-plugin-query-builder.modal.run/ }); - await fillFormAndClickTestQuery(); await waitFor(() => { expect(screen.queryByText('ui-plugin-query-builder.viewer.retrieving')).not.toBeInTheDocument(); }); - - await waitFor(() => { - expect(runQuery).toBeEnabled(); - }, { timeout: 5500 }); - - act(() => userEvent.click(runQuery)); - - await waitFor(() => { - expect(onRunSuccessMock).toHaveBeenCalled(); - }); }); it.skip('should show banner if limit is exceeded', async () => { @@ -196,6 +184,6 @@ describe('QueryBuilderModal', () => { await waitFor(() => { expect(screen.queryByText('ui-plugin-query-builder.modal.banner.limit')).toBeVisible(); - }); + }, { timeout: 5000 }); }); }); diff --git a/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js b/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js index 602f2f15..d1c66b81 100644 --- a/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js +++ b/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js @@ -108,6 +108,12 @@ export const TestQuery = ({ const handleColumnChange = ({ values }) => setVisibleColumns(values); + const handleDefaultVisibleColumnsChange = (values) => { + if (!visibleColumns.length) { + setVisibleColumns(values); + } + }; + const renderDropdown = ({ currentRecordsCount }) => !!currentRecordsCount && (