From 0edf7f3bc51134957467c46bd9bf244d7b59c70f Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Wed, 23 Aug 2023 14:44:16 -0400 Subject: [PATCH] Remove redundant check and better error message. --- .../updateHealthPlanFormData.test.ts | 4 ++-- .../updateHealthPlanFormData.ts | 17 ++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts b/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts index b0f14c18e9..efe2dc2039 100644 --- a/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts +++ b/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts @@ -373,7 +373,7 @@ describe.each(flagValueTestParameters)( ) const expectedErrorMsg = flagValue - ? 'Transient server error: Concurrent editing occurred. Please refresh the page to continue.' + ? 'Concurrent update error: The data you are trying to modify has changed since you last retrieved it. Please refresh the page to continue.' : 'Transient server error: attempted to modify un-modifiable field(s): updatedAt. Please refresh the page to continue.' expect(updateResult.errors[0].message).toBe(expectedErrorMsg) @@ -414,7 +414,7 @@ describe.each(flagValueTestParameters)( ) const expectedErrorMsg = flagValue - ? 'Transient server error: Concurrent editing occurred. Please refresh the page to continue.' + ? 'Concurrent update error: The data you are trying to modify has changed since you last retrieved it. Please refresh the page to continue.' : 'Transient server error: attempted to modify un-modifiable field(s): stateCode,stateNumber,createdAt,updatedAt. Please refresh the page to continue.' expect(updateResult.errors[0].message).toBe(expectedErrorMsg) diff --git a/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.ts b/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.ts index bf2c2f7e28..b466b8d4fd 100644 --- a/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.ts +++ b/services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.ts @@ -161,7 +161,7 @@ export function updateHealthPlanFormDataResolver( } // Can't update a submission that is locked or resubmitted - if (!['DRAFT', 'UNLOCKED'].includes(contractWithHistory.status)) { + if (!contractWithHistory.draftRevision) { const errMessage = `Package is not in editable state: ${input.pkgID} status: ${contractWithHistory.status}` logError('updateHealthPlanFormData', errMessage) setErrorAttributesOnActiveSpan(errMessage, span) @@ -170,25 +170,12 @@ export function updateHealthPlanFormDataResolver( }) } - // If contract is draft and draft revision does not exist, then possibly: - // - contract was mislabeled labelled DRAFT in the parsing functions. - // - something happened in the converter functions to not add draft revision. - // - there were no revisions without submitted info. - if (!contractWithHistory.draftRevision) { - const errMessage = `Issue finding a draft revision for contract id ${input.pkgID}. Message: Draft revision not found}` - throw new GraphQLError(errMessage, { - extensions: { - code: 'INTERNAL_SERVER_ERROR', - }, - }) - } - // If updatedAt does not match concurrent editing occurred. if ( contractWithHistory.draftRevision.updatedAt.getTime() !== unlockedFormData.updatedAt.getTime() ) { - const errMessage = `Transient server error: Concurrent editing occurred. Please refresh the page to continue.` + const errMessage = `Concurrent update error: The data you are trying to modify has changed since you last retrieved it. Please refresh the page to continue.` logError('updateHealthPlanFormData', errMessage) setErrorAttributesOnActiveSpan(errMessage, span) throw new UserInputError(errMessage)