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

Tests for AA script duplication #739

Merged
merged 2 commits into from
Oct 18, 2024
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
25 changes: 14 additions & 11 deletions components/MetaData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@ const MetaData = ({ language, data }: MetaDataProps) => {
<meta name="dcterms.service" content={d.service} />
</Head>

{process.env.ENVIRONMENT === 'production' ? (
<Script
strategy="beforeInteractive"
src="//assets.adobedtm.com/be5dfd287373/9b9cb7867b5b/launch-59d77766b86a.min.js"
/>
) : (
<Script
strategy="beforeInteractive"
src="https://assets.adobedtm.com/be5dfd287373/9b9cb7867b5b/launch-cad75bf2f0d2-staging.min.js"
/>
)}
{
// AA script must be loaded before the pageLoad event fires
process.env.ENVIRONMENT === 'production' ? (
<Script
strategy="beforeInteractive"
src="//assets.adobedtm.com/be5dfd287373/9b9cb7867b5b/launch-59d77766b86a.min.js"
/>
) : (
<Script
strategy="beforeInteractive"
src="https://assets.adobedtm.com/be5dfd287373/9b9cb7867b5b/launch-cad75bf2f0d2-staging.min.js"
/>
)
}
</>
)
}
Expand Down
11 changes: 11 additions & 0 deletions cypress/e2e/ContactUs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

describe('Validate Contact Us Landing page', () => {
beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/contact-us')
})

Expand Down Expand Up @@ -45,4 +50,10 @@ describe('Validate Contact Us Landing page', () => {
cy.location('pathname', { timeout: 10000 })
.should('equal', '/en/contact-us')
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
11 changes: 11 additions & 0 deletions cypress/e2e/ContactUsCPP.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
describe('Validate Contact Canada Pension Plan page', () => {

beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/contact-us/contact-canada-pension-plan')
})

Expand Down Expand Up @@ -79,4 +84,10 @@ describe('Validate Contact Canada Pension Plan page', () => {
})
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})

})
11 changes: 11 additions & 0 deletions cypress/e2e/ContactUsEI.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
describe('Validate EI Contact Us Landing page', () => {

beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/contact-us/contact-employment-insurance')
})

Expand Down Expand Up @@ -79,4 +84,10 @@ describe('Validate EI Contact Us Landing page', () => {
})
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})

})
12 changes: 11 additions & 1 deletion cypress/e2e/ContactUsOAS.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
describe('Validate Contact Old Age Security page', () => {

beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/contact-us/contact-old-age-security')
})

Expand Down Expand Up @@ -79,5 +84,10 @@ describe('Validate Contact Old Age Security page', () => {
.should('be.visible')
})
})


it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
11 changes: 11 additions & 0 deletions cypress/e2e/DecisionReviews.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

describe('Validate Request a review of a decision page', () => {
beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/en/decision-reviews')
})
it('Request a review has no detectable a11y violations on load', () => {
Expand Down Expand Up @@ -52,4 +57,10 @@ describe('Validate Request a review of a decision page', () => {
cy.get('[data-cy="breadcrumb-My dashboard"]').click()
cy.url().should('include', '/my-dashboard')
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
11 changes: 11 additions & 0 deletions cypress/e2e/Login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
It does not test the authentication functionality currently since those endpoints are on prem only at this time. **/

beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/auth/login')
})

Expand Down Expand Up @@ -36,4 +41,10 @@ describe('Validate login page', () => {
})
cy.get('[data-cy="loading-spinner"]').should('not.exist')
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
11 changes: 11 additions & 0 deletions cypress/e2e/Profile.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

describe('Validate Profile page', () => {
beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/profile')
})

Expand Down Expand Up @@ -142,4 +147,10 @@ describe('Validate Profile page', () => {
.and('not.have.attr', 'href', '#undefined')
})
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
11 changes: 11 additions & 0 deletions cypress/e2e/SecuritySettings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

describe('Validate Security Settings page', () => {
beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/security-settings')
})

Expand Down Expand Up @@ -81,4 +86,10 @@ describe('Validate Security Settings page', () => {
.should('be.visible')
.and('have.text', 'Profil')
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
10 changes: 10 additions & 0 deletions cypress/e2e/dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

describe('Validate dashboard page', () => {
beforeEach(() => {
cy.intercept({
method: 'GET',
hostname: 'assets.adobedtm.com',
path: /.*\/launch-.*/,
}).as('adobeAnalytics')
cy.visit('/my-dashboard')
})

Expand Down Expand Up @@ -369,4 +374,9 @@ describe('Validate dashboard page', () => {
})
})

it('Validate there is exactly one copy of the AA script and it was only loaded once', () => {
cy.get('@adobeAnalytics.all').its('length').should('eq', 1)
cy.get('script[src*="adobedtm"]').filter('[src*="launch-"]').as('analyticsScript')
cy.get('@analyticsScript').its('length').should('eq', 1)
})
})
Loading