diff --git a/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js b/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js index 2cafe161fa8..1527fa9debf 100644 --- a/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js +++ b/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js @@ -93,7 +93,14 @@ const assertLocationSpecificPianoDestinationExists = ({ service }) => { }); }; -const assertReverbViewabilityComponentEventParamsExist = ({ params }) => { +const assertReverbViewabilityComponentEventParamsExist = ({ + params, + applicationType, +}) => { + if (['responsive', 'lite'].includes(applicationType)) { + expect(params).to.have.property('idclient'); + } + expect(params).to.have.property('s'); // destination expect(params).to.have.property('events'); // event details expect(params).to.have.property('context'); @@ -243,20 +250,12 @@ export const assertPageView = ({ const assertViewabilityModelViewEvent = ({ pageIdentifier, params, - // applicationType, + applicationType, siteId, }) => { const eventContext = JSON.parse(params.context); - assertReverbViewabilityComponentEventParamsExist({ params }); - - // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222 - // if (['responsive', 'lite'].includes(applicationType)) { - // expect(params.idclient).to.equal( - // ATI_USER_ID_COOKIE, - // 'params.idclient (atuserid cookie value)', - // ); - // } + assertReverbViewabilityComponentEventParamsExist({ params, applicationType }); expect(params.events).to.satisfy( payload => @@ -272,6 +271,7 @@ export const assertATIComponentViewEvent = ({ component, pageIdentifier, contentType, + applicationType, siteId, }) => { const requestAlias = `@${component}-viewability-view`; @@ -286,6 +286,7 @@ export const assertATIComponentViewEvent = ({ pageIdentifier, contentType, params, + applicationType, siteId, }); }); @@ -294,23 +295,16 @@ export const assertATIComponentViewEvent = ({ const assertViewabilityModelClickEvent = ({ pageIdentifier, params, - // applicationType, + applicationType, siteId, }) => { const eventContext = JSON.parse(params.context); assertReverbViewabilityComponentEventParamsExist({ params, + applicationType, }); - // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222 - // if (['responsive', 'lite'].includes(applicationType)) { - // expect(params.idclient).to.equal( - // ATI_USER_ID_COOKIE, - // 'params.idclient (atuserid cookie value)', - // ); - // } - expect(params.events).to.satisfy( payload => validateViewabilityEventDetails({ @@ -328,6 +322,7 @@ export const assertATIComponentClickEvent = ({ component, contentType, pageIdentifier, + applicationType, siteId, }) => { const requestAlias = `@${component}-viewability-click`; @@ -341,6 +336,7 @@ export const assertATIComponentClickEvent = ({ contentType, pageIdentifier, params, + applicationType, siteId, }); }); diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts index 9f68970a4ea..62478db2e98 100644 --- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts +++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/billboard.ts @@ -5,7 +5,6 @@ const { BILLBOARD } = COMPONENTS; export const assertBillboardComponentView = ({ pageIdentifier, - contentType, path, applicationType, siteId, @@ -21,7 +20,6 @@ export const assertBillboardComponentView = ({ assertATIComponentViewEvent({ component: BILLBOARD, pageIdentifier, - contentType, applicationType, siteId, }); @@ -30,7 +28,6 @@ export const assertBillboardComponentView = ({ export const assertBillboardComponentClick = ({ pageIdentifier, - contentType, path, applicationType, siteId, @@ -49,7 +46,6 @@ export const assertBillboardComponentClick = ({ assertATIComponentClickEvent({ component: BILLBOARD, pageIdentifier, - contentType, applicationType, siteId, }); diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts index fcaa7d4576e..fba47465733 100644 --- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts +++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/continueReadingButton.ts @@ -32,6 +32,7 @@ export const assertContinueReadingButtonComponentView = ({ component: CONTINUE_READING_BUTTON, pageIdentifier, contentType, + applicationType, siteId, }); }, @@ -64,6 +65,7 @@ export const assertContinueReadingButtonComponentClick = ({ component: CONTINUE_READING_BUTTON, pageIdentifier, contentType, + applicationType, siteId, }); }, diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts index 04b25404e60..00305b96af4 100644 --- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts +++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/index.ts @@ -6,7 +6,7 @@ import { import { ATI_PAGE_VIEW, ATI_PAGE_VIEW_REVERB, - // ATI_USER_ID_COOKIE, + ATI_USER_ID_COOKIE, getATIParamsFromURL, interceptATIAnalyticsBeacons, getExpectedAtiDestination, @@ -14,7 +14,7 @@ import { import environment from '../../../../support/helpers/getAppEnv'; const usesReverbViewabilityModel = applicationType => - applicationType !== 'lite'; + !['lite', 'amp'].includes(applicationType); const getAppName = service => { if (service === 'ws') { @@ -93,7 +93,14 @@ const assertLocationSpecificPianoDestinationExists = ({ service }) => { }); }; -const assertReverbViewabilityComponentEventParamsExist = ({ params }) => { +const assertReverbViewabilityComponentEventParamsExist = ({ + params, + applicationType, +}) => { + if (['responsive', 'lite'].includes(applicationType)) { + expect(params).to.have.property('idclient'); + } + expect(params).to.have.property('s'); // destination expect(params).to.have.property('events'); // event details expect(params).to.have.property('context'); @@ -183,7 +190,6 @@ const validateViewabilityEventDetails = ({ payload, actionType }) => { }; export const assertPageView = ({ - useReverb, pageIdentifier, applicationType, contentType, @@ -196,10 +202,9 @@ export const assertPageView = ({ cy.visit(path, { retryOnStatusCodeFailure: true }); const useViewabilty = usesReverbViewabilityModel(applicationType); - const atiPageViewAlias = - useReverb && useViewabilty && applicationType !== 'amp' - ? ATI_PAGE_VIEW_REVERB - : ATI_PAGE_VIEW; + const atiPageViewAlias = useViewabilty + ? ATI_PAGE_VIEW_REVERB + : ATI_PAGE_VIEW; cy.wait(`@${atiPageViewAlias}`).then(({ request }) => { const params = getATIParamsFromURL(request.url); @@ -210,13 +215,12 @@ export const assertPageView = ({ applicationType, }); - // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222 - // if (['responsive', 'lite'].includes(applicationType)) { - // expect(params.idclient).to.equal( - // ATI_USER_ID_COOKIE, - // 'params.idclient (atuserid cookie value)', - // ); - // } + if (['responsive', 'lite'].includes(applicationType)) { + expect(params.idclient).to.equal( + ATI_USER_ID_COOKIE, + 'params.idclient (atuserid cookie value)', + ); + } expect(params.p).to.equal(pageIdentifier, 'params.p (page identifier)'); expect(parseInt(params.s2, 10)).to.equal( @@ -246,20 +250,12 @@ export const assertPageView = ({ const assertViewabilityModelViewEvent = ({ pageIdentifier, params, - // applicationType, + applicationType, siteId, }) => { const eventContext = JSON.parse(params.context); - assertReverbViewabilityComponentEventParamsExist({ params }); - - // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222 - // if (['responsive', 'lite'].includes(applicationType)) { - // expect(params.idclient).to.equal( - // ATI_USER_ID_COOKIE, - // 'params.idclient (atuserid cookie value)', - // ); - // } + assertReverbViewabilityComponentEventParamsExist({ params, applicationType }); expect(params.events).to.satisfy( payload => @@ -274,6 +270,7 @@ const assertViewabilityModelViewEvent = ({ export const assertATIComponentViewEvent = ({ component, pageIdentifier, + applicationType, siteId, }) => { const requestAlias = `@${component}-viewability-view`; @@ -286,6 +283,7 @@ export const assertATIComponentViewEvent = ({ assertViewabilityModelViewEvent({ pageIdentifier, params, + applicationType, siteId, }); }); @@ -294,23 +292,16 @@ export const assertATIComponentViewEvent = ({ const assertViewabilityModelClickEvent = ({ pageIdentifier, params, - // applicationType, + applicationType, siteId, }) => { const eventContext = JSON.parse(params.context); assertReverbViewabilityComponentEventParamsExist({ params, + applicationType, }); - // TODO: Commenting out temporarily until old ATI code is removed - https://bbc.atlassian.net/browse/WS-222 - // if (['responsive', 'lite'].includes(applicationType)) { - // expect(params.idclient).to.equal( - // ATI_USER_ID_COOKIE, - // 'params.idclient (atuserid cookie value)', - // ); - // } - expect(params.events).to.satisfy( payload => validateViewabilityEventDetails({ @@ -327,6 +318,7 @@ const assertViewabilityModelClickEvent = ({ export const assertATIComponentClickEvent = ({ component, pageIdentifier, + applicationType, siteId, }) => { const requestAlias = `@${component}-viewability-click`; @@ -338,6 +330,7 @@ export const assertATIComponentClickEvent = ({ assertViewabilityModelClickEvent({ pageIdentifier, params, + applicationType, siteId, }); }); diff --git a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts index 5ee6c57376a..777c896b868 100644 --- a/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts +++ b/ws-nextjs-app/cypress/e2e/specialFeatures/atiAnalytics/assertions/topBarOjs.ts @@ -12,6 +12,7 @@ export const assertTopBarOJComponentView = ({ pageIdentifier, contentType, path, + applicationType, siteId, }: AtiAssertionFnProps) => { it('should send a view event for the Top Bar OJ component', () => { @@ -27,6 +28,7 @@ export const assertTopBarOJComponentView = ({ component: TOP_BAR_OJ, pageIdentifier, contentType, + applicationType, siteId, }); }); @@ -36,6 +38,7 @@ export const assertTopBarOJComponentClick = ({ pageIdentifier, contentType, path, + applicationType, siteId, }: AtiAssertionFnProps) => { it('should send a click event for the Top Bar OJ component', () => { @@ -53,6 +56,7 @@ export const assertTopBarOJComponentClick = ({ component: TOP_BAR_OJ, pageIdentifier, contentType, + applicationType, siteId, }); });