From c8cb71298f8337f8609faf8c74120d47f7b57de8 Mon Sep 17 00:00:00 2001 From: Devon Bush Date: Wed, 11 Dec 2024 15:54:37 -0500 Subject: [PATCH 1/2] [JN-1525] adds subject to participant list --- package.json | 4 ++- .../ParticipantListTable.test.tsx | 26 ++++++++++++++++++- .../participantList/ParticipantListTable.tsx | 16 +++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2d666974eb..1ae9d07a47 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx b/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx index 7b54bb6693..428d499d63 100644 --- a/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx +++ b/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx @@ -1,4 +1,4 @@ -import { setupRouterTest } from '@juniper/ui-core' +import { renderWithRouter, setupRouterTest } from '@juniper/ui-core' import { mockEnrolleeSearchExpressionResult, mockStudyEnvContext @@ -46,4 +46,28 @@ describe('Participant List', () => { expect(window.URL.createObjectURL).toHaveBeenCalled() }) + + test('shows expected columns', async () => { + renderWithRouter() + + + await waitFor(async () => { + expect(await screen.findByText('Shortcode')).toBeInTheDocument() + }) + const expectedCols = ['Created', 'Last login', 'Consented'] + expectedCols.forEach(colName => { + expect(screen.getByText(colName)).toBeInTheDocument() + }) + + const hiddenCols = ['Given Name', 'Family Name', 'Username', 'Contact Email', 'Subject'] + hiddenCols.forEach(colName => { + expect(screen.queryByText(colName)).not.toBeInTheDocument() + }) + }) }) diff --git a/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx b/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx index 654130865f..9a4df76540 100644 --- a/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx +++ b/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx @@ -79,7 +79,8 @@ function ParticipantListTable({ const [columnVisibility, setColumnVisibility] = React.useState({ 'givenName': false, 'familyName': false, - 'contactEmail': false + 'contactEmail': false, + 'subject': false }) @@ -166,6 +167,19 @@ function ParticipantListTable({ meta: { columnType: 'string' } + }, { + id: 'subject', + header: 'Research 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() ? : '' }, { header: 'Consented', accessorKey: 'enrollee.consented', From b9f586e0cbfa824fc2b21cb0231fac1de59c5649 Mon Sep 17 00:00:00 2001 From: Devon Bush Date: Wed, 11 Dec 2024 16:18:48 -0500 Subject: [PATCH 2/2] test fixups --- .../ParticipantListTable.test.tsx | 53 +++++++++---------- .../participantList/ParticipantListTable.tsx | 2 +- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx b/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx index 428d499d63..ce24d46853 100644 --- a/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx +++ b/ui-admin/src/study/participants/participantList/ParticipantListTable.test.tsx @@ -1,11 +1,10 @@ -import { renderWithRouter, 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' @@ -14,9 +13,9 @@ 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( { + test('shows expected columns', async () => { + renderWithRouter( { reload={jest.fn()} />) - render(RoutedComponent) - - await act(async () => { - await userEvent.click(await screen.findByLabelText('Download table')) - }) await waitFor(async () => { - expect(await screen.findByLabelText('Confirm download')).toBeInTheDocument() + expect(screen.queryByText('Shortcode')).toBeVisible() }) - - - window.URL.createObjectURL = jest.fn() - document.createElement = jest.fn().mockReturnValue({ - click: jest.fn() + const expectedCols = ['Created', 'Last login', 'Consented'] + expectedCols.forEach(colName => { + expect(screen.getByText(colName)).toBeInTheDocument() }) - await act(async () => { - await userEvent.click(await screen.findByLabelText('Confirm download')) + const hiddenCols = ['Given Name', 'Family Name', 'Username', 'Contact Email', 'Is subject'] + hiddenCols.forEach(colName => { + expect(screen.queryByText(colName)).not.toBeInTheDocument() }) - - expect(window.URL.createObjectURL).toHaveBeenCalled() }) - test('shows expected columns', async () => { + test('should be able to download participant list', async () => { renderWithRouter( { reload={jest.fn()} />) + await act(async () => { + await userEvent.click(await screen.findByLabelText('Download table')) + }) await waitFor(async () => { - expect(await screen.findByText('Shortcode')).toBeInTheDocument() + expect(await screen.findByLabelText('Confirm download')).toBeInTheDocument() }) - const expectedCols = ['Created', 'Last login', 'Consented'] - expectedCols.forEach(colName => { - expect(screen.getByText(colName)).toBeInTheDocument() + + + window.URL.createObjectURL = jest.fn() + document.createElement = jest.fn().mockReturnValue({ + click: jest.fn() }) - const hiddenCols = ['Given Name', 'Family Name', 'Username', 'Contact Email', 'Subject'] - hiddenCols.forEach(colName => { - expect(screen.queryByText(colName)).not.toBeInTheDocument() + await act(async () => { + await userEvent.click(await screen.findByLabelText('Confirm download')) }) + + expect(window.URL.createObjectURL).toHaveBeenCalled() }) }) diff --git a/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx b/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx index 9a4df76540..97235c8982 100644 --- a/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx +++ b/ui-admin/src/study/participants/participantList/ParticipantListTable.tsx @@ -169,7 +169,7 @@ function ParticipantListTable({ } }, { id: 'subject', - header: 'Research subject', + header: 'Is subject', accessorKey: 'enrollee.subject', meta: { columnType: 'boolean',