Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full name field to access and submission page #1797

Merged
merged 6 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
165 changes: 139 additions & 26 deletions backend/cypress/e2e/check-access.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { testValidEligibility } from '../support/check-eligibility.js';
import { testValidAuditeeInfo } from '../support/auditee-info.js';
import { addValidEmail, testValidAccess } from '../support/check-access.js';
import { addValidInfo, testValidAccess } from '../support/check-access.js';

describe('Create New Audit', () => {

Expand All @@ -21,7 +21,7 @@ describe('Create New Audit', () => {

describe('A Blank Form', () => {
it('marks empty responses as invalid', () => {
cy.get('#grant-access input:invalid').should('have.length', 8);
cy.get('#grant-access input:invalid').should('have.length', 12);
});

it('will not submit', () => {
Expand All @@ -40,6 +40,31 @@ describe('Create New Audit', () => {
});

describe('Auditee certifying official', () => {
describe('Full name', () => {
it('should display an error message when left blank', () => {
cy.get('#certifying_auditee_contact_fullname').click().blur();
cy.get('#certifying_auditee_contact_fullname-not-null').should(
'be.visible'
);
});

it('should disable the submit button when fields are left blank', () => {
cy.get('#certifying_auditee_contact_fullname').click().blur();
cy.get('button').contains('Create').should('be.disabled');
});

it('should remove the error message when input is supplied', () => {
addValidInfo('#certifying_auditee_contact_fullname')
cy.get('#certifying_auditee_contact_fullname-not-null').should(
'not.be.visible'
);
});

it('should enable the "Create" button when entities are fixed', () => {
addValidInfo('#certifying_auditee_contact_fullname');
cy.get('button').contains('Create').should('not.be.disabled');
});
});
describe('Email Address', () => {
it('should display an error message when left blank', () => {
cy.get('#certifying_auditee_contact_email').click().blur();
Expand Down Expand Up @@ -76,21 +101,21 @@ describe('Create New Audit', () => {
});

it('should remove the error message when valid input is supplied', () => {
addValidEmail('#certifying_auditee_contact_email');
addValidInfo('#certifying_auditee_contact_email');
cy.get('#certifying_auditee_contact_email-error-message').should(
'not.be.visible'
);
});

it('should enable the "Create" button when entities are fixed', () => {
addValidEmail('#certifying_auditee_contact_email');
addValidInfo('#certifying_auditee_contact_email');
cy.get('button').contains('Create').should('not.be.disabled');
});
});

describe('Email Address Confirmation', () => {
it('should display an error message when input does not match email field', () => {
addValidEmail('#certifying_auditee_contact_email');
addValidInfo('#certifying_auditee_contact_email');
cy.get('#certifying_auditee_contact_re_email')
.clear()
.type('test.address-wit')
Expand All @@ -101,8 +126,8 @@ describe('Create New Audit', () => {
});

it('should remove the error message when input matches email field', () => {
addValidEmail('#certifying_auditee_contact_email');
addValidEmail('#certifying_auditee_contact_re_email');
addValidInfo('#certifying_auditee_contact_email');
addValidInfo('#certifying_auditee_contact_re_email');
cy.get('#certifying_auditee_contact_re_email-must-match').should(
'not.be.visible'
);
Expand All @@ -111,6 +136,33 @@ describe('Create New Audit', () => {
});

describe('Auditor certifying official', () => {

describe('Full name', () => {
it('should display an error message when left blank', () => {
cy.get('#certifying_auditor_contact_fullname').click().blur();
cy.get('#certifying_auditor_contact_fullname-not-null').should(
'be.visible'
);
});

it('should disable the submit button when fields are left blank', () => {
cy.get('#certifying_auditor_contact_fullname').click().blur();
cy.get('button').contains('Create').should('be.disabled');
});

it('should remove the error message when input is supplied', () => {
addValidInfo('#certifying_auditor_contact_fullname');
cy.get('#certifying_auditor_contact_fullname-not-null').should(
'not.be.visible'
);
});

it('should enable the "Create" button when entities are fixed', () => {
addValidInfo('#certifying_auditor_contact_fullname');
cy.get('button').contains('Create').should('not.be.disabled');
});
});

describe('Email Address', () => {
it('should display an error message when left blank', () => {
cy.get('#certifying_auditor_contact_email').click().blur();
Expand Down Expand Up @@ -151,7 +203,7 @@ describe('Create New Audit', () => {
});

it('should remove the error message when valid input is supplied', () => {
addValidEmail('#certifying_auditor_contact_email')
addValidInfo('#certifying_auditor_contact_email')
cy.get('#certifying_auditor_contact_email-email').should(
'not.be.visible'
);
Expand All @@ -164,7 +216,7 @@ describe('Create New Audit', () => {

describe('Email Address Confirmation', () => {
it('should display an error message when input does not match email field', () => {
addValidEmail('#certifying_auditor_contact_email')
addValidInfo('#certifying_auditor_contact_email')
cy.get('#certifying_auditor_contact_re_email')
.clear()
.type('test.address-wit')
Expand All @@ -175,8 +227,8 @@ describe('Create New Audit', () => {
});

it('should remove the error message when input matches email field', () => {
addValidEmail('#certifying_auditor_contact_email')
addValidEmail('#certifying_auditor_contact_re_email')
addValidInfo('#certifying_auditor_contact_email')
addValidInfo('#certifying_auditor_contact_re_email')

cy.get('#certifying_auditor_contact_re_email-must-match').should(
'not.be.visible'
Expand All @@ -186,6 +238,33 @@ describe('Create New Audit', () => {
});

describe('Auditee contacts', () => {

describe('Full name', () => {
it('should display an error message when left blank', () => {
cy.get('#auditee_contacts_fullname').click().blur();
cy.get('#auditee_contacts_fullname-not-null').should(
'be.visible'
);
});

it('should disable the submit button when fields are left blank', () => {
cy.get('#auditee_contacts_fullname').click().blur();
cy.get('button').contains('Create').should('be.disabled');
});

it('should remove the error message when input is supplied', () => {
addValidInfo('#auditee_contacts_fullname')
cy.get('#auditee_contacts_fullname-not-null').should(
'not.be.visible'
);
});

it('should enable the "Create" button when entities are fixed', () => {
addValidInfo('#auditee_contacts_fullname');
cy.get('button').contains('Create').should('not.be.disabled');
});
});

describe('Email Address', () => {
it('should display an error message when left blank', () => {
cy.get('#auditee_contacts_email').click().blur();
Expand All @@ -208,14 +287,14 @@ describe('Create New Audit', () => {
});

it('should remove the error message when valid input is supplied', () => {
addValidEmail('#auditee_contacts_email')
addValidInfo('#auditee_contacts_email')
cy.get('#auditee_contacts_email-email').should('not.be.visible');
});
});

describe('Email Address Confirmation', () => {
it('should display an error message when input does not match email field', () => {
addValidEmail('#auditee_contacts_email')
addValidInfo('#auditee_contacts_email')

cy.get('#auditee_contacts_re_email')
.clear()
Expand All @@ -225,8 +304,8 @@ describe('Create New Audit', () => {
});

it('should remove the error message when input matches email field', () => {
addValidEmail('#auditee_contacts_email')
addValidEmail('#auditee_contacts_re_email')
addValidInfo('#auditee_contacts_email')
addValidInfo('#auditee_contacts_re_email')

cy.get('#auditee_contacts_re_email-must-match').should(
'not.be.visible'
Expand All @@ -237,7 +316,7 @@ describe('Create New Audit', () => {
it('should allow adding new contact fields', () => {
cy.get('.auditee_contacts').within(() => {
cy.get('button').click();
cy.get('.grid-row').should('have.length', 2);
cy.get('.grid-row').should('have.length', 4);
});
});

Expand All @@ -247,13 +326,13 @@ describe('Create New Audit', () => {
});

cy.get('.auditee_contacts .delete-contact').click();
cy.get('.auditee_contacts .grid-row').should('have.length', 1);
cy.get('.auditee_contacts .grid-row').should('have.length', 3);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the new full name fields in their own row, which means two new rows are added each time you add a new contact.

});

it('should be able to add contact and contact info to new inputs', () => {
cy.get('.auditee_contacts').within(() => {
cy.get('button').click();
cy.get('.grid-row').should('have.length', 2);
cy.get('.grid-row').should('have.length', 4);
cy.get('input[id*="auditee_contacts_email"]')
.eq(1)
.clear()
Expand All @@ -267,6 +346,36 @@ describe('Create New Audit', () => {
});

describe('Auditor contacts', () => {

describe('Full name', () => {
it('should display an error message when left blank', () => {
cy.get('#auditor_contacts_fullname').click().blur();
cy.get('#auditor_contacts_fullname-not-null').should(
'be.visible'
);
});

it('should disable the submit button when fields are left blank', () => {
cy.get('#auditor_contacts_fullname').click().blur();
cy.get('button').contains('Create').should('be.disabled');
});

it('should remove the error message when input is supplied', () => {
cy.get('#auditor_contacts_fullname')
.clear()
.type('A Name')
.blur();
cy.get('#auditor_contacts_fullname-not-null').should(
'not.be.visible'
);
});

it('should enable the "Create" button when entities are fixed', () => {
addValidInfo('#auditor_contacts_fullname');
cy.get('button').contains('Create').should('not.be.disabled');
});
});

describe('Email Address', () => {
it('should display an error message when left blank', () => {
cy.get('#auditor_contacts_email').click().blur();
Expand Down Expand Up @@ -294,19 +403,19 @@ describe('Create New Audit', () => {
});

it('should remove the error message when valid input is supplied', () => {
addValidEmail('#auditor_contacts_email')
addValidInfo('#auditor_contacts_email')
cy.get('#auditor_contacts_email-email').should('not.be.visible');
});

it('should enable the "Create" button when entities are fixed', () => {
addValidEmail('#auditor_contacts_email')
addValidInfo('#auditor_contacts_email')
cy.get('button').contains('Create').should('not.be.disabled');
});
});

describe('Email Address Confirmation', () => {
it('should display an error message when input does not match email field', () => {
addValidEmail('#auditor_contacts_email')
addValidInfo('#auditor_contacts_email')

cy.get('#auditor_contacts_re_email')
.clear()
Expand All @@ -316,8 +425,8 @@ describe('Create New Audit', () => {
});

it('should remove the error message when input matches email field', () => {
addValidEmail('#auditor_contacts_email')
addValidEmail('#auditor_contacts_re_email')
addValidInfo('#auditor_contacts_email')
addValidInfo('#auditor_contacts_re_email')

cy.get('#auditor_contacts_re_email-must-match').should(
'not.be.visible'
Expand All @@ -328,7 +437,7 @@ describe('Create New Audit', () => {
it('should allow adding new contact fields', () => {
cy.get('.auditor_contacts').within(() => {
cy.get('button').click();
cy.get('.grid-row').should('have.length', 2);
cy.get('.grid-row').should('have.length', 4);
});
});

Expand All @@ -338,13 +447,17 @@ describe('Create New Audit', () => {
});

cy.get('.auditor_contacts .delete-contact').click();
cy.get('.auditor_contacts .grid-row').should('have.length', 1);
cy.get('.auditor_contacts .grid-row').should('have.length', 3);
});

it('should be able to add contact and contact info to new inputs', () => {
cy.get('.auditor_contacts').within(() => {
cy.get('button').click();
cy.get('.grid-row').should('have.length', 2);
cy.get('.grid-row').should('have.length', 4);
cy.get('input[id*="auditor_contacts_fullname"]')
.eq(1)
.clear()
.type('[email protected]');
cy.get('input[id*="auditor_contacts_email"]')
.eq(1)
.clear()
Expand Down
4 changes: 4 additions & 0 deletions backend/cypress/e2e/createNewAudit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ describe('Create new audit', () => {
});

it('Fills out the Audit submission access', () => {
cy.get('#certifying_auditee_contact_fullname').type('Real Full Name');
cy.get('#certifying_auditee_contact_email').type('va@test');
cy.get('#certifying_auditor_contact_email').type('[email protected]');
cy.get('#certifying_auditor_contact_fullname').type('A. Humanbeing');
cy.get('#auditee_contacts_fullname').type('Doe A. Deer');
cy.get('#auditee_contacts_email').type('[email protected]');
cy.get('#auditor_contacts_fullname').type('Percy Person');
cy.get('#auditor_contacts_email').type('[email protected]');
cy.get('#create').click();
cy.url().should('contain', '/report_submission/general-information/2023MAY0001000001');
Expand Down
33 changes: 20 additions & 13 deletions backend/cypress/support/check-access.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
// reusable code for the accessandsubmission page
const accessFields = [
'#certifying_auditee_contact_fullname', '#certifying_auditee_contact_email', '#certifying_auditee_contact_re_email',
'#certifying_auditor_contact_fullname', '#certifying_auditor_contact_email', '#certifying_auditor_contact_re_email',
'#auditee_contacts_fullname', '#auditee_contacts_email', '#auditee_contacts_re_email',
'#auditor_contacts_fullname', '#auditor_contacts_email', '#auditor_contacts_re_email',
];

export function addValidEmail(field) {
cy.get(field)
export function addValidInfo(field) {
const filedType = field.split('_').pop();
if(filedType === 'email') {
cy.get(field)
.clear()
.type('[email protected]')
.blur();
} else {
cy.get(field)
.clear()
.type('[email protected]')
.type('Real Full Name')
.blur();
}

function completeFormWithValidInfo() {
[
'#certifying_auditee_contact_email', '#certifying_auditee_contact_re_email',
'#certifying_auditor_contact_email', '#certifying_auditor_contact_re_email',
'#auditee_contacts_email', '#auditee_contacts_re_email',
'#auditor_contacts_email', '#auditor_contacts_re_email'
].forEach(field => addValidEmail(field))
}
}

export function testValidAccess() {
completeFormWithValidInfo();
cy.wrap(accessFields).each((field) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cy.wrap() might not be necessary (or used correctly here), but I was having some trouble with the cypress commands executing in the right order. My understanding is that Cypress commands have their own special queueing system that kinda looks and feels like promises but isn't exactly the same and can cause issues with sequencing. This helped tests pass consistently, but I'm not committed to the idea!

addValidInfo(field);
});
cy.get('.usa-button').contains('Create').click();
cy.url().should('contains', '/report_submission/general-information/');
}
Loading