Skip to content

Commit

Permalink
- Added new create user test in spanish (#875)
Browse files Browse the repository at this point in the history
- Added new command to visit spanish page
  • Loading branch information
cmstrandwold committed Apr 22, 2024
1 parent c7872ca commit 8c30966
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.es.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.visitSpanishPage('/');
cy.wait(2000);
cy.get('h1', { timeout: 8000 })
.contains('Acompáñanos en tu viaje de sanación')
.should('exist');
cy.get('a[href="/es/auth/register"]', { timeout: 5000 }).first().click({ force: true });
cy.wait(2000);
cy.get('h2', { timeout: 8000 }).should('contain', 'Crea una cuenta');
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('Crea una cuenta').click();
cy.wait(3000);
cy.get('h2', { timeout: 8000 }).should('contain', 'Ayúdanos a entender');
});

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 @@ -156,6 +156,19 @@ Cypress.Commands.add('visitGermanPage', (url) => {
});
});

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

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

0 comments on commit 8c30966

Please sign in to comment.