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

[JN-1525] adds subject to participant list #1331

Merged
merged 2 commits into from
Dec 12, 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
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
Loading