Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 16 additions & 20 deletions cypress/e2e/specialFeatures/atiAnalytics/assertions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 =>
Expand All @@ -272,6 +271,7 @@ export const assertATIComponentViewEvent = ({
component,
pageIdentifier,
contentType,
applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-view`;
Expand All @@ -286,6 +286,7 @@ export const assertATIComponentViewEvent = ({
pageIdentifier,
contentType,
params,
applicationType,
siteId,
});
});
Expand All @@ -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({
Expand All @@ -328,6 +322,7 @@ export const assertATIComponentClickEvent = ({
component,
contentType,
pageIdentifier,
applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-click`;
Expand All @@ -341,6 +336,7 @@ export const assertATIComponentClickEvent = ({
contentType,
pageIdentifier,
params,
applicationType,
siteId,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const { BILLBOARD } = COMPONENTS;

export const assertBillboardComponentView = ({
pageIdentifier,
contentType,
path,
applicationType,
siteId,
Expand All @@ -21,7 +20,6 @@ export const assertBillboardComponentView = ({
assertATIComponentViewEvent({
component: BILLBOARD,
pageIdentifier,
contentType,
applicationType,
siteId,
});
Expand All @@ -30,7 +28,6 @@ export const assertBillboardComponentView = ({

export const assertBillboardComponentClick = ({
pageIdentifier,
contentType,
path,
applicationType,
siteId,
Expand All @@ -49,7 +46,6 @@ export const assertBillboardComponentClick = ({
assertATIComponentClickEvent({
component: BILLBOARD,
pageIdentifier,
contentType,
applicationType,
siteId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const assertContinueReadingButtonComponentView = ({
component: CONTINUE_READING_BUTTON,
pageIdentifier,
contentType,
applicationType,
siteId,
});
},
Expand Down Expand Up @@ -64,6 +65,7 @@ export const assertContinueReadingButtonComponentClick = ({
component: CONTINUE_READING_BUTTON,
pageIdentifier,
contentType,
applicationType,
siteId,
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
import {
ATI_PAGE_VIEW,
ATI_PAGE_VIEW_REVERB,
// ATI_USER_ID_COOKIE,
ATI_USER_ID_COOKIE,
getATIParamsFromURL,
interceptATIAnalyticsBeacons,
getExpectedAtiDestination,
} from '../helpers';
import environment from '../../../../support/helpers/getAppEnv';

const usesReverbViewabilityModel = applicationType =>
applicationType !== 'lite';
!['lite', 'amp'].includes(applicationType);

const getAppName = service => {
if (service === 'ws') {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -183,7 +190,6 @@ const validateViewabilityEventDetails = ({ payload, actionType }) => {
};

export const assertPageView = ({
useReverb,
pageIdentifier,
applicationType,
contentType,
Expand All @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -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 =>
Expand All @@ -274,6 +270,7 @@ const assertViewabilityModelViewEvent = ({
export const assertATIComponentViewEvent = ({
component,
pageIdentifier,
applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-view`;
Expand All @@ -286,6 +283,7 @@ export const assertATIComponentViewEvent = ({
assertViewabilityModelViewEvent({
pageIdentifier,
params,
applicationType,
siteId,
});
});
Expand All @@ -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({
Expand All @@ -327,6 +318,7 @@ const assertViewabilityModelClickEvent = ({
export const assertATIComponentClickEvent = ({
component,
pageIdentifier,
applicationType,
siteId,
}) => {
const requestAlias = `@${component}-viewability-click`;
Expand All @@ -338,6 +330,7 @@ export const assertATIComponentClickEvent = ({
assertViewabilityModelClickEvent({
pageIdentifier,
params,
applicationType,
siteId,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -27,6 +28,7 @@ export const assertTopBarOJComponentView = ({
component: TOP_BAR_OJ,
pageIdentifier,
contentType,
applicationType,
siteId,
});
});
Expand All @@ -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', () => {
Expand All @@ -53,6 +56,7 @@ export const assertTopBarOJComponentClick = ({
component: TOP_BAR_OJ,
pageIdentifier,
contentType,
applicationType,
siteId,
});
});
Expand Down