diff --git a/services/app-web/src/components/Modal/V2/UnlockSubmitModalV2.tsx b/services/app-web/src/components/Modal/V2/UnlockSubmitModalV2.tsx index 67a9a9afd4..57b55a960e 100644 --- a/services/app-web/src/components/Modal/V2/UnlockSubmitModalV2.tsx +++ b/services/app-web/src/components/Modal/V2/UnlockSubmitModalV2.tsx @@ -5,6 +5,9 @@ import { Rate, Contract, useSubmitContractMutation, + useUnlockHealthPlanPackageMutation, + FetchHealthPlanPackageWithQuestionsDocument, + FetchContractDocument, } from '../../../gen/gqlClient' import { useFormik } from 'formik' import { usePrevious } from '../../../hooks/usePrevious' @@ -14,7 +17,10 @@ import * as Yup from 'yup' import styles from '../UnlockSubmitModal.module.scss' import { GenericApiErrorProps } from '../../Banner/GenericApiErrorBanner/GenericApiErrorBanner' import { ERROR_MESSAGES } from '../../../constants/errors' -import { submitMutationWrapperV2 } from '../../../gqlHelpers/mutationWrappersForUserFriendlyErrors' +import { + submitMutationWrapperV2, + unlockMutationWrapper, +} from '../../../gqlHelpers/mutationWrappersForUserFriendlyErrors' const RATE_UNLOCK_SUBMIT_TYPES = [ 'SUBMIT_RATE', @@ -38,12 +44,12 @@ type SharedAdditionalProps = { type RateModalProps = { submissionData: Rate - modalType: RateModalType[number] + modalType: RateModalType } & SharedAdditionalProps type ContractModalProps = { submissionData: Contract - modalType: ContractModalType[number] + modalType: ContractModalType } & SharedAdditionalProps type UnlockSubmitModalProps = RateModalProps | ContractModalProps @@ -89,11 +95,11 @@ const modalValueDictionary: { [Property in SharedModalType]: ModalValueType } = errorHeading: ERROR_MESSAGES.unlock_error_heading, }, UNLOCK_CONTRACT: { - modalHeading: 'Reason for unlocking rate', + modalHeading: 'Reason for unlocking submission', onSubmitText: 'Unlock', inputHint: 'Provide reason for unlocking', unlockSubmitModalInputValidation: - 'You must provide a reason for unlocking this contract', + 'You must provide a reason for unlocking this submission', errorHeading: ERROR_MESSAGES.unlock_error_heading, }, SUBMIT_RATE: { @@ -135,10 +141,14 @@ export const UnlockSubmitModalV2 = ({ } const [submitContract, { loading: submitContractLoading }] = - useSubmitContractMutation() // TODO this should be unlockContract - linked rates epic + useSubmitContractMutation() - // TODO submitRate and unlockRate should also be set up here - nunlock and edit rate epic - // TODO unlockContract should also be set up here - nunlock and edit rate epic + const [ + unlockHealthPlanPackage, + { loading: unlockContractLoading, client }, + ] = useUnlockHealthPlanPackageMutation() + + // TODO submitRate and unlockRate should also be set up here - unlock and edit rate epic const formik = useFormik({ initialValues: modalFormInitialValues, validationSchema: Yup.object().shape({ @@ -150,7 +160,10 @@ export const UnlockSubmitModalV2 = ({ }) const mutationLoading = - modalType === 'SUBMIT_CONTRACT' && submitContractLoading + modalType === 'UNLOCK_CONTRACT' + ? unlockContractLoading + : submitContractLoading + const isSubmitting = mutationLoading || formik.isSubmitting const includesFormInput = modalType === 'UNLOCK_CONTRACT' || @@ -177,26 +190,61 @@ export const UnlockSubmitModalV2 = ({ console.info('unlock rate not implemented yet') break - case 'SUBMIT_RATE' || 'RESUBMIT_RATE': - console.info('submit/resubmit rate not implemented yet') + case 'SUBMIT_RATE' : + console.info('submit rate not implemented yet') break + case 'RESUBMIT_RATE' : + console.info('submit rate not implemented yet') + break case 'SUBMIT_CONTRACT': result = await submitMutationWrapperV2( submitContract, submissionData.id, unlockSubmitModalInput ) - break + break; case 'RESUBMIT_CONTRACT': result = await submitMutationWrapperV2( submitContract, submissionData.id, unlockSubmitModalInput ) + break + case 'UNLOCK_CONTRACT': + if (unlockSubmitModalInput) { + // TODO: Remove HPP code fully from here, this is a hack to get through linked rates since we have no viable unlockContract + result = await unlockMutationWrapper( + unlockHealthPlanPackage, + submissionData.id, + unlockSubmitModalInput + ) + } else { + console.info('error has occured with unlocking contract') + } + break } - if (result instanceof Error) { + //Allow submitting/unlocking to continue on EMAIL_ERROR. + if (result instanceof Error && result.cause === 'EMAIL_ERROR') { + modalRef.current?.toggleModal(undefined, false) + + if (modalType !== 'UNLOCK_CONTRACT' && submissionName) { + navigate( + `/dashboard/submissions?justSubmitted=${submissionName}` + ) + } else { + await client.refetchQueries({ + include: [FetchContractDocument], + }) + // TODO: Remove HPP code fully from here, this is a hack to get through linked rates + // neded because sidebar UI that also displays questions that assumes latest data fetched on this page + // and we haven't had to migrate that yet to contract and ratesyet + await client.refetchQueries({ + include: [FetchHealthPlanPackageWithQuestionsDocument], + }) + } + } else if (result instanceof Error) { setModalAlert({ heading: modalValues.errorHeading, message: result.message, @@ -217,6 +265,16 @@ export const UnlockSubmitModalV2 = ({ navigate( `/dashboard/submissions?justSubmitted=${submissionName}` ) + } else { + await client.refetchQueries({ + include: [FetchContractDocument], + }) + // TODO: Remove HPP code fully from here, this is a hack to get through linked rates + // neded because sidebar UI that also displays questions that assumes latest data fetched on this page + // and we haven't had to migrate that yet to contract and ratesyet + await client.refetchQueries({ + include: [FetchHealthPlanPackageWithQuestionsDocument], + }) } } } diff --git a/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.test.tsx b/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.test.tsx index 4d1a58a418..f72bdbb9a5 100644 --- a/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.test.tsx +++ b/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.test.tsx @@ -34,7 +34,10 @@ describe('SingleRateSummarySection', () => { }), ], }, - featureFlags: { 'rate-edit-unlock': true }, + featureFlags: { + 'rate-edit-unlock': true, + 'link-rates': false, + }, } ) }) @@ -96,7 +99,8 @@ describe('SingleRateSummarySection', () => { screen.getByRole('heading', { name: 'Rate documents' }) ).toBeInTheDocument() }) - it('renders documents with linked submissions correctly', async () => { + // can delete the next test when linked rates flag is permanently on + it('renders documents with linked submissions correctly (legacy feature)', async () => { const rateData = rateDataMock() const parentContractRev = rateData.revisions[0].contractRevisions[0] const rateDoc = rateData.revisions[0].formData.rateDocuments[0] @@ -210,6 +214,65 @@ describe('SingleRateSummarySection', () => { ) ).toBeInTheDocument() }) + it('renders rates linked to other contract actions correctly', async () => { + const rateData = rateDataMock() + const parentContractRev = rateData.revisions[0].contractRevisions[0] + + const contractPackageName = packageName( + parentContractRev.contract.stateCode, + parentContractRev.contract.stateNumber, + parentContractRev.formData.programIDs, + rateData.state.programs + ) + + await waitFor(() => { + renderWithProviders( + , + { + apolloProvider: { + mocks: [ + fetchCurrentUserMock({ + statusCode: 200, + user: mockValidCMSUser(), + }), + ], + }, + featureFlags: { + 'rate-edit-unlock': true, + 'link-rates': true, + }, + } + ) + }) + + expect( + screen.getByRole('heading', { name: 'Rate documents' }) + ).toBeInTheDocument() + + const relatedContractActions = screen.getByRole('definition', { + name: 'Contract actions', + }) + + // Expect submissions this rate was submitted with link to exists + expect(relatedContractActions).toBeInTheDocument() + expect( + within(relatedContractActions).getByRole('link', { + name: contractPackageName, + }) + ).toBeInTheDocument() + expect( + within(relatedContractActions).getByRole('link', { + name: contractPackageName, + }) + ).toHaveAttribute( + 'href', + `/submissions/${parentContractRev.contract.id}` + ) + }) it('should not display missing field text to CMS users', async () => { const rateData = rateDataMock({ @@ -370,10 +433,7 @@ describe('SingleRateSummarySection', () => { name: 'Unlock rate', }) await waitFor(() => { - const parentContractSubmissionID = - rateData.revisions[0].contractRevisions[ - rateData.revisions[0].contractRevisions.length - 1 - ].contract.id + const parentContractSubmissionID = rateData.parentContractID expect(testLocation.pathname).toBe( `/submissions/${parentContractSubmissionID}` ) diff --git a/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.tsx b/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.tsx index f3b43803ec..eb08fc4264 100644 --- a/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.tsx +++ b/services/app-web/src/components/SubmissionSummarySection/RateDetailsSummarySection/SingleRateSummarySection.tsx @@ -197,10 +197,7 @@ export const SingleRateSummarySection = ({ ) } } - const parentContractSubmissionID = - rate.revisions[0].contractRevisions[ - rate.revisions[0].contractRevisions.length - 1 - ].contract.id + const parentContractSubmissionID = rate.parentContractID return ( const rowCount = `Displaying ${filteredRows.length} of ${analysts.length} ${pluralize( - 'analyst', - analysts.length + 'state', + filteredRows.length )}` const updateFilters = ( column: Column, diff --git a/services/app-web/src/pages/StateSubmission/Contacts/Contacts.tsx b/services/app-web/src/pages/StateSubmission/Contacts/Contacts.tsx index abd8dd5436..897616e98c 100644 --- a/services/app-web/src/pages/StateSubmission/Contacts/Contacts.tsx +++ b/services/app-web/src/pages/StateSubmission/Contacts/Contacts.tsx @@ -301,7 +301,7 @@ const Contacts = ({ showPageErrorMessage={showPageErrorMessage ?? false} /> - + - + { diff --git a/services/app-web/src/pages/StateSubmission/Documents/Documents.tsx b/services/app-web/src/pages/StateSubmission/Documents/Documents.tsx index e0ece3602b..950221e29e 100644 --- a/services/app-web/src/pages/StateSubmission/Documents/Documents.tsx +++ b/services/app-web/src/pages/StateSubmission/Documents/Documents.tsx @@ -260,7 +260,7 @@ export const Documents = (): React.ReactElement => { showPageErrorMessage={showPageErrorMessage ?? false} /> - + - + { diff --git a/services/app-web/src/pages/StateSubmission/ReviewSubmit/ReviewSubmit.tsx b/services/app-web/src/pages/StateSubmission/ReviewSubmit/ReviewSubmit.tsx index 432f753a38..1d653ee32a 100644 --- a/services/app-web/src/pages/StateSubmission/ReviewSubmit/ReviewSubmit.tsx +++ b/services/app-web/src/pages/StateSubmission/ReviewSubmit/ReviewSubmit.tsx @@ -75,7 +75,7 @@ export const ReviewSubmit = (): React.ReactElement => { /> - + { featureFlags.LINK_RATES.defaultValue ) return ( -
+
- + { contractID: id ?? 'unknown-contract', }, }, + fetchPolicy: 'network-only' }) const contract = fetchContractData?.fetchContract.contract if (fetchContractLoading) { diff --git a/services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts b/services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts index bb02eae69c..bcbea2582b 100644 --- a/services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts +++ b/services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts @@ -225,4 +225,236 @@ describe('CMS user', () => { }) }) }) + + it.skip('can unlock and resubmit with linked rates', () => { + cy.interceptFeatureFlags({"link-rates": true, '438-attestation': true}) + cy.logInAsStateUser() + + // fill out contract details + cy.startNewContractAndRatesSubmission() + cy.fillOutBaseContractDetails() + cy.navigateFormByButtonClick('CONTINUE') + + // fill out three rate details - two with child rates AND one with a linked rate + cy.findByRole('heading', { + level: 2, + name: /Rate details/, + }).should('exist') + + cy.findByRole('button', { + name: 'Add another rate certification', + }).click() + cy.findAllByTestId('rate-certification-form').each((form) => + cy.wrap(form).within(() => { + cy.fillOutNewRateCertification(); + }) + ) + cy.navigateContractRatesFormByButtonClick('CONTINUE') + + // fill out the rest of the form + cy.findByRole('heading', { + level: 2, + name: /Contacts/, + }).should('exist') + cy.fillOutStateContact() + // There is a currently bug with actuary contacts with linked rates that makes us delete actuary contacts that aren't even filled out on this page + cy.findAllByRole('button', { name: 'Remove contact' }).last() + .should('exist') + .click() + cy.fillOutAdditionalActuaryContact(); + cy.navigateFormByButtonClick('CONTINUE') + cy.findByRole('heading', { + level: 2, + name: /Supporting documents/, + }).should('exist') + cy.navigateFormByButtonClick('CONTINUE') + + cy.findByRole('heading', { + level: 2, + name: /Review and submit/, + }).should('exist') + + // Store submission url for reference later + cy.location().then((fullUrl) => { + const reviewURL = fullUrl.toString() + const submissionURL = reviewURL.replace( + 'edit/review-and-submit', + '' + ) + + // Submit, sent to dashboard + cy.submitStateSubmissionForm() + + // Login as CMS User + cy.logOut() + cy.logInAsCMSUser({ initialURL: submissionURL }) + cy.wait('@fetchContractQuery', { timeout: 20_000 }) + // click on the unlock button, type in reason and confirm + cy.unlockSubmission() + + //Unlock banner for CMS user to be present with correct data. + cy.findByTestId('unlockedBanner') + .should('exist') + .and('contain.text', 'zuko@example.com') + .and('contain.text', 'Unlock submission reason.') + .contains( + /Unlocked on: (0?[1-9]|[12][0-9]|3[01])\/[0-9]+\/[0-9]+\s[0-9]+:[0-9]+[a-zA-Z]+ ET/i + ) + .should('exist') + + //Find unlocked submission name + cy.get('#submissionName', {timeout: 2_000}).then(($h2) => { + //Set name to variable for later use in finding the unlocked submission + const submissionName = $h2.text() + + // Login as state user + cy.logOut() + cy.logInAsStateUser() + + // State user sees unlocked submission - check tag then submission link + cy.get('table') + .should('exist') + .findByText(submissionName) + .parent() + .siblings('[data-testid="submission-status"]') + .should('have.text', 'Unlocked') + + cy.get('table') + .should('exist') + .findByText(submissionName) + .should('have.attr', 'href') + .and('include', 'review-and-submit') + + cy.navigateFormByDirectLink(reviewURL) + cy.wait('@fetchContractQuery', { timeout: 20_000 }) + + //Unlock banner for state user to be present with correct data. + cy.findByRole('heading', { + level: 2, + name: /Review and submit/, + }) + cy.findByRole('heading', { + name: `Minnesota ${submissionName}`, + }).should('exist') + cy.findByTestId('unlockedBanner') + .should('exist') + .and('contain.text', 'zuko@example.com') + .and('contain.text', 'Unlock submission reason.') + .contains( + /Unlocked on: (0?[1-9]|[12][0-9]|3[01])\/[0-9]+\/[0-9]+\s[0-9]+:[0-9]+[a-zA-Z]+ ET+/i + ) + .should('exist') + + cy.submitStateSubmissionForm({success: true, resubmission: true}) + + cy.get('table') + .should('exist') + .findByText(submissionName) + .parent() + .siblings('[data-testid="submission-status"]') + .should('have.text', 'Submitted') + + cy.get('table') + .findByText(submissionName) + .should('have.attr', 'href') + .and('not.include', 'review-and-submit') + + // Navigate to resubmitted submission and check for submission updated banner + cy.get('table') + .findByRole('link', { name: submissionName }) + .should('exist') + .click() + + cy.findByTestId('updatedSubmissionBanner').should('exist') + + // Login as CMS User + cy.logOut() + cy.logInAsCMSUser({ initialURL: submissionURL }) + cy.wait('@fetchContractQuery', { timeout: 20_000 }) + + // CMS user sees resubmitted submission and active unlock button + cy.findByTestId('submission-summary', {timeout: 4_000}).should('exist') + cy.findByRole('button', { name: 'Unlock submission' }).should( + 'not.be.disabled' + ) + + //CMS user should not see unlock banner and should see updated submission banner + cy.findByTestId('unlockedBanner').should('not.exist') + cy.findByTestId('updatedSubmissionBanner').should('exist') + + //Open all change history accordion items + cy.findByTestId('accordion').should('exist') + + cy.get('[data-testid^="accordionButton_"]').each((button) => { + button.trigger('click') + button.siblings().hasClass('usa-accordion__content') /// make sure accordion is expanded + }) + //Check for view previous submission link in the initial accordion item to exist + cy.findByTestId('revision-link-1').should('be.visible') + cy.clickSubmissionLink('revision-link-1') + //Making sure we are on SubmissionRevisionSummary page and contains version text + cy.findByTestId('revision-version') + .should('exist') + .contains( + /(0?[1-9]|[12][0-9]|3[01])\/[0-9]+\/[0-9]+\s[0-9]+:[0-9]+[a-zA-Z]+ ET version/i + ) + //Previous submission banner should exist and able to click link to go back to current submission + cy.findByTestId('previous-submission-banner').should('exist') + //Navigate back to current submission using link inside banner. + cy.clickSubmissionLink('currentSubmissionLink') + //Make sure banner and revision version text are gone. + cy.findByTestId('previous-submission-banner').should( + 'not.exist' + ) + cy.findByTestId('revision-version').should('not.exist') + + // Unlock again and resubmit to test change history + cy.unlockSubmission('Second Unlock') + + // Resubmit again + cy.logOut() + cy.logInAsStateUser() + cy.navigateFormByDirectLink(reviewURL) + cy.wait('@fetchContractQuery', { timeout: 20_000 }) + cy.findByTestId('unlockedBanner').should('exist') + cy.submitStateSubmissionForm({ + success: true, + resubmission: true, + summary: 'Second resubmit' + } + ) + + // Visit the submission url and check the history + cy.navigateFormByDirectLink(submissionURL) + cy.findByTestId('updatedSubmissionBanner').should('exist') + + // No document dates or other fields are undefined + cy.findByText('N/A').should('not.exist') + + // Should have change history records + cy.findAllByTestId('change-history-record').should('have.length', 5) + + cy.findAllByTestId('change-history-record').then(records => { + // We put all the text of each record into an array + const recordText = records.map((index, record) => Cypress.$(record).text()) + + // Records are in reverse + // Second set of unlock and resubmit + expect(recordText[0]).to.contain('Changes made: Second resubmit') + expect(recordText[1]).to.contain('Reason for unlock: Second Unlock') + + // First set of unlock and resubmit + expect(recordText[2]).to.contain('Changes made: Resubmission summary') + expect(recordText[3]).to.contain('Reason for unlock: Unlock submission reason.') + + // Test for initial submission + expect(recordText[4]).to.contain('Submitted by: aang@example.com') + expect(recordText[4]).to.contain('View past submission version') + expect(recordText[4]).to.not.contain('Changes made:') + expect(recordText[4]).to.not.contain('Reason for unlock:') + console.log(recordText) + }) + }) + }) + }) }) diff --git a/services/cypress/support/commands.ts b/services/cypress/support/commands.ts index 484c339c30..f82e1f6c44 100644 --- a/services/cypress/support/commands.ts +++ b/services/cypress/support/commands.ts @@ -51,12 +51,15 @@ Cypress.Commands.add('interceptGraphQL', () => { aliasQuery(req, 'fetchHealthPlanPackageWithQuestions') aliasQuery(req, 'indexHealthPlanPackages') aliasQuery(req, 'indexRates') + aliasQuery(req, 'fetchContract') aliasMutation(req, 'createHealthPlanPackage') aliasMutation(req, 'updateHealthPlanFormData') aliasMutation(req, 'submitHealthPlanPackage') aliasMutation(req, 'updateCMSUser') aliasMutation(req, 'createQuestion') aliasMutation(req, 'createQuestionResponse') + aliasMutation(req, 'updateDraftContractRates') + aliasMutation(req, 'submitContract') }).as('GraphQL') }) diff --git a/services/cypress/support/index.ts b/services/cypress/support/index.ts index 9e64fffd8e..b5f7b92a46 100644 --- a/services/cypress/support/index.ts +++ b/services/cypress/support/index.ts @@ -59,6 +59,7 @@ declare global { fillOutBaseContractDetails(): void fillOutAmendmentToBaseContractDetails(): void fillOutNewRateCertification(): void + fillOutLinkedRate(): void fillOutAmendmentToPriorRateCertification(id?: number): void fillOutStateContact(): void fillOutAdditionalActuaryContact(): void @@ -74,6 +75,10 @@ declare global { buttonName: FormButtonKey, waitForLoad?: boolean ): void + navigateContractRatesFormByButtonClick( + buttonName: FormButtonKey, + waitForLoad?: boolean + ): void navigateFormByDirectLink(url: string, waitForLoad?: boolean): void // dashboard commands diff --git a/services/cypress/support/navigateCommands.ts b/services/cypress/support/navigateCommands.ts index 9f5e5b5dcb..71832a0e2c 100644 --- a/services/cypress/support/navigateCommands.ts +++ b/services/cypress/support/navigateCommands.ts @@ -44,6 +44,40 @@ Cypress.Commands.add( } } ) +// navigate helper for v2 forms +Cypress.Commands.add( + 'navigateContractRatesFormByButtonClick', + (buttonKey: FormButtonKey, waitForLoad = true) => { + cy.findByRole('button', { + name: buttonsWithLabels[buttonKey], + }).should('not.have.attr', 'aria-disabled') + cy.findByRole('button', { + name: buttonsWithLabels[buttonKey], + }).safeClick() + + if (buttonKey === 'SAVE_DRAFT') { + if(waitForLoad) { + cy.wait('@updateDraftContractRatesMutation', { timeout: 50_000}) + } + cy.findByTestId('state-dashboard-page').should('exist') + cy.findByRole('heading',{name:'Submissions'}).should('exist') + } else if (buttonKey === 'CONTINUE_FROM_START_NEW') { + if (waitForLoad) { + // cy.wait('@createContractMutation', { timeout: 50_000 }) + cy.wait('@fetchContractQuery') + } + cy.findByTestId('state-submission-form-page').should('exist') + } else if (buttonKey === 'CONTINUE') { + if (waitForLoad) { + cy.findAllByTestId('errorMessage').should('have.length', 0) + cy.wait('@updateDraftContractRatesMutation', { timeout: 50_000}) + } + cy.findByTestId('state-submission-form-page').should('exist') + } else { + cy.findByTestId('state-submission-form-page').should('exist') + } + } +) Cypress.Commands.add( 'navigateFormByDirectLink', diff --git a/services/cypress/support/stateSubmissionFormCommands.ts b/services/cypress/support/stateSubmissionFormCommands.ts index 007f2235ee..a2c84f2843 100644 --- a/services/cypress/support/stateSubmissionFormCommands.ts +++ b/services/cypress/support/stateSubmissionFormCommands.ts @@ -184,9 +184,9 @@ Cypress.Commands.add('fillOutAmendmentToBaseContractDetails', () => { cy.findByText('No, the contract does not fully comply with all applicable requirements').click() cy.findByRole('textbox', {name: 'Provide a brief description of any contractual or operational non-compliance, including regulatory citations and expected timeframe for remediation'}) .type('Non compliance explanation') - + cy.findByText('Unexecuted by some or all parties').click() - + cy.findAllByLabelText('Start date', {timeout: 2000}) .parents() .findByTestId('date-picker-external-input') @@ -318,13 +318,30 @@ Cypress.Commands.add('fillOutAmendmentToBaseContractDetails', () => { Cypress.Commands.add('fillOutNewRateCertification', () => { // Must be on '/submissions/:id/edit/rate-details' // Must be a contract and rates submission - cy.findByRole('radiogroup', { - name: /Was this rate certification uploaded to any other submissions?/, - }) - .should('exist') - .within(() => { - cy.findByText('No').click() + cy.getFeatureFlagStore(['link-rates']).then((store) => { + + if (store['link-rates']) { + //If this flag value is true, then it will test this code hidden behind the feature flag + cy.findByRole('radiogroup', { + name: /Was this rate certification included with another submission?/, }) + .should('exist') + .within(() => { + cy.findByText('No, this rate certification was not included with any other submissions').click() + }) + + } else { + // otherwise use legacy packages with shared rates UI + cy.findByRole('radiogroup', { + name: /Was this rate certification uploaded to any other submissions?/, + }) + .should('exist') + .within(() => { + cy.findByText(/No/).click() + }) + + } + cy.findByText('New rate certification').click() cy.findByText( @@ -362,6 +379,34 @@ Cypress.Commands.add('fillOutNewRateCertification', () => { cy.waitForDocumentsToLoad() cy.findAllByTestId('errorMessage').should('have.length', 0) }) +}) + +Cypress.Commands.add('fillOutLinkedRate', () => { + // Must be on '/submissions/:id/edit/rate-details' + // Must be a contract and rates submission + cy.getFeatureFlagStore(['link-rates']).then((store) => { + //If this flag value is true, then it will test this code hidden behind the feature flag + cy.findByRole('radiogroup', { + name: /Was this rate certification included with another submission?/, + }) + .should('exist') + .within(() => { + cy.findByText('Yes, this rate certification is part of another submission').click() + }) + + if (store['link-rates']) { + cy.findByRole('combobox', { name: 'Which rate certification was it?' }).click({ + force: true, + }) + cy.findAllByRole('option').first().click() + cy.findByText(/`Rate ID:/).should('be.visible') + } + + cy.verifyDocumentsHaveNoErrors() + cy.waitForDocumentsToLoad() + cy.findAllByTestId('errorMessage').should('have.length', 0) + }) +}) Cypress.Commands.add('fillOutAmendmentToPriorRateCertification', (id = 0) => { // Must be on '/submissions/:id/edit/rate-details' @@ -484,7 +529,8 @@ Cypress.Commands.add( name: 'Submit', }).safeClick() - cy.findAllByTestId('modalWindow') + cy.getFeatureFlagStore(['link-rates']).then((store) => { + cy.findAllByTestId('modalWindow') .eq(1) .should('exist') .within(() => { @@ -492,16 +538,35 @@ Cypress.Commands.add( cy.get('#unlockSubmitModalInput').type( summary || 'Resubmission summary' ) - cy.findByTestId('resubmit-modal-submit').click() + if (store['link-rates']) { + cy.findByTestId('resubmit_contract-modal-submit').click() + }else { + cy.findByTestId('resubmit-modal-submit').click() + } } else { - cy.findByTestId('submit-modal-submit').click() + + if (store['link-rates']) { + cy.findByTestId('submit_contract-modal-submit').click() + }else { + cy.findByTestId('submit-modal-submit').click() + } + } }) - cy.wait('@submitHealthPlanPackageMutation', { timeout: 50_000 }) + + if (store['link-rates']) { + cy.wait('@submitContractMutation', { timeout: 50_000 }) + } else { + cy.wait('@submitHealthPlanPackageMutation', { timeout: 50_000 }) + } + + if (success) { cy.findByTestId('state-dashboard-page').should('exist') cy.findByRole('heading',{name:'Submissions'}).should('exist') } + }) + } )