Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
dualcnhq committed Jun 4, 2024
1 parent 2aa31a9 commit e7d9784
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 450 deletions.
137 changes: 54 additions & 83 deletions tests/collection/collection-faceting.spec.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import { test } from '../fixtures';
import { test } from '../../tests/fixtures';

import { FacetGroupLocatorLabel, LayoutViewModeLocator } from '../models';
import {
FacetGroupLocatorLabel,
LayoutViewModeLocator,
} from '../../tests/models';

import { CollectionPage } from '../page-objects/collection-page';

let collectionPage: CollectionPage;

test.describe('Collection Page - Faceting tests', () => {
test.describe.configure({ mode: 'serial' });

test(`Search and go to "oldtimeradio" collection page`, async ({
browser,
}) => {
const browserPage = await browser.newPage();
collectionPage = new CollectionPage(browserPage);

await test.step(`Go to "oldtimeradio" collection page`, async () => {
await collectionPage.visit('oldtimeradio');
});
});

test('Verify if facets appear on first load', async () => {
await test.step('Assert facet group headers count', async () => {
await collectionPage.collectionFacets.assertCollectionFacetGroupCount();
});
test(`Verify if facets appear on first load`, async ({ collectionPage }) => {
await test.step('Assert facet group headers count', async () => {
await collectionPage.collectionFacets.assertCollectionFacetGroupCount();
});
});

test(`Select a facet for "videos"`, async () => {
test(
`Select a facet for videos and clear facet filters`,
async ({ collectionPage }) => {
await test.step(`Select "movies" from inside "Media Type" facet group and check 5 item results for "Movie" tile icon titles`, async () => {
await collectionPage.collectionFacets.selectFacetByGroup(
FacetGroupLocatorLabel.MEDIATYPE,
Expand All @@ -40,66 +27,54 @@ test.describe('Collection Page - Faceting tests', () => {
5,
);
});
});

test('Clear facet filters', async () => {
await test.step(`Click "Clear all filters"`, async () => {
await collectionPage.searchPage.clickClearAllFilters();
await collectionPage.searchPage.assertClearAllFiltersNotVisible();
await collectionPage.collectionBrowser.clickClearAllFilters();
await collectionPage.collectionBrowser.assertClearAllFiltersNotVisible();
});
},
);

test(`Select Year Published range via date picker`, async ({
collectionPage,
}) => {
await test.step(`Enter 2014 in start date text field (leftmost text box) and new results will be loaded`, async () => {
await collectionPage.collectionFacets.fillUpYearFilters('1954', '1955');
await collectionPage.collectionFacets.displaysResultCount();
});

test(`Select Year Published range via date picker`, async () => {
await test.step(`Enter 2014 in start date text field (leftmost text box) and new results will be loaded`, async () => {
await collectionPage.collectionFacets.fillUpYearFilters('1954', '1955');
await collectionPage.collectionFacets.displaysResultCount();
});

await test.step(`Switch to list view mode to check the first 10 item results Published texts are ONLY 2014 or 2015`, async () => {
await collectionPage.infiniteScroller.clickViewMode(
LayoutViewModeLocator.LIST,
);
await collectionPage.infiniteScroller.validateIncludedFacetedResults(
'list-date',
['1954', '1955'],
true,
10,
);
});
});

test(`Negative facet to exclude "audio"`, async () => {
await test.step(`Click "Clear all filters" and switch to Tile view mode`, async () => {
await collectionPage.searchPage.clickClearAllFilters();
await collectionPage.infiniteScroller.clickViewMode(
LayoutViewModeLocator.TILE,
);
});

await test.step(`Select "eye" icon near "audio" from inside "Media Type" facet group and check if there's no results with "Audio" tile icon title`, async () => {
await collectionPage.collectionFacets.selectFacetByGroup(
FacetGroupLocatorLabel.MEDIATYPE,
'audio',
'negative',
);
await collectionPage.infiniteScroller.validateIncludedFacetedResults(
'tile-collection-icontitle',
['Audio'],
false,
20,
);
});
await test.step(`Switch to list view mode to check the first 10 item results Published texts are ONLY 2014 or 2015`, async () => {
await collectionPage.infiniteScroller.clickViewMode(
LayoutViewModeLocator.LIST,
);
await collectionPage.infiniteScroller.validateIncludedFacetedResults(
'list-date',
['1954', '1955'],
true,
10,
);
});
});

test.skip(`Filter for title beginning with "X"`, async () => {
// TODO
test(`Negative facet to exclude audio`, async ({ collectionPage }) => {
await test.step(`Select "eye" icon near "audio" from inside "Media Type" facet group and check if there's no results with "Audio" tile icon title`, async () => {
await collectionPage.collectionFacets.selectFacetByGroup(
FacetGroupLocatorLabel.MEDIATYPE,
'audio',
'negative',
);
await collectionPage.infiniteScroller.validateIncludedFacetedResults(
'tile-collection-icontitle',
['Audio'],
false,
20,
);
});
});

test(`Facets can be selected via "Select filters" modal`, async () => {
await test.step(`Click "Clear all filters"`, async () => {
await collectionPage.searchPage.clickClearAllFilters();
});

test(
`Facets can be selected via Select filters modal`,
async ({ collectionPage }) => {
await test.step(`Click "More" button under Subject facet group`, async () => {
await collectionPage.collectionFacets.clickMoreInFacetGroup(
FacetGroupLocatorLabel.SUBJECT,
Expand All @@ -113,14 +88,10 @@ test.describe('Collection Page - Faceting tests', () => {
]);
await collectionPage.infiniteScroller.validateIncludedFacetedResults(
'tile-collection-icontitle',
['Audio', 'Movie'],
['Audio'],
true,
20,
);
});
});
});

test.afterAll(async () => {
await collectionPage.page.close();
});
},
);
29 changes: 15 additions & 14 deletions tests/collection/collection-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ test('Tile hover pane appears', async ({ collectionPage }) => {
});
});

test(`Clicking on an item tile takes you to the item`, async ({
collectionPage,
}) => {
await test.step('Click first item result and check if it directs to details page', async () => {
await collectionPage.infiniteScroller.clickFirstResultAndCheckRedirectToDetailsPage();
});
});
test(
`Clicking on an item tile takes you to the item`,
async ({ collectionPage }) => {
await test.step('Click first item result and check if it directs to details page', async () => {
await collectionPage.infiniteScroller.clickFirstResultAndCheckRedirectToDetailsPage();
});
},
);

test(`Sort by All-time views in Tile view`, async ({ collectionPage }) => {
await test.step('Switch to tile view mode', async () => {
Expand All @@ -60,7 +61,7 @@ test(`Sort by All-time views in Tile view`, async ({ collectionPage }) => {
'descending',
10,
);
await collectionPage.searchPage.validateURLParamsWithSortFilter(
await collectionPage.collectionBrowser.validateURLParamsWithSortFilter(
'All-time views',
'descending',
);
Expand All @@ -85,7 +86,7 @@ test(`Sort by Date published in List view`, async ({ collectionPage }) => {
'descending',
10,
);
await collectionPage.searchPage.validateURLParamsWithSortFilter(
await collectionPage.collectionBrowser.validateURLParamsWithSortFilter(
'Date published',
'descending',
);
Expand All @@ -107,10 +108,10 @@ test(`Sort by Date archived (ascending) in Compact view`, async ({
});

await test.step('Check list column headers for sort filter', async () => {
await collectionPage.searchPage.validateCompactViewModeListLineDateHeaders(
await collectionPage.collectionBrowser.validateCompactViewModeListLineDateHeaders(
'Date archived',
);
await collectionPage.searchPage.validateURLParamsWithSortFilter(
await collectionPage.collectionBrowser.validateURLParamsWithSortFilter(
'Date archived',
'ascending',
);
Expand All @@ -124,9 +125,9 @@ test.beforeEach(async ({ collectionPage }) => {
});

await test.step(`Select "Search metadata" and do a metadata search for "radio"`, async () => {
await collectionPage.searchPage.clickSearchInputOption(
await collectionPage.collectionBrowser.clickSearchInputOption(
SearchOption.METADATA,
);
await collectionPage.searchPage.queryFor('radio');
await collectionPage.collectionBrowser.queryFor('radio');
});
});
});
86 changes: 34 additions & 52 deletions tests/collection/collection-page.spec.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,44 @@
import { test } from '@playwright/test';
import { test } from '../../tests/fixtures';

import { CollectionPage } from '../page-objects/collection-page';

let collectionPage: CollectionPage;

test.describe('Collection Page - Basic display tests', () => {
test.describe.configure({ mode: 'serial' });

test(`Collections use collection page layout`, async ({ browser }) => {
const browserPage = await browser.newPage();
collectionPage = new CollectionPage(browserPage);

await test.step(`Go to "oldtimeradio" collection page`, async () => {
await collectionPage.visit('oldtimeradio');
});

await test.step(`Check if collection thumbnail, summary and action bar appears`, async () => {
await collectionPage.validatePageHeaderElements();
});

await test.step(`Check if Collection | About | Forum tabs are displayed`, async () => {
await collectionPage.validateCollectionPageTabs();
});
test(`Collections basic display - use collection page layout`, async ({
collectionPage,
}) => {
await test.step(`Check if collection thumbnail, summary and action bar appears`, async () => {
await collectionPage.validatePageHeaderElements();
});

test(`"More..." link to About tab appears below description`, async () => {
await test.step(`Go to "ytjdradio" collection page`, async () => {
await collectionPage.visit('ytjdradio');
});

await test.step(`Click the "More..." link and check if About page is displayed`, async () => {
await collectionPage.clickMoreBtnFromSummary();
await collectionPage.validateAboutTabPage();
});
await test.step(`Check if Collection | About | Forum tabs are displayed`, async () => {
await collectionPage.validateCollectionPageTabs();
});
});

test(`Tab navigation`, async () => {
await test.step(`Navigate to "oldtimeradio" collection page`, async () => {
await collectionPage.visit('oldtimeradio');
});
test(`Collections page - "More..." link to About tab appears below description`, async ({
page,
collectionPage,
}) => {
await test.step(`Go to "ytjdradio" collection page`, async () => {
await page.goto('/details/ytjdradio');
});

await test.step(`Click "About" tab button and check if About page is displayed`, async () => {
await collectionPage.clickCollectionTab('About');
await collectionPage.validateAboutTabPage();
});
await test.step(`Click the "More..." link and check if About page is displayed`, async () => {
await collectionPage.clickMoreBtnFromSummary();
await collectionPage.validateAboutTabPage();
});
});

await test.step(`Click "Forum" tab button and check if Forum page is displayed`, async () => {
await collectionPage.clickCollectionTab('Forum');
await collectionPage.validateForumTabPage();
});
test(`Tab navigation`, async ({ collectionPage }) => {
await test.step(`Click "About" tab button and check if About page is displayed in "oldtimeradio" collection page`, async () => {
await collectionPage.clickCollectionTab('About');
await collectionPage.validateAboutTabPage();
});

await test.step(`Click "Collection" tab button and check if Collections page is displayed`, async () => {
await collectionPage.clickCollectionTab('Collection');
await collectionPage.validateCollectionTabPage();
});
await test.step(`Click "Forum" tab button and check if Forum page is displayed`, async () => {
await collectionPage.clickCollectionTab('Forum');
await collectionPage.validateForumTabPage();
});
});

test.afterAll(async () => {
await collectionPage.page.close();
});
await test.step(`Click "Collection" tab button and check if Collections page is displayed`, async () => {
await collectionPage.clickCollectionTab('Collection');
await collectionPage.validateCollectionTabPage();
});
});
22 changes: 12 additions & 10 deletions tests/collection/collection-search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { SearchOption } from '../models';

test('Collection search metadata', async ({ collectionPage }) => {
await test.step(`Select "Search metadata"`, async () => {
await collectionPage.searchPage.clickSearchInputOption(
await collectionPage.collectionBrowser.clickSearchInputOption(
SearchOption.METADATA,
);
});

await test.step(`Search for "radio" in the search input text field`, async () => {
await collectionPage.searchPage.queryFor('radio');
await collectionPage.collectionBrowser.queryFor('radio');
});

await test.step(`Results are displayed in display area - validate first item displayed`, async () => {
Expand All @@ -22,11 +22,13 @@ test('Collection search text contents and clear filters', async ({
collectionPage,
}) => {
await test.step(`Select "Search text contents"`, async () => {
await collectionPage.searchPage.clickSearchInputOption(SearchOption.TEXT);
await collectionPage.collectionBrowser.clickSearchInputOption(
SearchOption.TEXT,
);
});

await test.step(`Search for "dragnet" in the search input text field`, async () => {
await collectionPage.searchPage.queryFor('dragnet');
await collectionPage.collectionBrowser.queryFor('dragnet');
});

await test.step(`Results are displayed in display area - validate first item displayed`, async () => {
Expand All @@ -35,22 +37,22 @@ test('Collection search text contents and clear filters', async ({
});

await test.step(`Click "X" button in search input and validate search input text is cleared`, async () => {
await collectionPage.searchPage.clickClearSearchInput();
await collectionPage.searchPage.validateClearSearchInput();
await collectionPage.collectionBrowser.clickClearSearchInput();
await collectionPage.collectionBrowser.validateClearSearchInput();
});
});

test('No results page displays when no results', async ({ collectionPage }) => {
await test.step(`Select "Search metadata"`, async () => {
await collectionPage.searchPage.clickSearchInputOption(
await collectionPage.collectionBrowser.clickSearchInputOption(
SearchOption.METADATA,
);
});

await test.step(`Search for "catsshfksahfkjhfkjsdhfkiewhkdsfahkjhfkjsda" and validate that the "No results" placeholder appears in place of the display area`, async () => {
await collectionPage.searchPage.queryFor(
await collectionPage.collectionBrowser.queryFor(
'catsshfksahfkjhfkjsdhfkiewhkdsfahkjhfkjsda',
);
await collectionPage.searchPage.validateEmptyPagePlaceholder();
await collectionPage.collectionBrowser.validateEmptyPagePlaceholder();
});
});
});
Loading

0 comments on commit e7d9784

Please sign in to comment.