From 72131aeee7a54737d8adcb0197a805fb410f33f0 Mon Sep 17 00:00:00 2001 From: Tyler Barna <57914086+tylerbarna@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:18:09 -0500 Subject: [PATCH] Playwright circulars archive basic tests (#2423) Resolves #2350. --- __playwright__/circulars/archive.spec.ts | 51 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/__playwright__/circulars/archive.spec.ts b/__playwright__/circulars/archive.spec.ts index 55512cadd..c0cc33262 100644 --- a/__playwright__/circulars/archive.spec.ts +++ b/__playwright__/circulars/archive.spec.ts @@ -1,4 +1,4 @@ -import { test } from '@playwright/test' +import { expect, test } from '@playwright/test' test.describe('Circulars archive page', () => { test('responds to changes in the number of results per page', async ({ @@ -17,4 +17,53 @@ 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') + }) + + 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() + }) + + test('search finds all results related to a specific object', async ({ + page, + }) => { + await page.goto('/circulars?query=230812B') + 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.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 ({ + 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') + const orderedListLocator = page.locator('ol') + const listItemLocator = orderedListLocator.locator('li') + + await expect(listItemLocator).toHaveCount(1) + }) })