Skip to content

Commit

Permalink
Playwright circulars archive basic tests (#2423)
Browse files Browse the repository at this point in the history
Resolves #2350.
  • Loading branch information
tylerbarna authored Jul 15, 2024
1 parent 530bc44 commit 72131ae
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion __playwright__/circulars/archive.spec.ts
Original file line number Diff line number Diff line change
@@ -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 ({
Expand All @@ -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)
})
})

0 comments on commit 72131ae

Please sign in to comment.