From a9081fad9f61626098c37117720da21b6304f248 Mon Sep 17 00:00:00 2001 From: Ed Olivares <34591886+eudoroolivares2016@users.noreply.github.com> Date: Mon, 27 Jan 2025 16:47:29 -0500 Subject: [PATCH] DCAT-2: Fix the usage score order DCAT-2: Trying to ensure test passing DCAT-2: Test removing the waitFor DCAT-2: Use env var for more consistency DCAT-2: Increase timeout that available to the waitFor DCAT-2: Fix the usage score order --- src/ts/component/SearchResultsList/SearchResultsList.tsx | 6 ++++-- .../SearchResultsList/__tests__/SearchResultList.test.tsx | 4 ++-- src/ts/pages/DataCatalog/__tests__/DataCatalog.test.tsx | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ts/component/SearchResultsList/SearchResultsList.tsx b/src/ts/component/SearchResultsList/SearchResultsList.tsx index ac9f6d5..4e9a55c 100644 --- a/src/ts/component/SearchResultsList/SearchResultsList.tsx +++ b/src/ts/component/SearchResultsList/SearchResultsList.tsx @@ -93,13 +93,15 @@ export const SearchResultsList: React.FC = ({ const rows = [10, 20, 50, 100] + const descUsageScore = '-usage_score' + const sortKeys: SortKey[] = [ { key: 'relevance', value: 'Relevance' }, { - key: 'usage_score', + key: descUsageScore, value: 'Usage' }, { @@ -255,7 +257,7 @@ export const SearchResultsList: React.FC = ({ SORT: - {currentSortKey === 'usage_score' ? 'usage' : currentSortKey } + {currentSortKey === descUsageScore ? 'usage' : currentSortKey } diff --git a/src/ts/component/SearchResultsList/__tests__/SearchResultList.test.tsx b/src/ts/component/SearchResultsList/__tests__/SearchResultList.test.tsx index a7ce6dd..40ee80e 100644 --- a/src/ts/component/SearchResultsList/__tests__/SearchResultList.test.tsx +++ b/src/ts/component/SearchResultsList/__tests__/SearchResultList.test.tsx @@ -266,7 +266,7 @@ describe('SearchResultList', () => { describe('Sort key', () => { describe('when selecting a sort key', () => { - test('calls setQuerySort with usage_score', async () => { + test('calls setQuerySort with -usage_score', async () => { const { props, user } = setup() await waitFor(async () => { @@ -275,7 +275,7 @@ describe('SearchResultList', () => { }) expect(props.setQuerySort).toHaveBeenCalledTimes(1) - expect(props.setQuerySort).toHaveBeenCalledWith('usage_score') + expect(props.setQuerySort).toHaveBeenCalledWith('-usage_score') }) test('calls setQuerySort with start_data', async () => { diff --git a/src/ts/pages/DataCatalog/__tests__/DataCatalog.test.tsx b/src/ts/pages/DataCatalog/__tests__/DataCatalog.test.tsx index 91f7e45..795d32c 100644 --- a/src/ts/pages/DataCatalog/__tests__/DataCatalog.test.tsx +++ b/src/ts/pages/DataCatalog/__tests__/DataCatalog.test.tsx @@ -416,8 +416,8 @@ describe('DataCatalog', () => { // Click the Next button await waitFor(async () => { - await user.click(screen.getByRole('button', { name: 'Next' })) - }) + await user.click(await screen.findByRole('button', { name: 'Next' })) + }, { timeout: 5000 }) const pagination = await screen.findByRole('list', { name: /pagination/i }) const pageItems = within(pagination).getAllByRole('listitem') @@ -462,7 +462,7 @@ describe('DataCatalog', () => { expect(await screen.findByText('Found collection 1')).toBeTruthy() - setupMockResponse('page_num=1&sort_key=usage_score') + setupMockResponse('page_num=1&sort_key=-usage_score') await waitFor(async () => { await user.click(screen.getByRole('button', { name: /SORT:/ })) @@ -477,7 +477,7 @@ describe('DataCatalog', () => { describe('when loading a URL containing a sort_key', () => { test('loads the page, using and displaying the appropriate sort key', async () => { - const params = 'sort_key=usage_score' + const params = 'sort_key=-usage_score' setupMockResponse(params, 1, 1, 'Found ')