Skip to content

Commit

Permalink
migrate cypress tests over to cypress folder
Browse files Browse the repository at this point in the history
  • Loading branch information
skylermcnamee-hibc committed Jul 16, 2024
1 parent 5da94e4 commit 86282e1
Show file tree
Hide file tree
Showing 14 changed files with 1,302 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jha/cypress/e2e/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
plugins: [
'cypress'
],
env: {
mocha: true,
'cypress/globals': true
},
rules: {
strict: 'off'
}
}
48 changes: 48 additions & 0 deletions jha/cypress/e2e/FPC.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { generateRequestObject } from '../fixtures/fpcStandaloneRequest';
import { removeUniqueFields } from '../support/helpers';

describe('FPC only application', () => {
const options = { includeFPC: true }
it('Fills eligibility questionnaire', () => {
cy.fillEligibilityQuestionnaire(options)
})

it('Accepts valid information for the personal-info page', () => {
cy.fillPersonalInfoPage(options)
});

it('Accepts valid information for the spouse page', () => {
cy.fillSpousePage(options)
});

it('Accepts valid information for the child page', () => {
cy.fillChildPage(options)
})

it('Accepts valid information for the FPC info page', () => {
cy.fillFPCInfoPage()
})

it('Accepts valid information for the contact info page', () => {
cy.fillMailingAddress()
});

it('Displays the phone number with contact information', () => {
cy.contains('(555) 555-5555')
cy.continue();
})

it('Submits with the expected payload', () => {
cy.fillConsent(options);
cy.submitApplication();
cy.wait('@submitApplication')
.then(interception => {
expect(removeUniqueFields(interception.request.body)).to.deep.equal(removeUniqueFields(generateRequestObject()))
});
});

it('Redirects user to confirmation page when successful', () => {
cy.url().should('include', 'submission');
cy.contains('Confirmation of submission')
});
});
44 changes: 44 additions & 0 deletions jha/cypress/e2e/MSP.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { generateRequestObject } from '../fixtures/mspStandaloneRequest.js';
import { removeUniqueFields } from '../support/helpers';

describe('MSP only application', () => {
const options = {includeMSP: true}
it('Fills eligibility questionnaire', () => {
cy.fillEligibilityQuestionnaire(options)
});

it('Accepts valid information for the personal-info page', () => {
cy.fillPersonalInfoPage(options)
});

it('Accepts valid information for the spouse page', () => {
cy.fillSpousePage(options)
});

it('Accepts valid information for the child page', () => {
cy.fillChildPage(options)
});

it('Accepts valid information for the contact info page', () => {
cy.fillResidentialAddress()
});

it('Displays the phone number with contact information', () => {
cy.contains('(555) 555-5555')
cy.continue();
});

it('submits form with expected payload', () => {
cy.fillConsent(options)
cy.submitApplication()
cy.wait('@submitApplication')
.then(interception => {
expect(removeUniqueFields(interception.request.body)).to.deep.equal(removeUniqueFields(generateRequestObject()))
})
});

it('Redirects user to confirmation page when successful', () => {
cy.url().should('include', 'submission');
cy.contains('Confirmation of submission')
});
});
48 changes: 48 additions & 0 deletions jha/cypress/e2e/SB.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { generateRequestObject } from '../fixtures/sbStandaloneRequest.js';
import { removeUniqueFields } from '../support/helpers';

describe('SB only application', () => {
const options = {includeSB: true}
it('Fills eligibility questionnaire', () => {
cy.fillEligibilityQuestionnaire(options)
});

it('Accepts valid information for the personal-info page', () => {
cy.fillPersonalInfoPage(options)
});

it('Accepts valid information for the spouse page', () => {
cy.fillSpousePage(options)
});

it('Accepts valid information for the supplemental benefits information page', () => {
cy.fillSBInfoPage(options)
});

it('Accepts valid information for the documents page', () => {
cy.fillDocumentsPage()
});

it('Accepts valid information for the contact info page', () => {
cy.fillMailingAddress()
});

it('Displays the phone number with contact information', () => {
cy.contains('(555) 555-5555')
cy.continue();
});

it('submits form with expected payload', () => {
cy.fillConsent(options)
cy.submitApplication()
cy.wait('@submitApplication')
.then(interception => {
expect(removeUniqueFields(interception.request.body)).to.deep.equal(removeUniqueFields(generateRequestObject()))
})
});

it('Redirects user to confirmation page when successful', () => {
cy.url().should('include', 'submission');
cy.contains('Confirmation of submission')
});
});
52 changes: 52 additions & 0 deletions jha/cypress/e2e/fullApplication.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { generateRequestObject } from '../fixtures/fullApplication.js';
import { removeUniqueFields } from '../support/helpers';

describe('Full application for MSP FPC and SB', () => {
const options = {includeMSP: true, includeFPC: false, includeSB: true}
it('Fills eligibility questionnaire', () => {
cy.fillEligibilityQuestionnaire(options)
});

it('Accepts valid information for the personal-info page', () => {
cy.fillPersonalInfoPage(options)
});

it('Accepts valid information for the spouse page', () => {
cy.fillSpousePage(options)
});

it('Accepts valid information for the child page', () => {
cy.fillChildPage(options)
});

it('Accepts valid information for the supplemental benefits information page', () => {
cy.fillSBInfoPage(options)
});

it('Accepts valid information for the documents page', () => {
cy.fillDocumentsPage()
});

it('Accepts valid information for the contact info page', () => {
cy.fillResidentialAddress()
});

it('Displays the phone number with contact information', () => {
cy.contains('(555) 555-5555')
cy.continue();
});

it('submits form with expected payload', () => {
cy.fillConsent(options)
cy.submitApplication()
cy.wait('@submitApplication')
.then(interception => {
expect(removeUniqueFields(interception.request.body)).to.deep.equal(removeUniqueFields(generateRequestObject()))
})
});

it('Redirects user to confirmation page when successful', () => {
cy.url().should('include', 'submission');
cy.contains('Confirmation of submission')
});
});
69 changes: 69 additions & 0 deletions jha/cypress/e2e/fullApplicationValidations.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// import { generateRequestObject } from '../fixtures/fullApplication.js';
// import { removeUniqueFields } from '../helpers';

describe('Full application for MSP FPC and SB', () => {
// const options = {includeMSP: true, includeFPC: false, includeSB: true}
it('Navigates the MSP Elibility page', () => {
const eligibilityError = "Please complete the questionnaire to continue.";
cy.visit("/msp-eligibility");
cy.location().should((loc) => {
expect(loc.pathname).to.eq("/ahdc/msp-eligibility");
});
cy.get("[data-cy=apply-msp-yes]").click({
force: true,
});
cy.get("[data-cy=continue]").click();
cy.contains(eligibilityError);
cy.get("[data-cy=live-in-bc-no]").click({
force: true,
});
cy.contains("you may not be eligible for MSP or related income-based programs.");
});

// it('Fills eligibility questionnaire', () => {
// cy.fillEligibilityQuestionnaire(options)
// });

// it('Accepts valid information for the personal-info page', () => {
// cy.fillPersonalInfoPage(options)
// });

// it('Accepts valid information for the spouse page', () => {
// cy.fillSpousePage(options)
// });

// it('Accepts valid information for the child page', () => {
// cy.fillChildPage(options)
// });

// it('Accepts valid information for the supplemental benefits information page', () => {
// cy.fillSBInfoPage(options)
// });

// it('Accepts valid information for the documents page', () => {
// cy.fillDocumentsPage()
// });

// it('Accepts valid information for the contact info page', () => {
// cy.fillResidentialAddress()
// });

// it('Displays the phone number with contact information', () => {
// cy.contains('(555) 555-5555')
// cy.continue();
// });

// it('submits form with expected payload', () => {
// cy.fillConsent(options)
// cy.submitApplication()
// cy.wait('@submitApplication')
// .then(interception => {
// expect(removeUniqueFields(interception.request.body)).to.deep.equal(removeUniqueFields(generateRequestObject()))
// })
// });

// it('Redirects user to confirmation page when successful', () => {
// cy.url().should('include', 'submission');
// cy.contains('Confirmation of submission')
// });
});
62 changes: 62 additions & 0 deletions jha/cypress/fixtures/fpcStandaloneRequest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { formatISODate } from 'common-lib-vue';

export const generateRequestObject = () => {
const currentDate = new Date();

return {
"firstName": "alex",
"secondName": "jaimie",
"lastName": "doe",
"sin": "238795439",
"phn": "9999999998",
"gender": null,
"birthDate": "2000-01-01",
"telephone": "5555555555",
"addressLine1": "123 fake st.",
"addressLine2": null,
"addressLine3": null,
"city": "duncan",
"postalCode": "V8P1A1",
"provinceOrState": "British Columbia",
"country": "Canada",
"authorizedByApplicant": "Y",
"powerOfAttorney": "N",
"spousePowerOfAttorney": "N",
"authorizedBySpouse": "Y",
"spouse": {
"firstName": "sarah",
"secondName": "jaimie",
"lastName": "doe",
"gender": null,
"birthDate": "1990-06-20",
"telephone": "5555555555",
"sin": "195544135",
"phn": "9348671676"
},
"fairPharmaCare": {
"uuid": "1f630383-be09-4bbf-b980-a516ce6ffb6f",
"clientName": null,
"processDate": formatISODate(currentDate),
"accountHolderNetIncome": "20000",
"accountHolderRDSP": "2000",
"spouseNetIncome": "20000",
"spouseRDSP": "2000",
"spousePostalCode": "V8P1A1",
"persons": [
{
"givenName": "ralph",
"surname": "wiggum",
"postalCode": "V8P1A1",
"perType": "2",
"dateOfBirth": "2019-02-01",
"phn": "9344507929"
}
],
"attachments": [],
"familyNumber": null,
"deductibleAmount": null,
"annualMaximumAmount": null,
"copayPercentage": null
}
}
}
Loading

0 comments on commit 86282e1

Please sign in to comment.