Skip to content

Commit ea53730

Browse files
authored
me-18581: refactor specs to use validateVideoIsPlaying (#775)
* vp test: refactor specs to use validateVideoIsPlaying * vp test: change step description based on review
1 parent ee264fc commit ea53730

13 files changed

+66
-67
lines changed

test/e2e/components/videoComponent.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from '@playwright/test';
1+
import { expect, Page } from '@playwright/test';
22
import { BaseComponent } from './BaseComponent';
33

44
/**
@@ -31,13 +31,12 @@ export class VideoComponent extends BaseComponent {
3131
}
3232

3333
/**
34-
* Validates whether the video is paused or playing.
35-
* expectedPaused - True if the video is expected to be paused, otherwise false.
34+
* Validates whether the video is currently playing.
35+
* This method uses the `isPaused` function to determine the current state of the video.
36+
* expectedPlaying - A boolean indicating the expected playback state of the video.
37+
* Pass `true` if the video is expected to be playing, or `false` if it is expected to be paused.
3638
*/
37-
public async validateVideoPaused(expectedPaused: boolean): Promise<void> {
38-
const isPaused = await this.isPaused();
39-
if (isPaused !== expectedPaused) {
40-
throw new Error(`Video paused state mismatch. Expected: ${expectedPaused}, Actual: ${isPaused}`);
41-
}
39+
public async validateVideoIsPlaying(expectedPlaying: boolean): Promise<void> {
40+
expect(await this.isPaused()).not.toEqual(expectedPlaying);
4241
}
4342
}

test/e2e/specs/analyticsPage.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { vpTest } from '../fixtures/vpTest';
2-
import { expect, test } from '@playwright/test';
2+
import { test } from '@playwright/test';
33
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
44
import { getLinkByName } from '../testData/pageLinksData';
55
import { ExampleLinkName } from '../testData/ExampleLinkNames';
@@ -14,7 +14,7 @@ vpTest(`Test if video on analytics page is playing as expected`, async ({ page,
1414
await pomPages.mainPage.clickLinkByName(link.name);
1515
await waitForPageToLoadWithTimeout(page, 5000);
1616
});
17-
await test.step('Validating that the video is playing (in case isPause is false)', async () => {
18-
expect(await pomPages.analyticsPage.analyticsVideoComponent.isPaused()).toEqual(false);
17+
await test.step('Validating that the video is playing', async () => {
18+
await pomPages.analyticsPage.analyticsVideoComponent.validateVideoIsPlaying(true);
1919
});
2020
});

test/e2e/specs/apiAndEventsPage.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { vpTest } from '../fixtures/vpTest';
2-
import { expect, test } from '@playwright/test';
2+
import { test } from '@playwright/test';
33
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
44
import { getLinkByName } from '../testData/pageLinksData';
55
import { ExampleLinkName } from '../testData/ExampleLinkNames';
@@ -14,7 +14,7 @@ vpTest(`Test if video on API and Events page is playing as expected`, async ({ p
1414
await pomPages.mainPage.clickLinkByName(link.name);
1515
await waitForPageToLoadWithTimeout(page, 5000);
1616
});
17-
await test.step('Validating that the video is playing (in case isPause is false)', async () => {
18-
expect(await pomPages.apiAndEventsPage.apiAndEventsVideoComponent.isPaused()).toEqual(false);
17+
await test.step('Validating that the video is playing', async () => {
18+
await pomPages.apiAndEventsPage.apiAndEventsVideoComponent.validateVideoIsPlaying(true);
1919
});
2020
});
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { vpTest } from '../fixtures/vpTest';
2-
import { expect, test } from '@playwright/test';
2+
import { test } from '@playwright/test';
33
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
44
import { getLinkByName } from '../testData/pageLinksData';
55
import { ExampleLinkName } from '../testData/ExampleLinkNames';
@@ -14,16 +14,16 @@ vpTest(`Test if 2 videos on audio player page are playing as expected`, async ({
1414
await pomPages.mainPage.clickLinkByName(link.name);
1515
await waitForPageToLoadWithTimeout(page, 5000);
1616
});
17-
await test.step('Click on play button of first video player to play video', async () => {
17+
await test.step('Click on play button of video player to play video', async () => {
1818
return pomPages.audioPlayerPage.audioPlayerVideoComponent.clickPlay();
1919
});
20-
await test.step('Validating that the first video is playing (in case isPause is false)', async () => {
21-
expect(await pomPages.audioPlayerPage.audioPlayerVideoComponent.isPaused()).toEqual(false);
20+
await test.step('Validating that the first video player is playing', async () => {
21+
await pomPages.audioPlayerPage.audioPlayerVideoComponent.validateVideoIsPlaying(true);
2222
});
23-
await test.step('Click on play button of second video player to play video', async () => {
23+
await test.step('Click on play button of audio player with transformation to play video', async () => {
2424
return pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.clickPlay();
2525
});
26-
await test.step('Validating that the second video is playing (in case isPause is false)', async () => {
27-
expect(await pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.isPaused()).toEqual(false);
26+
await test.step('Validating that the audio player with transformation is playing', async () => {
27+
await pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.validateVideoIsPlaying(true);
2828
});
2929
});

test/e2e/specs/autoplayOnScrollPage.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ vpTest(`Test if video on autoplay on scroll page is playing as expected`, async
1616
await pomPages.mainPage.clickLinkByName(link.name);
1717
await waitForPageToLoadWithTimeout(page, 5000);
1818
});
19-
await test.step('Validating that the video is not playing before scrolling (in case isPause is true)', async () => {
20-
expect(await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.isPaused()).toEqual(true);
19+
await test.step('Validating that the video is not playing before scrolling', async () => {
20+
await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.validateVideoIsPlaying(false);
2121
});
2222
await test.step('Scroll until the video element is visible', async () => {
2323
await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.locator.scrollIntoViewIfNeeded();
2424
});
25-
await test.step('Validating that the video is auto playing after scrolling (in case isPause is false)', async () => {
25+
await test.step('Validating that the video is auto playing after scrolling', async () => {
2626
await expect(async () => {
27-
expect(await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.isPaused()).toEqual(false);
27+
await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.validateVideoIsPlaying(true);
2828
}).toPass({ intervals: [500], timeout: 3000 });
2929
});
3030
});

test/e2e/specs/chaptersPage.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ vpTest(`Test if 3 videos on chapters page are playing as expected`, async ({ pag
1111
await pomPages.mainPage.clickLinkByName(link.name);
1212
await waitForPageToLoadWithTimeout(page, 5000);
1313
});
14-
await test.step('Validating that the first video is playing (in case isPause is false)', async () => {
15-
expect(await pomPages.chaptersPage.chaptersVttFIleVideoComponent.isPaused()).toEqual(false);
14+
await test.step('Validating that chapters vtt file video is playing', async () => {
15+
await pomPages.chaptersPage.chaptersVttFIleVideoComponent.validateVideoIsPlaying(true);
1616
});
17-
await test.step('Validating that the second video is playing (in case isPause is false)', async () => {
18-
expect(await pomPages.chaptersPage.chaptersConfigObjectVideoComponent.isPaused()).toEqual(false);
17+
await test.step('Validating that chapters config object video is playing', async () => {
18+
await pomPages.chaptersPage.chaptersConfigObjectVideoComponent.validateVideoIsPlaying(true);
1919
});
20-
await test.step('Scroll until the third video element is visible', async () => {
20+
await test.step('Scroll until chapters auto vtt file video element is visible', async () => {
2121
await pomPages.chaptersPage.chapterAutoVttFileVideoComponent.locator.scrollIntoViewIfNeeded();
2222
});
23-
await test.step('Validating that the third video is playing (in case isPause is false)', async () => {
23+
await test.step('Validating that chapters auto vtt file video is playing', async () => {
2424
await expect(async () => {
25-
expect(await pomPages.chaptersPage.chapterAutoVttFileVideoComponent.isPaused()).toEqual(false);
25+
await pomPages.chaptersPage.chapterAutoVttFileVideoComponent.validateVideoIsPlaying(true);
2626
}).toPass({ intervals: [500], timeout: 3000 });
2727
});
2828
});

test/e2e/specs/cldAnalyticsPage.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ vpTest(`Test if 4 videos on Cloudinary analytics page are playing as expected`,
1111
await pomPages.mainPage.clickLinkByName(link.name);
1212
await waitForPageToLoadWithTimeout(page, 5000);
1313
});
14-
await test.step('Validating that the first video is playing (in case isPause is false)', async () => {
15-
expect(await pomPages.cldAnalyticsPage.cldAnalyticsVideoComponent.validateVideoPaused(false));
14+
await test.step('Validating that Cloudinary analytics video is playing', async () => {
15+
await pomPages.cldAnalyticsPage.cldAnalyticsVideoComponent.validateVideoIsPlaying(true);
1616
});
17-
await test.step('Validating that the second video is playing (in case isPause is false)', async () => {
18-
expect(await pomPages.cldAnalyticsPage.cldAnalyticsAdpVideoComponent.validateVideoPaused(false));
17+
await test.step('Validating that Cloudinary analytics ADP video is playing', async () => {
18+
await pomPages.cldAnalyticsPage.cldAnalyticsAdpVideoComponent.validateVideoIsPlaying(true);
1919
});
20-
await test.step('Scroll until the third video element is visible', async () => {
20+
await test.step('Scroll until Cloudinary analytics custom data object video element is visible', async () => {
2121
await pomPages.cldAnalyticsPage.cldAnalyticsCustomDataObjectVideoComponent.locator.scrollIntoViewIfNeeded();
2222
});
23-
await test.step('Validating that the third video is playing (in case isPause is false)', async () => {
23+
await test.step('Validating that Cloudinary analytics custom data object video is playing', async () => {
2424
await expect(async () => {
25-
expect(await pomPages.cldAnalyticsPage.cldAnalyticsCustomDataObjectVideoComponent.validateVideoPaused(false));
25+
await pomPages.cldAnalyticsPage.cldAnalyticsCustomDataObjectVideoComponent.validateVideoIsPlaying(true);
2626
}).toPass({ intervals: [500], timeout: 3000 });
2727
});
28-
await test.step('Scroll until the fourth video element is visible', async () => {
28+
await test.step('Scroll until Cloudinary analytics custom data function video element is visible', async () => {
2929
await pomPages.cldAnalyticsPage.cldAnalyticsCustomDataFunctionVideoComponent.locator.scrollIntoViewIfNeeded();
3030
});
31-
await test.step('Validating that the fourth video is playing (in case isPause is false)', async () => {
31+
await test.step('Validating that Cloudinary analytics custom data function video is playing', async () => {
3232
await expect(async () => {
33-
expect(await pomPages.cldAnalyticsPage.cldAnalyticsCustomDataFunctionVideoComponent.validateVideoPaused(false));
33+
await pomPages.cldAnalyticsPage.cldAnalyticsCustomDataFunctionVideoComponent.validateVideoIsPlaying(true);
3434
}).toPass({ intervals: [500], timeout: 3000 });
3535
});
3636
});

test/e2e/specs/codecsAndFormats.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ vpTest(`Test if 3 videos on codecs and formats page are playing as expected`, as
1111
await pomPages.mainPage.clickLinkByName(link.name);
1212
await waitForPageToLoadWithTimeout(page, 5000);
1313
});
14-
await test.step('Validating that the first video is playing (in case isPause is false)', async () => {
15-
expect(await pomPages.codecsAndFormatsPage.codecsAndFormatsFAutoVideoComponent.validateVideoPaused(false));
14+
await test.step('Validating that f_auto video is playing', async () => {
15+
await pomPages.codecsAndFormatsPage.codecsAndFormatsFAutoVideoComponent.validateVideoIsPlaying(true);
1616
});
17-
await test.step('Validating that the second video is playing (in case isPause is false)', async () => {
18-
expect(await pomPages.codecsAndFormatsPage.codecsAndFormatsAv1VideoComponent.validateVideoPaused(false));
17+
await test.step('Validating that AV1 video is playing', async () => {
18+
await pomPages.codecsAndFormatsPage.codecsAndFormatsAv1VideoComponent.validateVideoIsPlaying(true);
1919
});
20-
await test.step('Scroll until the third video element is visible', async () => {
20+
await test.step('Scroll until VP9 video element is visible', async () => {
2121
await pomPages.codecsAndFormatsPage.codecsAndFormatsVp9VideoComponent.locator.scrollIntoViewIfNeeded();
2222
});
23-
await test.step('Validating that the third video is playing (in case isPause is false)', async () => {
23+
await test.step('Validating that VP9 video is playing', async () => {
2424
await expect(async () => {
25-
expect(await pomPages.codecsAndFormatsPage.codecsAndFormatsVp9VideoComponent.validateVideoPaused(false));
25+
await pomPages.codecsAndFormatsPage.codecsAndFormatsVp9VideoComponent.validateVideoIsPlaying(true);
2626
}).toPass({ intervals: [500], timeout: 3000 });
2727
});
2828
});

test/e2e/specs/colorsApiPage.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ vpTest(`Test if 3 videos on colors API page are playing as expected`, async ({ p
1111
await pomPages.mainPage.clickLinkByName(link.name);
1212
await waitForPageToLoadWithTimeout(page, 5000);
1313
});
14-
await test.step('Validating that modified color video is playing (in case isPause is false)', async () => {
15-
expect(await pomPages.colorsApiPage.colorsApiColorSkinVideoComponent.validateVideoPaused(false));
14+
await test.step('Validating that modified color video is playing', async () => {
15+
await pomPages.colorsApiPage.colorsApiColorSkinVideoComponent.validateVideoIsPlaying(true);
1616
});
17-
await test.step('Validating that dark skin video video is playing (in case isPause is false)', async () => {
18-
expect(await pomPages.colorsApiPage.colorsApiDarkSkinVideoComponent.validateVideoPaused(false));
17+
await test.step('Validating that dark skin video video is playing', async () => {
18+
await pomPages.colorsApiPage.colorsApiDarkSkinVideoComponent.validateVideoIsPlaying(true);
1919
});
2020
await test.step('Scroll until light skin video element is visible', async () => {
2121
await pomPages.colorsApiPage.colorsApiLightSkinVideoComponent.locator.scrollIntoViewIfNeeded();
2222
});
23-
await test.step('Validating that light skin video is playing (in case isPause is false)', async () => {
23+
await test.step('Validating that light skin video is playing', async () => {
2424
await expect(async () => {
25-
expect(await pomPages.colorsApiPage.colorsApiLightSkinVideoComponent.validateVideoPaused(false));
25+
await pomPages.colorsApiPage.colorsApiLightSkinVideoComponent.validateVideoIsPlaying(true);
2626
}).toPass({ intervals: [500], timeout: 3000 });
2727
});
2828
});

test/e2e/specs/componentsPage.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { vpTest } from '../fixtures/vpTest';
2-
import { expect, test } from '@playwright/test';
2+
import { test } from '@playwright/test';
33
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
44
import { getLinkByName } from '../testData/pageLinksData';
55
import { ExampleLinkName } from '../testData/ExampleLinkNames';
@@ -11,7 +11,7 @@ vpTest(`Test if video on components page is playing as expected`, async ({ page,
1111
await pomPages.mainPage.clickLinkByName(link.name);
1212
await waitForPageToLoadWithTimeout(page, 5000);
1313
});
14-
await test.step('Validating that components video is playing (in case isPause is false)', async () => {
15-
expect(await pomPages.componentsPage.componentsVideoComponent.validateVideoPaused(false));
14+
await test.step('Validating that components video is playing', async () => {
15+
await pomPages.componentsPage.componentsVideoComponent.validateVideoIsPlaying(true);
1616
});
1717
});

0 commit comments

Comments
 (0)