Skip to content

Commit

Permalink
add french user test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Vermersch authored and eleanorreem committed May 10, 2024
1 parent 10cec7c commit 32d5ed8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cypress/integration/create-user.fr.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe('Create User', () => {
let username = `cypresstestemail+${Date.now()}@chayn.co`;
before(() => {
cy.cleanUpTestState();
});

it('User should be able to create user', () => {
// Start from the home page
cy.visitFrenchPage('/');
cy.wait(2000);
cy.get('h1', { timeout: 8000 })
.contains('Rejoins-nous sur ton chemin de guérison')
.should('exist');
cy.get('a[href="/fr/auth/register"]', { timeout: 5000 }).first().click({ force: true });
cy.wait(2000);
cy.get('h2', { timeout: 8000 }).should('contain', 'Créer un compte');
cy.get('#name', { timeout: 8000 }).type('Cypress test');
cy.get('#email', { timeout: 8000 }).type(username);
cy.get('#password', { timeout: 8000 }).type('testpassword');
cy.get('button[type="submit"]').contains('Créer un compte').click();
cy.wait(3000);
cy.get('h2', { timeout: 8000 }).should('contain', 'Aidez-nous à compendre');
});

after(() => {
cy.logout();
});
});
13 changes: 13 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ Cypress.Commands.add('visitSpanishPage', (url) => {
});
});

Cypress.Commands.add('visitFrenchPage', (url) => {
cy.visit(url, {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, 'language', { value: 'fr-FR' });
Object.defineProperty(win.navigator, 'languages', { value: ['fr'] });
Object.defineProperty(win.navigator, 'accept_languages', { value: ['fr'] });
},
headers: {
'Accept-Language': 'fr',
},
});
});

// 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 @@ -36,5 +36,6 @@ declare namespace Cypress {
cleanUpTestState(): Chainable<Element>;
visitGermanPage(url: string): Chainable<Element>;
visitSpanishPage(url: string): Chainable<Element>;
visitFrenchPage(url: string): Chainable<Element>;
}
}

0 comments on commit 32d5ed8

Please sign in to comment.