Skip to content

Commit

Permalink
Fix Lucene search not working & update tests
Browse files Browse the repository at this point in the history
- Fix search not working when Lucene search mode selected
- Update tests to reflect URL params chhanges
  • Loading branch information
kennethnym committed Aug 31, 2023
1 parent dfab365 commit 19743c0
Show file tree
Hide file tree
Showing 35 changed files with 113 additions and 93 deletions.
14 changes: 7 additions & 7 deletions packages/datagateway-common/src/api/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ describe('generic api functions', () => {
});

expect(pushSpy).toHaveBeenCalledWith({
search: '?semanticSearch=false',
search: '?',
});
});
});
Expand Down Expand Up @@ -435,7 +435,7 @@ describe('generic api functions', () => {
});

expect(pushSpy).toHaveBeenCalledWith({
search: '?semanticSearch=false',
search: '?',
});
});
});
Expand Down Expand Up @@ -481,7 +481,7 @@ describe('generic api functions', () => {
});

expect(pushSpy).toHaveBeenCalledWith({
search: '?semanticSearch=false',
search: '?',
});
});
});
Expand Down Expand Up @@ -643,7 +643,7 @@ describe('generic api functions', () => {

expect(replaceSpy).toHaveBeenCalledWith({
search:
'?semanticSearch=false&filters=%7B%22name%22%3A%7B%22value%22%3A%22test%22%2C%22type%22%3A%22include%22%7D%2C%22title%22%3A%7B%22value%22%3A%22test2%22%2C%22type%22%3A%22include%22%7D%7D',
'?filters=%7B%22name%22%3A%7B%22value%22%3A%22test%22%2C%22type%22%3A%22include%22%7D%2C%22title%22%3A%7B%22value%22%3A%22test2%22%2C%22type%22%3A%22include%22%7D%7D',
});
});

Expand All @@ -665,7 +665,7 @@ describe('generic api functions', () => {
});

expect(replaceSpy).toHaveBeenCalledWith({
search: '?semanticSearch=false&sort=%7B%22name%22%3A%22asc%22%7D',
search: '?sort=%7B%22name%22%3A%22asc%22%7D',
});
});

Expand Down Expand Up @@ -794,7 +794,7 @@ describe('generic api functions', () => {
result.current(null);
});

expect(pushSpy).toHaveBeenLastCalledWith('?semanticSearch=false');
expect(pushSpy).toHaveBeenLastCalledWith('?');
});
});

Expand Down Expand Up @@ -822,7 +822,7 @@ describe('generic api functions', () => {
result.current(null);
});

expect(pushSpy).toHaveBeenLastCalledWith('?semanticSearch=false');
expect(pushSpy).toHaveBeenLastCalledWith('?');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('PageContainer Component', () => {
cy.get('[aria-rowindex="1"] [aria-colindex="4"]').contains('24');

cy.get('[data-testid="clear-filters-button"]').click();
cy.url().should('eq', `${url}?semanticSearch=false`);
cy.url().should('eq', `${url}?`);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe('PageContainer - Tests', () => {
expect(
await screen.findByRole('button', { name: 'app.clear_filters' })
).toBeDisabled();
expect(history.location.search).toEqual('?semanticSearch=false');
expect(history.location.search).toEqual('?');
});

it('display clear filters button and clear for filters onClick (/my-data/DLS)', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('Dataset - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -223,7 +223,7 @@ describe('Dataset - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('DLS Datasets - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -136,7 +136,7 @@ describe('DLS Datasets - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ describe('DLS Proposals - Card View', () => {
await user.type(filter, 'test');

expect(history.location.search).toBe(
`?semanticSearch=false&filters=${encodeURIComponent(
`?filters=${encodeURIComponent(
'{"title":{"value":"test","type":"include"}}'
)}`
);

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('uses default sort', () => {
renderComponent();
expect(history.length).toBe(1);
expect(history.location.search).toBe(
`?semanticSearch=false&sort=${encodeURIComponent('{"title":"asc"}')}`
`?sort=${encodeURIComponent('{"title":"asc"}')}`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('DLS Visits - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -139,7 +139,7 @@ describe('DLS Visits - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe('Investigation - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -268,7 +268,7 @@ describe('Investigation - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ describe('ISIS Data Publication - Card View', () => {
await user.type(filter, 'Test');

expect(history.location.search).toBe(
`?semanticSearch=false&filters=${encodeURIComponent(
`?filters=${encodeURIComponent(
'{"title":{"value":"Test","type":"include"}}'
)}`
);

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

jest.useRealTimers();
});
Expand All @@ -183,13 +183,13 @@ describe('ISIS Data Publication - Card View', () => {

await user.type(filterInput, '2019-08-06');
expect(history.location.search).toBe(
`?semanticSearch=false&filters=${encodeURIComponent(
`?filters=${encodeURIComponent(
'{"publicationDate":{"endDate":"2019-08-06"}}'
)}`
);

await user.clear(filterInput);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand All @@ -206,7 +206,7 @@ describe('ISIS Data Publication - Card View', () => {
);

expect(history.location.search).toBe(
`?semanticSearch=false&sort=${encodeURIComponent('{"title":"asc"}')}`
`?sort=${encodeURIComponent('{"title":"asc"}')}`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('ISIS Datasets - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -171,7 +171,7 @@ describe('ISIS Datasets - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('ISIS Facility Cycles - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -136,7 +136,7 @@ describe('ISIS Facility Cycles - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('ISIS Instruments - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('uses default sort', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('ISIS Investigations - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -288,7 +288,7 @@ describe('ISIS Investigations - Card View', () => {

await user.clear(filter);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('Datafile table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(6);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});
it('updates filter query params on date filter', async () => {
applyDatePickerWorkaround();
Expand All @@ -248,7 +248,7 @@ describe('Datafile table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(3);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('Dataset table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(6);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -257,7 +257,7 @@ describe('Dataset table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(3);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('DLS datafiles table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(6);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -217,7 +217,7 @@ describe('DLS datafiles table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(3);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand All @@ -239,7 +239,7 @@ describe('DLS datafiles table component', () => {

expect(history.length).toBe(2);
expect(history.location.search).toBe(
`?semanticSearch=false&sort=${encodeURIComponent('{"name":"asc"}')}`
`?sort=${encodeURIComponent('{"name":"asc"}')}`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('DLS Dataset table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(6);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -220,7 +220,7 @@ describe('DLS Dataset table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(3);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('DLS MyData table component', () => {

await user.clear(filterInput);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('updates filter query params on date filter', async () => {
Expand All @@ -246,7 +246,7 @@ describe('DLS MyData table component', () => {

await user.clear(filterInput);

expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');

cleanupDatePickerWorkaround();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('DLS Proposals table component', () => {
await user.clear(filterInput);

expect(history.length).toBe(6);
expect(history.location.search).toBe('?semanticSearch=false');
expect(history.location.search).toBe('?');
});

it('uses default sort', () => {
Expand Down
Loading

0 comments on commit 19743c0

Please sign in to comment.