Skip to content

Commit 3efca4a

Browse files
committed
test: video-config e2e
1 parent b342659 commit 3efca4a

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const player = async (id, playerOptions, ready) => {
2828

2929
try {
3030
const mergedOptions = await fetchAndMergeConfig(options);
31-
3231
return new VideoPlayer(videoElement, mergedOptions, ready);
3332
} catch (e) {
3433
const videoPlayer = new VideoPlayer(videoElement, options);

src/utils/fetch-config.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ const fetchConfig = async (options) => {
2727
// And:
2828
// `${urlPrefix}/profile/${profile.replaceAll(' ', '+')}.json`;
2929

30-
let profileUrl;
30+
let configUrl;
3131
if (profile) {
32-
profileUrl = isRawUrl(profile)
32+
configUrl = isRawUrl(profile)
3333
? profile
3434
: `${urlPrefix}/${profile.replaceAll(' ', '+')}.json`;
3535
} else if (publicId) {
36-
profileUrl = `${urlPrefix}/video/${type}/${publicId}.json`;
36+
configUrl = `${urlPrefix}/video/${type}/${publicId}.json`;
37+
// TODO: remove when endpoints are ready
38+
console.log('This will fetch:', configUrl);
39+
return {};
3740
} else {
3841
return {};
3942
}
4043

41-
return fetch(profileUrl, { method: 'GET' }).then(res => {
44+
return fetch(configUrl, { method: 'GET' }).then(res => {
4245
if (!res.ok) {
4346
// fail silently
4447
return {};
@@ -49,6 +52,18 @@ const fetchConfig = async (options) => {
4952

5053
export const fetchAndMergeConfig = async (options) => {
5154
const profileOptions = await fetchConfig(options);
52-
return Object.assign({}, profileOptions.playerOptions, profileOptions.sourceOptions, options);
55+
const profileAnalytics = {
56+
_internalAnalyticsMetadata: {
57+
newPlayerMethod: true,
58+
profile: options.profile ? (isDefaultProfile(options.profile) ? options.profile : true) : undefined
59+
}
60+
};
61+
return Object.assign(
62+
{},
63+
profileOptions.playerOptions || {},
64+
profileOptions.sourceOptions || {},
65+
options,
66+
profileAnalytics
67+
);
5368
};
5469

test/e2e/specs/ESM/esmProfilesPage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ESM_URL } from '../../testData/esmUrl';
66

77
const link = getEsmLinkByName(ExampleLinkName.Profiles);
88

9-
vpTest(`Test if 3 videos on ESM profiles page are playing as expected`, async ({ page, pomPages }) => {
9+
vpTest(`Test if 5 videos on ESM profiles page are playing as expected`, async ({ page, pomPages }) => {
1010
await page.goto(ESM_URL);
1111
await testProfilesPageVideoIsPlaying(page, pomPages, link);
1212
});

test/e2e/specs/NonESM/profilesPage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import { testProfilesPageVideoIsPlaying } from '../commonSpecs/profilesPageVideo
55

66
const link = getLinkByName(ExampleLinkName.Profiles);
77

8-
vpTest(`Test if 3 videos on profiles page are playing as expected`, async ({ page, pomPages }) => {
8+
vpTest(`Test if 5 videos on profiles page are playing as expected`, async ({ page, pomPages }) => {
99
await testProfilesPageVideoIsPlaying(page, pomPages, link);
1010
});

test/e2e/specs/commonSpecs/profilesPageVideoPlaying.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ export async function testProfilesPageVideoIsPlaying(page: Page, pomPages: PageM
1717
await test.step('Validating that custom profile video is playing', async () => {
1818
await pomPages.profilesPage.profilesCustomProfileVideoComponent.validateVideoIsPlaying(true);
1919
});
20-
await test.step('Scroll until custom profile overrides video element is visible', async () => {
21-
await pomPages.profilesPage.profilesCustomProfileOverridesVideoComponent.locator.scrollIntoViewIfNeeded();
20+
await test.step('Scroll until profile override video element is visible', async () => {
21+
await pomPages.profilesPage.profilesProfileOverrideVideoComponent.locator.scrollIntoViewIfNeeded();
2222
});
23-
await test.step('Validating that custom profile overrides video is playing', async () => {
24-
await pomPages.profilesPage.profilesCustomProfileOverridesVideoComponent.validateVideoIsPlaying(true);
23+
await test.step('Validating that profile override video is playing', async () => {
24+
await pomPages.profilesPage.profilesProfileOverrideVideoComponent.validateVideoIsPlaying(true);
25+
});
26+
await test.step('Scroll until source override video element is visible', async () => {
27+
await pomPages.profilesPage.profilesSourceOverrideVideoComponent.locator.scrollIntoViewIfNeeded();
28+
});
29+
await test.step('Validating that source override video is playing', async () => {
30+
await pomPages.profilesPage.profilesSourceOverrideVideoComponent.validateVideoIsPlaying(true);
31+
});
32+
await test.step('Scroll until asset config video element is visible', async () => {
33+
await pomPages.profilesPage.profilesAssetConfigVideoComponent.locator.scrollIntoViewIfNeeded();
34+
});
35+
await test.step('Validating that asset config video is playing', async () => {
36+
await pomPages.profilesPage.profilesAssetConfigVideoComponent.validateVideoIsPlaying(true);
2537
});
2638
}

test/e2e/src/pom/profilesPage.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ import { VideoComponent } from '../../components/videoComponent';
33
import { BasePage } from './BasePage';
44
const PROFILES_PAGE_DEFAULT_PROFILE_VIDEO_SELECTOR = '//*[@id="player-default-profile_html5_api"]';
55
const PROFILES_PAGE_CUSTOM_PROFILE_VIDEO_SELECTOR = '//*[@id="player-custom-profile_html5_api"]';
6-
const PROFILES_PAGE_CUSTOM_PROFILE_OVERRIDES_VIDEO_SELECTOR = '//*[@id="player-custom-profile-overrides_html5_api"]';
6+
const PROFILES_PAGE_PROFILE_OVERRIDE_VIDEO_SELECTOR = '//*[@id="player-profile-override_html5_api"]';
7+
const PROFILES_PAGE_SOURCE_OVERRIDE_VIDEO_SELECTOR = '//*[@id="player-source-override_html5_api"]';
8+
const PROFILES_PAGE_ASSET_CONFIG_VIDEO_SELECTOR = '//*[@id="player-asset-config_html5_api"]';
79

810
/**
911
* Video player examples profiles page object
1012
*/
1113
export class ProfilesPage extends BasePage {
1214
public profilesDefaultProfileVideoComponent: VideoComponent;
1315
public profilesCustomProfileVideoComponent: VideoComponent;
14-
public profilesCustomProfileOverridesVideoComponent: VideoComponent;
16+
public profilesProfileOverrideVideoComponent: VideoComponent;
17+
public profilesSourceOverrideVideoComponent: VideoComponent;
18+
public profilesAssetConfigVideoComponent: VideoComponent;
1519

1620
constructor(page: Page) {
1721
super(page);
1822
this.profilesDefaultProfileVideoComponent = new VideoComponent(page, PROFILES_PAGE_DEFAULT_PROFILE_VIDEO_SELECTOR);
1923
this.profilesCustomProfileVideoComponent = new VideoComponent(page, PROFILES_PAGE_CUSTOM_PROFILE_VIDEO_SELECTOR);
20-
this.profilesCustomProfileOverridesVideoComponent = new VideoComponent(page, PROFILES_PAGE_CUSTOM_PROFILE_OVERRIDES_VIDEO_SELECTOR);
24+
this.profilesProfileOverrideVideoComponent = new VideoComponent(page, PROFILES_PAGE_PROFILE_OVERRIDE_VIDEO_SELECTOR);
25+
this.profilesSourceOverrideVideoComponent = new VideoComponent(page, PROFILES_PAGE_SOURCE_OVERRIDE_VIDEO_SELECTOR);
26+
this.profilesAssetConfigVideoComponent = new VideoComponent(page, PROFILES_PAGE_ASSET_CONFIG_VIDEO_SELECTOR);
2127
}
2228
}

0 commit comments

Comments
 (0)