Skip to content

Commit

Permalink
Merge pull request #2164 from fecgov/patch/e2e-input-field-reading-ra…
Browse files Browse the repository at this point in the history
…ce-condition

Patch - E2E Input Field Race Condition
  • Loading branch information
toddlees authored Sep 10, 2024
2 parents ea45fe4 + e3db802 commit 8d0139a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions front-end/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ export CYPRESS_COMMITTEE_ID=''
export CYPRESS_PASSWORD=''
sudo circleci local execute -e CIRCLE_BRANCH=${CIRCLE_BRANCH} -e E2E_DJANGO_SECRET_KEY=${E2E_DJANGO_SECRET_KEY} -e E2E_DATABASE_URL=${E2E_DATABASE_URL} -e CYPRESS_EMAIL=${CYPRESS_EMAIL} -e CYPRESS_COMMITTEE_ID=${CYPRESS_COMMITTEE_ID} -e CYPRESS_PASSWORD=${CYPRESS_PASSWORD} --job e2e-test
```

## Tips for Writing E2E Tests

- Assertions made immediately after a page load will sometimes check the previous page before the new page loads. Add checks to ensure that the new page has loaded where possible.
- The `.contains()` Cypress method cannot find the value of a text input field. For assertions, you can instead use the `.should('have.value', VALUE)` method.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ describe('Form 24 Independent Expenditures', () => {

PageUtils.clickButton('Save');
PageUtils.clickLink('Independent Expenditure');
cy.contains(individualContactFormData.first_name).should('exist');
cy.contains(individualContactFormData.last_name).should('exist');
cy.contains('Address').should('exist');
cy.get('#first_name').should('have.value', individualContactFormData.first_name);
cy.get('#last_name').should('have.value', individualContactFormData.last_name);

ReportListPage.editReport('12-DAY PRE-GENERAL');
PageUtils.clickSidebarItem('Manage your transactions');
PageUtils.clickLink('Independent Expenditure');
cy.contains(individualContactFormData.first_name).should('exist');
cy.contains(individualContactFormData.last_name).should('exist');
cy.contains('Address').should('exist');
cy.get('#first_name').should('have.value', individualContactFormData.first_name);
cy.get('#last_name').should('have.value', individualContactFormData.last_name);
});
});
19 changes: 12 additions & 7 deletions front-end/cypress/e2e/F3X/disbursements.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ describe('Disbursements', () => {
TransactionDetailPage.enterScheduleFormData(defaultTransactionFormData);

PageUtils.clickButton('Save');
cy.contains('Transactions in this report').should('exist');
PageUtils.clickLink('100% Federal Election Activity Payment');
cy.contains(individualContactFormData.first_name).should('exist');
cy.contains(individualContactFormData.last_name).should('exist');
cy.contains('Address').should('exist');
cy.get('#last_name').should('have.value', individualContactFormData.last_name);
cy.get('#first_name').should('have.value', individualContactFormData.first_name);
});

it('should test Independent Expenditure - Void Schedule E disbursement', () => {
Expand All @@ -67,7 +69,8 @@ describe('Disbursements', () => {

PageUtils.clickButton('Save');
PageUtils.clickLink('Independent Expenditure - Void');
cy.contains(organizationFormData.name).should('exist');
cy.contains('Address').should('exist');
cy.get('#organization_name').should('have.value', organizationFormData.name);
});

it('should be able to link an Independent Expenditure to a Form 24', () => {
Expand All @@ -85,8 +88,9 @@ describe('Disbursements', () => {

PageUtils.clickButton('Save');
PageUtils.clickLink('Independent Expenditure');
cy.contains(individualContactFormData.first_name).should('exist');
cy.contains(individualContactFormData.last_name).should('exist');
cy.contains('Address').should('exist');
cy.get('#first_name').should('have.value', individualContactFormData.first_name);
cy.get('#last_name').should('have.value', individualContactFormData.last_name);
PageUtils.clickSidebarItem('Manage your transactions');

PageUtils.getKabob('Independent Expenditure').click();
Expand All @@ -98,8 +102,9 @@ describe('Disbursements', () => {

ReportListPage.editReport('FORM 24');
PageUtils.clickLink('Independent Expenditure');
cy.contains(individualContactFormData.first_name).should('exist');
cy.contains(individualContactFormData.last_name).should('exist');
cy.contains('Address').should('exist');
cy.get('#first_name').should('have.value', individualContactFormData.first_name);
cy.get('#last_name').should('have.value', individualContactFormData.last_name);
});

it('Create an Other Disbursement transaction', () => {
Expand Down

0 comments on commit 8d0139a

Please sign in to comment.