Skip to content

Commit

Permalink
Merge pull request #1856 from GSA-TTS/jp/cypress-workbooks-and-preval…
Browse files Browse the repository at this point in the history
…idation

Cypress Full Submission Fix
  • Loading branch information
jperson1 authored Aug 17, 2023
2 parents f1fb29b + 0e1fe76 commit 989f495
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
</tr>
</thead>
<tbody>
<tr>
{% for error in errors.errors %}<td>{{ error.error }}</td>{% endfor %}
</tr>
{% for error in errors.errors %}
<tr>
<td>{{ error.error }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>
In order to certify, your submission must be locked. No further changes will be possible. Click to lock this audit for certification by the designated certifying officials.
</p>
<button class="usa-button margin-top-10" id="continue">Lock for Certification</button>
<button class="usa-button margin-top-10" id="continue">Lock for certification</button>
<a href="{% url 'audit:CrossValidation' report_id %}">Back</a>
</fieldset>
</form>
Expand Down
1 change: 0 additions & 1 deletion backend/audit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,6 @@ def post(self, request, *args, **kwargs):

if form.is_valid():
file = request.FILES["upload_report"]
print("hi", form.cleaned_data)

component_page_numbers = {
"financial_statements": form.cleaned_data["financial_statements"],
Expand Down
2 changes: 1 addition & 1 deletion backend/cypress/e2e/audit-info-form.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
describe('Audit Information Form', () => {
beforeEach(() => {
cy.visit('/report_submission/audit-info/2022XB40001000002');
cy.visit('/audit/audit-info/2022JAN0001000006');
});

function answerAllQuestions() {
Expand Down
26 changes: 14 additions & 12 deletions backend/cypress/e2e/full-submission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { testWorkbookFederalAwards,
testWorkbookFindingsText,
testWorkbookCorrectiveActionPlan,
testWorkbookAdditionalUEIs } from '../support/workbook-uploads.js'
import { testAuditInformationForm } from '../support/audit-info-form.js'

describe('Full audit submission', () => {
before(() => {
Expand Down Expand Up @@ -42,34 +43,35 @@ describe('Full audit submission', () => {
// Fill out the general info form
testValidGeneralInfo();

// Upload all the workbooks
// Fill out the audit report package form, and upload its associated PDF
// testAuditReportPackage();

// Upload all the workbooks. Don't intercept the uploads, which means a file will make it into the DB.
cy.get(".usa-link").contains("Federal Awards").click();
testWorkbookFederalAwards(false); // don't intercept
testWorkbookFederalAwards(false);

cy.get(".usa-link").contains("Federal Awards Audit Findings").click();
testWorkbookFindingsUniformGuidance(false); // don't intercept
testWorkbookFindingsUniformGuidance(false);

cy.get(".usa-link").contains("Federal Awards Audit Findings Text").click();
testWorkbookFindingsText(false); // don't intercept
testWorkbookFindingsText(false);

cy.get(".usa-link").contains("Corrective Action Plan").click();
testWorkbookCorrectiveActionPlan(false); // don't intercept
testWorkbookCorrectiveActionPlan(false);

cy.get(".usa-link").contains("Additional UEIs").click();
testWorkbookAdditionalUEIs(false); // don't intercept
testWorkbookAdditionalUEIs(false);

// Complete the audit information form
cy.get(".usa-link").contains("Audit Information Form").click();
testAuditInformationForm();

cy.get(".usa-link").contains("Pre-submission validation").click();
testCrossValidation();

// Uncomment this block when ready to implement the certification steps.
/*
// These aren't enabled because the previous steps didn't actually upload anything. Our upload responses are mocked.
// First step, pre-validation.
cy.get(".usa-link").contains("Pre-submission validation").click();
cy.url().should('match', /\/audit\/ready-for-certification\/[0-9A-Z]{17}/);
// Mock a prositive response on validation, then it comes back to the checklist
// Second, auditor certification
cy.get(".usa-link").contains("Auditor Certification").click();
// Two pages:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37 changes: 37 additions & 0 deletions backend/cypress/support/audit-info-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Re-useable code for silling out the audit information form.
*/
export function testAuditInformationForm() {
// Select everything for the GAAP multiple choice checkboxes.
// Will pop the three conditional non-GAAP questions.
cy.get('[id^=gaap_results--]').each((item) => {
cy.get(item).click({force: true});
});

// Select everything for question i
cy.get('[id^=sp_framework_basis--]').each((item) => {
cy.get(item).click({force: true});
});

// Question ii is a true/false, and is covered below

// Select everything for question iii
cy.get('[id^=sp_framework_opinions--]').each((item) => {
cy.get(item).click({force: true});
});

// Answer 'Yes' to all Yes/No questions.
cy.get('[id$=--true]').each((item) => {
cy.get(item).click({force: true});
});

// Enter 750000 into the dollar theshold number field.
cy.get('#dollar_threshold').type('750000').blur();

// Select 0 and 1 for the multiple select agencies field.
cy.get('#agencies').select(['00', '01']).blur();

cy.get('.usa-button').contains('Save and continue').click({force: true});

cy.url().should('match', /\/audit\/submission-progress\/[0-9A-Z]{17}/);
}
10 changes: 5 additions & 5 deletions backend/cypress/support/auditee-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export function testValidAuditeeInfo() {
fixture: 'sam-gov-api-mock.json',
}).as('uei_check_success')

// hard-coding some UEI which may eventually become unregistered
cy.get('#auditee_uei').type('LZGKJ22EF7B5');
// Hard-coding some UEI which may eventually become unregistered
// This UEI needs to match up with the UEI in the workbooks.
cy.get('#auditee_uei').type('D7A4J33FUMJ1');
cy.get('#auditee_uei-btn').click().wait('@uei_check_success');
// modal search result box needs "Continue" to be clicked
cy.get('button[data-close-modal]').contains('Continue').click();

// Now fill in the audit dates
let today = new Date().toLocaleDateString();
cy.get('#auditee_fiscal_period_start').type(today);
cy.get('#auditee_fiscal_period_end').type(today);
cy.get('#auditee_fiscal_period_start').type("01/01/2022");
cy.get('#auditee_fiscal_period_end').type("12/31/2022");

// and click continue
cy.get('.usa-button').contains('Continue').click();
Expand Down
13 changes: 10 additions & 3 deletions backend/cypress/support/cross-validation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
export function testCrossValidation() {
cy.url().should('match', /\/audit\/cross-validation\/[0-9A-Z]{17}/);

// Cross val runs and passes
cy.get(".usa-button").contains("Begin Validation").click();
cy.get('.usa-fieldset').contains('Looks good!');
cy.get('.usa-fieldset').contains('No errors were found.');

// Continue to the lock screen
cy.get('.usa-button').contains('Proceed to certification').click();
cy.url().should('match', /\/audit\/ready-for-certification\/[0-9A-Z]{17}/);

const reportTestId = '2023AUG0001000010';
cy.visit(`/audit/submission-progress/${reportTestId}`);
// Lock the submission for the certification steps
cy.get('.usa-button').contains('Lock for certification').click();
cy.url().should('match', /\/audit\/submission-progress\/[0-9A-Z]{17}/);
}
36 changes: 21 additions & 15 deletions backend/cypress/support/workbook-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

// testWorkbookUpload('/audit/excel/federal-awards-expended/*', '#file-input-federal-awards-xlsx', 'federal-awards-expended-UPDATE.xlsx')
// assumes you are on the appropriate upload page already
function testWorkbookUpload(interceptUrl, uploadSelector, filename, intercept = true) {
function testWorkbookUpload(interceptUrl, uploadSelector, filename, will_intercept = true) {
cy.intercept(interceptUrl + '*', (req) => {
if (intercept) {
if (will_intercept) {
// return a success fixture
req.reply({ fixture: 'success-res.json' });
} else {
Expand All @@ -13,53 +13,59 @@ function testWorkbookUpload(interceptUrl, uploadSelector, filename, intercept =
}
}).as('uploadSuccess');
cy.get(uploadSelector).attachFile(filename);
cy.wait('@uploadSuccess').its('response.statusCode').should('eq', 200);
cy.wait(2000)
.get('#info_box')
// Upload url (POST /audit/excel/workbookname) returns a redirect to "/" on successful upload. So, 302.
cy.wait('@uploadSuccess').its('response.statusCode').should('eq', 302);
cy.get('#info_box')
.should(
'have.text',
'File successfully validated! Your work has been saved.'
);

cy.get('#continue').click();
cy.url().should('match', /\/audit\/submission-progress\/[0-9A-Z]{17}/);
}

export function testWorkbookFederalAwards(intercept = true) {
export function testWorkbookFederalAwards(will_intercept = true) {
testWorkbookUpload(
'/audit/excel/federal-awards-expended/*',
'#file-input-federal-awards-xlsx',
'federal-awards-UPDATE.xlsx'
'test_workbooks/federal-awards-workbook.xlsx',
will_intercept
);
}

export function testWorkbookFindingsUniformGuidance(intercept = true) {
export function testWorkbookFindingsUniformGuidance(will_intercept = true) {
testWorkbookUpload(
'/audit/excel/findings-uniform-guidance/',
'#file-input-audit-findings-xlsx',
'federal-awards-audit-findings-UPDATE.xlsx'
'test_workbooks/federal-awards-audit-findings-workbook.xlsx',
will_intercept
)
}

export function testWorkbookFindingsText(intercept = true) {
export function testWorkbookFindingsText(will_intercept = true) {
testWorkbookUpload(
'/audit/excel/findings-text/',
'#file-input-audit-findings-text-xlsx',
'audit-findings-text-UPDATE.xlsx'
'test_workbooks/audit-findings-text-workbook.xlsx',
will_intercept
)
}

export function testWorkbookCorrectiveActionPlan(intercept = true) {
export function testWorkbookCorrectiveActionPlan(will_intercept = true) {
testWorkbookUpload(
'/audit/excel/corrective-action-plan/',
'#file-input-CAP-xlsx',
'corrective-action-plan-UPDATE.xlsx'
'test_workbooks/corrective-action-plan-workbook.xlsx',
will_intercept
)
}

export function testWorkbookAdditionalUEIs(intercept = true) {
export function testWorkbookAdditionalUEIs(will_intercept = true) {
testWorkbookUpload(
'/audit/excel/additional-ueis/',
'#file-input-additional-ueis-xlsx',
'additional-ueis.xlsx'
'test_workbooks/additional-ueis-workbook.xlsx',
will_intercept
)
}

0 comments on commit 989f495

Please sign in to comment.