Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Chore: add e2e tests for Intercom #3880

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ tsconfig.tsbuildinfo
public/**/*.js
jest.results.json
*.#*
cypress/videos
cypress/screenshots
45 changes: 45 additions & 0 deletions cypress/integration/intercom.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const RINKEBY_TEST_SAFE = 'rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac'
const intercomIfame = 'iframe[id="intercom-frame"]'
Copy link
Contributor

Choose a reason for hiding this comment

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

"intercomIfame" for "intercomIframe"

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest looks good. Nice job

const intercomButton = '[aria-label="Open Intercom Messenger"]'
const fakeIntercomButton = 'img[alt="Open Intercom"]'

describe('Intercom and cookie prefs', () => {
it('should show the Intercom chat if cookies are enabled', () => {
cy.visit('/')

// Don't accept Intercom cookies
cy.contains('a', 'Accept selection').click()

// Click on the Intercom button
cy.get(fakeIntercomButton).click()

// Cookie preferences appear
cy.contains('You attempted to open the customer support chat. Please accept the community support & updates cookies')

cy.contains('a', 'Accept all').click()

// Intercom is now active
cy.get(intercomIfame).should('exist')
cy.get(fakeIntercomButton).should('not.exist')
cy.get(intercomButton).click()
cy.get('#intercom-container').should('exist')

// Intercom should be disabled on a Safe App page
cy.visit(`/${RINKEBY_TEST_SAFE}/apps`)

// Click on first app link
cy.get('[data-testid="safe_apps__all-apps-container"] a').first().click()
cy.get(intercomButton).should('not.exist')

// Go to Settings and change the cookie settings
cy.visit(`/${RINKEBY_TEST_SAFE}/settings`)
cy.get(intercomIfame).should('exist')
cy.contains('button', 'Preferences').click()
cy.contains('Community support & updates').click()
cy.contains('a', 'Accept selection').click()

// Intercom should be now disabled
cy.get(intercomButton).should('not.exist')
cy.get(fakeIntercomButton).should('be.visible')
})
})