-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,276 additions
and
1,865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { findAllRatesWithHistoryBySubmitInfo } from './findAllRatesWithHistoryBySubmitInfo' | ||
import { sharedTestPrismaClient } from '../../testHelpers/storeHelpers' | ||
import { mockInsertRateArgs, must } from '../../testHelpers' | ||
import { | ||
mockInsertContractArgs, | ||
mockInsertRateArgs, | ||
must, | ||
} from '../../testHelpers' | ||
import { v4 as uuidv4 } from 'uuid' | ||
import { insertDraftRate } from './insertRate' | ||
import { submitRate } from './submitRate' | ||
import { unlockRate } from './unlockRate' | ||
import { insertDraftContract } from './insertContract' | ||
import { submitContract } from './submitContract' | ||
import { unlockContract } from './unlockContract' | ||
|
||
describe('findAllRatesWithHistoryBySubmittedInfo', () => { | ||
it('returns only rates that have been submitted or unlocked', async () => { | ||
|
@@ -20,79 +25,60 @@ describe('findAllRatesWithHistoryBySubmittedInfo', () => { | |
}, | ||
}) | ||
|
||
const cmsUser = await client.user.create({ | ||
data: { | ||
id: uuidv4(), | ||
givenName: 'Zuko', | ||
familyName: 'Hotman', | ||
email: '[email protected]', | ||
role: 'CMS_USER', | ||
}, | ||
const draftContractData = mockInsertContractArgs({ | ||
submissionDescription: 'one contract', | ||
}) | ||
const contractA = must( | ||
await insertDraftContract(client, draftContractData) | ||
) | ||
|
||
const draftRateData = mockInsertRateArgs({ | ||
rateCertificationName: 'one rate', | ||
}) | ||
|
||
// make two submitted rates and submit them | ||
const rateOne = must(await insertDraftRate(client, draftRateData)) | ||
const rateTwo = must(await insertDraftRate(client, draftRateData)) | ||
const submittedRateOne = must( | ||
await submitRate(client, { | ||
rateID: rateOne.id, | ||
submittedByUserID: stateUser.id, | ||
submittedReason: 'rateOne submit', | ||
}) | ||
const rateOne = must( | ||
await insertDraftRate(client, contractA.id, draftRateData) | ||
) | ||
const submittedRateTwo = must( | ||
await submitRate(client, { | ||
rateID: rateTwo.id, | ||
submittedByUserID: stateUser.id, | ||
submittedReason: 'rateTwo submit', | ||
}) | ||
const rateTwo = must( | ||
await insertDraftRate(client, contractA.id, draftRateData) | ||
) | ||
|
||
// make two draft rates | ||
const draftRateOne = must(await insertDraftRate(client, draftRateData)) | ||
const draftRateTwo = must(await insertDraftRate(client, draftRateData)) | ||
|
||
// make one unlocked rate | ||
const rateThree = must(await insertDraftRate(client, draftRateData)) | ||
must( | ||
await submitRate(client, { | ||
rateID: rateThree.id, | ||
await submitContract(client, { | ||
contractID: contractA.id, | ||
submittedByUserID: stateUser.id, | ||
submittedReason: 'unlockRateOne submit', | ||
submittedReason: 'Submitting A.1', | ||
}) | ||
) | ||
const unlockedRate = must( | ||
await unlockRate(client, { | ||
rateID: rateThree.id, | ||
unlockedByUserID: cmsUser.id, | ||
unlockReason: 'unlock unlockRateOne', | ||
|
||
must( | ||
await unlockContract(client, { | ||
contractID: contractA.id, | ||
unlockedByUserID: stateUser.id, | ||
unlockReason: 'Unlock A.1', | ||
}) | ||
) | ||
|
||
// make two draft rates | ||
const draftRateOne = must( | ||
await insertDraftRate(client, contractA.id, draftRateData) | ||
) | ||
const draftRateTwo = must( | ||
await insertDraftRate(client, contractA.id, draftRateData) | ||
) | ||
|
||
// call the find by submit info function | ||
const rates = must(await findAllRatesWithHistoryBySubmitInfo(client)) | ||
|
||
// expect our two submitted rates | ||
expect(rates).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
rateID: submittedRateOne.id, | ||
rateID: rateOne.id, | ||
}), | ||
expect.objectContaining({ | ||
rateID: submittedRateTwo.id, | ||
}), | ||
]) | ||
) | ||
|
||
// expect our one unlocked rate | ||
expect(rates).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
rateID: unlockedRate.id, | ||
rateID: rateTwo.id, | ||
}), | ||
]) | ||
) | ||
|
@@ -123,31 +109,38 @@ describe('findAllRatesWithHistoryBySubmittedInfo', () => { | |
}, | ||
}) | ||
|
||
const draftContractData = mockInsertContractArgs({ | ||
submissionDescription: 'one contract', | ||
}) | ||
const contractA = must( | ||
await insertDraftContract(client, draftContractData) | ||
) | ||
|
||
const rateDataForAS = must( | ||
await insertDraftRate( | ||
client, | ||
contractA.id, | ||
mockInsertRateArgs({ | ||
stateCode: 'AS', | ||
rateCertificationName: 'one rate', | ||
}) | ||
) | ||
) | ||
const submittedRateAmericanSamoa = must( | ||
await submitRate(client, { | ||
rateID: rateDataForAS.id, | ||
must( | ||
await submitContract(client, { | ||
contractID: contractA.id, | ||
submittedByUserID: stateUser.id, | ||
submittedReason: 'rateOne submit', | ||
submittedReason: 'Submitting A.1', | ||
}) | ||
) | ||
|
||
// call the find by submit info function | ||
const rates = must(await findAllRatesWithHistoryBySubmitInfo(client)) | ||
|
||
// expect our AS rate to not be in the results | ||
expect(rates).not.toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
rateID: submittedRateAmericanSamoa.id, | ||
rateID: rateDataForAS.id, | ||
}), | ||
]) | ||
) | ||
|
@@ -166,20 +159,28 @@ describe('findAllRatesWithHistoryBySubmittedInfo', () => { | |
}, | ||
}) | ||
|
||
const draftContractData = mockInsertContractArgs({ | ||
submissionDescription: 'one contract', | ||
}) | ||
const contractA = must( | ||
await insertDraftContract(client, draftContractData) | ||
) | ||
|
||
const rateDataForMN = must( | ||
await insertDraftRate( | ||
client, | ||
contractA.id, | ||
mockInsertRateArgs({ | ||
stateCode: 'MN', | ||
rateCertificationName: 'one rate', | ||
}) | ||
) | ||
) | ||
const submittedRateMinnesota = must( | ||
await submitRate(client, { | ||
rateID: rateDataForMN.id, | ||
must( | ||
await submitContract(client, { | ||
contractID: contractA.id, | ||
submittedByUserID: stateUser.id, | ||
submittedReason: 'rateOne submit', | ||
submittedReason: 'Submitting A.1', | ||
}) | ||
) | ||
|
||
|
@@ -192,7 +193,7 @@ describe('findAllRatesWithHistoryBySubmittedInfo', () => { | |
expect(rates).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
rateID: submittedRateMinnesota.id, | ||
rateID: rateDataForMN.id, | ||
}), | ||
]) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.