Skip to content

Commit

Permalink
Fix home page tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dualcnhq committed Oct 23, 2024
1 parent 97fe102 commit 9fa4e33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/home/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down
4 changes: 4 additions & 0 deletions tests/page-objects/home-page.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {
Expand Down

0 comments on commit 9fa4e33

Please sign in to comment.