-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(nuxt-app): adding tests for analytics events
- Loading branch information
David Featherston
committed
Jul 21, 2024
1 parent
91dcb0b
commit 33a4994
Showing
13 changed files
with
197 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: Analytics | ||
|
||
Background: | ||
Given the site endpoint returns fixture "/site/reference" with status 200 | ||
|
||
@mockserver | ||
Scenario: DataLayer events | ||
Given the site endpoint returns fixture "/site/reference" with status 200 | ||
And the page endpoint for path "/" returns fixture "/landingpage/home" with status 200 | ||
Given I visit the page "/" | ||
|
||
Then the dataLayer should include the following events | ||
| event | page_title | page_url | content_type | | ||
| routeChange | Demo Landing Page | / | landing_page | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/ripple-test-utils/step_definitions/common/site/analytics.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { DataTable, Then } from '@badeball/cypress-cucumber-preprocessor' | ||
|
||
Then( | ||
'the dataLayer should include the following events', | ||
(dataTable: DataTable) => { | ||
const table = dataTable.hashes() | ||
|
||
table.forEach((row) => { | ||
cy.window().then((window) => { | ||
const dataLayer = window.dataLayer | ||
|
||
const event = dataLayer.find((i) => i.event === row.event) | ||
|
||
const updatedRow = Object.entries(row).reduce((acc, [key, value]) => { | ||
return { | ||
...acc, | ||
[key]: value | ||
} | ||
}, {}) | ||
|
||
cy.wrap(event).should('include', updatedRow) | ||
}) | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/ripple-test-utils/step_definitions/components/media-embed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor' | ||
|
||
Given('a media embed with ID {string} should exist', (id: string) => { | ||
cy.get(`[data-component-id="${id}"]`).as('component') | ||
cy.get('@component').should('exist') | ||
cy.get(`@component`).should( | ||
'have.attr', | ||
'data-component-type', | ||
'TideLandingPageMediaEmbed' | ||
) | ||
}) | ||
|
||
Then( | ||
'I click the action {string} for media embed {string}', | ||
(label: string, id: string) => { | ||
cy.get(`[data-component-id="${id}"]`).as('component') | ||
|
||
cy.get('@component').within(() => { | ||
cy.contains('.rpl-media-embed__action', label).click() | ||
}) | ||
} | ||
) | ||
|
||
Then( | ||
'I trigger a click for the action {string} on the media embed {string}', | ||
(label: string, id: string) => { | ||
cy.get(`[data-component-id="${id}"]`).as('component') | ||
|
||
cy.get('@component').within(() => { | ||
cy.contains('.rpl-media-embed__action', label).trigger('click') | ||
}) | ||
} | ||
) | ||
|
||
Then( | ||
'the media embed image for {string} should be {string}', | ||
(id: string, image: string) => { | ||
cy.get(`[data-component-id="${id}"]`).as('component') | ||
|
||
cy.get('@component').within(() => { | ||
cy.get('.rpl-media-embed__image').should('have.attr', 'src', image) | ||
}) | ||
} | ||
) | ||
|
||
Then( | ||
'the extra data for media embed {string} should be visible', | ||
(id: string) => { | ||
cy.get(`[data-component-id="${id}"]`).as('component') | ||
|
||
cy.get('@component').within(() => { | ||
cy.get('.rpl-media-embed__view-data-content').should('be.visible') | ||
}) | ||
} | ||
) | ||
|
||
Then( | ||
'the extra data for media embed {string} should be hidden', | ||
(id: string) => { | ||
cy.get(`[data-component-id="${id}"]`).as('component') | ||
|
||
cy.get('@component').within(() => { | ||
cy.get('.rpl-media-embed__view-data-content').should('be.hidden') | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters