Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Shared rates across submissions behavior for unlocked packages with linked rates flag on #2394

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,49 @@ describe('UploadedDocumentsTable', () => {
expect(await screen.findByTestId('tag')).toHaveTextContent('SHARED')
})

it('still renders SHARED tag to state user when linked rates flag on', async () => {
it('still renders SHARED tag to state user on submission summary when linked rates flag on', async () => {
const packagesWithSharedRateCerts = [
{
packageId: '333b4225-5b49-4e82-aa71-be0d33d7418d',
packageName: 'MCR-MN-0001-SNBC',
},
{
packageId: '21467dba-6ae8-11ed-a1eb-0242ac120002',
packageName: 'MCR-MN-0002-PMAP',
},
]
const testDocuments = [
{
s3URL: 's3://foo/bar/test-1',
name: 'supporting docs test 1',
sha256: 'fakesha',
dateAdded: new Date('01/01/00'),
},
]
renderWithProviders(
<UploadedDocumentsTable
documents={testDocuments}
caption="Rate"
documentCategory="Rate certification"
packagesWithSharedRateCerts={packagesWithSharedRateCerts}
previousSubmissionDate={new Date('01/01/01')}
hideDynamicFeedback={false}
/>,
{
apolloProvider: {
mocks: [fetchCurrentUserMock({ user: mockValidStateUser(), statusCode: 200 })],
},
featureFlags: {
'link-rates': true,
},
}
)

expect(await screen.findByTestId('tag')).toHaveTextContent('SHARED')
expect(await screen.findByText('Linked submissions')).toBeInTheDocument()
})

it('does not render SHARED tag to state user on review submit when linked rates flag on', async () => {
const packagesWithSharedRateCerts = [
{
packageId: '333b4225-5b49-4e82-aa71-be0d33d7418d',
Expand Down Expand Up @@ -567,7 +609,8 @@ describe('UploadedDocumentsTable', () => {
}
)

expect(await screen.findByTestId('tag')).toBeInTheDocument()
expect(await screen.findByTestId('tag')).not.toBeInTheDocument()
expect(await screen.queryByText('Linked submissions')).not.toBeInTheDocument()
})

it('does not validations when hideDynamicFeedback is set to true', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { useAuth } from '../../../contexts/AuthContext'
import { DataDetailMissingField } from '../../DataDetail/DataDetailMissingField'
import { GenericDocument } from '../../../gen/gqlClient'
import { DocumentDateLookupTableType } from '../../../documentHelpers/makeDocumentDateLookupTable'
import { featureFlags } from '../../../common-code/featureFlags'
import { useLDClient } from 'launchdarkly-react-client-sdk'

// V2 API migration note: intentionally trying to avoid making V2 version of this reuseable sub component since it has such a contained focus (on displaying documents only).
// Use props to pass needed information and seek to make content as domain agnostic as possible.
Expand All @@ -33,7 +35,7 @@ export type UploadedDocumentsTableProps = {
documents: GenericDocument[]
caption: string | null
previousSubmissionDate: Date | null // used to calculate NEW tag based on doc dateAdded
hideDynamicFeedback: boolean // used to determine if we display static data for submission summary experience or if we display dynamic feedback UI (validations, edit buttons) like on review submit experience
hideDynamicFeedback: boolean // used to determine if we display static data the dynamic feedback UI (validations, edit buttons). If true, assume submission summary experience, if false, assume review submit experience
packagesWithSharedRateCerts?: SharedRateCertDisplay[] // deprecated - could be deleted after we resolve all historical data linked rates
isSupportingDocuments?: boolean // used to calculate empty state and styles around the secondary supporting docs tables - would be nice to remove this in favor of more domain agnostic prop such as 'emptyStateText'
multipleDocumentsAllowed?: boolean // used to determined if we display validations based on doc list length
Expand All @@ -50,19 +52,27 @@ export const UploadedDocumentsTable = ({
multipleDocumentsAllowed = true,
hideDynamicFeedback = false,
}: UploadedDocumentsTableProps): React.ReactElement => {
const ldClient = useLDClient()
const initialDocState = documents.map((doc) => ({
...doc,
url: null,
s3Key: null,
}))
const { loggedInUser } = useAuth()
const isStateUser = loggedInUser?.__typename === 'StateUser'
const isCMSUser = loggedInUser?.__typename === 'CMSUser'
const { getDocumentsWithS3KeyAndUrl } = useDocument()
const [refreshedDocs, setRefreshedDocs] =
useState<DocumentWithS3Data[]>(initialDocState)
const shouldShowEditButton = !hideDynamicFeedback && isSupportingDocuments // at this point only contract supporting documents need the inline EDIT button - this can be deleted when we move supporting docs to ContractDetails page

// canDisplayDateAddedForDocument - guards against passing in null or undefined to dayjs

const useLinkedRates = ldClient?.variation(
featureFlags.LINK_RATES.flag,
featureFlags.LINK_RATES.defaultValue
) ?? false

// canDisplayDateForDocument - guards against passing in null or undefined to dayjs
// don't display on new initial submission
const canDisplayDateAddedForDocument = (doc: DocumentWithS3Data) => {
return doc.dateAdded && previousSubmissionDate
Expand All @@ -85,9 +95,7 @@ export const UploadedDocumentsTable = ({

// show legacy shared rates across submissions (this is feature replaced by linked rates)
// to cms users always when data available, to state users only when linked rates flag is off
const showLegacySharedRatesAcross = Boolean(
packagesWithSharedRateCerts && packagesWithSharedRateCerts.length > 0
)
const showLegacySharedRatesAcross = Boolean((useLinkedRates && hideDynamicFeedback? !isStateUser: true) && (packagesWithSharedRateCerts && packagesWithSharedRateCerts.length > 0))

const borderTopGradientStyles = `borderTopLinearGradient ${styles.uploadedDocumentsTable}`
const supportingDocsTopMarginStyles = isSupportingDocuments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,37 @@ describe('ReviewSubmit', () => {
)
expect(ratingPeriod).toHaveTextContent('02/02/2020 to 02/02/2021')
})

it('hides the legacy shared rates across submissions UI for state users when unlocked', async () => {
renderWithProviders(
<Routes>
<Route
path={RoutesRecord.SUBMISSIONS_REVIEW_SUBMIT}
element={<ReviewSubmitV2 />}
/>
</Routes>,
{
apolloProvider: {
mocks: [
fetchCurrentUserMock({
statusCode: 200,
user: mockValidStateUser(),
}),
fetchContractMockSuccess({
contract: mockContractPackageUnlocked(),
}),
],
},
routerProvider: {
route: '/submissions/test-abc-123/edit/review-and-submit',
},
featureFlags: {
'link-rates': true,
},
}
)

expect(await screen.queryByText('Linked submissions')).not.toBeInTheDocument()
expect(await screen.queryByText('SHARED')).not.toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,45 @@ describe('SubmissionSummary', () => {
expect(ratingPeriod).toHaveTextContent('01/01/2020 to 01/01/2021')
})

it('displays the legacy shared rates across submissions UI for CMS users when unlocked', async () => {
renderWithProviders(
<Routes>
<Route element={<SubmissionSideNav />}>
<Route
path={RoutesRecord.SUBMISSIONS_SUMMARY}
element={<SubmissionSummaryV2 />}
/>
</Route>
</Routes>,
{
apolloProvider: {
mocks: [
fetchCurrentUserMock({
statusCode: 200,
user: mockValidCMSUser(),
}),
fetchContractMockSuccess({
contract: mockContractPackageUnlocked(),
}),
fetchStateHealthPlanPackageWithQuestionsMockSuccess({
id: 'test-abc-123',
}),
],
},
routerProvider: {
route: '/submissions/test-abc-123',
},
featureFlags: {
'link-rates': true,
},
}
)

expect(await screen.findByText('SHARED')).toBeInTheDocument()
expect(await screen.findByText('Linked submissions')).toBeInTheDocument()
})


it('renders add mccrs-id link for CMS user', async () => {
renderWithProviders(
<Routes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,10 @@ function mockContractPackageUnlocked(
},
],
actuaryCommunicationPreference: 'OACT_TO_ACTUARY',
packagesWithSharedRateCerts: []
packagesWithSharedRateCerts: [ {
packageName: 'testABC1',
packageId: 'test-abc-1',
},]
}
},
],
Expand Down
Loading