Skip to content

Commit

Permalink
Merge pull request #1709 from fecgov/release/sprint-37
Browse files Browse the repository at this point in the history
Release/sprint 37
  • Loading branch information
dheitzer authored Feb 20, 2024
2 parents 58b909e + b2f4bd5 commit ef482c5
Show file tree
Hide file tree
Showing 286 changed files with 10,464 additions and 4,555 deletions.
2 changes: 1 addition & 1 deletion .circleci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ Authentication must be configured in a set of evironment variables:
An E2E test job was added to the fecfile-web-app CircleCI configuration file and a corresponding technical details section added to the Cypress README.md. This job can be kicked off using the following command (You will need to ensure you pass additional required environment variables to the job as needed and documented in the Cypress README.md. Also, you may need to temporarily add 'e2e-test' to each workflow defined under the CircleCI config's 'workflows' section so that the command line can find it. You also may need to add 'sudo' in front of the docker commands (otherwise it will complain about not being able to find Docker Daemon listening)).

```
sudo circleci local execute -e E2E_BRANCH_NAME=${E2E_BRANCH_NAME} --job e2e-test
sudo circleci local execute -e CIRCLE_BRANCH=${CIRCLE_BRANCH} --job e2e-test
```
14 changes: 11 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
- run:
name: start fecfile-web-api
command: |
git checkout ${E2E_BRANCH_NAME}
git checkout ${CIRCLE_BRANCH}
docker-compose down
DB_DOCKERFILE="Dockerfile-e2e" WORKER_DOCKERFILE="Worker_Dockerfile-e2e" API_DOCKERFILE="Dockerfile-e2e" FECFILE_TEST_DB_NAME="postgres" DJANGO_SECRET_KEY=${E2E_DJANGO_SECRET_KEY} DATABASE_URL=${E2E_DATABASE_URL} FEC_API=${E2E_FEC_API} FEC_API_KEY=${E2E_FEC_API_KEY} docker-compose up --build -d
docker container run --network container:fecfile-api \
Expand All @@ -123,11 +123,11 @@ jobs:
- run:
name: execute e2e tests
command: |
docker container run --name fecfile-web-app-e2e -e E2E_BRANCH_NAME=${E2E_BRANCH_NAME} -e CYPRESS_EMAIL=${CYPRESS_EMAIL} -e CYPRESS_COMMITTEE_ID=${CYPRESS_COMMITTEE_ID} -e CYPRESS_PASSWORD=${CYPRESS_PASSWORD} --network container:fecfile-api cypress/browsers:node18.12.0-chrome107 /bin/bash -c '\
docker container run --name fecfile-web-app-e2e -e CIRCLE_BRANCH=${CIRCLE_BRANCH} -e CYPRESS_EMAIL=${CYPRESS_EMAIL} -e CYPRESS_COMMITTEE_ID=${CYPRESS_COMMITTEE_ID} -e CYPRESS_PASSWORD=${CYPRESS_PASSWORD} --network container:fecfile-api cypress/browsers:node18.12.0-chrome107 /bin/bash -c '\
cd ~; \
git clone https://github.com/fecgov/fecfile-web-app.git; \
cd fecfile-web-app/front-end; \
git checkout ${E2E_BRANCH_NAME}; \
git checkout ${CIRCLE_BRANCH}; \
npm install; \
node --max_old_space_size=4000 ./node_modules/@angular/cli/bin/ng e2e --spec "cypress/e2e/*.cy.ts" --headless --watch=false --browser chrome;'\
- run:
Expand Down Expand Up @@ -297,10 +297,18 @@ workflows:
- lint
- test
- dependency-check
- e2e-test:
filters:
branches:
only: /release\/sprint-\d+|main/
- deploy:
requires:
- test
- dependency-check
# - e2e-test -- temporarily turn off until dropdown issue fixed
filters:
branches:
only: /develop|release\/sprint-\d+|main/

nightly-run:
when: << pipeline.parameters.is-nightly-run >>
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ From within the front-end directory, run the command:
`
to start a local server for the application. The front-end can then be accessed through your browser at port 4200.

### Running end-to-end (E2E) tests

To run the end-to-end tests locally, `cd` into the front-end directory and run `ng e2e` at the command line.

# Deployment (FEC team only)

### Create a feature branch
Expand Down
6 changes: 3 additions & 3 deletions front-end/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Once the CircleCI E2E job spins up fecfile-web-api in the remote docker, it then

There are a number of environment variables that are required by the CircleCI E2E job. These are currently set within the CircleCI fecfile-web-app project and include:

E2E_BRANCH_NAME (fecfile-web-api and fecfile-web-app branch to checkout for the E2E test execution)
CIRCLE_BRANCH (fecfile-web-api and fecfile-web-app branch to checkout for the E2E test execution)
E2E_DJANGO_SECRET_KEY (The Django secret key used to spin up the api)
E2E_DATABASE_URL (The database url for the api)
CYPRESS_EMAIL (email of the e2e account for login)
Expand All @@ -63,11 +63,11 @@ Finally, a CircleCI Trigger was added to [schedule a nightly job](https://circle
To run locally (you may need to add e2e-test to all workflow jobs in app circleci config.yml first, or circleci will complain about not being able to find it. Also, you also may need to add 'sudo' in front of the docker commands (otherwise it will complain about not being able to find Docker Daemon listening):

```
export E2E_BRANCH_NAME=''
export CIRCLE_BRANCH=''
export E2E_DJANGO_SECRET_KEY=''
export E2E_DATABASE_URL=''
export CYPRESS_EMAIL=''
export CYPRESS_COMMITTEE_ID=''
export CYPRESS_PASSWORD=''
sudo circleci local execute e2e-test -e E2E_BRANCH_NAME=${E2E_BRANCH_NAME} -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}
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
```
43 changes: 43 additions & 0 deletions front-end/cypress/e2e/F3X/f3x-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
defaultFormData as reportFormData,
defaultFormData as defaultReportFormData,
F3xCreateReportFormData
} from "../models/ReportFormModel";
import { ContactListPage } from "../pages/contactListPage";
import { ReportListPage } from "../pages/reportListPage";
import { currentYear } from "../pages/pageUtils";

export interface Setup {
organization?: boolean;
individual?: boolean;
candidate?: boolean;
committee?: boolean;
report?: F3xCreateReportFormData;
}

export function F3XSetup(setup: Setup = {}) {
if (setup.individual) ContactListPage.createIndividual();
if (setup.organization) ContactListPage.createOrganization();
if (setup.candidate) ContactListPage.createCandidate();
if (setup.committee) ContactListPage.createCommittee();
ReportListPage.createF3X(setup.report ?? defaultReportFormData);
}


export const reportFormDataApril: F3xCreateReportFormData = {
...reportFormData,
...{
report_code: 'Q1',
coverage_from_date: new Date(currentYear, 0, 1),
coverage_through_date: new Date(currentYear, 3, 30),
},
};

export const reportFormDataJuly: F3xCreateReportFormData = {
...reportFormData,
...{
report_code: 'Q2',
coverage_from_date: new Date(currentYear, 4, 1),
coverage_through_date: new Date(currentYear, 7, 30),
},
};
104 changes: 104 additions & 0 deletions front-end/cypress/e2e/F3X/reattributions.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { ContactListPage } from '../pages/contactListPage';
import { LoginPage } from '../pages/loginPage';
import { currentYear, PageUtils } from '../pages/pageUtils';
import { ReportListPage } from '../pages/reportListPage';
import { TransactionDetailPage } from '../pages/transactionDetailPage';
import {
ContactFormData,
ContactType,
createContact,
defaultFormData as individualContactFormData,
} from '../models/ContactFormModel';
import { StartTransaction } from './start-transaction/start-transaction';
import { F3XSetup, reportFormDataApril, reportFormDataJuly } from './f3x-setup';
import { ScheduleFormData } from '../models/TransactionFormModel';
import { Individual } from './start-transaction/receipts';

const APRIL_15 = 'APRIL 15';

const receiptData: ScheduleFormData = {
amount: 100.55,
category_code: '',
date_received: new Date(currentYear, 4 - 1, 27),
electionType: undefined,
electionYear: undefined,
election_other_description: '',
purpose_description: PageUtils.randomString(20),
memo_code: false,
memo_text: PageUtils.randomString(20),
};

const reattributeData: ScheduleFormData = {
amount: 100.55,
category_code: '',
date_received: new Date(currentYear, 4 - 1, 27),
electionType: undefined,
electionYear: undefined,
election_other_description: '',
purpose_description: undefined,
memo_code: false,
memo_text: '',
};

const assignee: ContactFormData = createContact(ContactType.INDIVIDUAL);

function CreateReceipt() {
F3XSetup({ individual: true, candidate: true, report: reportFormDataApril });
StartTransaction.Receipts().Individual().IndividualReceipt();

cy.get('[role="searchbox"]').type(individualContactFormData.last_name.slice(0, 1));
cy.contains(individualContactFormData.last_name).should('exist');
cy.contains(individualContactFormData.last_name).click();
TransactionDetailPage.enterScheduleFormData(new ScheduleFormData(receiptData));

PageUtils.clickButton('Save');
PageUtils.urlCheck('/list');
cy.contains(Individual.INDIVIDUAL_RECEIPT).should('exist');
}

function Reattribute(old = false) {
PageUtils.getKabob(' 11(a)(ii) ').contains('Reattribute').first().click({ force: true });
const alias = PageUtils.getAlias('');
if (old) {
const selector = cy.get(alias).find('#report-selector');
selector.select('FORM 3X: JULY 15 QUARTERLY REPORT (Q2)');
PageUtils.clickButton('Continue');
}
cy.wait(500);

cy.get('[role="searchbox"]').type(assignee.last_name.slice(0, 1));
cy.contains(assignee.last_name).should('exist');
cy.contains(assignee.last_name).click();
TransactionDetailPage.enterScheduleFormData(new ScheduleFormData(reattributeData));

PageUtils.clickButton('Save');
PageUtils.urlCheck('/list');
cy.contains(Individual.INDIVIDUAL_RECEIPT).should('exist');
}

describe('Reattributions', () => {
beforeEach(() => {
LoginPage.login();
ReportListPage.deleteAllReports();
ContactListPage.deleteAllContacts();
});

it('should test reattributing a Schedule A in the current report', () => {
// Create an individual contact to be used as reattributor to
ContactListPage.createIndividual(assignee);
CreateReceipt();
Reattribute();
});

it('should test reattributing a Schedule A in a submitted report', () => {
// Create an individual contact to be used with contact lookup
ContactListPage.createIndividual(assignee);
CreateReceipt();
ReportListPage.createF3X(reportFormDataJuly);
ReportListPage.submitReport(APRIL_15);
ReportListPage.editReport(APRIL_15, 'Review report');
PageUtils.clickSidebarSection('REVIEW TRANSACTIONS');
cy.wait(500);
Reattribute(true);
});
});
89 changes: 89 additions & 0 deletions front-end/cypress/e2e/F3X/redesignations.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { ContactListPage } from '../pages/contactListPage';
import { LoginPage } from '../pages/loginPage';
import { PageUtils } from '../pages/pageUtils';
import { ReportListPage } from '../pages/reportListPage';
import { TransactionDetailPage } from '../pages/transactionDetailPage';
import { candidateFormData, committeeFormData } from '../models/ContactFormModel';
import { StartTransaction } from './start-transaction/start-transaction';
import { F3XSetup, reportFormDataApril, reportFormDataJuly } from './f3x-setup';
import {
ContributionFormData,
defaultScheduleFormData as defaultTransactionFormData,
} from '../models/TransactionFormModel';
import { Contributions } from './start-transaction/disbursements';

const APRIL_15 = 'APRIL 15';

const contributionData: ContributionFormData = {
...defaultTransactionFormData,
...{
candidate: candidateFormData.candidate_id,
},
};

const redesignationData: ContributionFormData = {
...defaultTransactionFormData,
...{
electionType: 'P',
purpose_description: undefined,
category_code: undefined,
},
};

function CreateContribution() {
F3XSetup({ committee: true, candidate: true, report: reportFormDataApril });

StartTransaction.Disbursements().Contributions().ToCandidate();

cy.get('[role="searchbox"]').type(committeeFormData.name.slice(0, 1));
cy.contains(committeeFormData.name).should('exist');
cy.contains(committeeFormData.name).click();

TransactionDetailPage.enterScheduleFormDataForContribution(contributionData);

PageUtils.clickButton('Save');
PageUtils.urlCheck('/list');
cy.contains(Contributions.TO_CANDIDATE).should('exist');
}

function Redesignate(old = false) {
PageUtils.getKabob(Contributions.TO_CANDIDATE).contains('Redesignate').first().click({ force: true });
const alias = PageUtils.getAlias('');
if (old) {
const selector = cy.get(alias).find('#report-selector');
selector.select('FORM 3X: JULY 15 QUARTERLY REPORT (Q2)');
PageUtils.clickButton('Continue');
}
cy.wait(500);

TransactionDetailPage.enterScheduleFormDataForContribution(new ContributionFormData(redesignationData));

PageUtils.clickButton('Save');
PageUtils.urlCheck('/list');
cy.contains(Contributions.TO_CANDIDATE).should('exist');
}

describe('Redesignations', () => {
beforeEach(() => {
LoginPage.login();
ReportListPage.deleteAllReports();
ContactListPage.deleteAllContacts();
});

it('should test redesignating a Schedule E contribution in the current report', () => {
// Create an individual contact to be used as reattributor to
CreateContribution();
Redesignate();
});

it('should test redesignating a Schedule E contribution from a submitted report', () => {
// Create an individual contact to be used with contact lookup
CreateContribution();
ReportListPage.createF3X(reportFormDataJuly);
ReportListPage.submitReport(APRIL_15);
ReportListPage.editReport(APRIL_15, 'Review report');
PageUtils.clickSidebarSection('REVIEW TRANSACTIONS');
cy.wait(500);
Redesignate(true);
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defaultFormData as contactFormData } from './models/ContactFormModel';
import { defaultFormData as reportFormData } from './models/ReportFormModel';
import { ContactListPage } from './pages/contactListPage';
import { F3xCreateReportPage } from './pages/f3xCreateReportPage';
import { LoginPage } from './pages/loginPage';
import { PageUtils } from './pages/pageUtils';
import { ReportListPage } from './pages/reportListPage';
import { defaultFormData as contactFormData } from '../models/ContactFormModel';
import { defaultFormData as reportFormData } from '../models/ReportFormModel';
import { ContactListPage } from '../pages/contactListPage';
import { F3xCreateReportPage } from '../pages/f3xCreateReportPage';
import { LoginPage } from '../pages/loginPage';
import { PageUtils } from '../pages/pageUtils';
import { ReportListPage } from '../pages/reportListPage';

describe('Amendments', () => {
beforeEach(() => {
Expand All @@ -14,7 +14,7 @@ describe('Amendments', () => {
ReportListPage.goToPage();
});

it('should test Create an amendment', () => {
xit('should test Create an amendment', () => {
ContactListPage.goToPage();
PageUtils.clickButton('New');
const formData = {
Expand All @@ -36,14 +36,14 @@ describe('Amendments', () => {
PageUtils.clickSidebarItem('Cash on hand');
const alias = PageUtils.getAlias('');
PageUtils.enterValue('#L6a_cash_on_hand_jan_1_ytd', 60000);
PageUtils.calendarSetValue('p-calendar', new Date('05/27/2023'), alias);
PageUtils.calendarSetValue('p-calendar', new Date('05/27/2024'), alias);
PageUtils.clickButton('Save & continue');

PageUtils.urlCheck('/list');
PageUtils.clickSidebarItem('SUBMIT YOUR REPORT');
PageUtils.clickLink('Submit report');
PageUtils.urlCheck('/submit/step2');
PageUtils.enterValue('#filingPassword', 'T3stUpl@ad');
PageUtils.enterValue('#filingPassword', ''); // Insert password from env variable
cy.get(alias).find('p-checkbox[inputid="userCertified"]').click();
PageUtils.clickButton('Submit');
PageUtils.findOnPage('div', 'Are you sure?');
Expand Down
Loading

0 comments on commit ef482c5

Please sign in to comment.