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

MR-3545, MR-2370: Fix change history, add cypress tests, and turn on remaining API Unit tests #1959

Merged
merged 99 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
18b53ba
populating
rswerve Aug 11, 2023
4907a99
merge main
rswerve Aug 11, 2023
725a917
keep incoming
rswerve Aug 11, 2023
ea2f4fc
Merge branch 'main' into ma_3211_migrator
mojotalantikite Aug 15, 2023
5303350
remove default name. not sure why it's here?
mojotalantikite Aug 15, 2023
de6de60
Merge branch 'main' into ma_3211_migrator
mojotalantikite Aug 21, 2023
ab026b8
use the right deploy script
mojotalantikite Aug 21, 2023
6d3028c
move the migration into a func
mojotalantikite Aug 23, 2023
d88712d
return errors in prepopulate updateinfo
mojotalantikite Aug 23, 2023
0f71154
use error returns on insertContractId
mojotalantikite Aug 24, 2023
1f11890
return the error. no throws here for try/catch
mojotalantikite Aug 24, 2023
ffc7a90
clean up error messaging
mojotalantikite Aug 24, 2023
4c7b89d
move contract ops to migrateContract()
mojotalantikite Aug 28, 2023
1d72a83
don't forget the associations error handling
mojotalantikite Aug 28, 2023
e023d62
the migrate results type
mojotalantikite Aug 30, 2023
8350b15
more tests
mojotalantikite Aug 31, 2023
96130ce
Merge branch 'main' into ma_3211_migrator
mojotalantikite Aug 31, 2023
afb184a
make it a helper func
mojotalantikite Aug 31, 2023
736fc35
rate revision test
mojotalantikite Aug 31, 2023
9020604
check that we can get the migrated revision back
mojotalantikite Sep 7, 2023
1774f24
Merge branch 'main' into ma_3211_migrator
mojotalantikite Sep 7, 2023
aa9cbfc
record the exception no need to return a packageId
mojotalantikite Sep 7, 2023
69d5fda
fix test
mojotalantikite Sep 7, 2023
e7025af
more logging
mojotalantikite Sep 7, 2023
401c4a9
clearAllMocks
mojotalantikite Sep 7, 2023
a11a7ae
doesnt' test anything now
mojotalantikite Sep 7, 2023
349858e
some debug
mojotalantikite Sep 11, 2023
cc174ee
keep track of migrations that did not complete
mojotalantikite Sep 11, 2023
d31e1d0
crashing on the user find
mojotalantikite Sep 11, 2023
a8be47c
log out some stats
mojotalantikite Sep 12, 2023
a6b9f80
need to continue
mojotalantikite Sep 13, 2023
e3ff72e
Merge branch 'main' into ma_3211_migrator
mojotalantikite Sep 14, 2023
8b5a9c1
just use the client we already get
mojotalantikite Sep 14, 2023
6d833e9
remove some debug
mojotalantikite Sep 14, 2023
85990d1
all the contract ammendment info
mojotalantikite Sep 15, 2023
fb80fb3
get unlockInfoID
mojotalantikite Sep 18, 2023
1ec5388
rate revision as well
mojotalantikite Sep 18, 2023
b477396
Merge branch 'main' into ma_3211_migrator
mojotalantikite Sep 19, 2023
7ebbb6a
testing file
mojotalantikite Sep 21, 2023
1a8b0a6
fix up test some more
mojotalantikite Sep 21, 2023
dca252a
Adding test fixes and fixes from test
mojotalantikite Sep 22, 2023
b649404
Merge branch 'main' into ma_3211_migrator
mojotalantikite Sep 25, 2023
49b7d1d
Merge branch 'main' into ma_3211_migrator
mojotalantikite Sep 27, 2023
77e8531
fixes in migrate. add DB reset at init.
mojotalantikite Sep 29, 2023
d1d4b90
Merge branch 'main' into ma_3211_migrator
mojotalantikite Sep 29, 2023
d9d0a44
use the prisma types in the test
mojotalantikite Sep 29, 2023
f580d0c
Merge branch 'main' into ma_3211_migrator
mojotalantikite Oct 2, 2023
774a4d6
finish adding contract docs
mojotalantikite Oct 3, 2023
37e5204
adds the rate docs
mojotalantikite Oct 3, 2023
0791c55
add another fake doc
mojotalantikite Oct 3, 2023
7ef0a81
contract/rate doc migration moved.
mojotalantikite Oct 3, 2023
28b7b8a
move join table work to the create phase
mojotalantikite Oct 3, 2023
1c90834
cleanup all the things
mojotalantikite Oct 3, 2023
ef70254
format on save?
mojotalantikite Oct 3, 2023
f2f6356
enable remaining jest tests
macrael Oct 5, 2023
59ebaff
fix up compare
mojotalantikite Oct 5, 2023
336995c
Enable `rates-db-refactor` and `supporting-docs-by-rate` flag for cyp…
JasonLin0991 Oct 5, 2023
1906272
Skip Q&A tests, resolver not modified for refactor yet.
JasonLin0991 Oct 5, 2023
9ca10f5
logging data objects out for compare
mojotalantikite Oct 5, 2023
ebbbc38
Merge branch 'main' into jl-fix-change-history-and-add-cypress-tests
JasonLin0991 Oct 5, 2023
63b4a34
refactor comparison
mojotalantikite Oct 5, 2023
6e1bb38
more cleaning on test
mojotalantikite Oct 5, 2023
2b42b2f
fix the map to flatmap
mojotalantikite Oct 5, 2023
9b017c3
fix up which we compare with
mojotalantikite Oct 5, 2023
fc40e78
error check
mojotalantikite Oct 5, 2023
7021d1f
Add extra test for change history order and count.
JasonLin0991 Oct 5, 2023
6e0ee29
Remove rate history from contract history.
JasonLin0991 Oct 5, 2023
067f06a
Add a check for which query to wait for.
JasonLin0991 Oct 5, 2023
e2b1daa
Merge branch 'main' into jl-fix-change-history-and-add-cypress-tests
JasonLin0991 Oct 5, 2023
ce92615
Merge branch 'wml-enable-all-tests' into jl-fix-change-history-and-ad…
JasonLin0991 Oct 6, 2023
381fa0a
Apply suggestions from code review
macrael Oct 6, 2023
b7c7430
some fixes to the migrator
macrael Oct 6, 2023
6dcab69
Merge branch 'main' into ma_3211_migrator
macrael Oct 6, 2023
7e6b7ad
fix ordering of contract revisions
macrael Oct 6, 2023
e35cfda
update yarn.lock
macrael Oct 6, 2023
cc51976
Merge branch 'main' into wml-enable-all-tests
JasonLin0991 Oct 6, 2023
07b1595
Merge branch 'wml-enable-all-tests' into jl-fix-change-history-and-ad…
JasonLin0991 Oct 6, 2023
20b8e3a
Fix contractWithHistoryToDomainModel.
JasonLin0991 Oct 6, 2023
45abb45
debug helper.
JasonLin0991 Oct 6, 2023
95459cf
Update tests
JasonLin0991 Oct 6, 2023
7350888
Longer timeout looking for unlock button.
JasonLin0991 Oct 6, 2023
3d48821
Update services/app-api/src/resolvers/healthPlanPackage/indexHealthPl…
JasonLin0991 Oct 6, 2023
c8efccf
Update services/app-api/src/resolvers/healthPlanPackage/indexHealthPl…
JasonLin0991 Oct 6, 2023
e349bb1
Merge branch 'wml-enable-all-tests' into jl-fix-change-history-and-ad…
JasonLin0991 Oct 6, 2023
ce3b015
cypress re-run
JasonLin0991 Oct 6, 2023
93eeba4
add position to actuary contacts
mojotalantikite Oct 6, 2023
208a93a
Increase timeouts for more docs.
JasonLin0991 Oct 6, 2023
5238cb7
tests are suspiciously fixed
macrael Oct 6, 2023
ba8607e
Skip tests for rate history.
JasonLin0991 Oct 6, 2023
ce7ec5a
test and fix how update contract with rates reads rateInfo.id
macrael Oct 6, 2023
1ee6138
Merge branch 'wml-fix-update-cr' into jl-fix-change-history-and-add-c…
macrael Oct 6, 2023
f96a974
Merge branch 'main' into jl-fix-change-history-and-add-cypress-tests
macrael Oct 6, 2023
793359b
update migrators handling of submittedAt and unlocked rates
macrael Oct 9, 2023
2844a56
pass tx into findContractWithHistory. variable name changes for clarity.
JasonLin0991 Oct 9, 2023
a678fc1
Change setting id from revision id to rate id.
JasonLin0991 Oct 9, 2023
01ba2e9
Fix tests for rate formData.id change.
JasonLin0991 Oct 9, 2023
e1e1080
connect related contract
macrael Oct 9, 2023
0b59b7b
fix tests proactively
macrael Oct 9, 2023
8448ac3
Merge branch 'wml-fixup-unlock-locked-migrate' into jl-fix-change-his…
macrael Oct 9, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ describe('findContract', () => {
if (threeContract instanceof Error) {
throw threeContract
}
expect(threeContract.revisions).toHaveLength(4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very hesitant to lose the specific values in this test. This test was written to check that we get the expected number of revisions everywhere. I'd rather mark this test as skip or something than adapt it to work with the interim solution.

Copy link
Contributor Author

@JasonLin0991 JasonLin0991 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! Let's mark as skip.


// Expect 3 rate revisions on contract revision
expect(threeContract.revisions[0].rateRevisions).toHaveLength(3)

// remove the connection from rate 2
must(
Expand All @@ -149,14 +151,14 @@ describe('findContract', () => {
})
)

// Now, find that contract and assert the history is what we expected
// Now, find that contract and assert it has 2 rate revisions
const twoContract = must(
await findContractWithHistory(client, contractA.id)
)
if (twoContract instanceof Error) {
throw twoContract
}
expect(twoContract.revisions).toHaveLength(5)

expect(twoContract.revisions[0].rateRevisions).toHaveLength(2)

// update rate 1 to have a new version, should make one new rev.
Expand All @@ -182,14 +184,18 @@ describe('findContract', () => {
})
)

// Now, find that contract and assert the history is what we expected
// Now, find that contract and assert rateRevision includes our updated rate
const backAgainContract = must(
await findContractWithHistory(client, contractA.id)
)
if (backAgainContract instanceof Error) {
throw backAgainContract
}
expect(backAgainContract.revisions).toHaveLength(6)
expect(backAgainContract.revisions[0].rateRevisions).toHaveLength(2)
expect(
backAgainContract.revisions[0].rateRevisions[1].submitInfo
?.updatedReason
).toContain('1.1 new name')

// Make a new Contract Revision, should show up as a single new rev with all the old info
must(
Expand All @@ -214,7 +220,12 @@ describe('findContract', () => {
if (testingContract instanceof Error) {
throw testingContract
}
expect(testingContract.revisions).toHaveLength(7)
expect(testingContract.revisions).toHaveLength(2)
expect(testingContract.revisions[0].rateRevisions).toHaveLength(2)
expect(
testingContract.revisions[0].rateRevisions[1].submitInfo
?.updatedReason
).toContain('1.1 new name')

// Make a new Contract Revision, changing the connections should show up as a single new rev.
const unlockedContractA = must(
Expand Down Expand Up @@ -258,7 +269,12 @@ describe('findContract', () => {
if (testingContract instanceof Error) {
throw testingContract
}
expect(testingContract.revisions).toHaveLength(8)
expect(testingContract.revisions).toHaveLength(3)
expect(testingContract.revisions[0].rateRevisions).toHaveLength(1)
expect(
testingContract.revisions[0].rateRevisions[0].formData
.rateCertificationName
).toContain('threepointo')

// Now, find that contract and assert the history is what we expected
const resultingContract = must(
Expand All @@ -277,72 +293,39 @@ describe('findContract', () => {

// Each Revision needs a Reason, one of the contracts or revisions associated with it should have changed and why.

expect(revisionsInTimeOrder).toHaveLength(8)
expect(revisionsInTimeOrder[0].rateRevisions).toHaveLength(0)
// Assert Initial submitted revision has correct data
expect(revisionsInTimeOrder).toHaveLength(3)
expect(revisionsInTimeOrder[0].rateRevisions).toHaveLength(2)
expect(revisionsInTimeOrder[0].unlockInfo).toBeUndefined()
expect(revisionsInTimeOrder[0].submitInfo?.updatedReason).toBe(
'initial submit'
)

expect(revisionsInTimeOrder[1].rateRevisions).toHaveLength(1)
expect(revisionsInTimeOrder[1].unlockInfo).toBeUndefined()
expect(revisionsInTimeOrder[1].submitInfo?.updatedReason).toBe(
'Rate Submit'
)

expect(revisionsInTimeOrder[2].rateRevisions).toHaveLength(2)
expect(revisionsInTimeOrder[2].unlockInfo).toBeUndefined()
expect(revisionsInTimeOrder[2].submitInfo?.updatedReason).toBe(
'RateSubmit 2'
)

expect(revisionsInTimeOrder[3].rateRevisions).toHaveLength(3)
expect(revisionsInTimeOrder[3].unlockInfo).toBeUndefined()
expect(revisionsInTimeOrder[3].submitInfo?.updatedReason).toBe(
'3.0 create'
)

expect(revisionsInTimeOrder[4].rateRevisions).toHaveLength(2)
expect(revisionsInTimeOrder[4].unlockInfo?.updatedReason).toBe(
'unlock for 2.1 remove'
)
expect(revisionsInTimeOrder[4].unlockInfo?.updatedBy).toBe(
'zuko@example.com'
// Assert first unlock and resubmit has correct data
expect(revisionsInTimeOrder[1].rateRevisions).toHaveLength(2)
expect(revisionsInTimeOrder[1].unlockInfo?.updatedReason).toBe(
'unlocking A.0'
)
expect(revisionsInTimeOrder[4].submitInfo?.updatedReason).toBe(
'2.1 remove'
expect(revisionsInTimeOrder[1].submitInfo?.updatedReason).toBe(
'Submitting A.1'
)

expect(revisionsInTimeOrder[5].rateRevisions).toHaveLength(2)
expect(
revisionsInTimeOrder[5].rateRevisions[1].formData
.rateCertificationName
).toBe('onepointone')
expect(revisionsInTimeOrder[5].unlockInfo?.updatedReason).toBe(
'unlock for 1.1'
)
expect(revisionsInTimeOrder[5].submitInfo?.updatedReason).toBe(
'1.1 new name'
// Assert final unlock and resubmit has correct data
expect(revisionsInTimeOrder[2].unlockInfo?.updatedReason).toBe(
'unlocking A.1'
)

expect(revisionsInTimeOrder[6].rateRevisions).toHaveLength(2)
expect(revisionsInTimeOrder[6].submitInfo?.updatedReason).toBe(
'Submitting A.1'
expect(revisionsInTimeOrder[2].submitInfo?.updatedReason).toBe(
'Submitting A.2'
)

expect(revisionsInTimeOrder[7].rateRevisions).toHaveLength(1)
expect(revisionsInTimeOrder[7].formData).toEqual(
expect(revisionsInTimeOrder[2].formData).toEqual(
expect.objectContaining({
submissionType: 'CONTRACT_AND_RATES',
submissionDescription: 'a.2 body',
})
)
expect(revisionsInTimeOrder[7].submitInfo?.updatedReason).toBe(
'Submitting A.2'
)
expect(revisionsInTimeOrder[2].rateRevisions).toHaveLength(1)

// check for rate and see if it handles the removed bit right

const rate1fetched = await findRateWithHistory(client, rate1.id)
if (rate1fetched instanceof Error) {
throw rate1fetched
Expand Down Expand Up @@ -578,36 +561,21 @@ describe('findContract', () => {

// Each Revision needs a Reason, one of the contracts or revisions associated with it should have changed and why.

expect(revisions).toHaveLength(8)
expect(revisions[0].rateRevisions).toHaveLength(0)
expect(revisions).toHaveLength(3)
expect(revisions[0].rateRevisions).toHaveLength(2)
expect(revisions[0].submitInfo?.updatedReason).toBe('initial submit')

expect(revisions[1].rateRevisions).toHaveLength(1)
expect(revisions[1].submitInfo?.updatedReason).toBe('Rate Submit')

expect(revisions[2].rateRevisions).toHaveLength(2)
expect(revisions[2].submitInfo?.updatedReason).toBe('RateSubmit 2')

expect(revisions[3].rateRevisions).toHaveLength(3)
expect(revisions[4].rateRevisions).toHaveLength(2)

expect(revisions[5].rateRevisions).toHaveLength(2)
expect(
revisions[5].rateRevisions[1].formData.rateCertificationName
).toBe('onepointone')
expect(revisions[5].submitInfo?.updatedReason).toBe('1.1 new name')

expect(revisions[6].rateRevisions).toHaveLength(2)
expect(revisions[6].submitInfo?.updatedReason).toBe('Submitting A.1')
expect(revisions[1].rateRevisions).toHaveLength(2)
expect(revisions[1].submitInfo?.updatedReason).toBe('Submitting A.1')

expect(revisions[7].rateRevisions).toHaveLength(1)
expect(revisions[7].formData).toEqual(
expect(revisions[2].rateRevisions).toHaveLength(1)
expect(revisions[2].submitInfo?.updatedReason).toBe('Submitting A.2')
expect(revisions[2].formData).toEqual(
expect.objectContaining({
submissionType: 'CONTRACT_AND_RATES',
submissionDescription: 'a.2 body',
})
)
expect(revisions[7].submitInfo?.updatedReason).toBe('Submitting A.2')

// check for rate and see if it handles the removed bit right

Expand Down Expand Up @@ -818,19 +786,16 @@ describe('findContract', () => {
JSON.stringify(revisions, null, ' ')
)

expect(revisions).toHaveLength(3)
expect(revisions).toHaveLength(2)
expect(revisions[0].rateRevisions).toHaveLength(2)
expect(revisions[0].submitInfo?.updatedReason).toBe('initial submit')

expect(revisions[1].rateRevisions).toHaveLength(2)
expect(revisions[1].submitInfo?.updatedReason).toBe('2.1 update')

expect(revisions[2].rateRevisions).toHaveLength(2)
expect(revisions[2].submitInfo?.updatedReason).toBe('third submit')
expect(revisions[1].submitInfo?.updatedReason).toBe('third submit')

// these revisions can be in any order because they were saved at the same time
const revisionFormDatas = new Set(
revisions[2].rateRevisions.map(
revisions[1].rateRevisions.map(
(rr) => rr.formData.rateCertificationName
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import { insertDraftRate } from './insertRate'
import { updateDraftRate } from './updateDraftRate'
import { unlockRate } from './unlockRate'
import { findRateWithHistory } from './findRateWithHistory'
import { must, createInsertContractData } from '../../testHelpers'
import {
must,
createInsertContractData,
consoleLogFullData,
} from '../../testHelpers'
import { createInsertRateData } from '../../testHelpers/contractAndRates/rateHelpers'
import { findContractWithHistory } from './findContractWithHistory'
import type { DraftContractType } from '../../domain-models/contractAndRates/contractTypes'
Expand Down Expand Up @@ -368,10 +372,14 @@ describe('findRate', () => {
throw contract1fetched
}

expect(contract1fetched.revisions).toHaveLength(4)
expect(contract1fetched.revisions[0].submitInfo?.updatedReason).toBe(
'Submitting A.2'
)
consoleLogFullData(contract1fetched.revisions)
expect(contract1fetched.revisions).toHaveLength(2)

// Latest revision should have no rates now
expect(contract1fetched.revisions[0].rateRevisions).toHaveLength(0)

// Initial submit should have 1 rate
expect(contract1fetched.revisions[1].rateRevisions).toHaveLength(1)
})

it('finds a full rate', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,56 @@ function contractWithHistoryToDomainModel(

allRevisionSets.push(initialEntry)

let lastEntry = initialEntry
// Now we construct a revision history for each change in rate revisions.
// go through every rate revision in the join table in time order and construct a revisionSet
// with (or without) the new rate revision in it.
// This code below was used to construct rate change history and add into our contract revision history by pushing
// new contract revisions into the array. This however caused issues with the frontend apollo cache because we
// used duplicate contract revision ids to create new revisions for rate changes.
// For now, we are commenting out the code until we are ready for this feature and leaving it intact.

// let lastEntry = initialEntry
// // Now we construct a revision history for each change in rate revisions.
// // go through every rate revision in the join table in time order and construct a revisionSet
// // with (or without) the new rate revision in it.
// for (const rateRev of contractRev.rateRevisions) {
// if (!rateRev.rateRevision.submitInfo) {
// return new Error(
// 'Programming Error: a contract is associated with an unsubmitted rate'
// )
// }
//
// // if it's from before this contract was submitted, it's there at the beginning.
// if (
// rateRev.rateRevision.submitInfo.updatedAt <=
// contractRev.submitInfo.updatedAt
// ) {
// if (!rateRev.isRemoval) {
// initialEntry.rateRevisions.push(rateRev.rateRevision)
// }
// } else {
// // if after, then it's always a new entry in the list
// let lastRates = [...lastEntry.rateRevisions]
//
// // take out the previous rate revision this revision supersedes
// lastRates = lastRates.filter(
// (r) => r.rateID !== rateRev.rateRevision.rateID
// )
// // an isRemoval entry indicates that this rate was removed from this contract.
// if (!rateRev.isRemoval) {
// lastRates.push(rateRev.rateRevision)
// }
//
// const newRev: ContractRevisionSet = {
// contractRev,
// submitInfo: rateRev.rateRevision.submitInfo,
// unlockInfo: rateRev.rateRevision.unlockInfo || undefined,
// rateRevisions: lastRates,
// }
//
// lastEntry = newRev
// allRevisionSets.push(newRev)
// }
// }

// Basically the same as above, except we do not create new contract revisions for rate changes.
for (const rateRev of contractRev.rateRevisions) {
if (!rateRev.rateRevision.submitInfo) {
return new Error(
Expand All @@ -167,7 +213,7 @@ function contractWithHistoryToDomainModel(
}
} else {
// if after, then it's always a new entry in the list
let lastRates = [...lastEntry.rateRevisions]
let lastRates = [...initialEntry.rateRevisions]

// take out the previous rate revision this revision supersedes
lastRates = lastRates.filter(
Expand All @@ -178,15 +224,7 @@ function contractWithHistoryToDomainModel(
lastRates.push(rateRev.rateRevision)
}

const newRev: ContractRevisionSet = {
contractRev,
submitInfo: rateRev.rateRevision.submitInfo,
unlockInfo: rateRev.rateRevision.unlockInfo || undefined,
rateRevisions: lastRates,
}

lastEntry = newRev
allRevisionSets.push(newRev)
initialEntry.rateRevisions = lastRates
}
}
}
Expand Down
Loading
Loading