Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] - start date. To delete later. #1107

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions __tests__/pages/api/benefits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ describe('consolidated benefit tests: ineligible', () => {
partnerIncomeWork: 0,
age: 50,
oasDefer: false,
whenToStartOAS: true, //asap
receiveOAS: false,
oasDeferDuration: undefined,
oasAge: undefined,
Expand Down Expand Up @@ -791,6 +792,7 @@ describe('consolidated benefit tests: eligible: 65+', () => {
partnerIncomeWork: 0,
age: 75,
oasDefer: false,
whenToStartOAS: true, //asap
receiveOAS: false,
oasDeferDuration: undefined,
oasAge: undefined,
Expand Down Expand Up @@ -973,6 +975,7 @@ describe('consolidated benefit tests: eligible: 60-64', () => {
age: 64,
oasDefer: false,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
oasAge: undefined,
maritalStatus: MaritalStatus.PARTNERED,
Expand Down
9 changes: 9 additions & 0 deletions __tests__/pages/api/field-reqs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('field requirement analysis', () => {
oasDefer: undefined,
oasAge: undefined,
receiveOAS: false,
whenToStartOAS: undefined, //asap
oasDeferDuration: undefined,
maritalStatus: undefined,
livingCountry: undefined,
Expand All @@ -39,6 +40,7 @@ describe('field requirement analysis', () => {
expect(res.body.summary.state).toEqual(SummaryState.MORE_INFO)
expect(res.body.missingFields).toEqual([
FieldKey.AGE,
FieldKey.WHEN_TO_START,
FieldKey.INCOME,
//FieldKey.INCOME_WORK,
FieldKey.LEGAL_STATUS,
Expand All @@ -48,6 +50,7 @@ describe('field requirement analysis', () => {
])
expect(res.body.visibleFields).toEqual([
FieldKey.AGE,
FieldKey.WHEN_TO_START,
FieldKey.INCOME,
FieldKey.INCOME_WORK,
FieldKey.LEGAL_STATUS,
Expand All @@ -66,6 +69,7 @@ describe('field requirement analysis', () => {
oasDefer: true,
oasAge: 70,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: '{ "months": 0, "years": 5 }',
maritalStatus: MaritalStatus.PARTNERED,
...canadian,
Expand All @@ -87,6 +91,7 @@ describe('field requirement analysis', () => {
expect(res.body.visibleFields).toEqual([
FieldKey.AGE,
FieldKey.ALREADY_RECEIVE_OAS,
FieldKey.WHEN_TO_START,
FieldKey.OAS_AGE,
// FieldKey.INCOME_AVAILABLE,
FieldKey.INCOME,
Expand Down Expand Up @@ -119,6 +124,7 @@ describe('field requirements analysis: conditional fields', () => {
partnerIncomeWork: 0,
...age65NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.SINGLE,
...canadian,
Expand All @@ -140,6 +146,7 @@ describe('field requirements analysis: conditional fields', () => {
partnerIncomeWork: 0,
...age65NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.SINGLE,
...canadian,
Expand All @@ -161,6 +168,7 @@ describe('field requirements analysis: conditional fields', () => {
partnerIncomeWork: 0,
...age65NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.SINGLE,
livingCountry: LivingCountry.NO_AGREEMENT,
Expand All @@ -183,6 +191,7 @@ describe('field requirements analysis: conditional fields', () => {
partnerIncomeWork: 0,
...age65NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.PARTNERED,
...canadian,
Expand Down
5 changes: 5 additions & 0 deletions __tests__/pages/api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ describe('basic Allowance scenarios', () => {
...income10k,
...age60NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.PARTNERED,
invSeparated: false,
Expand Down Expand Up @@ -356,6 +357,7 @@ describe('basic Allowance for Survivor scenarios', () => {
...age65NoDefer,
incomeWork: 0,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.WIDOWED,
...canadian,
Expand All @@ -372,6 +374,7 @@ describe('basic Allowance for Survivor scenarios', () => {
...income10k,
...age65NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.WIDOWED,
invSeparated: false,
Expand All @@ -394,6 +397,7 @@ describe('basic Allowance for Survivor scenarios', () => {
age: 59,
oasDefer: false,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
oasAge: undefined,
maritalStatus: MaritalStatus.WIDOWED,
Expand Down Expand Up @@ -438,6 +442,7 @@ describe('basic Allowance for Survivor scenarios', () => {
...income10k,
...age60NoDefer,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
maritalStatus: MaritalStatus.PARTNERED,
invSeparated: false,
Expand Down
32 changes: 32 additions & 0 deletions __tests__/pages/api/july2013Deferral.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,36 @@ describe('july2013Deferral', () => {
expectGisEligible(res, 0, true)
expectAlwTooOld(res, true)
})

/* CALC-187 */
it('should TEST TEST - CALC-187', async () => {
const desiredName = 'CALC-187'
const extractedPayload = getTransformedPayloadByName(filePath, desiredName)
const res = await mockGetRequest({
...extractedPayload,
maritalStatus: 'single',
invSeparated: 'false',
age: 55.0,
clientBirthDate: '1969;08',
yearsInCanadaSince18: '10',
income: 2000,
whenToStartOAS: false,
startDateForOAS: -10.08,
partnerBenefitStatus: undefined,
partnerIncome: 0,
partnerIncomeWork: 0,
partnerAge: undefined,
partnerBirthDate: undefined,
partnerLivingCountry: undefined,
partnerLegalStatus: undefined,
partnerLivedOnlyInCanada: undefined,
})

const future = res.body.futureClientResults[0][65]
console.log('#####', future)
expect(res.status).toEqual(400)
expect(res.body.summary.state).toEqual('AVAILABLE_INELIGIBLE')
expect(future.oas.eligibility.result).toEqual('eligible')
expect(future.oas.entitlement.result).toBeCloseTo(359.17, 0.01)
})
})
199 changes: 199 additions & 0 deletions __tests__/pages/api/smokeTests.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import {
LegalStatus,
LivingCountry,
MaritalStatus,
PartnerBenefitStatus,
ResultKey,
ResultReason,
ValidationErrors,
EntitlementResultType,
SummaryState,
} from '../../../utils/api/definitions/enums'
import { FieldKey } from '../../../utils/api/definitions/fields'
import roundToTwo from '../../../utils/api/helpers/roundToTwo'
import legalValues from '../../../utils/api/scrapers/output'
import {
age60NoDefer,
age65NoDefer,
canadaWholeLife,
canadian,
expectAlwsMarital,
expectAllIneligible,
expectAlwTooOld,
expectOasGisTooYoung,
income10k,
partnerIncomeZero,
partnerNoHelpNeeded,
partnerUndefined,
getErrorDetails,
expectOasEligible,
} from '../../utils/expectUtils'
import { mockGetRequest } from '../../utils/factory'

const obsolete = {
incomeWork: 0,
oasDefer: false,
oasAge: 0,
livedOnlyInCanada: false,
everLivedSocialCountry: false,
partnerIncomeWork: 0,
}

describe('Smoke tests', () => {
it('SMKTST-17', async () => {
const res = await mockGetRequest({
age: 55.0,
receiveOAS: false,
oasDeferDuration: undefined,
whenToStartOAS: false,
startDateForOAS: -10.08,
incomeAvailable: undefined,
income: 2000,
yearsInCanadaSince18: 10,
maritalStatus: MaritalStatus.SINGLE,
invSeparated: false,
...canadian,
...partnerUndefined,
...obsolete,
clientBirthDate: '1969;08',
})

const future = res.body.futureClientResults[0][65]

expect(res.status).toEqual(400)
expect(res.body.summary.state).toEqual(SummaryState.AVAILABLE_INELIGIBLE)
expect(future.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(future.oas.entitlement.result).toBeCloseTo(359.17, 0.01)
})

it('SMKTST-18', async () => {
const res = await mockGetRequest({
age: 45.5,
receiveOAS: false,
oasDeferDuration: undefined,
whenToStartOAS: false,
startDateForOAS: -20.08,
incomeAvailable: undefined,
income: 15000,
yearsInCanadaSince18: 15,
maritalStatus: MaritalStatus.SINGLE,
invSeparated: undefined,
...partnerUndefined,
...canadian,
...obsolete,
})

const future = res.body.futureClientResults[0][65]

expect(res.body.summary.state).toEqual(SummaryState.AVAILABLE_INELIGIBLE)
expect(future.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(future.oas.entitlement.result).toBeCloseTo(632.56, 0.01)
})

it('SMKTST-19', async () => {
const res = await mockGetRequest({
age: 50,
receiveOAS: false,
oasDeferDuration: undefined,
whenToStartOAS: false,
startDateForOAS: -26.0,
incomeAvailable: undefined,
income: 5000,
yearsInCanadaSince18: 20,
maritalStatus: MaritalStatus.PARTNERED,
invSeparated: false,
partnerBenefitStatus: PartnerBenefitStatus.OAS_GIS,
partnerIncomeAvailable: undefined,
partnerIncome: 25000,
partnerAge: 65.0,
partnerLivingCountry: LivingCountry.CANADA,
partnerLegalStatus: LegalStatus.YES,
partnerLivedOnlyInCanada: false,
partnerYearsInCanadaSince18: 20,
...canadian,
...obsolete,
})

const future = res.body.futureClientResults[0][65]

expect(res.body.summary.state).toEqual(SummaryState.AVAILABLE_INELIGIBLE)
expect(future.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(future.oas.entitlement.result).toBeCloseTo(359.17, 0.01)
})

it('SMKTST-25C', async () => {
const res = await mockGetRequest({
age: 66.32,
receiveOAS: false,
oasDeferDuration: undefined,
whenToStartOAS: false,
startDateForOAS: -0.669, // 67yrs
incomeAvailable: undefined,
income: 0,
yearsInCanadaSince18: 20,
maritalStatus: MaritalStatus.SINGLE,
invSeparated: undefined,
...partnerUndefined,
...canadian,
...obsolete,
clientBirthDate: '1958;04',
})

const result = res.body.results

expect(res.body.summary.state).toEqual(SummaryState.AVAILABLE_ELIGIBLE)
expect(result.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(result.oas.entitlement.result).toBeCloseTo(376.4, 0.01)
})

it('SMKTST-25D', async () => {
const res = await mockGetRequest({
age: 66.32,
receiveOAS: false,
oasDeferDuration: undefined,
whenToStartOAS: false,
startDateForOAS: -1.58, // 67yrs 11 months
incomeAvailable: undefined,
income: 0,
yearsInCanadaSince18: 20,
maritalStatus: MaritalStatus.SINGLE,
invSeparated: undefined,
...partnerUndefined,
...canadian,
...obsolete,
clientBirthDate: '1958;04',
})

const result = res.body.results

expect(res.body.summary.state).toEqual(SummaryState.AVAILABLE_ELIGIBLE)
expect(result.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(result.oas.entitlement.result).toBeCloseTo(392.96, 0.01)
})

it('SMKTST-20B', async () => {
const res = await mockGetRequest({
age: 68.75,
receiveOAS: false,
oasDeferDuration: undefined,
whenToStartOAS: false,
startDateForOAS: -0.58, // 69yrs 4 months
incomeAvailable: undefined,
income: 0,
yearsInCanadaSince18: 15,
maritalStatus: MaritalStatus.SINGLE,
invSeparated: undefined,
...partnerUndefined,
...canadian,
...obsolete,
clientBirthDate: '1955;11',
})

const result = res.body.results

expect(res.body.summary.state).toEqual(SummaryState.AVAILABLE_ELIGIBLE)
expect(result.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE)
expect(result.oas.entitlement.result).toBeCloseTo(280.69, 0.01)
})
//
})
3 changes: 3 additions & 0 deletions __tests__/utils/expectUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export const age65NoDefer = {
oasDefer: false,
oasAge: undefined,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
}

Expand All @@ -350,6 +351,7 @@ export const age75NoDefer = {
oasDefer: false,
oasAge: undefined,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
}

Expand All @@ -358,6 +360,7 @@ export const age60NoDefer = {
oasDefer: false,
oasAge: undefined,
receiveOAS: false,
whenToStartOAS: true, //asap
oasDeferDuration: undefined,
}

Expand Down
Loading
Loading