Skip to content

Commit

Permalink
Welcome e2e tests (#1092)
Browse files Browse the repository at this point in the history
* Add checkPageUrl command

* Add welcome tests

* Copy over commands added for meet-the-team tests

* Add welcome badoo tests

* Remove first as it is breaking the test

* Fix test after moving env vars to .env.local

* Fix public user env var

* Removed after feedback as it is duplicated
  • Loading branch information
boodland authored Aug 26, 2024
1 parent 075fb17 commit 5d5c034
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 0 deletions.
94 changes: 94 additions & 0 deletions cypress/integration/welcome.badoo.cy.tsx
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
37 changes: 37 additions & 0 deletions cypress/integration/welcome.cy.tsx
Original file line number Diff line number Diff line change
@@ -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');
});
});
6 changes: 6 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ declare namespace Cypress {
visitHindiPage(url: string): Chainable<Element>;
checkImage(alt: string, subSrc: string): Chainable<Element>;
checkLink(href: string, text: string): Chainable<Element>;
checkPageUrl(url: string, locale?: string): Chainable<Element>;
}
}

0 comments on commit 5d5c034

Please sign in to comment.