Skip to content

Commit bc732f9

Browse files
authored
vp test: refactor to support ExampleLinkName enum (#736)
* vp test: refactor to support ExampleLinkName enum * vp test: rename file
1 parent 7e95fae commit bc732f9

File tree

7 files changed

+95
-83
lines changed

7 files changed

+95
-83
lines changed

test/e2e/specs/highlightsGraphPageVideoIsPlaying.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { vpTest } from '../fixtures/vpTest';
22
import { expect, test } from '@playwright/test';
33
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
4-
import { ExampleLinkName, getLinkByName } from '../testData/pageLinksData';
4+
import { getLinkByName } from '../testData/pageLinksData';
5+
import { ExampleLinkName } from '../testData/ExampleLinkNames';
56

67
// Link to AI Highlights Graph page
78
const link = getLinkByName(ExampleLinkName.AIHighlightsGraph);

test/e2e/specs/linksConsolErros.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { vpTest } from '../fixtures/vpTest';
33
import { LINKS } from '../testData/pageLinksData';
44
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
55
import { validatePageErrors } from '../src/helpers/validatePageErrors';
6+
import { ExampleLinkName } from '../testData/ExampleLinkNames';
67

78
/**
89
* Console error test generated by LINKS object array data.
@@ -29,19 +30,19 @@ vpTest('Link count test', async ({ page }) => {
2930
/**
3031
* Helper function to handle common browser errors.
3132
*/
32-
function handleCommonBrowsersErrors(linkName: string, consoleErrors: ConsoleMessage[]) {
33+
function handleCommonBrowsersErrors(linkName: ExampleLinkName, consoleErrors: ConsoleMessage[]) {
3334
switch (linkName) {
34-
case 'Custom Errors':
35+
case ExampleLinkName.CustomErrors:
3536
validatePageErrors(
3637
consoleErrors,
3738
['(CODE:999 undefined) My custom error message'],
3839
['No compatible source was found for this media', 'Video cannot be played Public ID snow_horses not found', 'the server responded with a status of 404', 'Cannot read properties of undefined']
3940
);
4041
break;
41-
case 'Debug mode':
42+
case ExampleLinkName.DebugMode:
4243
validatePageErrors(consoleErrors, ['invalid player configuration', `cloudinary video player: \'fluid\' should be a boolean`], []);
4344
break;
44-
case 'VAST & VPAID Support':
45+
case ExampleLinkName.VASTAndVPAIDSupport:
4546
validatePageErrors(consoleErrors, ['The Cross-Origin-Opener-Policy header'], ["Blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set"]);
4647
break;
4748
default:

test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ESM_LINKS } from '../testData/esmPageLinksData';
44
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout';
55
import { validatePageErrors } from '../src/helpers/validatePageErrors';
66
import { ExampleLinkType } from '../types/exampleLinkType';
7+
import { ExampleLinkName } from '../testData/ExampleLinkNames';
78

89
const EDGE_ESM_URL = 'https://cld-vp-esm-pages.netlify.app/';
910
// On PR level it will use the preview deploy URL and locally it will use the latest EDGE.
@@ -41,16 +42,16 @@ vpTest('ESM page Link count test', async ({ page }) => {
4142
/**
4243
* Helper function to handle common browser errors.
4344
*/
44-
function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleMessage[]) {
45+
function handleCommonEsmBrowsersErrors(linkName: ExampleLinkName, consoleErrors: ConsoleMessage[]) {
4546
switch (linkName) {
46-
case 'Custom Errors':
47+
case ExampleLinkName.CustomErrors:
4748
validatePageErrors(
4849
consoleErrors,
4950
['(CODE:999 undefined) My custom error message'],
5051
['No compatible source was found for this media', 'Video cannot be played Public ID snow_horses not found', 'the server responded with a status of 404', 'Cannot read properties of undefined']
5152
);
5253
break;
53-
case 'VAST & VPAID Support':
54+
case ExampleLinkName.VASTAndVPAIDSupport:
5455
validatePageErrors(consoleErrors, [], ["Blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set", 'the server responded with a status of 404']);
5556
break;
5657
default:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Enum representing the names of example pages.
3+
*/
4+
export enum ExampleLinkName {
5+
AdaptiveStreaming = 'Adaptive Streaming',
6+
AIHighlightsGraph = 'AI Highlights Graph',
7+
Analytics = 'Analytics',
8+
APIAndEvents = 'API and Events',
9+
AudioPlayer = 'Audio Player',
10+
AutoplayOnScroll = 'Autoplay on Scroll',
11+
Chapters = 'Chapters',
12+
CloudinaryAnalytics = 'Cloudinary Analytics',
13+
CodecsAndFormats = 'Codecs and formats',
14+
ColorsAPI = 'Colors API',
15+
Components = 'Components',
16+
CustomErrors = 'Custom Errors',
17+
DisplayConfigurations = 'Display Configurations',
18+
DebugMode = 'Debug mode',
19+
ESMDebugMode = 'Debug',
20+
ESModuleImports = 'ES Module Imports',
21+
FloatingPlayer = 'Floating Player',
22+
FluidLayouts = 'Fluid Layouts',
23+
ForceHLSSubtitles = 'Force HLS Subtitles',
24+
HighlightsGraph = 'Highlights Graph',
25+
InteractionArea = 'Interaction Area',
26+
MultiplePlayers = 'Multiple Players',
27+
Playlist = 'Playlist',
28+
PlaylistByTag = 'Playlist by Tag',
29+
PosterOptions = 'Poster Options',
30+
Profiles = 'Profiles',
31+
RawURL = 'Raw URL',
32+
Recommendations = 'Recommendations',
33+
SeekThumbnails = 'Seek Thumbnails',
34+
ShoppableVideos = 'Shoppable Videos',
35+
SubtitlesAndCaptions = 'Subtitles & Captions',
36+
VideoTransformations = 'Video Transformations',
37+
UIConfig = 'UI Config',
38+
VASTAndVPAIDSupport = 'VAST & VPAID Support',
39+
VR360Videos = 'VR/360 Videos',
40+
EmbeddedIframePlayer = 'Embedded (iframe) player',
41+
ESMImports = 'ESM Imports',
42+
}
Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
import { ExampleLinkType } from '../types/exampleLinkType';
2+
import { ExampleLinkName } from './ExampleLinkNames';
23

34
/**
45
* Array of all the examples pages names and links on ESM import page.
56
*/
67
export const ESM_LINKS: ExampleLinkType[] = [
7-
{ name: 'Adaptive Streaming', endpoint: 'adaptive-streaming' },
8-
{ name: 'Analytics', endpoint: 'analytics' },
9-
{ name: 'API and Events', endpoint: 'api' },
10-
{ name: 'Audio Player', endpoint: 'audio' },
11-
{ name: 'Autoplay on Scroll', endpoint: 'autoplay-on-scroll' },
12-
{ name: 'Chapters', endpoint: 'chapters' },
13-
{ name: 'Cloudinary Analytics', endpoint: 'cloudinary-analytics' },
14-
{ name: 'Codecs and formats', endpoint: 'codec-formats' },
15-
{ name: 'Colors API', endpoint: 'colors' },
16-
{ name: 'Components', endpoint: 'components' },
17-
{ name: 'Custom Errors', endpoint: 'custom-cld-errors' },
18-
{ name: 'Display Configurations', endpoint: 'ui-config' },
19-
{ name: 'Debug', endpoint: 'debug' },
20-
{ name: 'Floating Player', endpoint: 'floating-player' },
21-
{ name: 'Fluid Layouts', endpoint: 'fluid' },
22-
{ name: 'Force HLS Subtitles', endpoint: 'force-hls-subtitles' },
23-
{ name: 'Highlights Graph', endpoint: 'highlights-graph' },
24-
{ name: 'Interaction Area', endpoint: 'interaction-area' },
25-
{ name: 'Multiple Players', endpoint: 'multiple-players' },
26-
{ name: 'Playlist', endpoint: 'playlist' },
27-
{ name: 'Playlist by Tag', endpoint: 'playlist-by-tag' },
28-
{ name: 'Poster Options', endpoint: 'poster' },
29-
{ name: 'Profiles', endpoint: 'profiles' },
30-
{ name: 'Raw URL', endpoint: 'raw-url' },
31-
{ name: 'Recommendations', endpoint: 'recommendations' },
32-
{ name: 'Seek Thumbnails', endpoint: 'seek-thumbs' },
33-
{ name: 'Shoppable Videos', endpoint: 'shoppable' },
34-
{ name: 'Subtitles & Captions', endpoint: 'subtitles-and-captions' },
35-
{ name: 'Video Transformations', endpoint: 'transformations' },
36-
{ name: 'UI Config', endpoint: 'ui-config' },
37-
{ name: 'VAST & VPAID Support', endpoint: 'vast-vpaid' },
38-
{ name: 'VR/360 Videos', endpoint: '360' },
8+
{ name: ExampleLinkName.AdaptiveStreaming, endpoint: 'adaptive-streaming' },
9+
{ name: ExampleLinkName.Analytics, endpoint: 'analytics' },
10+
{ name: ExampleLinkName.APIAndEvents, endpoint: 'api' },
11+
{ name: ExampleLinkName.AudioPlayer, endpoint: 'audio' },
12+
{ name: ExampleLinkName.AutoplayOnScroll, endpoint: 'autoplay-on-scroll' },
13+
{ name: ExampleLinkName.Chapters, endpoint: 'chapters' },
14+
{ name: ExampleLinkName.CloudinaryAnalytics, endpoint: 'cloudinary-analytics' },
15+
{ name: ExampleLinkName.CodecsAndFormats, endpoint: 'codec-formats' },
16+
{ name: ExampleLinkName.ColorsAPI, endpoint: 'colors' },
17+
{ name: ExampleLinkName.Components, endpoint: 'components' },
18+
{ name: ExampleLinkName.CustomErrors, endpoint: 'custom-cld-errors' },
19+
{ name: ExampleLinkName.DisplayConfigurations, endpoint: 'ui-config' },
20+
{ name: ExampleLinkName.ESMDebugMode, endpoint: 'debug' },
21+
{ name: ExampleLinkName.FloatingPlayer, endpoint: 'floating-player' },
22+
{ name: ExampleLinkName.FluidLayouts, endpoint: 'fluid' },
23+
{ name: ExampleLinkName.ForceHLSSubtitles, endpoint: 'force-hls-subtitles' },
24+
{ name: ExampleLinkName.HighlightsGraph, endpoint: 'highlights-graph' },
25+
{ name: ExampleLinkName.InteractionArea, endpoint: 'interaction-area' },
26+
{ name: ExampleLinkName.MultiplePlayers, endpoint: 'multiple-players' },
27+
{ name: ExampleLinkName.Playlist, endpoint: 'playlist' },
28+
{ name: ExampleLinkName.PlaylistByTag, endpoint: 'playlist-by-tag' },
29+
{ name: ExampleLinkName.PosterOptions, endpoint: 'poster' },
30+
{ name: ExampleLinkName.Profiles, endpoint: 'profiles' },
31+
{ name: ExampleLinkName.RawURL, endpoint: 'raw-url' },
32+
{ name: ExampleLinkName.Recommendations, endpoint: 'recommendations' },
33+
{ name: ExampleLinkName.SeekThumbnails, endpoint: 'seek-thumbs' },
34+
{ name: ExampleLinkName.ShoppableVideos, endpoint: 'shoppable' },
35+
{ name: ExampleLinkName.SubtitlesAndCaptions, endpoint: 'subtitles-and-captions' },
36+
{ name: ExampleLinkName.VideoTransformations, endpoint: 'transformations' },
37+
{ name: ExampleLinkName.UIConfig, endpoint: 'ui-config' },
38+
{ name: ExampleLinkName.VASTAndVPAIDSupport, endpoint: 'vast-vpaid' },
39+
{ name: ExampleLinkName.VR360Videos, endpoint: '360' },
3940
];
41+
42+
/**
43+
* Retrieves an example link object from the `ESM_LINKS` array based on a given name.
44+
*/
45+
export function getEsmLinkByName(name: ExampleLinkName): ExampleLinkType {
46+
return ESM_LINKS.find((link) => link.name === name);
47+
}

test/e2e/testData/pageLinksData.ts

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,5 @@
11
import { ExampleLinkType } from '../types/exampleLinkType';
2-
3-
/**
4-
* Enum representing the names of example pages.
5-
*/
6-
export enum ExampleLinkName {
7-
AdaptiveStreaming = 'Adaptive Streaming',
8-
AIHighlightsGraph = 'AI Highlights Graph',
9-
Analytics = 'Analytics',
10-
APIAndEvents = 'API and Events',
11-
AudioPlayer = 'Audio Player',
12-
AutoplayOnScroll = 'Autoplay on Scroll',
13-
Chapters = 'Chapters',
14-
CloudinaryAnalytics = 'Cloudinary Analytics',
15-
CodecsAndFormats = 'Codecs and formats',
16-
ColorsAPI = 'Colors API',
17-
Components = 'Components',
18-
CustomErrors = 'Custom Errors',
19-
DisplayConfigurations = 'Display Configurations',
20-
DebugMode = 'Debug mode',
21-
ESModuleImports = 'ES Module Imports',
22-
FloatingPlayer = 'Floating Player',
23-
FluidLayouts = 'Fluid Layouts',
24-
ForceHLSSubtitles = 'Force HLS Subtitles',
25-
HighlightsGraph = 'Highlights Graph',
26-
InteractionArea = 'Interaction Area',
27-
MultiplePlayers = 'Multiple Players',
28-
Playlist = 'Playlist',
29-
PlaylistByTag = 'Playlist by Tag',
30-
PosterOptions = 'Poster Options',
31-
Profiles = 'Profiles',
32-
RawURL = 'Raw URL',
33-
Recommendations = 'Recommendations',
34-
SeekThumbnails = 'Seek Thumbnails',
35-
ShoppableVideos = 'Shoppable Videos',
36-
SubtitlesAndCaptions = 'Subtitles & Captions',
37-
VideoTransformations = 'Video Transformations',
38-
UIConfig = 'UI Config',
39-
VASTAndVPAIDSupport = 'VAST & VPAID Support',
40-
VR360Videos = 'VR/360 Videos',
41-
EmbeddedIframePlayer = 'Embedded (iframe) player',
42-
ESMImports = 'ESM Imports',
43-
}
2+
import { ExampleLinkName } from './ExampleLinkNames';
443

454
/**
465
* Array of all the examples pages names and links.

test/e2e/types/exampleLinkType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExampleLinkName } from '../testData/pageLinksData';
1+
import { ExampleLinkName } from '../testData/ExampleLinkNames';
22

33
/**
44
* Example links type

0 commit comments

Comments
 (0)