Skip to content

Commit 244950e

Browse files
authored
test(video-20810): smoke test for profiles and config applet (#1033)
* test(video-20810): smoke test for profiles and config applet * test(video-20810): smoke test for profiles and config applet
1 parent 9f2809d commit 244950e

6 files changed

Lines changed: 147 additions & 0 deletions

File tree

test/e2e/components/videoComponent.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,29 @@ export class VideoComponent extends BaseComponent {
5252
expect(isPaused).not.toEqual(expectedPlaying);
5353
}).toPass({ intervals: [500], timeout });
5454
}
55+
56+
/**
57+
* Validates theme CSS custom properties on the `.cld-video-player` wrapper ancestor.
58+
*/
59+
public async validateColors(
60+
expectedColors: { base: string; accent: string; text: string },
61+
timeout: number = 10000
62+
): Promise<void> {
63+
const wrapperLocator = this.locator.locator('xpath=ancestor::div[contains(@class, "cld-video-player")]');
64+
65+
await expect(async () => {
66+
const colors = await wrapperLocator.evaluate((el) => {
67+
const styles = getComputedStyle(el as HTMLElement);
68+
return {
69+
base: styles.getPropertyValue('--color-base').trim(),
70+
accent: styles.getPropertyValue('--color-accent').trim(),
71+
text: styles.getPropertyValue('--color-text').trim(),
72+
};
73+
});
74+
75+
expect(colors.base.toLowerCase()).toBe(expectedColors.base.toLowerCase());
76+
expect(colors.accent.toLowerCase()).toBe(expectedColors.accent.toLowerCase());
77+
expect(colors.text.toLowerCase()).toBe(expectedColors.text.toLowerCase());
78+
}).toPass({ intervals: [500], timeout });
79+
}
5580
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { vpTest } from '../../fixtures/vpTest';
2+
import { getLinkByName } from '../../testData/pageLinksData';
3+
import { ExampleLinkName } from '../../testData/ExampleLinkNames';
4+
import { testProfileAndConfigAppletMockedColors } from '../commonSpecs/profilesAndConfigAppletMockedColors';
5+
6+
const link = getLinkByName(ExampleLinkName.Profiles);
7+
8+
vpTest('Profile and config mocked colors are applied to the players',
9+
async ({ page, pomPages }) => {
10+
await testProfileAndConfigAppletMockedColors(page, pomPages, link);
11+
}
12+
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { vpTest } from '../../fixtures/vpTest';
2+
import { getLinkByName } from '../../testData/pageLinksData';
3+
import { ExampleLinkName } from '../../testData/ExampleLinkNames';
4+
import { testProfileAndConfigAppletUrlsFetch } from '../commonSpecs/profilesAndConfigAppletFetch';
5+
6+
const link = getLinkByName(ExampleLinkName.Profiles);
7+
8+
vpTest('Profile and config requests are sent with correct URLs',
9+
async ({ page, pomPages }) => {
10+
await testProfileAndConfigAppletUrlsFetch(page, pomPages, link);
11+
}
12+
);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Page, test, expect, Request } from '@playwright/test';
2+
import { waitForPageToLoadWithTimeout } from '../../src/helpers/waitForPageToLoadWithTimeout';
3+
import PageManager from '../../src/pom/PageManager';
4+
import { ExampleLinkType } from '../../types/exampleLinkType';
5+
import { PROFILE_ROUTE_PATTERN, CONFIG_ROUTE_PATTERN } from '../../src/consts/appletRoutes';
6+
7+
8+
export async function testProfileAndConfigAppletUrlsFetch(page: Page, pomPages: PageManager,link: ExampleLinkType
9+
) {
10+
const profileRequests: Request[] = [];
11+
const configRequests: Request[] = [];
12+
13+
await test.step('Track profile and config requests', async () => {
14+
await page.route(PROFILE_ROUTE_PATTERN, (route) => {
15+
profileRequests.push(route.request());
16+
return route.continue();
17+
});
18+
19+
await page.route(CONFIG_ROUTE_PATTERN, (route) => {
20+
configRequests.push(route.request());
21+
return route.continue();
22+
});
23+
});
24+
25+
await test.step('Navigate to profiles page', async () => {
26+
await pomPages.mainPage.clickLinkByName(link.name);
27+
await waitForPageToLoadWithTimeout(page, 5000);
28+
});
29+
30+
await test.step('Validate profile request URL', async () => {
31+
expect(profileRequests.length, 'Expected at least one profile request').toBeGreaterThanOrEqual(1);
32+
33+
const profileUrl = new URL(profileRequests[0].url());
34+
expect(profileUrl.pathname).toMatch(
35+
/\/_applet_\/video_service\/video_player_profiles\/[^/]+\.json$/
36+
);
37+
});
38+
39+
await test.step('Validate config request URL', async () => {
40+
expect(configRequests.length, 'Expected at least one config request').toBeGreaterThanOrEqual(1);
41+
42+
const configUrl = new URL(configRequests[0].url());
43+
expect(configUrl.pathname).toMatch(
44+
/\/_applet_\/video_service\/video_player_config\/video\/[^/]+\/[^/]+\.json$/
45+
);
46+
});
47+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Page, test, expect, Request } from '@playwright/test';
2+
import { waitForPageToLoadWithTimeout } from '../../src/helpers/waitForPageToLoadWithTimeout';
3+
import PageManager from '../../src/pom/PageManager';
4+
import { ExampleLinkType } from '../../types/exampleLinkType';
5+
import { PROFILE_ROUTE_PATTERN, CONFIG_ROUTE_PATTERN } from '../../src/consts/appletRoutes';
6+
7+
export async function testProfileAndConfigAppletMockedColors(page: Page, pomPages: PageManager,link: ExampleLinkType
8+
) {
9+
10+
const profileMockColors = { base: '#FF0000', accent: '#00FF00', text: '#0000FF' };
11+
const configMockColors = { base: '#AA0000', accent: '#00AA00', text: '#0000AA' };
12+
13+
await test.step('Mock profile and config responses with custom colors', async () => {
14+
await page.route(PROFILE_ROUTE_PATTERN, async (route) => {
15+
await route.fulfill({
16+
status: 200,
17+
contentType: 'application/json',
18+
body: JSON.stringify({
19+
playerOptions: { colors: profileMockColors },
20+
sourceOptions: {},
21+
}),
22+
});
23+
});
24+
25+
await page.route(CONFIG_ROUTE_PATTERN, async (route) => {
26+
await route.fulfill({
27+
status: 200,
28+
contentType: 'application/json',
29+
body: JSON.stringify({
30+
playerOptions: { colors: configMockColors },
31+
sourceOptions: {},
32+
}),
33+
});
34+
});
35+
});
36+
37+
await test.step('Navigate to profiles page', async () => {
38+
await pomPages.mainPage.clickLinkByName(link.name);
39+
await waitForPageToLoadWithTimeout(page, 5000);
40+
});
41+
42+
await test.step('Validate mocked profile colors are applied', async () => {
43+
await pomPages.profilesPage.profilesCustomProfileVideoComponent.validateColors(profileMockColors);
44+
});
45+
46+
await test.step('Validate mocked config colors are applied', async () => {
47+
await pomPages.profilesPage.profilesAssetConfigVideoComponent.validateColors(configMockColors);
48+
});
49+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const PROFILE_ROUTE_PATTERN = '**/_applet_/video_service/video_player_profiles/*.json*';
2+
export const CONFIG_ROUTE_PATTERN = '**/_applet_/video_service/video_player_config/**/*.json*';

0 commit comments

Comments
 (0)