Skip to content

Commit

Permalink
UIPQB-56 Prevent columns from being reset when query is changed (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs authored Oct 27, 2023
1 parent bfeade5 commit 02c17fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -77,7 +77,7 @@ const fillFormAndClickTestQuery = async () => {
expect(testQuery).toBeEnabled();
});

await act(async () => userEvent.click(await testQuery));
userEvent.click(testQuery);
};

describe('QueryBuilderModal', () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -196,6 +184,6 @@ describe('QueryBuilderModal', () => {

await waitFor(() => {
expect(screen.queryByText('ui-plugin-query-builder.modal.banner.limit')).toBeVisible();
});
}, { timeout: 5000 });
});
});
8 changes: 7 additions & 1 deletion src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ export const TestQuery = ({

const handleColumnChange = ({ values }) => setVisibleColumns(values);

const handleDefaultVisibleColumnsChange = (values) => {
if (!visibleColumns.length) {
setVisibleColumns(values);
}
};

const renderDropdown = ({ currentRecordsCount }) => !!currentRecordsCount && (
<ColumnsDropdown
columns={columns}
Expand Down Expand Up @@ -154,7 +160,7 @@ export const TestQuery = ({
onSuccess={handleQueryRetrieved}
onPreviewShown={handlePreviewShown}
onSetDefaultColumns={setColumns}
onSetDefaultVisibleColumns={setVisibleColumns}
onSetDefaultVisibleColumns={handleDefaultVisibleColumnsChange}
contentDataSource={queryDetailsDataSource}
entityTypeDataSource={entityTypeDataSource}
headline={renderHeadline}
Expand Down

0 comments on commit 02c17fb

Please sign in to comment.