From 723a552cbf5cba814287ee2fac6ec45d22b5eaaf Mon Sep 17 00:00:00 2001 From: Hana Worku Date: Fri, 1 Sep 2023 17:48:09 -0500 Subject: [PATCH] Add back status tests - remove calculated status in submit --- .../contractAndRates/prismaSharedContractRateHelpers.ts | 5 ++--- .../postgres/contractAndRates/prismaToDomainModel.test.ts | 2 +- .../healthPlanPackage/submitHealthPlanPackage.test.ts | 2 +- .../healthPlanPackage/submitHealthPlanPackage.ts | 5 ++--- .../healthPlanFormDataType/healthPlanFormData.ts | 8 ++++---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/services/app-api/src/postgres/contractAndRates/prismaSharedContractRateHelpers.ts b/services/app-api/src/postgres/contractAndRates/prismaSharedContractRateHelpers.ts index 9424bcdc98..7364237459 100644 --- a/services/app-api/src/postgres/contractAndRates/prismaSharedContractRateHelpers.ts +++ b/services/app-api/src/postgres/contractAndRates/prismaSharedContractRateHelpers.ts @@ -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, @@ -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] diff --git a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts index 3054278729..a38b7ed14e 100644 --- a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts +++ b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.test.ts @@ -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: { diff --git a/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.test.ts b/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.test.ts index b35489b34d..9e8641afe3 100644 --- a/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.test.ts +++ b/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.test.ts @@ -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 diff --git a/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.ts b/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.ts index 791ff0fb73..b509aeee2e 100644 --- a/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.ts +++ b/services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.ts @@ -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' @@ -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) @@ -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: { diff --git a/services/app-web/src/common-code/healthPlanFormDataType/healthPlanFormData.ts b/services/app-web/src/common-code/healthPlanFormDataType/healthPlanFormData.ts index f1a5d0e6f7..f5ea77f2f7 100644 --- a/services/app-web/src/common-code/healthPlanFormDataType/healthPlanFormData.ts +++ b/services/app-web/src/common-code/healthPlanFormDataType/healthPlanFormData.ts @@ -329,8 +329,8 @@ const convertRateSupportingDocs = ( } const removeRatesData = ( - pkg: UnlockedHealthPlanFormDataType -): UnlockedHealthPlanFormDataType => { + pkg: HealthPlanFormDataType +): HealthPlanFormDataType => { pkg.rateInfos = [] pkg.addtlActuaryContacts = [] pkg.addtlActuaryCommunicationPreference = undefined @@ -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)