Skip to content

Commit

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

it('User should be able to create account in hindi', () => {
// Start from the home page
cy.visitHindiPage('/');
cy.wait(2000);

cy.get('a[href="/hi/auth/register"]', { timeout: 5000 }).first().click({ force: true });
cy.wait(2000);
cy.get('h2', { timeout: 8000 }).should('contain', 'Account banaiye');
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('Account Banao').click();
cy.wait(3000);
});

after(() => {
cy.logout();
});
});
17 changes: 15 additions & 2 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('visitHindiPage', (url) => {
cy.visit(url, {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, 'language', { value: 'hi-IN' });
Object.defineProperty(win.navigator, 'languages', { value: ['hi'] });
Object.defineProperty(win.navigator, 'accept_languages', { value: ['hi'] });
},
headers: {
'Accept-Language': 'hi',
},
});
});

Cypress.Commands.add('visitFrenchPage', (url) => {
cy.visit(url, {
onBeforeLoad(win) {
Expand Down Expand Up @@ -203,8 +216,8 @@ const attachCustomCommands = (Cypress, auth) => {
currentUser = user;
token = currentUser
? currentUser.getIdToken().then((t) => {
token = t;
})
token = t;
})
: null;
});

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 @@ -37,5 +37,6 @@ declare namespace Cypress {
visitGermanPage(url: string): Chainable<Element>;
visitSpanishPage(url: string): Chainable<Element>;
visitFrenchPage(url: string): Chainable<Element>;
visitHindiPage(url: string): Chainable<Element>;
}
}
2 changes: 1 addition & 1 deletion messages/auth/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"emailLabel": "Email",
"passwordLabel": "Password",
"contactPermissionLabel": "Kya hum Bloom ko behtar banane ke bare mein feedback ke liye aapko email kar sakte hain?",
"registerSubmit": " Account Banao",
"registerSubmit": "Account Banao",
"resetPasswordStep1": "Hum aapko ek email bhejenge taki aap apna password reset kar sakein. ",
"resetPasswordStep2": "Bas aap anth tak pahuchne wale hain! Ab aap apna naya password set kar sakte hain. ",
"resetPasswordSubmit": "Password reset kariye",
Expand Down

0 comments on commit ae73d59

Please sign in to comment.