{
} />
- >
+
)
}
diff --git a/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.test.tsx b/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.test.tsx
index 49460fdf7c..d50a2b5670 100644
--- a/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.test.tsx
+++ b/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.test.tsx
@@ -14,7 +14,6 @@ import {
mockDraftHealthPlanPackage,
mockQuestionsPayload,
mockSubmittedHealthPlanPackage,
- mockUnlockedHealthPlanPackage,
mockValidCMSUser,
} from '../../testHelpers/apolloMocks'
@@ -360,98 +359,6 @@ describe('SubmissionSideNav', () => {
expect(await screen.findByText('System error')).toBeInTheDocument()
})
- it('DRAFT redirects a state user to beginning of form', async () => {
- let testLocation: Location
- const pkg = mockDraftHealthPlanPackage()
-
- renderWithProviders(
-
- }>
- }
- />
- }
- />
-
- ,
- {
- apolloProvider: {
- mocks: [
- fetchCurrentUserMock({
- statusCode: 200,
- }),
- fetchStateHealthPlanPackageWithQuestionsMockSuccess(
- {
- id: '15',
- stateSubmission: pkg,
- }
- ),
- ],
- },
- routerProvider: {
- route: '/submissions/15',
- },
- location: (location) => (testLocation = location),
- featureFlags: { 'cms-questions': true },
- }
- )
-
- await waitFor(() =>
- expect(testLocation.pathname).toBe(`/submissions/15/edit/type`)
- )
- })
-
- it('UNLOCKED redirects a state user to beginning of form', async () => {
- let testLocation: Location
- const pkg = mockUnlockedHealthPlanPackage()
-
- renderWithProviders(
-
- }>
- }
- />
- }
- />
-
- ,
- {
- apolloProvider: {
- mocks: [
- fetchCurrentUserMock({
- statusCode: 200,
- }),
- fetchStateHealthPlanPackageWithQuestionsMockSuccess(
- {
- id: '15',
- stateSubmission: pkg,
- }
- ),
- ],
- },
- routerProvider: {
- route: '/submissions/15',
- },
- location: (location) => (testLocation = location),
- featureFlags: { 'cms-questions': true },
- }
- )
-
- await waitFor(() =>
- expect(testLocation.pathname).toBe(`/submissions/15/edit/type`)
- )
- })
-
it('DRAFT displays an error to a CMS user', async () => {
const pkg = mockDraftHealthPlanPackage()
diff --git a/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.tsx b/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.tsx
index 3cedab9dc8..683174afa3 100644
--- a/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.tsx
+++ b/services/app-web/src/pages/SubmissionSideNav/SubmissionSideNav.tsx
@@ -1,12 +1,12 @@
import { Link, SideNav, GridContainer, Icon } from '@trussworks/react-uswds'
import { NavLink } from 'react-router-dom'
import styles from './SubmissionSideNav.module.scss'
-import { useParams, useLocation, useNavigate, Outlet } from 'react-router-dom'
+import { useParams, useLocation, Outlet } from 'react-router-dom'
import { useAuth } from '../../contexts/AuthContext'
import {
QUESTION_RESPONSE_SHOW_SIDEBAR_ROUTES,
- RouteT,
RoutesRecord,
+ STATE_SUBMISSION_FORM_ROUTES,
} from '../../constants/routes'
import { getRouteName } from '../../routeHelpers'
import { useFetchHealthPlanPackageWithQuestionsWrapper } from '../../gqlHelpers'
@@ -54,7 +54,6 @@ export const SubmissionSideNav = () => {
}
const { loggedInUser } = useAuth()
const { pathname } = useLocation()
- const navigate = useNavigate()
const ldClient = useLDClient()
const routeName = getRouteName(pathname)
@@ -64,11 +63,13 @@ export const SubmissionSideNav = () => {
featureFlags.CMS_QUESTIONS.defaultValue
)
- const showSidebar =
- showQuestionResponse &&
- QUESTION_RESPONSE_SHOW_SIDEBAR_ROUTES.includes(routeName)
- const isSelectedLink = (route: RouteT): string => {
- return routeName === route ? 'usa-current' : ''
+ const isSelectedLink = (route: string | string[]): string => {
+ //We pass an array of the form routes in order to display the sideNav on all of the pages
+ if (typeof route != 'string') {
+ return route.includes(routeName) ? 'usa-current' : ''
+ } else {
+ return routeName === route ? 'usa-current' : ''
+ }
}
const { result: fetchResult } =
@@ -107,7 +108,15 @@ export const SubmissionSideNav = () => {
const submissionStatus = pkg.status
+ //The sideNav should not be visible to a state user if the submission is a draft that has never been submitted
+ const showSidebar =
+ showQuestionResponse &&
+ submissionStatus !== 'DRAFT' &&
+ pkg.initiallySubmittedAt !== null &&
+ QUESTION_RESPONSE_SHOW_SIDEBAR_ROUTES.includes(routeName)
+
const isCMSUser = loggedInUser?.role === 'CMS_USER'
+ const isStateUser = loggedInUser?.role === 'STATE_USER'
const isAdminUser = loggedInUser?.role === 'ADMIN_USER'
const isHelpdeskUser = loggedInUser?.role === 'HELPDESK_USER'
const isBusinessOwnerUser = loggedInUser?.role === 'BUSINESSOWNER_USER'
@@ -120,19 +129,14 @@ export const SubmissionSideNav = () => {
return
}
- // State users should not see the submission summary page for DRAFT or UNLOCKED, it should redirect them to the edit flow.
- if (
- !(isCMSUser || isAdminUser || isHelpdeskUser || isBusinessOwnerUser) &&
- (submissionStatus === 'DRAFT' || submissionStatus === 'UNLOCKED')
- ) {
- navigate(`/submissions/${id}/edit/type`)
- }
-
- // Current Revision is the last SUBMITTED revision, SubmissionSummary doesn't display data that is currently being edited
- // Since we've already bounced on DRAFT packages, this _should_ exist.
- const edge = pkg.revisions.find((rEdge) => rEdge.node.submitInfo)
+ // Current Revision is either the last submitted revision (cms users) or the most recent revision (for state users looking submission form)
+ const edge =
+ (submissionStatus === 'UNLOCKED' || submissionStatus === 'DRAFT') &&
+ loggedInUser.role === 'STATE_USER'
+ ? pkg.revisions[0]
+ : pkg.revisions.find((rEdge) => rEdge.node.submitInfo)
if (!edge) {
- const errMsg = `No currently submitted revision for this package: ${pkg.id}, programming error. `
+ const errMsg = `Not able to determine current revision for sidebar: ${pkg.id}, programming error.`
recordJSException(errMsg)
return
}
@@ -159,6 +163,7 @@ export const SubmissionSideNav = () => {
className={
showSidebar ? styles.backgroundSidebar : styles.backgroundForm
}
+ data-testid="submission-side-nav"
>
{showSidebar && (
@@ -182,13 +187,24 @@ export const SubmissionSideNav = () => {
- Submission summary
+ {isStateUser &&
+ submissionStatus === 'UNLOCKED'
+ ? 'Submission'
+ : 'Submission summary'}
,
{
).toBeInTheDocument()
})
+ it('renders the sidenav for CMS users', async () => {
+ renderWithProviders(
+
+ }>
+ }
+ />
+
+ ,
+ {
+ apolloProvider: {
+ mocks: [
+ fetchCurrentUserMock({
+ user: mockValidCMSUser(),
+ statusCode: 200,
+ }),
+ fetchStateHealthPlanPackageWithQuestionsMockSuccess({
+ id: '1337',
+ }),
+ ],
+ },
+ routerProvider: {
+ route: '/submissions/1337',
+ },
+ }
+ )
+
+ expect(
+ await screen.findByTestId('submission-side-nav')
+ ).toBeInTheDocument()
+ })
+
+ it('renders the sidenav for State users', async () => {
+ renderWithProviders(
+
+ }>
+ }
+ />
+
+ ,
+ {
+ apolloProvider: {
+ mocks: [
+ fetchCurrentUserMock({
+ user: mockValidStateUser(),
+ statusCode: 200,
+ }),
+ fetchStateHealthPlanPackageWithQuestionsMockSuccess({
+ id: '1337',
+ }),
+ ],
+ },
+ routerProvider: {
+ route: '/submissions/1337',
+ },
+ }
+ )
+
+ expect(
+ await screen.findByTestId('submission-side-nav')
+ ).toBeInTheDocument()
+ })
+
describe('Submission package data display', () => {
it('renders the OLD data for an unlocked submission for CMS user, ignoring unsubmitted changes from state user', async () => {
const pkg = mockUnlockedHealthPlanPackage()
diff --git a/services/cypress/support/navigateCommands.ts b/services/cypress/support/navigateCommands.ts
index 207f5f72ea..9f5e5b5dcb 100644
--- a/services/cypress/support/navigateCommands.ts
+++ b/services/cypress/support/navigateCommands.ts
@@ -1,5 +1,3 @@
-import { aliasQuery, aliasMutation } from '../utils/graphql-test-utils'
-
type FormButtonKey =
| 'CONTINUE_FROM_START_NEW'
| 'CONTINUE'
@@ -13,8 +11,6 @@ const buttonsWithLabels: FormButtons = {
BACK: 'Back',
}
-const isSubmissionEditUrl = /submissions\/([0-9a-fA-F-]+)\/edit/
-
Cypress.Commands.add(
'navigateFormByButtonClick',
(buttonKey: FormButtonKey, waitForLoad = true) => {
@@ -34,7 +30,7 @@ Cypress.Commands.add(
} else if (buttonKey === 'CONTINUE_FROM_START_NEW') {
if (waitForLoad) {
cy.wait('@createHealthPlanPackageMutation', { timeout: 50_000 })
- cy.wait('@fetchHealthPlanPackageQuery')
+ cy.wait('@fetchHealthPlanPackageWithQuestionsQuery')
}
cy.findByTestId('state-submission-form-page').should('exist')
} else if (buttonKey === 'CONTINUE') {
@@ -54,11 +50,7 @@ Cypress.Commands.add(
(url: string, waitForLoad = true) => {
cy.visit(url)
if (waitForLoad) {
- if(isSubmissionEditUrl.test(url)) {
- cy.wait('@fetchHealthPlanPackageQuery', { timeout: 50_000 })
- } else {
- cy.wait('@fetchHealthPlanPackageWithQuestionsQuery', { timeout: 50_000 })
- }
+ cy.wait('@fetchHealthPlanPackageWithQuestionsQuery', { timeout: 50_000 })
}
}
)