Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/Van/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Login Flow', () => {
.and('have.focus');

cy.get('#logInModal')
.find('button.close')
.find('button[aria-label="Close"]')
.click();

cy.get('#logInModal').should('not.be.visible');
Expand Down
90 changes: 88 additions & 2 deletions cypress/e2e/Van/signup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,94 @@ describe('Signup tests', () => {
});

// - Both fields empty validation
// - Password requirements (if applicable)
// - Successful signup creates account
it('should show a browser prompt when both fields are empty', () => {
const randomEmail = Cypress.generateRandomEmail();

cy.window().then((win) => {
cy.stub(win as any, 'alert').as('alertStub');
});

cy.get('#narvbarx').within(() => {
cy.get('[data-target="#signInModal"]').click();
});

cy.get('#signInModal').within(() => {
cy.get('#sign-username').clear().invoke('val', '');
cy.get('#sign-password').clear().invoke('val', '');
cy.contains('button', 'Sign up').click();
});

cy.get('@alertStub').should('have.been.calledWith', 'Please fill out Username and Password.');
});

// - Successful signup creates account
it('should create an account after successful signup', () => {
const randomEmail = Cypress.generateRandomEmail();

cy.window().then((win) => {
cy.stub(win as any, 'alert').as('alertStub');
});

cy.get('#narvbarx').within(() => {
cy.get('[data-target="#signInModal"]').click();
});

cy.get('#signInModal').within(() => {
cy.get('#sign-username').clear().invoke('val', randomEmail);
cy.get('#sign-password').clear().invoke('val', 'test');
cy.contains('button', 'Sign up').click();
});

cy.get('@alertStub').should('have.been.calledWith', 'Sign up successful.');

cy.get('#narvbarx').within(() => {
cy.get('[data-target="#logInModal"]').click();
});

cy.get('#logInModal').within(() => {
cy.get('#loginusername').clear().invoke('val', randomEmail);
cy.get('#loginpassword').clear().invoke('val', 'test');
cy.contains('button', 'Log in').click();
});

cy.get('#narvbarx').within(() => {
cy.get('#nameofuser').contains(randomEmail);
});
});

// - Signup modal closes correctly
it('should open and close the login modal', () => {
// Via x button
cy.get('#narvbarx').within(() => {
cy.get('[data-target="#signInModal"]').click();
});

cy.get('#signInModal')
.should('be.visible')
.should('have.attr', 'tabindex', '-1')
.and('have.focus');

cy.get('#signInModal')
.find('button[aria-label="Close"]')
.click();

cy.get('#signInModal').should('not.be.visible');

// Via Close button
cy.get('#narvbarx').within(() => {
cy.get('[data-target="#logInModal"]').click();
});

cy.get('#logInModal')
.should('be.visible')
.should('have.attr', 'tabindex', '-1')
.and('have.focus');

cy.get('#logInModal')
.find('button').contains('Close')
.click();

cy.get('#logInModal').should('not.be.visible');
});
});
});