Skip to content

Commit

Permalink
[ENH] Modified the result tables for humans and machines (#357)
Browse files Browse the repository at this point in the history
* Updated `generateTSVString` function

* Implemented `convertURIToLabel` function

- Updated `generateTSVString` function
- Updated relevant components

* Renamed `dataset-level` button and moved it to `GetDataDialog`

* Added and updated component tests

* Updated `ResultsTSV` e2e test

* Removed `only` statement

* Removed `only` statement

* test flakyness

* not sure why this is failing remotely and passing locally

* Addressed suggested changes from PR review

* Updated `ResultTSV` e2e test and `mocked-responses`

* Fixed an oopsie

* Updated README.md

* Addressed requested changes from PR review

* Updated documentation links

* Updated `Navbar` component test

* Fixed an oopsie
  • Loading branch information
rmanaem authored Nov 21, 2024
1 parent d6e5290 commit 04e2678
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 126 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The query tool is a React application, developed in [TypeScript](https://www.typ

</div>

Please refer to our [**official documentation**](https://neurobagel.org/query_tool/) for more detailed information on how to use the query tool.
Please refer to our [**official documentation**](https://neurobagel.org/user_guide/query_tool/) for more detailed information on how to use the query tool.

## Quickstart

Expand Down Expand Up @@ -179,19 +179,21 @@ To define a cohort, set your inclusion criteria using the following:
- Sex: Sex of participant that should be included in the results.
- Diagnosis: Diagnosis of participant that should be included in the results
- Healthy control: Whether healthy participants should be included in the results. Once healthy control checkbox is selected, diagnosis field will be disabled since a participant cannot be both a healthy control and have a diagnosis.
- Minimum number of sessions: Minimum number of imaging sessions that participant should have to be included in the results.
- Minimum number of imaging sessions: Minimum number of imaging sessions that participant should have to be included in the results.
- Minimum number of phenotypic sessions: Minimum number of phenotypic sessions that participant should have to be included in the results.
- Assessment tool: Non-imaging assessment completed by participant that should be included in the results.
- Modality: Imaging modality of participant scans that should be included in the results.
- Imaging modality: Imaging modality of participant scans that should be included in the results.
- Pipeline name: Name of the pipeline used to process subject scans.
- Pipeline version: Version of the pipeline used to process subject scans.

Once you've defined your criteria, submit them as a query and the query tool will display the results.\
The query tool offers two different TSV files for results:

- Dataset-level results TSV contains: dataset id, dataset name, dataset portal uri, number of matching subjects, and available imaging modalities
- Participant-level results TSV contains: dataset id, subject id, age, sex, diagnosis, assessment, session id, session file path, number of sessions, and imaging modality
- cohort participant results TSV contains: dataset name, portal uri, number of matching subjects, subject id, session id, session file path, session type, age, sex, diagnosis, assessment, number of matching phenotypic sessions, number of matching imaging sessions, session imaging modality, session completed pipelines, dataset imaging modality, and dataset pipelines

The output files can be joined using `DatasetID` as key.
- cohort participant machine results TSV contains: dataset name, dataset portal uri, subject id, session id, session file path, session type, number of matching phenotypic sessions, number of matching imaging sessions, session imaging modality, session completed pipelines, dataset imaging modality, and dataset pipeline

You can refer to [the neurobagel documentation](https://neurobagel.org/query_tool/#downloading-query-results) to see what the outputs of the query tool look like and how they are structured. You can also download the raw example output files [here](https://github.com/neurobagel/neurobagel_examples/tree/main/query-tool-results).
You can refer to [the neurobagel documentation](https://neurobagel.org/user_guide/query_tool/#downloading-query-results) to see what the outputs of the query tool look like and how they are structured. You can also download the raw example output files [here](https://github.com/neurobagel/neurobagel_examples/tree/main/query-tool-results).

## Testing

Expand Down
2 changes: 1 addition & 1 deletion cypress/component/DownloadResultButton.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('DownloadResultButton', () => {
/>
);
cy.get('[data-cy="test-download-results-button"]').should('be.visible');
cy.get('[data-cy="test-download-results-button"]').should('contain', 'Download test Result');
cy.get('[data-cy="test-download-results-button"]').should('contain', 'Download test result');
cy.get('[data-cy="test-download-results-button"]').should('not.be', 'disabled');
});
it('Displays a disabled MUI Button and a tooltip when the button is hovered over', () => {
Expand Down
45 changes: 41 additions & 4 deletions cypress/component/GetDataDialog.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,63 @@ import GetDataDialog from '../../src/components/GetDataDialog';
const props = {
open: true,
onClose: () => {},
disableDownloadResultsButton: false,
handleDownloadResultButtonClick: () => {},
};

describe('GetDataDialog', () => {
it('Displays a MUI Diaglog with the title and content', () => {
cy.mount(<GetDataDialog open={props.open} onClose={props.onClose} />);
cy.mount(
<GetDataDialog
open={props.open}
onClose={props.onClose}
disableDownloadResultsButton={props.disableDownloadResultsButton}
handleDownloadResultButtonClick={props.handleDownloadResultButtonClick}
/>
);
cy.get('[data-cy="get-data-dialog"]').should('be.visible');
cy.get('[data-cy="get-data-dialog"] h2').should('contain', 'Example usage');
cy.get('[data-cy="get-data-dialog"] p').should(
'contain',
'The command for automatically getting the data currently only applies to datasets available through datalad.'
);
cy.get('[data-cy="cohort-participant-machine-download-results-button"]').should('be.visible');
});
it("Doesn't display the dialog when open prop is set to false", () => {
cy.mount(<GetDataDialog open={false} onClose={props.onClose} />);
cy.mount(
<GetDataDialog
open={false}
onClose={props.onClose}
disableDownloadResultsButton={props.disableDownloadResultsButton}
handleDownloadResultButtonClick={props.handleDownloadResultButtonClick}
/>
);
cy.get('[data-cy="get-data-dialog"]').should('not.exist');
});
it('Fires onClose event handler when the close button is clicked', () => {
const onCloseSpy = cy.spy().as('onCloseSpy');
cy.mount(<GetDataDialog open={props.open} onClose={onCloseSpy} />);
cy.get('[data-cy="get-data-dialog"] button').click();
cy.mount(
<GetDataDialog
open={props.open}
onClose={onCloseSpy}
disableDownloadResultsButton={props.disableDownloadResultsButton}
handleDownloadResultButtonClick={props.handleDownloadResultButtonClick}
/>
);
cy.get('[data-cy="get-data-dialog-close-button"]').click();
cy.get('@onCloseSpy').should('have.been.called');
});
it('Fires handleDownloadResultButtonClick event handler when the download button is clicked', () => {
const handleDownloadResultButtonClickSpy = cy.spy().as('handleDownloadResultButtonClickSpy');
cy.mount(
<GetDataDialog
open={props.open}
onClose={props.onClose}
disableDownloadResultsButton={props.disableDownloadResultsButton}
handleDownloadResultButtonClick={handleDownloadResultButtonClickSpy}
/>
);
cy.get('[data-cy="cohort-participant-machine-download-results-button"]').click();
cy.get('@handleDownloadResultButtonClickSpy').should('have.been.called');
});
});
4 changes: 2 additions & 2 deletions cypress/component/Navbar.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ describe('Navbar', () => {
cy.get("[data-cy='navbar'] a").eq(0).find('svg').should('be.visible');
cy.get("[data-cy='navbar'] a")
.eq(0)
.should('have.attr', 'href', 'https://neurobagel.org/query_tool/');
.should('have.attr', 'href', 'https://neurobagel.org/user_guide/query_tool/');
cy.get("[data-cy='navbar'] a").eq(1).find('svg').should('be.visible');
cy.get("[data-cy='navbar'] a")
.eq(1)
.should('have.attr', 'href', 'https://github.com/neurobagel/react-query-tool/');
.should('have.attr', 'href', 'https://github.com/neurobagel/query-tool/');
});
});
38 changes: 22 additions & 16 deletions cypress/component/ResultContainer.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@ import ResultContainer from '../../src/components/ResultContainer';
import { protectedResponse2 } from '../fixtures/mocked-responses';

describe('ResultContainer', () => {
it('Displays a set of Result Cards, select all checkbox, disabled download result buttons, summary stats, and how to get data dialog button', () => {
cy.mount(<ResultContainer response={protectedResponse2} />);
it('Displays a set of Result Cards, select all checkbox, a disabled download result button, summary stats, and how to get data dialog button', () => {
cy.mount(
<ResultContainer response={protectedResponse2} assessmentOptions={[]} diagnosisOptions={[]} />
);
cy.get('[data-cy="card-https://someportal.org/datasets/ds0001"]').should('be.visible');
cy.get('[data-cy="card-https://someportal.org/datasets/ds0002"]').should('be.visible');
cy.get('[data-cy="select-all-checkbox"]').should('be.visible');
cy.get('[data-cy="summary-stats"]')
.should('be.visible')
.should('contain', 'Summary stats: 2 datasets, 4 subjects');
cy.get('[data-cy="participant-level-download-results-button"]')
.should('be.visible')
.should('be.disabled');
cy.get('[data-cy="dataset-level-download-results-button"]')
cy.get('[data-cy="cohort-participant-download-results-button"]')
.should('be.visible')
.should('be.disabled');
cy.get('[data-cy="how-to-get-data-dialog-button"]').should('be.visible');
});
it('Selecting a dataset should enable the download result buttons', () => {
cy.mount(<ResultContainer response={protectedResponse2} />);
it('Selecting a dataset should enable the download result button', () => {
cy.mount(
<ResultContainer response={protectedResponse2} assessmentOptions={[]} diagnosisOptions={[]} />
);
cy.get('[data-cy="card-https://someportal.org/datasets/ds0001-checkbox"] input').check();
cy.get('[data-cy="participant-level-download-results-button"]')
.should('be.visible')
.should('not.be.disabled');
cy.get('[data-cy="dataset-level-download-results-button"]')
cy.get('[data-cy="cohort-participant-download-results-button"]')
.should('be.visible')
.should('not.be.disabled');
});
it('Selecting/unselecting select all datasets checkbox should check/uncheck all dataset cards', () => {
cy.mount(<ResultContainer response={protectedResponse2} />);
cy.mount(
<ResultContainer response={protectedResponse2} assessmentOptions={[]} diagnosisOptions={[]} />
);
cy.get('[data-cy="select-all-checkbox"] input').check();
cy.get('[data-cy="card-https://someportal.org/datasets/ds0001-checkbox"] input').should(
'be.checked'
Expand All @@ -46,21 +46,27 @@ describe('ResultContainer', () => {
);
});
it('Clicking the how to get data dialog button should open the dialog', () => {
cy.mount(<ResultContainer response={protectedResponse2} />);
cy.mount(
<ResultContainer response={protectedResponse2} assessmentOptions={[]} diagnosisOptions={[]} />
);
cy.get('[data-cy="get-data-dialog"]').should('not.exist');
cy.get('[data-cy="how-to-get-data-dialog-button"]').click();
cy.get('[data-cy="get-data-dialog"]').should('be.visible');
});
it('Shows no result view when result is empty', () => {
cy.mount(
<ResultContainer response={{ responses: [], errors: [], nodes_response_status: 'success' }} />
<ResultContainer
response={{ responses: [], errors: [], nodes_response_status: 'success' }}
assessmentOptions={[]}
diagnosisOptions={[]}
/>
);
cy.get('[data-cy="empty-result-container-view"]')
.should('be.visible')
.should('contain', 'No results');
});
it('Shows Click Submit Query view when result is null', () => {
cy.mount(<ResultContainer response={null} />);
cy.mount(<ResultContainer response={null} assessmentOptions={[]} diagnosisOptions={[]} />);
cy.get('[data-cy="default-result-container-view"]')
.should('be.visible')
.should('contain', "Click 'Submit Query' for results");
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Feedback.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Feedback', () => {
cy.get('[data-cy="openneuro-alert"]').find('[data-testid="CloseIcon"]').click();
cy.get('[data-cy="openneuro-alert"]').should('not.exist');
});
it.only('Displays and closes small screen size dialog', () => {
it('Displays and closes small screen size dialog', () => {
cy.viewport(766, 500);
cy.visit('/');
cy.get('[data-cy="small-screen-size-dialog"]').should('be.visible');
Expand Down
Loading

0 comments on commit 04e2678

Please sign in to comment.