diff --git a/services/app-api/src/resolvers/healthPlanPackage/createHealthPlanPackage.test.ts b/services/app-api/src/resolvers/healthPlanPackage/createHealthPlanPackage.test.ts index 5a730a8a25..2402cb04c2 100644 --- a/services/app-api/src/resolvers/healthPlanPackage/createHealthPlanPackage.test.ts +++ b/services/app-api/src/resolvers/healthPlanPackage/createHealthPlanPackage.test.ts @@ -4,92 +4,34 @@ import { constructTestPostgresServer } from '../../testHelpers/gqlHelpers' import { latestFormData } from '../../testHelpers/healthPlanPackageHelpers' import { testCMSUser } from '../../testHelpers/userHelpers' import { testLDService } from '../../testHelpers/launchDarklyHelpers' +import { + FeatureFlagLDConstant, + FlagValue, +} from '../../../../app-web/src/common-code/featureFlags' -describe('createHealthPlanPackage', () => { - it('returns package with unlocked form data', async () => { - const server = await constructTestPostgresServer() +const flagValueTestParameters: { + flagName: FeatureFlagLDConstant + flagValue: FlagValue + testName: string +}[] = [ + { + flagName: 'rates-db-refactor', + flagValue: true, + testName: 'createHealthPlanPackage with all feature flags off', + }, + { + flagName: 'rates-db-refactor', + flagValue: true, + testName: 'createHealthPlanPackage with rates-db-refactor on', + }, +] - const input: CreateHealthPlanPackageInput = { - programIDs: [ - '5c10fe9f-bec9-416f-a20c-718b152ad633', - '037af66b-81eb-4472-8b80-01edf17d12d9', - ], - riskBasedContract: false, - submissionType: 'CONTRACT_ONLY', - submissionDescription: 'A real submission', - contractType: 'BASE', - } - const res = await server.executeOperation({ - query: CREATE_HEALTH_PLAN_PACKAGE, - variables: { input }, - }) - - expect(res.errors).toBeUndefined() - - const pkg = res.data?.createHealthPlanPackage.pkg - const draft = latestFormData(pkg) - - expect(draft.submissionDescription).toBe('A real submission') - expect(draft.submissionType).toBe('CONTRACT_ONLY') - expect(draft.programIDs).toEqual([ - '5c10fe9f-bec9-416f-a20c-718b152ad633', - '037af66b-81eb-4472-8b80-01edf17d12d9', - ]) - expect(draft.documents).toHaveLength(0) - expect(draft.managedCareEntities).toHaveLength(0) - expect(draft.federalAuthorities).toHaveLength(0) - expect(draft.contractDateStart).toBeUndefined() - expect(draft.contractDateEnd).toBeUndefined() - }) - - it('returns an error if the program id is not in valid', async () => { - const server = await constructTestPostgresServer() - const input: CreateHealthPlanPackageInput = { - programIDs: ['xyz123'], - riskBasedContract: false, - submissionType: 'CONTRACT_ONLY', - submissionDescription: 'A real submission', - contractType: 'BASE', - } - const res = await server.executeOperation({ - query: CREATE_HEALTH_PLAN_PACKAGE, - variables: { input }, - }) - - expect(res.errors).toBeDefined() - expect(res.errors && res.errors[0].message).toBe( - 'The program id xyz123 does not exist in state FL' - ) - }) - - it('returns an error if a CMS user attempts to create', async () => { - const server = await constructTestPostgresServer({ - context: { - user: testCMSUser(), - }, - }) - - const input: CreateHealthPlanPackageInput = { - programIDs: ['xyz123'], - riskBasedContract: false, - submissionType: 'CONTRACT_ONLY', - submissionDescription: 'A real submission', - contractType: 'BASE', - } - const res = await server.executeOperation({ - query: CREATE_HEALTH_PLAN_PACKAGE, - variables: { input }, - }) - - expect(res.errors).toBeDefined() - expect(res.errors && res.errors[0].message).toBe( - 'user not authorized to create state data' - ) - }) +describe.each(flagValueTestParameters)( + `Tests $testName`, + ({ flagName, flagValue }) => { + const mockLDService = testLDService({ [flagName]: flagValue }) - describe('ratesDatabaseRefactor feature flag on', () => { - it('inserts contract to new tables and returns a health plan package', async () => { - const mockLDService = testLDService({ 'rates-db-refactor': true }) + it('returns package with unlocked form data', async () => { const server = await constructTestPostgresServer({ ldService: mockLDService, }) @@ -126,5 +68,53 @@ describe('createHealthPlanPackage', () => { expect(draft.contractDateStart).toBeUndefined() expect(draft.contractDateEnd).toBeUndefined() }) - }) -}) + + it('returns an error if the program id is not in valid', async () => { + const server = await constructTestPostgresServer({ + ldService: mockLDService, + }) + const input: CreateHealthPlanPackageInput = { + programIDs: ['xyz123'], + riskBasedContract: false, + submissionType: 'CONTRACT_ONLY', + submissionDescription: 'A real submission', + contractType: 'BASE', + } + const res = await server.executeOperation({ + query: CREATE_HEALTH_PLAN_PACKAGE, + variables: { input }, + }) + + expect(res.errors).toBeDefined() + expect(res.errors && res.errors[0].message).toBe( + 'The program id xyz123 does not exist in state FL' + ) + }) + + it('returns an error if a CMS user attempts to create', async () => { + const server = await constructTestPostgresServer({ + context: { + user: testCMSUser(), + }, + ldService: mockLDService, + }) + + const input: CreateHealthPlanPackageInput = { + programIDs: ['xyz123'], + riskBasedContract: false, + submissionType: 'CONTRACT_ONLY', + submissionDescription: 'A real submission', + contractType: 'BASE', + } + const res = await server.executeOperation({ + query: CREATE_HEALTH_PLAN_PACKAGE, + variables: { input }, + }) + + expect(res.errors).toBeDefined() + expect(res.errors && res.errors[0].message).toBe( + 'user not authorized to create state data' + ) + }) + } +)