From 6a3c7bbfb515a281485fbe8c69e894468c15397d Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 26 Jun 2024 13:53:43 -0500 Subject: [PATCH 1/8] initial commit this consists of basic tests for making sure the query is responsive --- __playwright__/circulars/archive.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 55512cadd..db27ae528 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -17,4 +17,16 @@ test.describe('Circulars archive page', () => { ) } }) + + test('search is functional via mouse click', async ({ page }) => { + await page.goto('/circulars') + await page.locator('#query').fill('GRB') + await page.getByRole('button', { name: 'Search' }).click() + }) + + test('search is functional via keyboard input', async ({ page }) => { + await page.goto('/circulars') + await page.locator('#query').fill('GRB') + await page.getByTestId('textInput').press('Enter') + }) }) From 0e6b705b4e8f1604d84beae774d9dfa9b2962394 Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 26 Jun 2024 14:33:17 -0500 Subject: [PATCH 2/8] add test for searching body --- __playwright__/circulars/archive.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index db27ae528..2f27417a5 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -1,4 +1,6 @@ -import { test } from '@playwright/test' +import { expect, test } from '@playwright/test' + +const expectedSubjectQueryResults = ['34769'] test.describe('Circulars archive page', () => { test('responds to changes in the number of results per page', async ({ @@ -29,4 +31,11 @@ test.describe('Circulars archive page', () => { await page.locator('#query').fill('GRB') await page.getByTestId('textInput').press('Enter') }) + + test('search finds query string in body of circular', async ({ page }) => { + await page.goto('/circulars?query=ATLAS23srq') + await expect( + page.locator('a[href="/circulars/34730?query=ATLAS23srq"]') + ).toBeVisible() + }) }) From 4c1e2ff2cb477386177789eaac60075615c9dacf Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 26 Jun 2024 14:39:13 -0500 Subject: [PATCH 3/8] delete const --- __playwright__/circulars/archive.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 2f27417a5..cab73ee96 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -1,7 +1,5 @@ import { expect, test } from '@playwright/test' -const expectedSubjectQueryResults = ['34769'] - test.describe('Circulars archive page', () => { test('responds to changes in the number of results per page', async ({ page, From bcc019424c8a6a3014247bb4b25a24d4d0754273 Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 26 Jun 2024 14:51:04 -0500 Subject: [PATCH 4/8] test for minimum correct results --- __playwright__/circulars/archive.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index cab73ee96..333ab3696 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -36,4 +36,16 @@ test.describe('Circulars archive page', () => { page.locator('a[href="/circulars/34730?query=ATLAS23srq"]') ).toBeVisible() }) + + test('search finds all results related to a specific object', async ({ + page, + }) => { + await page.goto('/circulars?query=230812B') + await page.waitForFunction( + (n) => + document.getElementsByTagName('ol')[0].getElementsByTagName('li') + .length >= n, + 64 + ) + }) }) From 1cf9c39b646df48eb7c3038cbc605070d6497859 Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 26 Jun 2024 14:56:11 -0500 Subject: [PATCH 5/8] additional test for irrelevant query --- __playwright__/circulars/archive.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 333ab3696..fbf33c735 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -48,4 +48,14 @@ test.describe('Circulars archive page', () => { 64 ) }) + + test('search finds no results for irrelevant query', async ({ page }) => { + await page.goto('/circulars?query=230812C') + await page.waitForFunction( + (n) => + document.getElementsByTagName('ol')[0].getElementsByTagName('li') + .length === n, + 0 + ) + }) }) From 06a9dfd4559a211b55f53814a57e5d7bee32ff43 Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Wed, 26 Jun 2024 15:01:43 -0500 Subject: [PATCH 6/8] additional testing for exact string queries --- __playwright__/circulars/archive.spec.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index fbf33c735..5744f7fd8 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -49,7 +49,8 @@ test.describe('Circulars archive page', () => { ) }) - test('search finds no results for irrelevant query', async ({ page }) => { + test('search finds no results for query with typo', async ({ page }) => { + // this highlights this search behaviour does not capture cases where there is a minor typo await page.goto('/circulars?query=230812C') await page.waitForFunction( (n) => @@ -58,4 +59,18 @@ test.describe('Circulars archive page', () => { 0 ) }) + + test('search finds results that contain exact string but not similar strings', async ({ + page, + }) => { + // this highlights the search returns limited results because it is looking for exact matches to the string + // this should return many more results and include strings like 230812B + await page.goto('/circulars?query=230812') + await page.waitForFunction( + (n) => + document.getElementsByTagName('ol')[0].getElementsByTagName('li') + .length === n, + 1 + ) + }) }) From e069102cdaf6aaf8919195be0fd71125a8852fff Mon Sep 17 00:00:00 2001 From: dakota002 Date: Mon, 8 Jul 2024 14:28:53 -0400 Subject: [PATCH 7/8] Example of using the waitForLoadState function and counts of results --- __playwright__/circulars/archive.spec.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 5744f7fd8..4b3c3d211 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -41,23 +41,18 @@ test.describe('Circulars archive page', () => { page, }) => { await page.goto('/circulars?query=230812B') - await page.waitForFunction( - (n) => - document.getElementsByTagName('ol')[0].getElementsByTagName('li') - .length >= n, - 64 - ) + await page.waitForLoadState() + await expect(page.locator('ol', { has: page.locator('li') })).toBeVisible() + expect(await page.locator('ol > li').count()).toBe(64) }) test('search finds no results for query with typo', async ({ page }) => { // this highlights this search behaviour does not capture cases where there is a minor typo await page.goto('/circulars?query=230812C') - await page.waitForFunction( - (n) => - document.getElementsByTagName('ol')[0].getElementsByTagName('li') - .length === n, - 0 - ) + await page.waitForLoadState() + await expect( + page.locator('ol', { has: page.locator('li') }) + ).not.toBeVisible() }) test('search finds results that contain exact string but not similar strings', async ({ From 35ff0c908144c65218b8bf1142e3781a61271cf7 Mon Sep 17 00:00:00 2001 From: tylerbarna Date: Mon, 15 Jul 2024 16:02:38 -0500 Subject: [PATCH 8/8] use locator instead of DOM manipulation --- __playwright__/circulars/archive.spec.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 4b3c3d211..c0cc33262 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -58,14 +58,12 @@ test.describe('Circulars archive page', () => { test('search finds results that contain exact string but not similar strings', async ({ page, }) => { - // this highlights the search returns limited results because it is looking for exact matches to the string - // this should return many more results and include strings like 230812B + // This highlights the search returns limited results because it is looking for exact matches to the string + // This should return many more results and include strings like 230812B await page.goto('/circulars?query=230812') - await page.waitForFunction( - (n) => - document.getElementsByTagName('ol')[0].getElementsByTagName('li') - .length === n, - 1 - ) + const orderedListLocator = page.locator('ol') + const listItemLocator = orderedListLocator.locator('li') + + await expect(listItemLocator).toHaveCount(1) }) })