Skip to content

Commit

Permalink
754 import from sleuth file (#770)
Browse files Browse the repository at this point in the history
* feat: adding sleuth import

* feat: help modal and initial upload page for sleuth upload

* feat: finished import UI and added intro

* feat: wizard build step

* feat: finished initial sleuth import implementation

* feat: created sleuth import build and review

* feat: change step

* feat: added meta-analyses to sleuth import

* feat: handle reject build meta-analyses

* feat: added creation of meta analyses

* feat: change wording

* feat: convert from doi to pmid and create imperative pmid fetch function

* feat: finished flow of sleuth import

* fix: solved sleuth import curation bug

* fix: minor improvements, added sleuth import testing

* fix: finished e2e tests

* fix: removed console log

* fix: remove unused imports

* fix: failing test case

* fix: failing test case

* fix: add env variables

* feat: add missing tests and skip ones that require api calls
  • Loading branch information
nicoalee committed Jun 19, 2024
1 parent 52fb994 commit c56fad4
Show file tree
Hide file tree
Showing 91 changed files with 4,635 additions and 572 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ jobs:
REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
REACT_APP_AUTH0_CLIENT_SECRET: ${{ secrets.REACT_APP_AUTH0_CLIENT_SECRET }}
REACT_APP_ENV: DEV
REACT_APP_NEUROSTORE_API_DOMAIN: ${{ secrets.REACT_APP_NEUROSTORE_API_DOMAIN }}
REACT_APP_NEUROSYNTH_API_DOMAIN: ${{ secrets.REACT_APP_NEUROSYNTH_API_DOMAIN }}
with:
build: npm run build:dev
start: npm run start-ci:dev
Expand Down
3 changes: 2 additions & 1 deletion compose/neurosynth-frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ REACT_APP_AUTH0_CLIENT_SECRET=YOUR_AUTH0_CLIENT_SECRET
REACT_APP_AUTH0_AUDIENCE=localhost
REACT_APP_NEUROSTORE_API_DOMAIN=http://localhost/api
REACT_APP_NEUROSYNTH_API_DOMAIN=http://localhost:81/api
REACT_APP_ENV=DEV
REACT_APP_ENV=DEV
REACT_APP_PUBMED_API_KEY=YOUR_PUBMED_KEY
2 changes: 2 additions & 0 deletions compose/neurosynth-frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ export default defineConfig({
auth0ClientSecret: process.env.REACT_APP_AUTH0_CLIENT_SECRET,
auth0Domain: process.env.REACT_APP_AUTH0_DOMAIN,
auth0Audience: process.env.REACT_APP_AUTH0_AUDIENCE,
neurostoreAPIBaseURL: process.env.REACT_APP_NEUROSTORE_API_DOMAIN,
neurosynthAPIBaseURL: process.env.REACT_APP_NEUROSYNTH_API_DOMAIN,
},
});
21 changes: 4 additions & 17 deletions compose/neurosynth-frontend/cypress/e2e/pages/EditStudyPage.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,13 @@ describe(PAGE_NAME, () => {
cy.intercept('GET', `**/api/annotations/*`, { fixture: 'annotation' }).as(
'annotationFixture'
);
cy.intercept('GET', `**/api/studysets/*`, { fixture: 'studyset' }).as('studysetFixture');
cy.login('mocked').visit(PATH);
cy.visit(PATH)
.wait('@studyFixture')
.wait('@projectFixture')
.wait('@annotationFixture')
.wait('@semanticScholarFixture');
// cy.login('mocked').wait('@realProjectsRequest').visit(PATH).wait('@studyFixture');
.wait('@semanticScholarFixture')
.wait('@studysetFixture');
});

// it('should redirect if the user is not authenticated', () => {
// cy.intercept('GET', `**/api/studies/mock-study-id*`, { fixture: 'study' }).as(
// 'studyFixture'
// );
// cy.visit(PATH)
// .wait(['@studyFixture']) // request made twice as the first time, once for the edit page and again for the study page
// .url()
// .should('be.equal', `${Cypress.config('baseUrl')}/studies/mock-study-id`);
// });

// TODO:
// it('should switch to the second last tab if the selected analysis is last and gets deleted', () => {

// });
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {};
const PATH = '/meta-analyses';
const PAGE_NAME = 'MetaAnalysesPage';

describe(PAGE_NAME, () => {
describe.skip(PAGE_NAME, () => {
beforeEach(() => {
cy.clearLocalStorage().clearSessionStorage();
cy.intercept('GET', 'https://api.appzi.io/**', { fixture: 'appzi' }).as('appziFixture');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {};
const PATH = '/base-studies';
const PAGE_NAME = 'StudiesPage';

describe(PAGE_NAME, () => {
describe.skip(PAGE_NAME, () => {
beforeEach(() => {
cy.clearLocalStorage().clearSessionStorage();
cy.intercept('GET', 'https://api.appzi.io/**', { fixture: 'appzi' }).as('appziFixture');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('ImportStudiesDialog', () => {
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
});

it.only('should open the import studies dialog', () => {
cy.login('mocked', { sub: 'github|26612023' })
it('should open the import studies dialog', () => {
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
Expand All @@ -26,6 +26,7 @@ describe('ImportStudiesDialog', () => {

describe('Import via Neurostore', () => {
beforeEach(() => {
cy.login('mocked').visit('/projects/abc123/curation');
cy.intercept('GET', '**/api/base-studies/**', {
fixture: 'baseStudies/baseStudiesWithResults',
}).as('baseStudiesFixture');
Expand Down Expand Up @@ -67,7 +68,10 @@ describe('ImportStudiesDialog', () => {

describe('Import via Pubmed IDs', () => {
beforeEach(() => {
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
cy.intercept('PUT', '**/api/projects/abc123').as('updateProjectFixture');
// not going to mock this for now as cypress does not seem to support XML fixtures
// cy.intercept('POST', 'https://eutils.ncbi.nlm.nih.gov/**', {
Expand Down Expand Up @@ -123,7 +127,10 @@ describe('ImportStudiesDialog', () => {

describe('Manually create a new study', () => {
beforeEach(() => {
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
cy.intercept('PUT', '**/api/projects/abc123').as('updateProjectFixture');
cy.contains('button', 'import studies').click();
cy.contains('Manually create a new study').click();
Expand Down Expand Up @@ -169,7 +176,10 @@ describe('ImportStudiesDialog', () => {

describe('Import via File Format', () => {
beforeEach(() => {
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
cy.intercept('PUT', '**/api/projects/abc123').as('updateProjectFixture');
cy.contains('button', 'import studies').click();
cy.contains('Import via File Format').click();
Expand Down Expand Up @@ -253,7 +263,10 @@ describe('ImportStudiesDialog', () => {

describe('IMPORT DUPLICATES', () => {
beforeEach(() => {
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
cy.intercept('PUT', '**/api/projects/abc123').as('updateProjectFixture');
cy.contains('button', 'import studies').click();
cy.contains('Import via File Format').click();
Expand Down Expand Up @@ -296,8 +309,14 @@ describe('ImportStudiesDialog', () => {
cy.intercept('GET', `**/api/projects/*`, {
fixture: 'projects/projectWithStub',
}).as('projectFixture');
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
cy.intercept('PUT', '**/api/projects/**').as('updateProjectFixture');
// not a very good mocked update, but we need to provide a fixture so that it doesnt send a real request to the BE
cy.intercept('PUT', '**/api/projects/**', { fixture: 'projects/projectWithStub' }).as(
'updateProjectFixture'
);
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
cy.contains('button', 'import studies').click();
cy.contains('Import via File Format').click();
cy.contains('button', 'next').click();
Expand Down Expand Up @@ -337,7 +356,10 @@ describe('ImportStudiesDialog', () => {
fixture: 'baseStudies/baseStudiesWithResults',
}).as('baseStudiesFixture');
cy.intercept('PUT', '**/api/projects/abc123').as('updateProjectFixture');
cy.visit('/projects/abc123/curation').wait('@projectFixture').wait('@studysetFixture');
cy.login('mocked')
.visit('/projects/abc123/curation')
.wait('@projectFixture')
.wait('@studysetFixture');
cy.contains('button', 'import studies').click();
cy.contains('button', 'next').click();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ describe('CreateSpecificationDialog', () => {
cy.intercept('GET', `**/api/meta-analyses*`, { fixture: 'metaAnalyses' }).as(
'metaAnalysesFixture'
);
cy.intercept('GET', '**/api/meta-analysis-results/**', {
fixture: 'metaAnalysisResults',
}).as('metaAnalysisResultsFixture');
cy.intercept('GET', `**/api/projects/*`, {
fixture: 'projects/projectCanCreateSpecification',
}).as('projectFixture');
Expand Down
Loading

0 comments on commit c56fad4

Please sign in to comment.