Skip to content

Commit dd69d85

Browse files
authored
me-17978: tests if videos are playing on vast and vpaid page (#795)
* vp test: tests if videos are playing on vast and vpaid page * vp test: modification based on review
1 parent c7f41d9 commit dd69d85

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

test/e2e/components/videoComponent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ export class VideoComponent extends BaseComponent {
3434
* Validates whether the video is currently playing.
3535
* This method uses the `isPaused` function to determine the current state of the video.
3636
* expectedPlaying - A boolean indicating the expected playback state of the video.
37+
* timeout - Optional. The maximum time (in milliseconds) to wait for the validation. Defaults to 3000ms if not provided.
3738
* Pass `true` if the video is expected to be playing, or `false` if it is expected to be paused.
3839
*/
39-
public async validateVideoIsPlaying(expectedPlaying: boolean): Promise<void> {
40+
public async validateVideoIsPlaying(expectedPlaying: boolean, timeout: number = 3000): Promise<void> {
4041
await expect(async () => {
4142
expect(await this.isPaused()).not.toEqual(expectedPlaying);
42-
}).toPass({ intervals: [500], timeout: 3000 });
43+
}).toPass({ intervals: [500], timeout });
4344
}
4445
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { vpTest } from '../fixtures/vpTest';
2+
import { test } from '@playwright/test';
3+
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
4+
import { getLinkByName } from '../testData/pageLinksData';
5+
import { ExampleLinkName } from '../testData/ExampleLinkNames';
6+
7+
const link = getLinkByName(ExampleLinkName.VASTAndVPAIDSupport);
8+
9+
vpTest(`Test if 2 videos on vast and vpaid page are playing as expected`, async ({ page, pomPages }) => {
10+
await test.step('Navigate to vast and vpaid page by clicking on link', async () => {
11+
await pomPages.mainPage.clickLinkByName(link.name);
12+
await waitForPageToLoadWithTimeout(page, 5000);
13+
});
14+
await test.step('Click on play button of single video with ads to play video', async () => {
15+
return pomPages.vastAndVpaidPage.singleVideoWithAdsVideoComponent.clickPlay();
16+
});
17+
//Sending timeout of 12 seconds to wait until the ad finishes (10 sec) and the video will start
18+
await test.step('Validating that single video with ads is playing', async () => {
19+
await pomPages.vastAndVpaidPage.singleVideoWithAdsVideoComponent.validateVideoIsPlaying(true, 12000);
20+
});
21+
await test.step('Validating that playlist with ads video is playing', async () => {
22+
await pomPages.vastAndVpaidPage.playlistWithAdsVideoComponent.validateVideoIsPlaying(true, 12000);
23+
});
24+
});

test/e2e/src/pom/PageManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { SeekThumbnailsPage } from './seekThumbnailsPage';
2626
import { ShoppableVideosPage } from './shoppableVideosPage';
2727
import { SubtitlesAndCaptionsPage } from './subtitlesAndCaptionsPage';
2828
import { VideoTransformationsPage } from './videoTransformationsPage';
29+
import { VastAndVpaidPage } from './vastAndVpaidPage';
2930

3031
/**
3132
* Page manager,
@@ -181,5 +182,9 @@ export class PageManager {
181182
public get videoTransformationsPage(): VideoTransformationsPage {
182183
return this.getPage(VideoTransformationsPage);
183184
}
185+
186+
public get vastAndVpaidPage(): VastAndVpaidPage {
187+
return this.getPage(VastAndVpaidPage);
188+
}
184189
}
185190
export default PageManager;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Page } from '@playwright/test';
2+
import { VideoComponent } from '../../components/videoComponent';
3+
import { BasePage } from './BasePage';
4+
const SINGLE_VIDEO_WITH_ADS_VIDEO_SELECTOR = '//*[@id="player_html5_api"]';
5+
const PLAYLIST_WITH_ADS_VIDEO_SELECTOR = '//*[@id="player-playlist_html5_api"]';
6+
7+
/**
8+
* Video player examples vast and vpaid page object
9+
*/
10+
export class VastAndVpaidPage extends BasePage {
11+
public singleVideoWithAdsVideoComponent: VideoComponent;
12+
public playlistWithAdsVideoComponent: VideoComponent;
13+
14+
constructor(page: Page) {
15+
super(page);
16+
this.singleVideoWithAdsVideoComponent = new VideoComponent(page, SINGLE_VIDEO_WITH_ADS_VIDEO_SELECTOR);
17+
this.playlistWithAdsVideoComponent = new VideoComponent(page, PLAYLIST_WITH_ADS_VIDEO_SELECTOR);
18+
}
19+
}

0 commit comments

Comments
 (0)