Skip to content

Commit

Permalink
me-18308: refactor to use page manager (#749)
Browse files Browse the repository at this point in the history
* vp test: refactor to use page manager

* vp test: refactor to use page manager

* vp test: remove comment
  • Loading branch information
ShayLevi authored Dec 9, 2024
1 parent a990f5f commit 5c98ded
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
14 changes: 2 additions & 12 deletions test/e2e/fixtures/vpTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,10 @@ export const vpTest = test.extend<FixtureParams>({
pomPages: [
async ({ page }, use) => {
const pomPages = new PageManager(page);
await pomPages.mainPage.goto();
await use(pomPages);
},
{ scope: 'test' },
],
/**
* Fixture for the video player examples page object.
*/
vpExamples: [
async ({ page }, use) => {
const vpExamplePage = new MainPage(page);
await vpExamplePage.goto();
await use(vpExamplePage);
},
{ auto: true },
{ scope: 'test', auto: true },
],

/**
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/highlightsGraphPageVideoIsPlaying.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const link = getLinkByName(ExampleLinkName.AIHighlightsGraph);
/**
* Testing if video on highlights graph page is playing by checking that is pause return false.
*/
vpTest(`Test if video on highlights graph page is playing as expected`, async ({ page, vpExamples, pomPages }) => {
vpTest(`Test if video on highlights graph page is playing as expected`, async ({ page, pomPages }) => {
await test.step('Navigate to highlights graph page by clicking on link', async () => {
await vpExamples.clickLinkByName(link.name);
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
});
await test.step('Validating that the video is playing (in case isPause is false)', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/linksConsolErros.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { ExampleLinkName } from '../testData/ExampleLinkNames';
* Console error test generated by LINKS object array data.
*/
for (const link of LINKS) {
vpTest(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, vpExamples }) => {
vpTest(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, pomPages }) => {
vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI');
await vpExamples.clickLinkByName(link.name);
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
expect(page.url()).toContain(link.endpoint);
handleCommonBrowsersErrors(link.name, consoleErrors);
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ let isPreviewUrlLoaded = false;
* Console error test generated by LINKS object array data.
*/
for (const link of ESM_LINKS) {
vpTest(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, vpExamples }) => {
vpTest(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, pomPages }) => {
vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI');
//Wait for deploy URL to be available if PREVIEW_URL is set, and it is not available yet
if (process.env.PREVIEW_URL && !isPreviewUrlLoaded) {
await waitForDeployPreviewUrl(link, page);
}
await page.goto(ESM_URL);
await vpExamples.clickLinkByName(link.name);
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
expect(page.url()).toContain(link.endpoint);
handleCommonEsmBrowsersErrors(link.name, consoleErrors);
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/mainPageVideoIsPlaying.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWi
* Testing if video on main page is playing by checking that is pause return false.
* The video in the main page is not configured as autoplay so first need to click on play button.
*/
vpTest(`Test if video on main page can play as expected`, async ({ page, vpExamples }) => {
vpTest(`Test if video on main page can play as expected`, async ({ page, pomPages }) => {
await test.step('Click on play button to play video', async () => {
//making sure the page is loaded
await waitForPageToLoadWithTimeout(page, 5000);
return vpExamples.videoMainPage.clickPlay();
return pomPages.mainPage.videoMainPage.clickPlay();
});
await test.step('Validating that the video is playing (in case isPause is false)', async () => {
expect(await vpExamples.videoMainPage.isPaused()).toEqual(false);
expect(await pomPages.mainPage.videoMainPage.isPaused()).toEqual(false);
});
});
8 changes: 8 additions & 0 deletions test/e2e/src/pom/PageManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Page } from '@playwright/test';
import { HighlightsGraphPage } from './highlightsGraphPage';
import { BasePage } from './BasePage';
import { MainPage } from './mainPage';

/**
* Page manager,
Expand All @@ -26,6 +27,13 @@ export class PageManager {
return this.pageMap.get(pageName) as T;
}

/**
* Returns main page object
*/
public get mainPage(): MainPage {
return this.getPage(MainPage);
}

/**
* Returns highlightGraphPage page object
*/
Expand Down

0 comments on commit 5c98ded

Please sign in to comment.