Skip to content

Commit 3867dc1

Browse files
Refactor cypress tests: mediaAsset page (#12960)
* refactor: update to match article page format * refactor: add .amp tests * refactor: update per comment * refactor:add getPathWithSuffix in shared location * refactor:import the MEDIA_ASSET_PAGE page type * refactor: fix an import issue * refactor:remove unvalid URL * refactor:add /zhongwen/simp * refactor: update per comment * refactor: fix 404ing pages --------- Co-authored-by: Toby Cox <[email protected]>
1 parent 682c94a commit 3867dc1

File tree

9 files changed

+344
-1113
lines changed

9 files changed

+344
-1113
lines changed

cypress/e2e/pages/articles/testsForLiteOnly.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const hasInformationPageLinkTranslation = ({
44
service,
55
variant = 'default',
66
}) => {
7-
return appConfig[service][variant].translations?.liteSite
7+
return appConfig[service][variant]?.translations?.liteSite
88
?.informationPageLink;
99
};
1010

Lines changed: 322 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,324 @@
1-
import runTestsForPage from '../../../support/helpers/runTestsForPage';
2-
import { testsThatFollowSmokeTestConfigForAMPOnly } from './testsForAMPOnly';
3-
import { testsThatFollowSmokeTestConfigForCanonicalOnly } from './testsForCanonicalOnly';
1+
import runTestsForPage from '#nextjs/cypress/support/helpers/runTestsForPage';
2+
import { testsThatAlwaysRunForAllPages as testsForAllPages } from '../testsForAllPages';
3+
import { testsThatFollowSmokeTestConfigForAllCanonicalPages as testsForAllCanonicalPages } from '../testsForAllCanonicalPages';
4+
import { testsThatFollowSmokeTestConfigForAllAMPPages as testsForAllAMPPages } from '../testsForAllAMPPages';
5+
import ampArticleTests from './testsForAMPOnly';
6+
import canonicalArticleTests from './testsForCanonicalOnly';
7+
import liteTests from '../articles/testsForLiteOnly';
8+
import getPathWithSuffix from '../../../support/helpers/getPathWithSuffix';
9+
import { MEDIA_ASSET_PAGE } from '../../../../src/app/routes/utils/pageTypes';
410

5-
const testsForPage = {
6-
pageType: 'mediaAssetPage',
7-
testsThatFollowSmokeTestConfigForCanonicalOnly,
8-
testsThatFollowSmokeTestConfigForAMPOnly,
9-
};
11+
const canonicalTests = [
12+
testsForAllPages,
13+
testsForAllCanonicalPages,
14+
canonicalArticleTests,
15+
];
1016

11-
runTestsForPage(testsForPage);
17+
const ampTests = [testsForAllPages, testsForAllAMPPages, ampArticleTests];
18+
19+
const canonicalSmokeTestSuites = [
20+
{
21+
path: '/hausa/labarai-51622389', // CPS MAP with video clip,
22+
service: 'hausa',
23+
runforEnv: ['live'],
24+
tests: canonicalTests,
25+
},
26+
{
27+
path: '/hausa/23269030', // CPS MAP with video clip
28+
service: 'hausa',
29+
runforEnv: ['test'],
30+
tests: canonicalTests,
31+
},
32+
{
33+
path: '/persian/media-49522521', // CPS MAP with live stream
34+
service: 'persian',
35+
runforEnv: ['live'],
36+
tests: canonicalTests,
37+
},
38+
{
39+
path: '/persian/world-51497110', // CPS MAP with video clip
40+
service: 'persian',
41+
runforEnv: ['live'],
42+
tests: canonicalTests,
43+
},
44+
{
45+
path: '/persian/tv-and-radio-51780528', // CPS MAP with audio clip
46+
service: 'persian',
47+
runforEnv: ['live'],
48+
tests: canonicalTests,
49+
},
50+
{
51+
path: '/persian/iran-23231114', // CPS MAP with audio clip
52+
service: 'persian',
53+
runforEnv: ['test'],
54+
tests: canonicalTests,
55+
},
56+
{
57+
path: '/persian/iran-23231114', // CPS MAP with audio clip
58+
service: 'persian',
59+
runforEnv: ['local'],
60+
tests: canonicalTests,
61+
},
62+
];
63+
64+
const canonicalNonSmokeTestSuites = [
65+
{
66+
path: '/afrique/media-52121324', // CPS MAP
67+
service: 'afrique',
68+
runforEnv: ['live'],
69+
tests: canonicalTests,
70+
},
71+
{
72+
path: '/afrique/region-23278969', // CPS MAP
73+
service: 'afrique',
74+
runforEnv: ['test'],
75+
tests: canonicalTests,
76+
},
77+
{
78+
path: '/amharic/news-51270657', // CPS MAP with video clip
79+
service: 'amharic',
80+
runforEnv: ['live'],
81+
tests: canonicalTests,
82+
},
83+
{
84+
path: '/amharic/news-23263266', // CPS MAP with video clip
85+
service: 'amharic',
86+
runforEnv: ['test'],
87+
tests: canonicalTests,
88+
},
89+
{
90+
path: '/arabic/media-53135426', // CPS video
91+
service: 'arabic',
92+
runforEnv: ['live'],
93+
tests: canonicalTests,
94+
},
95+
{
96+
path: '/arabic/world-23278971', // CPS audio
97+
service: 'arabic',
98+
runforEnv: ['test'],
99+
tests: canonicalTests,
100+
},
101+
{
102+
path: '/hindi/media-53139567',
103+
service: 'hindi',
104+
runforEnv: ['live'],
105+
tests: canonicalTests,
106+
},
107+
{
108+
path: '/hindi/23201477', // CPS video
109+
service: 'hindi',
110+
runforEnv: ['test'],
111+
tests: canonicalTests,
112+
},
113+
{
114+
path: '/russian/av/media-45527896', // CPS video with redirect
115+
service: 'russian',
116+
runforEnv: ['live'],
117+
tests: canonicalTests,
118+
},
119+
{
120+
path: '/russian/av/media-23320267', // CPS video with redirect
121+
service: 'russian',
122+
runforEnv: ['test'],
123+
tests: canonicalTests,
124+
},
125+
{
126+
path: '/serbian/cyr/srbija-52895074', // CPS video
127+
service: 'serbian',
128+
runforEnv: ['live'],
129+
tests: canonicalTests,
130+
},
131+
{
132+
path: '/serbian/cyr/23279016', // CPS video
133+
service: 'serbian',
134+
runforEnv: ['test'],
135+
tests: canonicalTests,
136+
},
137+
{
138+
path: '/serbian/lat/srbija-52895074', // CPS video
139+
service: 'serbian',
140+
runforEnv: ['live'],
141+
tests: canonicalTests,
142+
},
143+
{
144+
path: '/serbian/lat/23279016', // CPS video
145+
service: 'serbian',
146+
runforEnv: ['test'],
147+
tests: canonicalTests,
148+
},
149+
{
150+
path: '/swahili/gnb-51703829', // CPS MAP with video clip
151+
service: 'swahili',
152+
runforEnv: ['live'],
153+
tests: canonicalTests,
154+
},
155+
{
156+
path: '/tigrinya/news-23263262', // CPS MAP with video clip
157+
service: 'tigrinya',
158+
runforEnv: ['test'],
159+
tests: canonicalTests,
160+
},
161+
{
162+
path: '/urdu/entertainment-51584098', // CPS MAP with audio clip
163+
service: 'urdu',
164+
runforEnv: ['live'],
165+
tests: canonicalTests,
166+
},
167+
{
168+
path: '/zhongwen/simp/world-53107744', // CPS video
169+
service: 'zhongwen',
170+
runforEnv: ['live'],
171+
tests: canonicalTests,
172+
},
173+
{
174+
path: '/zhongwen/simp/uk-23283128', // CPS Audio
175+
service: 'zhongwen',
176+
runforEnv: ['test'],
177+
tests: canonicalTests,
178+
},
179+
{
180+
path: '/zhongwen/trad/world-53107744', // CPS video
181+
service: 'zhongwen',
182+
runforEnv: ['live'],
183+
tests: canonicalTests,
184+
},
185+
{
186+
path: '/zhongwen/trad/uk-23283128', // CPS Audio
187+
service: 'zhongwen',
188+
runforEnv: ['test'],
189+
tests: canonicalTests,
190+
},
191+
];
192+
193+
// TC2 MAPs do not support AMP pages
194+
const tc2CanonicalTestSuites = Cypress.env('SMOKE')
195+
? [
196+
{
197+
path: '/hausa/multimedia/2016/07/160714_tc2_audiomap?renderer_env=test', // TC2 MAP with audio clip
198+
service: 'hausa',
199+
runforEnv: ['test'],
200+
tests: canonicalTests,
201+
},
202+
]
203+
: [
204+
{
205+
path: '/afrique/institutionelles/2015/07/150714_hissene_habre_explainer', // TC2 MAP
206+
service: 'afrique',
207+
runforEnv: ['live'],
208+
tests: canonicalTests,
209+
},
210+
{
211+
path: '/afrique/nos_emissions/2016/06/160622_tc2_testmap1?renderer_env=test', // TC2 MAP
212+
service: 'afrique',
213+
runforEnv: ['test'],
214+
tests: canonicalTests,
215+
},
216+
{
217+
path: '/arabic/multimedia/2016/06/160601_qatar_sewika_smoking', // TC2 video
218+
service: 'arabic',
219+
runforEnv: ['live'],
220+
tests: canonicalTests,
221+
},
222+
{
223+
path: '/arabic/worldnews/2015/11/151120_t_arabic_av?renderer_env=test', // TC2 video
224+
service: 'arabic',
225+
runforEnv: ['test'],
226+
tests: canonicalTests,
227+
},
228+
{
229+
path: '/hindi/multimedia/2015/09/150921_what_is_innovation_ms', // TC2 video
230+
service: 'hindi',
231+
runforEnv: ['live'],
232+
tests: canonicalTests,
233+
},
234+
{
235+
path: '/hindi/sport/2016/08/160822_tc2_testmap1?renderer_env=test', // TC2 video
236+
service: 'hindi',
237+
runforEnv: ['test'],
238+
tests: canonicalTests,
239+
},
240+
{
241+
path: '/russian/multimedia/2012/04/120411_v_titanic_last_survivor', // TC2 video
242+
service: 'russian',
243+
runforEnv: ['live'],
244+
tests: canonicalTests,
245+
},
246+
{
247+
path: '/russian/news/2016/05/160510_tc2_testmap3?renderer_env=test', // TC2 video
248+
service: 'russian',
249+
runforEnv: ['test'],
250+
tests: canonicalTests,
251+
},
252+
{
253+
path: '/swahili/medianuai/2016/05/160517_apatae_fatacky', // TC2 MAP with video clip
254+
service: 'swahili',
255+
runforEnv: ['live'],
256+
tests: canonicalTests,
257+
},
258+
{
259+
path: '/swahili/michezo/2016/07/160713_tc2_testmap2?renderer_env=test', // TC2 MAP with audio clip
260+
service: 'swahili',
261+
runforEnv: ['test'],
262+
tests: canonicalTests,
263+
},
264+
{
265+
path: '/urdu/multimedia/2014/11/141104_hindu_riaz_kq', // TC2 MAP with video clip
266+
service: 'urdu',
267+
runforEnv: ['live'],
268+
tests: canonicalTests,
269+
},
270+
{
271+
path: '/zhongwen/simp/multimedia/2016/06/160608_vid_gaokao_voxpop', // TC2 video
272+
service: 'zhongwen',
273+
runforEnv: ['live'],
274+
tests: canonicalTests,
275+
},
276+
{
277+
path: '/zhongwen/simp/multimedia/2016/11/161107_tc2_testmap1?renderer_env=test', // TC2 Video
278+
service: 'zhongwen',
279+
runforEnv: ['test'],
280+
tests: canonicalTests,
281+
},
282+
{
283+
path: '/zhongwen/trad/multimedia/2016/06/160608_vid_gaokao_voxpop', // TC2 video
284+
service: 'zhongwen',
285+
runforEnv: ['live'],
286+
tests: canonicalTests,
287+
},
288+
];
289+
290+
const canonicalTestSuites = Cypress.env('SMOKE')
291+
? canonicalSmokeTestSuites
292+
: canonicalNonSmokeTestSuites;
293+
294+
const ampTestSuites = canonicalTestSuites.map(testSuite => {
295+
return {
296+
...testSuite,
297+
path: getPathWithSuffix({ path: testSuite.path, suffix: '.amp' }),
298+
tests: [...ampTests],
299+
};
300+
});
301+
302+
const liteTestSuites = Cypress.env('SMOKE')
303+
? canonicalTestSuites
304+
.filter(
305+
({ service }) => !['news', 'sport', 'newsround'].includes(service),
306+
)
307+
.map(testSuite => {
308+
return {
309+
...testSuite,
310+
path: `${testSuite.path}.lite`,
311+
tests: [liteTests],
312+
};
313+
})
314+
: [];
315+
316+
runTestsForPage({
317+
pageType: MEDIA_ASSET_PAGE,
318+
testSuites: [
319+
...canonicalTestSuites,
320+
...tc2CanonicalTestSuites,
321+
...ampTestSuites,
322+
...liteTestSuites,
323+
],
324+
});

cypress/e2e/pages/mediaAssetPage/testsForAMPOnly.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
// For testing features that may differ across services but share a common logic e.g. translated strings.
4-
export const testsThatFollowSmokeTestConfigForAMPOnly = ({
5-
service,
6-
pageType,
7-
}) => {
8-
describe(`testsThatFollowSmokeTestConfigForAMPOnly for ${service} ${pageType}`, () => {
2+
export default ({ service, pageType, path }) => {
3+
describe(`AMP tests for ${service} ${pageType} ${path}`, () => {
94
describe('Media Player', () => {
105
it('should render an iframe with a valid URL', () => {
116
if (!`${Cypress.env('currentPath')}`.includes('/russian/av/')) {

cypress/e2e/pages/mediaAssetPage/testsForCanonicalOnly.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
/* eslint-disable import/prefer-default-export */
21
import appToggles from '../../../support/helpers/useAppToggles';
32
import envConfig from '../../../support/config/envs';
43

54
// For testing features that may differ across services but share a common logic e.g. translated strings.
6-
export const testsThatFollowSmokeTestConfigForCanonicalOnly = ({
7-
service,
8-
pageType,
9-
}) => {
10-
describe(`testsThatFollowSmokeTestConfigForCanonicalOnly for ${service} ${pageType}`, () => {
5+
export default ({ service, pageType }) => {
6+
describe(`Canonical tests for ${service} ${pageType}`, () => {
117
if (appToggles.chartbeatAnalytics.enabled && envConfig.chartbeatEnabled) {
128
describe('Chartbeat', () => {
139
it('should have a script with correct src', () => {

cypress/e2e/specialFeatures/atiAnalytics/helpers/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,6 @@ export const interceptATIAnalyticsBeacons = () => {
161161
).as(`${ATI_PAGE_VIEW_REVERB}`);
162162
};
163163

164-
export const getPathWithSuffix = ({ path, suffix = '' }) => {
165-
const { pathname, search } = new URL(`https://www.bbc.com${path}`);
166-
167-
return `${pathname}${suffix}${search}`;
168-
};
169-
170164
export const setUserIDCookie = () => {
171165
cy.setCookie('atuserid', JSON.stringify({ val: ATI_USER_ID_COOKIE }));
172166
};

cypress/e2e/specialFeatures/atiAnalytics/index.cy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ import {
7171
assertTopStoriesComponentClick,
7272
assertTopStoriesComponentView,
7373
} from './assertions/topStories';
74-
import { getPathWithSuffix, setUserIDCookie } from './helpers';
74+
import { setUserIDCookie } from './helpers';
75+
import getPathWithSuffix from '../../../support/helpers/getPathWithSuffix';
7576

7677
const canonicalTestSuites = [
7778
{

0 commit comments

Comments
 (0)