Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WORLDSERVICE-122: Cypress E2E tests for ATI Analytics #12412

Merged
merged 49 commits into from
Feb 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
195852a
Add gahuza fixture data to ensure clicking on links does not render a…
karinathomasbbc Feb 17, 2025
b410771
Adding E2E tests for ATI component view & click tracking
karinathomasbbc Feb 17, 2025
c6ea155
Update test description
karinathomasbbc Feb 17, 2025
9b008c5
Add assertions for the top stories component to the article tests
karinathomasbbc Feb 17, 2025
423f045
Rename tests
karinathomasbbc Feb 17, 2025
82055f3
Tidy up event interception
karinathomasbbc Feb 17, 2025
c360b01
Include assertions for the radio schedule on live radio pages
karinathomasbbc Feb 17, 2025
275d252
Add assertions for message banner on homepages & related topics/relat…
karinathomasbbc Feb 17, 2025
ee40daf
Add podcast promo & rename helper functions
karinathomasbbc Feb 17, 2025
1048d44
Set data-e2e attribute on the podcast promo component
karinathomasbbc Feb 17, 2025
3e9fbbb
Attempting to fix the issue with the features/analysis click
karinathomasbbc Feb 17, 2025
facb0db
Update podcast promo test
karinathomasbbc Feb 17, 2025
aac9fee
Loosen route matcher
karinathomasbbc Feb 17, 2025
1047939
Add test attribute to the podcast promo component
karinathomasbbc Feb 17, 2025
5983cf8
Add podcast promo tests to the article assertions
karinathomasbbc Feb 17, 2025
34a3b28
Add placeholder test for lite site cta
karinathomasbbc Feb 17, 2025
c1eef43
Add recent audio episodes for OD Audio page
karinathomasbbc Feb 17, 2025
808453d
Update snapshots
karinathomasbbc Feb 17, 2025
76cc8f4
Add whitespace before assertion
karinathomasbbc Feb 17, 2025
ac7e2e3
Tweak URLs for different environments
karinathomasbbc Feb 17, 2025
e0796f3
Add assertions for podcast external links to podcast pages
karinathomasbbc Feb 17, 2025
a37aba2
Tests for latest media component on media article pages
karinathomasbbc Feb 17, 2025
5053c8c
Add latest media component
karinathomasbbc Feb 17, 2025
d794133
Include examples for all express page types in ATI analytics tests
karinathomasbbc Feb 17, 2025
1347601
Merge branch 'latest' into cypress-ati-tracking
karinathomasbbc Feb 17, 2025
261223b
Shorten name of podcast links e2e test ID
karinathomasbbc Feb 17, 2025
8360b40
Exclude TV & most read pages from lite tests, as lite is not currentl…
karinathomasbbc Feb 17, 2025
d689b3f
Merge branch 'cypress-ati-tracking' of github.com:bbc/simorgh into cy…
karinathomasbbc Feb 17, 2025
ce37c56
Update snapshots
karinathomasbbc Feb 17, 2025
96bc138
Adding tests for recommendations & scrollable promo components
karinathomasbbc Feb 18, 2025
9f59d63
Remove unnecessary filter
karinathomasbbc Feb 18, 2025
0ff8170
Update snapshots
karinathomasbbc Feb 18, 2025
5a78537
Adding coverage for topic page
karinathomasbbc Feb 18, 2025
0b5d154
Adding coverage for topic page
karinathomasbbc Feb 18, 2025
4ec7e73
Merge branch 'latest' of github.com:bbc/simorgh into cypress-ati-trac…
karinathomasbbc Feb 19, 2025
6a7f76e
Add lite tests
karinathomasbbc Feb 19, 2025
0e46d16
Assert that expected fields are set on page view, component view & co…
karinathomasbbc Feb 19, 2025
bf537fb
Assert that expected fields are set on page view, component view & co…
karinathomasbbc Feb 19, 2025
b38376c
Use regex to intercept events
karinathomasbbc Feb 19, 2025
9f068c6
Additional message to the assertions to include the parameter name & …
karinathomasbbc Feb 19, 2025
b76bc3c
Don't check x1 on most read
karinathomasbbc Feb 19, 2025
29edbb3
Tidy up assertions
karinathomasbbc Feb 19, 2025
314a6f9
Move page view interception to after component views & clicks
karinathomasbbc Feb 20, 2025
a4b2d40
Use its to get the url from the aliased request
karinathomasbbc Feb 20, 2025
5676351
Update test description
karinathomasbbc Feb 20, 2025
d0fd435
Stub the ATI requests to ensure events not fired / send to Piano
karinathomasbbc Feb 20, 2025
8e7dd9c
Merge branch 'latest' of github.com:bbc/simorgh into cypress-ati-trac…
karinathomasbbc Feb 21, 2025
0dc7dc9
Only run lite tests against services which have it enabled (only gahu…
karinathomasbbc Feb 21, 2025
c87ef55
Merge branch 'latest' into cypress-ati-tracking
karinathomasbbc Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 40 additions & 20 deletions cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ const assertATIComponentViewEventParamsExist = params => {
expect(params).to.have.property('p'); // page identifier
expect(params).to.have.property('ati'); // view event
expect(params).to.have.property('type');
expect(params.type).to.equal('AT');
expect(params.type).to.equal('AT', 'params.type');
};

const assertATIComponentClickEventParamsExist = params => {
@@ -51,7 +51,7 @@ const assertATIComponentClickEventParamsExist = params => {
expect(params).to.have.property('p'); // page identifier
expect(params).to.have.property('atc'); // click event
expect(params).to.have.property('type');
expect(params.type).to.equal('AT');
expect(params.type).to.equal('AT', 'params.type');
};

export const assertPageView = ({
@@ -74,32 +74,49 @@ export const assertPageView = ({
applicationType,
});

expect(params.p).to.equal(pageIdentifier);
expect(params.x2).to.equal(`[${applicationType}]`);
expect(params.x3).to.equal(`[news-${service}]`);
expect(params.x7).to.equal(`[${contentType}]`);
expect(params.p).to.equal(pageIdentifier, 'params.p (page identifier)');
expect(params.x2).to.equal(
`[${applicationType}]`,
'params.x2 (application type)',
);
expect(params.x3).to.equal(
`[news-${service}]`,
'params.x3 (application name)',
);
expect(params.x7).to.equal(
`[${contentType}]`,
'params.x7 (content type)',
);
});
});
});
};

const getViewClickEventRegex = ({ contentType, component, pageIdentifier }) =>
new RegExp(
`PUB-\\[${contentType}.*?\\]-\\[${component}.*?\\]-\\[.*?\\]-\\[.*?\\]-\\[${pageIdentifier}\\]-\\[.*?\\]-\\[.*?\\]-\\[.*?\\]`,
'g',
);

export const assertATIComponentViewEvent = ({
component,
pageIdentifier,
contentType,
}) =>
cy.wait(`@${component}-ati-view`).then(({ request: { url } }) => {
const viewEventDetails = new RegExp(
`PUB-\\[${contentType}\\]-\\[${component}.*?\\]-\\[.*?\\]-\\[.*?\\]-\\[${pageIdentifier}\\]-\\[.*?\\]-\\[.*?\\]-\\[.*?\\]`,
'g',
);

const params = getATIParamsFromURL(url);

assertATIComponentViewEventParamsExist(params);

expect(params.p).to.equal(pageIdentifier);
expect(params.ati).to.match(viewEventDetails);
expect(params.ati).to.match(
getViewClickEventRegex({
contentType,
component,
pageIdentifier,
}),
'params.ati (publisher impression)',
);
});

export const assertATIComponentClickEvent = ({
@@ -109,19 +126,22 @@ export const assertATIComponentClickEvent = ({
applicationType,
}) =>
cy.wait(`@${component}-ati-click`).then(({ request: { url } }) => {
const clickEventDetails = new RegExp(
`PUB-\\[${contentType}\\]-\\[${component}.*?\\]-\\[.*?\\]-\\[.*?\\]-\\[${pageIdentifier}\\]-\\[.*?\\]-\\[.*?\\]-\\[.*?\\]`,
'g',
);

const params = getATIParamsFromURL(url);

assertATIComponentClickEventParamsExist(params);

if (applicationType === 'lite') {
expect(params.app_type).to.equal(applicationType);
expect(params.app_type).to.equal(applicationType, 'params.app_type');
}

expect(params.p).to.equal(pageIdentifier);
expect(params.atc).to.match(clickEventDetails);
expect(params.p).to.equal(pageIdentifier, 'params.p (page identifier)');

expect(params.atc).to.match(
getViewClickEventRegex({
contentType,
pageIdentifier,
component,
}),
'params.atc (publisher click)',
);
});