From 9fa4e337e84ecfa37ee305626b1873fe160d36bd Mon Sep 17 00:00:00 2001 From: clau <1281581+dualcnhq@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:57:58 -0700 Subject: [PATCH] Fix home page tests --- tests/home/home.spec.ts | 22 +++++++++++----------- tests/page-objects/home-page.ts | 4 ++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/home/home.spec.ts b/tests/home/home.spec.ts index 11c4845a..f90a6670 100644 --- a/tests/home/home.spec.ts +++ b/tests/home/home.spec.ts @@ -10,39 +10,39 @@ test('Home page displays all of its elements', async ({ homePage }) => { test('Do simple metadata search', async ({ homePage }) => { await test.step(`Query for "cats" and validate that "cats" appears as the search term `, async () => { - await homePage.collectionBrowser.queryFor('cats'); - await homePage.collectionBrowser.validateSearchInput('cats'); + await homePage.collectionSearchInput.queryFor('cats'); + await homePage.collectionSearchInput.validateSearchInput('cats'); }); }); test('Do simple full-text search', async ({ homePage }) => { await test.step(`Select text contents in search options, query for "dogs" and validate that "dogs" appears as the search term`, async () => { - await homePage.collectionBrowser.clickSearchInputOption(SearchOption.TEXT, 'search'); - await homePage.collectionBrowser.queryFor('dogs'); - await homePage.collectionBrowser.validateSearchInput('dogs'); + await homePage.collectionSearchInput.clickSearchInputOption(SearchOption.TEXT, 'search'); + await homePage.collectionSearchInput.queryFor('dogs'); + await homePage.collectionSearchInput.validateSearchInput('dogs'); }); }); test('Do simple TV search', async ({ homePage }) => { await test.step(`Select TV in search options, query for "iguanas" and validate that "iguanas" appears as the search term`, async () => { - await homePage.collectionBrowser.clickSearchInputOption(SearchOption.TV, 'search'); - await homePage.collectionBrowser.queryFor('iguanas'); + await homePage.collectionSearchInput.clickSearchInputOption(SearchOption.TV, 'search'); + await homePage.collectionSearchInput.queryFor('iguanas'); await homePage.collectionBrowser.validateTVPage('iguanas'); }); }); test('Do simple radio search', async ({ homePage }) => { await test.step(`Select radio in search options, query for "rabbits" and validate that "rabbits" appears as the search term`, async () => { - await homePage.collectionBrowser.clickSearchInputOption(SearchOption.RADIO, 'search'); - await homePage.collectionBrowser.queryFor('rabbits'); + await homePage.collectionSearchInput.clickSearchInputOption(SearchOption.RADIO, 'search'); + await homePage.collectionSearchInput.queryFor('rabbits'); await homePage.collectionBrowser.validateRadioPage('rabbits'); }); }); test('Redirect web search to Wayback machine page', async ({ homePage }) => { await test.step(`Select TV in search options, query for "parrots" and validate that "parrots" appears as the search term`, async () => { - await homePage.collectionBrowser.clickSearchInputOption(SearchOption.WEB, 'search'); - await homePage.collectionBrowser.queryFor('parrots'); + await homePage.collectionSearchInput.clickSearchInputOption(SearchOption.WEB, 'search'); + await homePage.collectionSearchInput.queryFor('parrots'); await homePage.collectionBrowser.validateWaybackPage('parrots'); }); }); diff --git a/tests/page-objects/home-page.ts b/tests/page-objects/home-page.ts index 548a9e7a..33d1f52d 100644 --- a/tests/page-objects/home-page.ts +++ b/tests/page-objects/home-page.ts @@ -1,6 +1,7 @@ import { type Page, Locator, expect } from '@playwright/test'; import { CollectionBrowser } from './collection-browser'; +import { CollectionSearchInput } from './collection-search-input'; export class HomePage { readonly page: Page; @@ -9,11 +10,14 @@ export class HomePage { readonly collectionBrowser: CollectionBrowser; + readonly collectionSearchInput: CollectionSearchInput; + public constructor(page: Page) { this.page = page; this.waybackSearch = this.page.locator('ia-wayback-search'); this.collectionBrowser = new CollectionBrowser(page); + this.collectionSearchInput = new CollectionSearchInput(page); } async validatePageElements() {