Skip to content

Commit

Permalink
updated Cypress tests and added test for Slack Guidelines checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
recondesigns committed Feb 8, 2024
1 parent 247e5c6 commit 7a192aa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 33 additions & 2 deletions cypress/e2e/join.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const inputFields = {
firstName: 'First Name*',
lastName: 'Last Name*',
zipcode: 'Zipcode*',
codeOfConduct: /I have read and agree to/,
codeOfConduct: /Code of Conduct/,
slackGuidelines: /Slack Community Guidelines/,
};

const assertError = ({
Expand Down Expand Up @@ -70,6 +71,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin({ numberOfErrors: 2 });
});
Expand All @@ -84,6 +86,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin({ numberOfErrors: 2 });
});
Expand All @@ -102,6 +105,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(invalidUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(invalidUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin({ errorMessage: validationErrorMessages.email });
});
Expand All @@ -117,6 +121,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -133,6 +138,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin({ errorMessage: validationErrorMessages.emailsMatch });
});
Expand All @@ -144,6 +150,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(existingUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(existingUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin({ errorMessage: validationErrorMessages.emailExists, shouldWait: true });
});
Expand All @@ -162,6 +169,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -177,6 +185,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -192,6 +201,7 @@ describe('join', () => {

cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -207,6 +217,7 @@ describe('join', () => {

cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -225,6 +236,7 @@ describe('join', () => {
assertError();

cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -240,6 +252,7 @@ describe('join', () => {
assertError();

cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertFailedLogin();
});
Expand All @@ -253,15 +266,32 @@ describe('join', () => {

cy.findByLabelText(inputFields.codeOfConduct).focus();
cy.findByLabelText(inputFields.codeOfConduct).blur();
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);

assertError({ numberOfErrors: 1, errorMessage: validationErrorMessages.codeOfConduct });
assertFailedLogin({ numberOfErrors: 1, errorMessage: validationErrorMessages.codeOfConduct });
});

it('should NOT be able to register when Slack Community Guidelines is not agreed to', () => {
cy.findByLabelText(inputFields.email).type(validUser.email);
cy.findByLabelText(inputFields.confirmEmail).type(validUser.email);
cy.findByLabelText(inputFields.firstName).type(validUser.firstName);
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);

cy.findByLabelText(inputFields.slackGuidelines).focus();
cy.findByLabelText(inputFields.slackGuidelines).blur();

assertError({ numberOfErrors: 1, errorMessage: validationErrorMessages.slackGuidelines });
assertFailedLogin({ numberOfErrors: 1, errorMessage: validationErrorMessages.slackGuidelines });
});

/**
* Registration without all fields
*/
it('should NOT be able to register without filling all required fields', () => {
assertFailedLogin({ numberOfErrors: 6 });
assertFailedLogin({ numberOfErrors: 7 });
});

/**
Expand All @@ -274,6 +304,7 @@ describe('join', () => {
cy.findByLabelText(inputFields.lastName).type(validUser.lastName);
cy.findByLabelText(inputFields.zipcode).type(validUser.zipcode);
cy.findByLabelText(inputFields.codeOfConduct).type(validUser.codeOfConduct);
cy.findByLabelText(inputFields.slackGuidelines).type(validUser.slackGuidelines);
cy.findByText('Submit').click();

cy.url({ timeout: 20000 }).should('contain', '/join/form');
Expand Down
2 changes: 2 additions & 0 deletions test-utils/mockGenerators/mockUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function mockUser({
* so that the mocked value is correct in all contexts.
*/
const codeOfConduct = typeof Cypress === 'object' ? ' ' : true;
const slackGuidelines = typeof Cypress === 'object' ? ' ' : true;

const user = {
email,
Expand All @@ -46,6 +47,7 @@ export default function mockUser({
lastName,
zipcode,
codeOfConduct,
slackGuidelines,
};

return user;
Expand Down

0 comments on commit 7a192aa

Please sign in to comment.