From 17c762ccc7f49a4ec231ac881ce3253a1f7f0709 Mon Sep 17 00:00:00 2001 From: Johan Bisse Mattsson Date: Thu, 27 Jun 2024 14:32:37 +0200 Subject: [PATCH] LWS-213: Change default limit of results to 20 (#1076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change default limit of results to 20 * Update changelog * Update en.md * Update sv.md --------- Co-authored-by: Kalle Wåhlin <72360110+kwahlin@users.noreply.github.com> --- lxl-web/src/lib/utils/addDefaultSearchParams.test.ts | 6 +++--- lxl-web/src/lib/utils/addDefaultSearchParams.ts | 2 +- lxl-web/src/lib/utils/http.test.ts | 4 ++-- lxl-web/src/routes/(app)/[[lang=lang]]/help/en.md | 3 ++- lxl-web/src/routes/(app)/[[lang=lang]]/help/sv.md | 11 ++++++----- lxl-web/tests/error.spec.ts | 2 +- lxl-web/tests/find.spec.ts | 10 +++++----- lxl-web/tests/index.spec.ts | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lxl-web/src/lib/utils/addDefaultSearchParams.test.ts b/lxl-web/src/lib/utils/addDefaultSearchParams.test.ts index 2d354522c..ea54d41b1 100644 --- a/lxl-web/src/lib/utils/addDefaultSearchParams.test.ts +++ b/lxl-web/src/lib/utils/addDefaultSearchParams.test.ts @@ -6,7 +6,7 @@ describe('addDefaultSearchParams', () => { expect(addDefaultSearchParams(new URLSearchParams())).toStrictEqual( new URLSearchParams([ ['_q', '*'], - ['_limit', '10'], + ['_limit', '20'], ['_offset', '0'], ['_sort', ''] ]) @@ -16,7 +16,7 @@ describe('addDefaultSearchParams', () => { expect(addDefaultSearchParams(new URLSearchParams([['_q', 'test']]))).toStrictEqual( new URLSearchParams([ ['_q', 'test'], - ['_limit', '10'], + ['_limit', '20'], ['_offset', '0'], ['_sort', ''] ]) @@ -27,7 +27,7 @@ describe('addDefaultSearchParams', () => { new URLSearchParams([ ['_offset', '30'], ['_q', '*'], - ['_limit', '10'], + ['_limit', '20'], ['_sort', ''] ]) ); diff --git a/lxl-web/src/lib/utils/addDefaultSearchParams.ts b/lxl-web/src/lib/utils/addDefaultSearchParams.ts index 8d4c0a536..c57fd61b0 100644 --- a/lxl-web/src/lib/utils/addDefaultSearchParams.ts +++ b/lxl-web/src/lib/utils/addDefaultSearchParams.ts @@ -8,7 +8,7 @@ function addDefaultSearchParams(searchParams: URLSearchParams): URLSearchParams params.set('_q', '*'); } if (!params.has('_limit')) { - params.set('_limit', '10'); + params.set('_limit', '20'); } if (!params.has('_offset')) { params.set('_offset', '0'); diff --git a/lxl-web/src/lib/utils/http.test.ts b/lxl-web/src/lib/utils/http.test.ts index a44147f59..b96b12644 100644 --- a/lxl-web/src/lib/utils/http.test.ts +++ b/lxl-web/src/lib/utils/http.test.ts @@ -8,8 +8,8 @@ describe('relativize', () => { ); }); it('removes the opening slash from a relative path', () => { - expect(relativizeUrl('/find?q=*&@type=Work&_limit=10')).toStrictEqual( - 'find?q=*&@type=Work&_limit=10' + expect(relativizeUrl('/find?q=*&@type=Work&_limit=20')).toStrictEqual( + 'find?q=*&@type=Work&_limit=20' ); }); }); diff --git a/lxl-web/src/routes/(app)/[[lang=lang]]/help/en.md b/lxl-web/src/routes/(app)/[[lang=lang]]/help/en.md index 2005fd719..097e2071d 100644 --- a/lxl-web/src/routes/(app)/[[lang=lang]]/help/en.md +++ b/lxl-web/src/routes/(app)/[[lang=lang]]/help/en.md @@ -10,9 +10,10 @@ Here we will continuously provide information about newly added features and pla ### 2024-06-27 +- Change default number of hits per page to 20 - Added search on result list for people and subjects - Hide labels for free text queries and add quotes instead -- Fix bug which prevented closing of initially opened holdings modal +- Bug fixes ### 2024-06-12 diff --git a/lxl-web/src/routes/(app)/[[lang=lang]]/help/sv.md b/lxl-web/src/routes/(app)/[[lang=lang]]/help/sv.md index 2dc673697..7e7441db2 100644 --- a/lxl-web/src/routes/(app)/[[lang=lang]]/help/sv.md +++ b/lxl-web/src/routes/(app)/[[lang=lang]]/help/sv.md @@ -10,8 +10,9 @@ Här kommer vi kontinuerligt berätta om nytillkomna funktioner och planerad utv ### 2024-06-27 +- Ändra antalet sökträffar per sida till 20 - Dölj etikett för fritextsökningar och lägg till citattecken istället -- Rätta bugg som förhindrade stängning av beståndsmodal +- Buggrättningar - Stöd för sök i träfflistan för personer och ämnen ### 2024-06-12 @@ -103,19 +104,19 @@ Här följer några exempel som går att skriva in som sökfrågor direkt i sök Engelska och franska verk som matchar sökfrasen "pippi långstrump" som givits ut efter år 2002: -[`pippi långstrump språk:(engelska OR franska) ÅR>2002`]() +[`pippi långstrump språk:(engelska OR franska) ÅR>2002`]() Material med utgivning mellan 2010 och 2024, som är på svenska och har [drakar](https://id.kb.se/term/sao/Drakar) som ämne: -[`språk:svenska ÅR>2010 ÅR<=2024 ämne:"sao:Drakar"`](https://beta.libris-qa.kb.se/find?_i=&_q=SPR%C3%85K:svenska+%C3%85R%3E2010+%C3%85R%3C%3D2024+subject:%22sao:Drakar%22&_limit=10&_x=advanced) +[`språk:svenska ÅR>2010 ÅR<=2024 ämne:"sao:Drakar"`](https://beta.libris-qa.kb.se/find?_i=&_q=SPR%C3%85K:svenska+%C3%85R%3E2010+%C3%85R%3C%3D2024+subject:%22sao:Drakar%22&_limit=20&_x=advanced) Fritextsökning på träd\*, där alla träffar ingår i bibliografin Digitaliserat Svenskt Tryck men som inte har verkstyp "Text": -[`träd* bibliografi:"sigel:DST" NOT typ:Text`](https://beta.libris-qa.kb.se/find?_i=tr%C3%A4d*&_q=tr%C3%A4d*+bibliography:%22sigel:DST%22+NOT+%22rdf:type%22:Text&_limit=10&_x=advanced) +[`träd* bibliografi:"sigel:DST" NOT typ:Text`](https://beta.libris-qa.kb.se/find?_i=tr%C3%A4d*&_q=tr%C3%A4d*+bibliography:%22sigel:DST%22+NOT+%22rdf:type%22:Text&_limit=20&_x=advanced) Verk där Selma Lagerlöf är författare som har minst en upplaga som är en elektronisk resurs: -[`författare:"selma lagerlöf" "hasInstanceType":Electronic`](https://beta.libris-qa.kb.se/find?_i=&_q=F%C3%96RF:%22selma+lagerl%C3%B6f%22+hasInstanceType:Electronic&_limit=10&_x=advanced) +[`författare:"selma lagerlöf" "hasInstanceType":Electronic`](https://beta.libris-qa.kb.se/find?_i=&_q=F%C3%96RF:%22selma+lagerl%C3%B6f%22+hasInstanceType:Electronic&_limit=20&_x=advanced) ### Detaljvyn diff --git a/lxl-web/tests/error.spec.ts b/lxl-web/tests/error.spec.ts index 485be1511..e73d1fca1 100644 --- a/lxl-web/tests/error.spec.ts +++ b/lxl-web/tests/error.spec.ts @@ -44,7 +44,7 @@ test.describe('Missing resource page', () => { test.describe('Find page with invalid query', () => { test.beforeEach(async ({ page }) => { await page.goto( - '/find?_i=geh&_q=test+unrecognizedproperty:%22https://id.kb.se/language/swe%22&_limit=10' + '/find?_i=geh&_q=test+unrecognizedproperty:%22https://id.kb.se/language/swe%22&_limit=20' ); }); test('has expected h1', async ({ page }) => { diff --git a/lxl-web/tests/find.spec.ts b/lxl-web/tests/find.spec.ts index 9938dd003..b45ae49bd 100644 --- a/lxl-web/tests/find.spec.ts +++ b/lxl-web/tests/find.spec.ts @@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test'; import AxeBuilder from '@axe-core/playwright'; test.beforeEach(async ({ page }) => { - await page.goto('/find?_q=d&_limit=10&_offset=0&_sort=&_i=d'); + await page.goto('/find?_q=f&_limit=20&_offset=0&_sort=&_i=f'); }); test('should not have any detectable a11y issues', async ({ page }) => { @@ -23,8 +23,8 @@ test('can change the language', async ({ page }) => { await expect(page).toHaveURL(/\/en\/find/); }); -test('displays 10 search cards on a page', async ({ page }) => { - await expect(page.getByTestId('search-card')).toHaveCount(10); +test('displays 20 search cards on a page', async ({ page }) => { + await expect(page.getByTestId('search-card')).toHaveCount(20); }); test('search card contains a link', async ({ page }) => { @@ -63,9 +63,9 @@ test('has pagination', async ({ page }) => { }); test('can paginate to next and previous', async ({ page }) => { - await expect(page).not.toHaveURL(/_offset=10/); + await expect(page).not.toHaveURL(/_offset=20/); await page.getByTestId('pagination').getByLabel('Nästa sida').click(); - await expect(page).toHaveURL(/_offset=10/); + await expect(page).toHaveURL(/_offset=20/); await page.getByTestId('pagination').getByLabel('Föregående sida').click(); await expect(page).not.toHaveURL(/_offset=/); }); diff --git a/lxl-web/tests/index.spec.ts b/lxl-web/tests/index.spec.ts index 294307454..2372427dc 100644 --- a/lxl-web/tests/index.spec.ts +++ b/lxl-web/tests/index.spec.ts @@ -34,5 +34,5 @@ test('url is populated with correct searchparams', async ({ page }) => { await page.getByTestId('main-search').click(); await page.getByTestId('main-search').fill('somephrase'); await page.getByTestId('main-search').press('Enter'); - await expect(page).toHaveURL(/_q=somephrase&_limit=10&_offset=0&_sort=&_i=somephrase/); + await expect(page).toHaveURL(/_q=somephrase&_limit=20&_offset=0&_sort=&_i=somephrase/); });