Skip to content

Commit

Permalink
[DT-783] Add study details page (#2741)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-rubenstein authored Dec 5, 2024
1 parent 0b8f37a commit dad1fbc
Show file tree
Hide file tree
Showing 10 changed files with 407 additions and 117 deletions.
6 changes: 6 additions & 0 deletions DEVNOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,10 @@ To run cypress component tests in a browser:
```shell
npm run cypress:open:component
```

To run a single test suite:

```shell
npm run cypress:open:component --spec "**/data_access_governance.spec.js"
```

82 changes: 82 additions & 0 deletions cypress/component/StudyDetails/StudyDetails.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* eslint-disable no-undef */

import React from 'react';
import {mount} from 'cypress/react';
import { StudyDetails } from '../../../src/components/study_details/StudyDetails';
import {TerraDataRepo} from '../../../src/libs/ajax/TerraDataRepo';
import {DataSet} from '../../../src/libs/ajax/DataSet';
import {BrowserRouter} from 'react-router-dom';

const datasets = [
{
datasetId: 123456,
datasetIdentifier: `DUOS-123456`,
datasetName: 'Some Dataset 1',
participantCount: 1,
study: {
studyId: 1,
studyName: 'study name',
description: 'study description',
phenotype: 'phenotype',
species: 'species',
piName: 'piName',
dataCustodianEmail: ['[email protected]', '[email protected]'],
}
},
{
datasetId: 123457,
datasetIdentifier: `DUOS-123457`,
datasetName: 'Some Dataset 2',
participantCount: 2,
study: {
studyId: 1,
studyName: 'study name',
description: 'study description',
phenotype: 'phenotype',
species: 'species',
piName: 'piName',
dataCustodianEmail: ['[email protected]', '[email protected]'],
}
}
];

// It's necessary to wrap components that contain `Link` components
const WrappedStudyDetailsComponent = (props) => {
return <BrowserRouter>
<StudyDetails {...props}/>
</BrowserRouter>;
};


describe('Study details test', () => {
beforeEach(() => {
cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({});
cy.stub(DataSet, 'searchDatasetIndex').returns(Promise.resolve(datasets));
const props = {
history: {},
match: { params: { studyId: 1 } }
};
// @ts-ignore
mount(<WrappedStudyDetailsComponent {...props} />);
});

it('shows the appropriate data for fields', () => {
cy.contains(datasets[0].study.studyName).should('exist');
cy.contains(datasets[0].study.description).should('exist');
cy.contains((datasets[0].participantCount + datasets[1].participantCount).toString()).should('exist');
cy.contains(datasets[0].study.phenotype).should('exist');
cy.contains(datasets[0].study.species).should('exist');
cy.contains(datasets[0].study.piName).should('exist');
cy.contains(datasets[0].study.dataCustodianEmail.join(', ')).should('exist');
cy.get('[role=row]').should('have.length', datasets.length + 1);
});

it('displays DatasetSearchFooter when dataset is selected', () => {
cy.get('.row-data-0').find('input').click();
cy.contains('1 dataset selected from 1 study').should('exist');
});

it('allows navigation back to datalibrary', () => {
cy.get('#link_datalibrary').should('have.attr', 'href', '/datalibrary');
});
});
102 changes: 52 additions & 50 deletions src/Routes.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import {Redirect, Route, Switch} from 'react-router-dom';
import { StudyDetails } from './components/study_details/StudyDetails';
import AuthenticatedRoute from './components/AuthenticatedRoute';
import {USER_ROLES} from './libs/utils';
import ManageDac from './pages/manage_dac/ManageDac';
Expand Down Expand Up @@ -47,65 +48,66 @@ import EditDac from './pages/manage_dac/EditDac';

const Routes = (props) => (
<Switch>
<Route exact path="/" render={(routeProps) => <Home {...routeProps} {...props} />} />
<Route exact path="/home" render={(routeProps) => <Home {...routeProps} {...props} />} />
<Route exact path="/status" render={(routeProps) => <Status {...routeProps} {...props} />} />
<Route exact path="/liveness" component={HealthCheck} />
<Route exact path="/backgroundsignin" render={
<Route exact path='/' render={(routeProps) => <Home {...routeProps} {...props} />} />
<Route exact path='/home' render={(routeProps) => <Home {...routeProps} {...props} />} />
<Route exact path='/status' render={(routeProps) => <Status {...routeProps} {...props} />} />
<Route exact path='/liveness' component={HealthCheck} />
<Route exact path='/backgroundsignin' render={
(routeProps) =>
checkEnv(envGroups.NON_STAGING)
? <BackgroundSignIn {...routeProps} />
: <NotFound />
} />
<Route path="/nih_ic_webform" component={NIHICWebform} />
<Route path="/nih_pilot_info" component={NIHPilotInfo} />
<Route path="/privacy" component={PrivacyPolicy} />
<Route path="/tos" component={TermsOfService} props={props} />
<Route path="/tos_acceptance" component={TermsOfServiceAcceptance} props={props} />
<Route path="/consent_text_generator" component={ConsentTextGenerator} />
<Route path="/nih_dms_policy" component={NIHDMSPolicyInfo} />
<Route path="/anvil_dms_policy" component={AnVILDMSPolicyInfo} />
<AuthenticatedRoute path="/profile" component={UserProfile} props={props} rolesAllowed={[USER_ROLES.all]} />
<AuthenticatedRoute path="/request_role" component={RequestForm} rolesAllowed={[USER_ROLES.all]} />
<AuthenticatedRoute path="/admin_review_collection/:collectionId" component={DarCollectionReview} props={Object.assign({adminPage: true}, props)} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path="/admin_manage_users" component={AdminManageUsers} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path="/admin_edit_user/:userId" component={AdminEditUser} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path="/manage_dac" component={ManageDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path="/manage_edit_dac/:dacId" component={ManageEditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path="/manage_add_dac" component={ManageEditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
{DAAUtils.isEnabled() && <AuthenticatedRoute path="/manage_edit_dac_daa/:dacId" component={EditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />}
{DAAUtils.isEnabled() && <AuthenticatedRoute path="/manage_add_dac_daa" component={EditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />}
<AuthenticatedRoute path="/admin_manage_institutions" component={AdminManageInstitutions} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path="/researcher_console" component={ResearcherConsole} props={props} rolesAllowed={[USER_ROLES.researcher]}/>
<AuthenticatedRoute path="/dar_collection/:collectionId" component={DarCollectionReview} props={props} rolesAllowed={[USER_ROLES.researcher, USER_ROLES.chairperson, USER_ROLES.member, USER_ROLES.signingOfficial]}/>
<AuthenticatedRoute path="/chair_console" component={ChairConsole} props={props} rolesAllowed={[USER_ROLES.chairperson]}/>
<AuthenticatedRoute path="/member_console" component={MemberConsole} props={props} rolesAllowed={[USER_ROLES.member]}/>
<AuthenticatedRoute path="/dar_vote_review/:collectionId" component={DarCollectionReview} props={Object.assign({readOnly: true}, props)}
<Route path='/nih_ic_webform' component={NIHICWebform} />
<Route path='/nih_pilot_info' component={NIHPilotInfo} />
<Route path='/privacy' component={PrivacyPolicy} />
<Route path='/tos' component={TermsOfService} props={props} />
<Route path='/tos_acceptance' component={TermsOfServiceAcceptance} props={props} />
<Route path='/consent_text_generator' component={ConsentTextGenerator} />
<Route path='/nih_dms_policy' component={NIHDMSPolicyInfo} />
<Route path='/anvil_dms_policy' component={AnVILDMSPolicyInfo} />
<AuthenticatedRoute path='/profile' component={UserProfile} props={props} rolesAllowed={[USER_ROLES.all]} />
<AuthenticatedRoute path='/request_role' component={RequestForm} rolesAllowed={[USER_ROLES.all]} />
<AuthenticatedRoute path='/admin_review_collection/:collectionId' component={DarCollectionReview} props={Object.assign({adminPage: true}, props)} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path='/admin_manage_users' component={AdminManageUsers} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path='/admin_edit_user/:userId' component={AdminEditUser} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path='/manage_dac' component={ManageDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path='/manage_edit_dac/:dacId' component={ManageEditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path='/manage_add_dac' component={ManageEditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
{DAAUtils.isEnabled() && <AuthenticatedRoute path='/manage_edit_dac_daa/:dacId' component={EditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />}
{DAAUtils.isEnabled() && <AuthenticatedRoute path='/manage_add_dac_daa' component={EditDac} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />}
<AuthenticatedRoute path='/admin_manage_institutions' component={AdminManageInstitutions} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path='/researcher_console' component={ResearcherConsole} props={props} rolesAllowed={[USER_ROLES.researcher]}/>
<AuthenticatedRoute path='/dar_collection/:collectionId' component={DarCollectionReview} props={props} rolesAllowed={[USER_ROLES.researcher, USER_ROLES.chairperson, USER_ROLES.member, USER_ROLES.signingOfficial]}/>
<AuthenticatedRoute path='/chair_console' component={ChairConsole} props={props} rolesAllowed={[USER_ROLES.chairperson]}/>
<AuthenticatedRoute path='/member_console' component={MemberConsole} props={props} rolesAllowed={[USER_ROLES.member]}/>
<AuthenticatedRoute path='/dar_vote_review/:collectionId' component={DarCollectionReview} props={Object.assign({readOnly: true}, props)}
rolesAllowed={[USER_ROLES.chairperson, USER_ROLES.member]}/>
<AuthenticatedRoute path="/dar_application_review/:collectionId" component={DataAccessRequestApplication} props={Object.assign({}, props, {readOnlyMode: true})}
<AuthenticatedRoute path='/dar_application_review/:collectionId' component={DataAccessRequestApplication} props={Object.assign({}, props, {readOnlyMode: true})}
rolesAllowed={[USER_ROLES.researcher]} />
{/* Order is important for processing links with embedded dataRequestIds */}
<AuthenticatedRoute path="/dar_application/:dataRequestId" component={DataAccessRequestApplication} props={Object.assign({}, props, {draftDar: true})}
<AuthenticatedRoute path='/dar_application/:dataRequestId' component={DataAccessRequestApplication} props={Object.assign({}, props, {draftDar: true})}
rolesAllowed={[USER_ROLES.researcher]} />
<AuthenticatedRoute path="/dar_application" component={DataAccessRequestApplication} props={props} rolesAllowed={[USER_ROLES.researcher]} />
<AuthenticatedRoute path="/signing_official_console/researchers" component={ensureSoHasDaaAcknowledgement(SigningOfficialResearchers, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />
{DAAUtils.isEnabled() && <AuthenticatedRoute path="/signing_official_console/researchers_daa_associations" component={ensureSoHasDaaAcknowledgement(ManageResearcherDAAs, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />}
<AuthenticatedRoute path="/signing_official_console/dar_requests" component={ensureSoHasDaaAcknowledgement(SigningOfficialDarRequests)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />
{DAAUtils.isEnabled() && <AuthenticatedRoute path="/signing_official_console/data_submitters" component={ensureSoHasDaaAcknowledgement(SigningOfficialDataSubmitters, false, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />}
<AuthenticatedRoute path="/dataset_submissions" component={DatasetSubmissions} props={props} rolesAllowed={[USER_ROLES.dataSubmitter]}/>
<AuthenticatedRoute path="/dataset_update/:datasetId" component={DatasetUpdateForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path="/data_submission_form" component={DataSubmissionForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson, USER_ROLES.dataSubmitter]} />
<AuthenticatedRoute path="/study_update/:studyId" component={StudyUpdateForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson, USER_ROLES.dataSubmitter]} />
<AuthenticatedRoute path="/admin_manage_lc/" component={AdminManageLC} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path="/admin_manage_dar_collections/" component={AdminManageDarCollections} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path="/datalibrary/:query" component={DatasetSearch} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.all]} />
<AuthenticatedRoute path="/datalibrary" component={DatasetSearch} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.all]} />
<AuthenticatedRoute path="/dataset/:datasetIdentifier" component={DatasetStatistics} props={props} rolesAllowed={[USER_ROLES.all]} />
<Redirect from="/DUOS-:duosId" to="/dataset/DUOS-:duosId" props={props} rolesAllowed={[USER_ROLES.all]} />
<AuthenticatedRoute path="/dac_datasets" component={DACDatasets} props={props} rolesAllowed={[USER_ROLES.chairperson]} />
<AuthenticatedRoute path="/tos_acceptance" component={TermsOfServiceAcceptance} props={props} rolesAllowed={[USER_ROLES.all]} />
{checkEnv(envGroups.NON_PROD) && <AuthenticatedRoute path="/translate" component={Translator} props={props} rolesAllowed={[USER_ROLES.researcher]}/>}
<Route path="*" component={NotFound} />
<AuthenticatedRoute path='/dar_application' component={DataAccessRequestApplication} props={props} rolesAllowed={[USER_ROLES.researcher]} />
<AuthenticatedRoute path='/signing_official_console/researchers' component={ensureSoHasDaaAcknowledgement(SigningOfficialResearchers, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />
{DAAUtils.isEnabled() && <AuthenticatedRoute path='/signing_official_console/researchers_daa_associations' component={ensureSoHasDaaAcknowledgement(ManageResearcherDAAs, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />}
<AuthenticatedRoute path='/signing_official_console/dar_requests' component={ensureSoHasDaaAcknowledgement(SigningOfficialDarRequests)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />
{DAAUtils.isEnabled() && <AuthenticatedRoute path='/signing_official_console/data_submitters' component={ensureSoHasDaaAcknowledgement(SigningOfficialDataSubmitters, false, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />}
<AuthenticatedRoute path='/dataset_submissions' component={DatasetSubmissions} props={props} rolesAllowed={[USER_ROLES.dataSubmitter]}/>
<AuthenticatedRoute path='/dataset_update/:datasetId' component={DatasetUpdateForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path='/data_submission_form' component={DataSubmissionForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson, USER_ROLES.dataSubmitter]} />
<AuthenticatedRoute path='/study_update/:studyId' component={StudyUpdateForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson, USER_ROLES.dataSubmitter]} />
<AuthenticatedRoute path='/admin_manage_lc/' component={AdminManageLC} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path='/admin_manage_dar_collections/' component={AdminManageDarCollections} props={props} rolesAllowed={[USER_ROLES.admin]} />
<AuthenticatedRoute path='/datalibrary/:query' component={DatasetSearch} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.all]} />
<AuthenticatedRoute path='/datalibrary' component={DatasetSearch} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.all]} />
<AuthenticatedRoute path='/studies/:studyId' component={StudyDetails} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.all]} />
<AuthenticatedRoute path='/dataset/:datasetIdentifier' component={DatasetStatistics} props={props} rolesAllowed={[USER_ROLES.all]} />
<Redirect from='/DUOS-:duosId' to='/dataset/DUOS-:duosId' props={props} rolesAllowed={[USER_ROLES.all]} />
<AuthenticatedRoute path='/dac_datasets' component={DACDatasets} props={props} rolesAllowed={[USER_ROLES.chairperson]} />
<AuthenticatedRoute path='/tos_acceptance' component={TermsOfServiceAcceptance} props={props} rolesAllowed={[USER_ROLES.all]} />
{checkEnv(envGroups.NON_PROD) && <AuthenticatedRoute path='/translate' component={Translator} props={props} rolesAllowed={[USER_ROLES.researcher]}/>}
<Route path='*' component={NotFound} />
</Switch>
);

Expand Down
Loading

0 comments on commit dad1fbc

Please sign in to comment.