diff --git a/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.integration.test.tsx b/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.integration.test.tsx index 64f5416695..12558d2dd8 100644 --- a/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.integration.test.tsx +++ b/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.integration.test.tsx @@ -20,10 +20,10 @@ import { getEndpoint, } from '../../utils/functions/getEndpoint' import { - AccessControlList, ACCESS_TYPE, - SubmissionState, + AccessControlList, FileHandleAssociation, + SubmissionState, } from '@sage-bionetworks/synapse-types' import { mockApprovedSubmission, @@ -35,8 +35,10 @@ import { mockManagedACTAccessRequirement } from '../../mocks/accessRequirement/m import { rest, server } from '../../mocks/msw/server' import { MOCK_USER_ID, + MOCK_USER_ID_3, MOCK_USER_NAME, MOCK_USER_NAME_2, + MOCK_USER_NAME_3, } from '../../mocks/user/mock_user_profile' import * as RejectDataAccessRequestModalModule from './RejectDataAccessRequestModal' import failOnConsoleError from 'jest-fail-on-console' @@ -290,8 +292,7 @@ describe('Submission Page tests', () => { ).not.toBeInTheDocument() }) - // Flaky in TravisCI - it.skip('Renders a user card if the AR has an ACL', async () => { + it('Renders a user card if the AR has an ACL', async () => { // Fetching the AR's ACL will yield a designated reviewer server.use( rest.get( @@ -307,6 +308,11 @@ describe('Submission Page tests', () => { principalId: MOCK_USER_ID, accessType: [ACCESS_TYPE.REVIEW_SUBMISSIONS], }, + { + // User 3 should not be shown + principalId: MOCK_USER_ID_3, + accessType: [ACCESS_TYPE.EXEMPTION_ELIGIBLE], + }, ], } return res(ctx.status(200), ctx.json(responseBody)) @@ -318,12 +324,15 @@ describe('Submission Page tests', () => { submissionId: SUBMITTED_SUBMISSION_ID, }) - // When an ACL exists, don't show the ACT as the reviewer - expect(screen.queryByText(mockActTeam.name)).not.toBeInTheDocument() - // User 1 now appears as the submitter, modifier, an accessor, and the Reviewer await waitFor(() => expect(screen.getAllByText('@' + MOCK_USER_NAME)).toHaveLength(4), ) + + // User 3 should not appear - they are not a reviewer + expect(screen.queryByText('@' + MOCK_USER_NAME_3)).not.toBeInTheDocument() + + // When an ACL exists, don't show the ACT as the reviewer + expect(screen.queryByText(mockActTeam.name)).not.toBeInTheDocument() }) }) diff --git a/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.tsx b/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.tsx index bbd1b43933..f004033cad 100644 --- a/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.tsx +++ b/packages/synapse-react-client/src/components/dataaccess/SubmissionPage.tsx @@ -1,5 +1,5 @@ import { Button, Skeleton, Typography } from '@mui/material' -import { toLower, upperFirst } from 'lodash-es' +import { isEmpty, toLower, upperFirst } from 'lodash-es' import dayjs from 'dayjs' import React, { useState } from 'react' import { useErrorHandler } from 'react-error-boundary' @@ -14,6 +14,7 @@ import { } from '../../synapse-queries/dataaccess/useAccessRequirements' import { ACT_TEAM_ID } from '../../utils/SynapseConstants' import { + ACCESS_TYPE, FileHandleAssociateType, ManagedACTAccessRequirement, SubmissionState, @@ -133,7 +134,7 @@ export default function SubmissionPage(props: SubmissionPageProps) { { enabled: !!submission }, ) - const { data: acl } = useGetAccessRequirementACL( + const { data: acl, isLoading: isLoadingACL } = useGetAccessRequirementACL( submission?.accessRequirementId!, { enabled: !!submission, throwOnError: true }, ) @@ -148,6 +149,10 @@ export default function SubmissionPage(props: SubmissionPageProps) { }) } + const reviewerIds = acl?.resourceAccess + .filter(ra => ra.accessType.includes(ACCESS_TYPE.REVIEW_SUBMISSIONS)) + .map(ra => ra.principalId) + return (
Assigned Reviewer - {acl !== undefined ? ( - acl !== null ? ( - acl.resourceAccess.map(ra => { - return ( - - ) - }) - ) : ( - - ) - ) : ( - + {isLoadingACL && } + {!isLoadingACL && + !isEmpty(reviewerIds) && + reviewerIds!.map(id => { + return + })} + {!isLoadingACL && isEmpty(reviewerIds) && ( + )}