Skip to content

Commit

Permalink
Add back status tests - remove calculated status in submit
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Sep 1, 2023
1 parent d188e21 commit 723a552
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Prisma } from '@prisma/client'
import type { DocumentCategoryType } from 'app-web/src/common-code/healthPlanFormDataType'
import type {
ContractFormDataType,
ContractType,
RateFormDataType,
RateRevisionType,
PackageStatusType,
Expand Down Expand Up @@ -36,10 +35,10 @@ function convertUpdateInfoToDomainModel(
}

// -----
function getContractRateStatus(contractWithRates: ContractType): PackageStatusType {
function getContractRateStatus(revisions: ContractRevisionTableWithFormData[]| RateRevisionTableWithFormData[]): PackageStatusType {

// need to order revisions from latest to earliest
const revs = contractWithRates.revisions.sort(
const revs = revisions.sort(
(revA, revB) => revB.createdAt.getTime() - revA.createdAt.getTime()
)
const latestRevision = revs[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('prismaToDomainModel', () => {
})
})

describe.skip('getContractRateStatus', () => {
describe('getContractRateStatus', () => {
// Using type coercion in these tests rather than creating revisions
// we just care about unit testing different variations of submitInfo, updateInfo, and createdAt
const contractWithUnorderedRevs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe.each(flagValueTestParameters)(
`Tests $testName`,
({ flagName, flagValue }) => {
const cmsUser = testCMSUser()
it('returns a StateSubmission if complete', async () => {
it.only('returns a StateSubmission if complete', async () => {
const server = await constructTestPostgresServer()

// setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import type {
} from '../../../../app-web/src/common-code/healthPlanFormDataType'
import type { LDService } from '../../launchDarkly/launchDarkly'
import { convertContractWithRatesToFormData, convertContractWithRatesToUnlockedHPP } from '../../domain-models/contractAndRates/convertContractWithRatesToHPP'
import { getContractRateStatus } from '../../postgres/contractAndRates/prismaSharedContractRateHelpers'
import type { Span } from '@opentelemetry/api'
import type { PackageStatusType } from '../../domain-models/contractAndRates'

Expand Down Expand Up @@ -254,7 +253,7 @@ export function submitHealthPlanPackageResolver(
)
}

validateStatusAndUpdateInfo(getContractRateStatus(contractWithHistory.revisions),updateInfo, span, submittedReason || undefined)
validateStatusAndUpdateInfo(contractWithHistory.status,updateInfo, span, submittedReason || undefined)

// reassign variable set up before rates feature flag
currentFormData = convertContractWithRatesToFormData(contractWithHistory.revisions[0], contractWithHistory.stateCode, contractWithHistory.stateNumber)
Expand All @@ -264,7 +263,7 @@ export function submitHealthPlanPackageResolver(
input.pkgID
)

if (isStoreError(initialPackage) || !initialPackage) {
if (isStoreError(initialPackage) || !initialPackage) {
if (!initialPackage) {
throw new GraphQLError('Issue finding package.', {
extensions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ const convertRateSupportingDocs = (
}

const removeRatesData = (
pkg: UnlockedHealthPlanFormDataType
): UnlockedHealthPlanFormDataType => {
pkg: HealthPlanFormDataType
): HealthPlanFormDataType => {
pkg.rateInfos = []
pkg.addtlActuaryContacts = []
pkg.addtlActuaryCommunicationPreference = undefined
Expand All @@ -342,8 +342,8 @@ const removeRatesData = (
// Remove any provisions and federal authorities that aren't valid for population type (e.g. CHIP)
// since user can change theses submission type fields on unlock and not necesarily update the contract details
const removeInvalidProvisionsAndAuthorities = (
pkg: UnlockedHealthPlanFormDataType
): UnlockedHealthPlanFormDataType => {
pkg: HealthPlanFormDataType
): HealthPlanFormDataType => {
// remove invalid provisions
if (isContractWithProvisions(pkg) && pkg.contractAmendmentInfo) {
const validProvisionsKeys = generateApplicableProvisionsList(pkg)
Expand Down

0 comments on commit 723a552

Please sign in to comment.