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

Conversation

karinathomasbbc
Copy link
Contributor

@karinathomasbbc karinathomasbbc commented Feb 17, 2025

Resolves JIRA https://jira.dev.bbc.co.uk/browse/WORLDSERVICE-122

Overall changes

Allows us to test ATI analytics events are being fired as expected from all page types, especially the lite site (where we are enabling click tracking as part of #12360)

Code changes

  • Add a new test suite within specialFeatures for ATI analytics
  • Tests that ATI view and click events are sent where applicable, for all page types in the Express JS app

Testing

  • PR checks passing
  • CYPRESS_APP_ENV=test yarn cypress run --spec './cypress/e2e/specialFeatures/atiAnalytics/*'
    Expected Failing tests (as the attribute has been added in this PR):
    • Podcast Links
  • CYPRESS_APP_ENV=live yarn cypress run --spec './cypress/e2e/specialFeatures/atiAnalytics/*'
    Expected Failing tests (as the attribute has been added in this PR):
    • Podcast Links
    • Podcast Promo
    • Scrollable Promo

See test output here: https://github.com/bbc/simorgh/actions/runs/13389554089/job/37393937077?pr=12412 - search for specialFeatures/atiAnalytics

@karinathomasbbc karinathomasbbc self-assigned this Feb 17, 2025
};

export const assertFeaturesAnalysisComponentClick = () => {
it.skip('should send a click event for the Features & Analysis component', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO try to fix this 🤷‍♀️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #12421 (need to check what the implications are of this fix)

@karinathomasbbc karinathomasbbc changed the title Cypress E2E tests for ATI Analytics WORLDSERVICE-122: Cypress E2E tests for ATI Analytics Feb 17, 2025
@karinathomasbbc karinathomasbbc marked this pull request as ready for review February 17, 2025 18:12
Comment on lines +7 to +58
const assertATIPageViewEventParamsExist = ({
params,
contentType,
applicationType,
}) => {
expect(params).to.have.property('s'); // destination
expect(params).to.have.property('s2'); // producer
expect(params).to.have.property('p'); // page identifier
expect(params).to.have.property('x2'); // application type
expect(params).to.have.property('x3'); // application name
expect(params).to.have.property('x4'); // language
expect(params).to.have.property('x7'); // content type
expect(params).to.have.property('x8'); // library version
expect(params).to.have.property('x9'); // page title

if (['responsive', 'amp'].includes(applicationType)) {
expect(params).to.have.property('r'); // screen resolution & colour depth
expect(params).to.have.property('re'); // browser/viewport resolution
expect(params).to.have.property('hl'); // timestamp
expect(params).to.have.property('lng'); // device language
expect(params).to.have.property('x5'); // url
}

if (contentType !== 'list-datadriven') {
expect(params).to.have.property('x1'); // content ID
}

if (contentType === 'article') {
expect(params).to.have.property('x11'); // first published
expect(params).to.have.property('x12'); // last published
expect(params).to.have.property('x13'); // ldp things
expect(params).to.have.property('x17'); // category
}
};

const assertATIComponentViewEventParamsExist = params => {
expect(params).to.have.property('s'); // destination
expect(params).to.have.property('s2'); // producer
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', 'params.type');
};

const assertATIComponentClickEventParamsExist = params => {
expect(params).to.have.property('s'); // destination
expect(params).to.have.property('s2'); // producer
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', 'params.type');
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewers: I've added a tests to assert that the query params exist, but we are not asserting on the values as they are often dynamic (and the value of adding them is low).

Copy link
Contributor

@amoore108 amoore108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very indepth, thanks for tackling this!

Keen to see how this behaves on the pipelines 👍

Copy link
Contributor

@LilyL0u LilyL0u left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way this is done. Easy to add to.

@karinathomasbbc
Copy link
Contributor Author

Looks very indepth, thanks for tackling this!

Keen to see how this behaves on the pipelines 👍

Thanks! It should be OK in the pipelines, I've run it against test & live data (see Testing section in the PR description above), to ensure that it wouldn't block anything 😅 ). But failing tests can easily be fixed forward or component assertions removed e.g. if a homepage no longer has a message banner. Hopefully they are fairly robust & give us confidence in our analytics 🤞

@karinathomasbbc karinathomasbbc merged commit f975ca9 into latest Feb 21, 2025
11 checks passed
@karinathomasbbc karinathomasbbc deleted the cypress-ati-tracking branch February 21, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants