-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DT-783] Add study details page (#2741)
- Loading branch information
1 parent
0b8f37a
commit dad1fbc
Showing
10 changed files
with
407 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.