diff --git a/cypress/integration/welcome.badoo.cy.tsx b/cypress/integration/welcome.badoo.cy.tsx new file mode 100644 index 00000000..e7177260 --- /dev/null +++ b/cypress/integration/welcome.badoo.cy.tsx @@ -0,0 +1,94 @@ +const welcomeBadooPageUrl = '/welcome/badoo'; + +describe('Welcome badoo page should display', () => { + before(() => { + cy.cleanUpTestState(); + }); + beforeEach(() => { + cy.visit(welcomeBadooPageUrl); + }); + it('bloom in partnership with badoo logo', () => { + cy.checkImage('Bloom in partnership with Badoo logo', 'bloom_badoo_logo'); + }); + it('woman head purple illustration', () => { + cy.checkImage( + "Illustration of a person's face and shoulders, with big leaves and flowers blooming above them", + 'illustration_bloom_head_purple', + ); + }); + it('partnership explanation text', () => { + cy.get('p').should( + 'contain', + 'Together, Badoo and Bloom are providing resources to sexual assault and relationship abuse survivors within the global Badoo community, through a free, online trauma support program.', + ); + }); + it('about the program content', () => { + const partnershipBadooUrl = '/partnership/badoo'; + cy.checkImage('person with legs crossed holding heart', 'badoo_welcome_1'); + cy.get('h2').should('contain', 'About the program'); + cy.get('p').should( + 'contain', + 'Everyone’s healing journey is different. When we experience trauma due to sexual assault and relationship abuse, we may need support. Badoo partnered with Bloom to create a free, curated, online trauma support program for survivors. This program has been developed based on feedback from the global Badoo and Bloom communities.', + ); + cy.checkLink(partnershipBadooUrl, 'About the partnership'); + }); + + it('about Bloom content', () => { + cy.checkImage('leaves with a rose bloom', 'leaf_mix_bloom'); + cy.get('h2').should('contain', 'About Bloom'); + cy.get('p').should( + 'contain', + 'Bloom informs and empowers survivors by offering remote courses that combine the insights of survivors globally on trauma and gender-based violence with therapeutic practices to heal from trauma. Bloom is a programme by Chayn.', + ); + }); + + it('about Badoo content', () => { + cy.checkImage('two leaves and a heart', 'illustration_leaf_mix_badoo'); + cy.get('h2').should('contain', 'About Badoo'); + cy.get('p').should( + 'contain', + 'Badoo is the app that keeps dating straightforward and exciting. Unlike other dating apps, which are high on pressure and superficiality, Badoo lets its community chat instantly and discover real people near them. Meanwhile, Badoo’s many safety features help daters stay in control.', + ); + }); + + it('about you content', () => { + cy.checkImage('leaves with fire', 'leaf_mix_fire'); + cy.get('h2').should('contain', 'About you'); + cy.get('p').should( + 'contain', + 'The programme is available to any Badoo user who reports sexual abuse or assault to Badoo, regardless of your background, race, age, disability, religion or belief, sexuality, gender identity or expression, or life circumstances – we are here for you.', + ); + }); + + describe('for a non-logged in user', () => { + const inputAccessCodeTag = 'input[id="accessCode"]'; + const labelAccessCodeTag = 'label[id="accessCode-label"]'; + it('get started panel', () => { + cy.get('h2').should('contain', 'Get started'); + cy.get('p').should( + 'contain', + 'Enter the access code you received from Badoo to begin your Bloom journey.', + ); + cy.get(labelAccessCodeTag).should('exist').should('have.attr', 'for', 'accessCode'); + cy.get(inputAccessCodeTag).should('exist'); + }); + }); + describe('for a public logged in user', () => { + before(() => { + cy.cleanUpTestState(); + cy.logInWithEmailAndPassword( + Cypress.env('CYPRESS_PUBLIC_EMAIL'), + Cypress.env('CYPRESS_PUBLIC_PASSWORD'), + ); + }); + it('continue to bloom panel', () => { + const coursesUrl = '/courses'; + cy.get('h2').should('contain', 'Continue to Bloom'); + cy.get('p').should('contain', 'Pick up where you left off.'); + cy.checkLink(coursesUrl, 'Go to courses'); + }); + after(() => { + cy.logout(); + }); + }); +}); diff --git a/cypress/integration/welcome.cy.tsx b/cypress/integration/welcome.cy.tsx new file mode 100644 index 00000000..6f543534 --- /dev/null +++ b/cypress/integration/welcome.cy.tsx @@ -0,0 +1,37 @@ +const welcomePageUrl = '/welcome'; +const invalidPartnerPageUrl = `${welcomePageUrl}/invalid-partner`; +const coursesPageUrl = '/courses'; + +describe('Welcome page should', () => { + before(() => { + cy.cleanUpTestState(); + }); + + describe('Redirect to courses page', () => { + it('for a non-logged in user visiting page without partner', () => { + cy.visit(welcomePageUrl); + cy.checkPageUrl(coursesPageUrl); + }); + describe('for a public logged in user', () => { + before(() => { + cy.cleanUpTestState(); + cy.logInWithEmailAndPassword( + Cypress.env('CYPRESS_PUBLIC_EMAIL'), + Cypress.env('CYPRESS_PUBLIC_PASSWORD'), + ); + }); + it('visiting page without partner', () => { + cy.visit(welcomePageUrl); + cy.checkPageUrl(coursesPageUrl); + }); + after(() => { + cy.logout(); + }); + }); + }); + + it('Display not found page for an invalid partner', () => { + cy.visit(invalidPartnerPageUrl, { failOnStatusCode: false }); + cy.get('p').contains('This page could not be found'); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 04739fdc..dfdfc290 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -207,6 +207,12 @@ Cypress.Commands.add('checkLink', (href, text) => { link.should('contain', text); }); +Cypress.Commands.add('checkPageUrl', (url, locale = 'en') => { + const localePart = locale === 'en' ? '' : `/${locale}`; + const pageUrl = `${Cypress.config('baseUrl')}${localePart}${url}`; + cy.url().should('be.equal', pageUrl); +}); + // CUSTOM COMMANDS THAT NEED FIREBASE ACCESS const fbConfig = { apiKey: Cypress.env('NEXT_PUBLIC_FIREBASE_API_KEY'), diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index 92e8011f..06ae1a1f 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -40,5 +40,6 @@ declare namespace Cypress { visitHindiPage(url: string): Chainable; checkImage(alt: string, subSrc: string): Chainable; checkLink(href: string, text: string): Chainable; + checkPageUrl(url: string, locale?: string): Chainable; } }