Skip to content

Commit

Permalink
[JN-1525] adds subject to participant list (#1331)
Browse files Browse the repository at this point in the history
  • Loading branch information
devonbush authored Dec 12, 2024
1 parent 65cc5ae commit 955713b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
},
"scripts": {
"test": "npm -w ui-core test && npm -w ui-admin test && npm -w ui-participant test",
"lint": "npm -w ui-core run build && eslint --max-warnings=0 e2e-tests/src ui-admin/src ui-core/src ui-participant/src"
"lint": "npm -w ui-core run build && eslint --max-warnings=0 e2e-tests/src ui-admin/src ui-core/src ui-participant/src",
"admin-dev-local": "VITE_UNAUTHED_LOGIN=true HTTPS=true DANGEROUSLY_DISABLE_HOST_CHECK=true npm -w ui-admin start",
"admin-dev": "HTTPS=true npm -w ui-admin start"
},
"dependencies": {
"@dnd-kit/core": "^6.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { setupRouterTest } from '@juniper/ui-core'
import { renderWithRouter } from '@juniper/ui-core'
import {
mockEnrolleeSearchExpressionResult,
mockStudyEnvContext
} from 'test-utils/mocking-utils'
import {
act,
render,
screen,
waitFor
} from '@testing-library/react'
Expand All @@ -14,17 +13,39 @@ import ParticipantListTable from 'study/participants/participantList/Participant
import { userEvent } from '@testing-library/user-event'


describe('Participant List', () => {
test('should be able to download participant list', async () => {
const { RoutedComponent } = setupRouterTest(<ParticipantListTable
describe('Participant List Table', () => {
test('shows expected columns', async () => {
renderWithRouter(<ParticipantListTable
studyEnvContext={mockStudyEnvContext()}
participantList={[
mockEnrolleeSearchExpressionResult()
]}
reload={jest.fn()}
/>)

render(RoutedComponent)

await waitFor(async () => {
expect(screen.queryByText('Shortcode')).toBeVisible()
})
const expectedCols = ['Created', 'Last login', 'Consented']
expectedCols.forEach(colName => {
expect(screen.getByText(colName)).toBeInTheDocument()
})

const hiddenCols = ['Given Name', 'Family Name', 'Username', 'Contact Email', 'Is subject']
hiddenCols.forEach(colName => {
expect(screen.queryByText(colName)).not.toBeInTheDocument()
})
})

test('should be able to download participant list', async () => {
renderWithRouter(<ParticipantListTable
studyEnvContext={mockStudyEnvContext()}
participantList={[
mockEnrolleeSearchExpressionResult()
]}
reload={jest.fn()}
/>)

await act(async () => {
await userEvent.click(await screen.findByLabelText('Download table'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ function ParticipantListTable({
const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({
'givenName': false,
'familyName': false,
'contactEmail': false
'contactEmail': false,
'subject': false
})


Expand Down Expand Up @@ -166,6 +167,19 @@ function ParticipantListTable({
meta: {
columnType: 'string'
}
}, {
id: 'subject',
header: 'Is subject',
accessorKey: 'enrollee.subject',
meta: {
columnType: 'boolean',
filterOptions: [
{ value: true, label: 'Subject' },
{ value: false, label: 'Not a subject (e.g. is only a proxy)' }
]
},
filterFn: 'equals',
cell: info => info.getValue() ? <FontAwesomeIcon icon={faCheck}/> : ''
}, {
header: 'Consented',
accessorKey: 'enrollee.consented',
Expand Down

0 comments on commit 955713b

Please sign in to comment.