diff --git a/front-end/cypress/README.md b/front-end/cypress/README.md index 8d9c0afbb..35315a959 100644 --- a/front-end/cypress/README.md +++ b/front-end/cypress/README.md @@ -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. diff --git a/front-end/cypress/e2e/F24/reports-f24-independent-expenditures.cy.ts b/front-end/cypress/e2e/F24/reports-f24-independent-expenditures.cy.ts index af77c5a27..e3fcde422 100644 --- a/front-end/cypress/e2e/F24/reports-f24-independent-expenditures.cy.ts +++ b/front-end/cypress/e2e/F24/reports-f24-independent-expenditures.cy.ts @@ -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); }); }); diff --git a/front-end/cypress/e2e/F3X/disbursements.cy.ts b/front-end/cypress/e2e/F3X/disbursements.cy.ts index 7a1c2ef89..821ec956e 100644 --- a/front-end/cypress/e2e/F3X/disbursements.cy.ts +++ b/front-end/cypress/e2e/F3X/disbursements.cy.ts @@ -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', () => { @@ -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', () => { @@ -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(); @@ -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', () => {