Skip to content

Commit 08e15f2

Browse files
authored
feat: added test to check (#803)
1 parent cca5459 commit 08e15f2

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

compose/neurosynth-frontend/cypress/e2e/workflows/SleuthImport/DoSleuthImport.cy.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ describe('DoSleuthImport', () => {
1616
beforeEach(() => {
1717
cy.clearLocalStorage().clearSessionStorage();
1818
cy.intercept('GET', 'https://api.appzi.io/**', { fixture: 'appzi' }).as('appziFixture');
19+
20+
cy.intercept('POST', `https://www.google-analytics.com/*/**`, {}).as(
21+
'googleAnalyticsFixture'
22+
);
1923
});
2024

2125
it('should load successfully', () => {
@@ -429,7 +433,7 @@ describe('DoSleuthImport', () => {
429433
});
430434

431435
describe('edge cases', () => {
432-
it('should apply the pubmed details to the study if a matching pubmed study is found', () => {
436+
it.only('should apply the pubmed details to the study if a matching pubmed study is found', () => {
433437
// this stuff exists just to make sure cypress doesnt send any real requests. They are not under test
434438
// synth API responses
435439
cy.intercept('POST', `${neurostoreAPIBaseURL}/analyses/**`, {
@@ -486,6 +490,7 @@ describe('DoSleuthImport', () => {
486490
fixture: 'DoSleuthImport/pubmedResponses/efetchSingleResponse.xml',
487491
}).as('pmidsFetch');
488492

493+
// this is not important but is needed to finish the rest of the import
489494
cy.intercept('POST', `${neurostoreAPIBaseURL}/base-studies/**`, {
490495
fixture:
491496
'DoSleuthImport/neurosynthResponses/baseStudiesMultipleSleuthStudyResponse.json',
@@ -501,12 +506,18 @@ describe('DoSleuthImport', () => {
501506

502507
cy.wait('@baseStudiesIngestFixture').then((baseStudiesResponse) => {
503508
const baseStudy = baseStudiesResponse.request.body[0];
509+
510+
// we should still have all the data from the original base study created from the sleuth import file
504511
expect(baseStudy.authors).equals('Gerardin E,');
505512
expect(baseStudy.doi).equals('some-doi.org');
506513
expect(baseStudy.name).equals('The brains default mode network.');
507514
expect(baseStudy.year).equals(2000);
508-
expect(baseStudy.pmid).equals('25938726');
509515
expect(baseStudy.publication).equals('Annual review of neuroscience');
516+
// additional data should be added from the pubmed query if it did not exist
517+
expect(baseStudy.pmcid).equals('PMCTEST');
518+
expect(baseStudy.description).equals(
519+
`\nThe brains default mode network consists of discrete, bilateral and symmetrical cortical areas, in the medial and lateral parietal, medial prefrontal, and medial and lateral temporal cortices of the human, nonhuman primate, cat, and rodent brains. Its discovery was an unexpected consequence of brain-imaging studies first performed with positron emission tomography in which various novel, attention-demanding, and non-self-referential tasks were compared with quiet repose either with eyes closed or with simple visual fixation. The default mode network consistently decreases its activity when compared with activity during these relaxed nontask states. The discovery of the default mode network reignited a longstanding interest in the significance of the brain's ongoing or intrinsic activity. Presently, studies of the brain's intrinsic activity, popularly referred to as resting-state studies, have come to play a major role in studies of the human brain in health and disease. The brain's default mode network plays a central role in this work.`
520+
);
510521
});
511522
});
512523

compose/neurosynth-frontend/cypress/fixtures/DoSleuthImport/pubmedResponses/efetchSingleResponse.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<PublicationStatus>ppublish</PublicationStatus>
125125
<ArticleIdList>
126126
<ArticleId IdType="pubmed">25938726</ArticleId>
127+
<ArticleId IdType="pmc">PMCTEST</ArticleId>
127128
<ArticleId IdType="doi">some-doi.org</ArticleId>
128129
</ArticleIdList>
129130
</PubmedData>

compose/neurosynth-frontend/src/pages/SleuthImport/SleuthImport.helpers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ export const applyPubmedStudyDetailsToBaseStudiesAndRemoveDuplicates = (
613613
if (pubmedStudy.DOI) idToPubmedStudyMap.set(pubmedStudy.DOI, pubmedStudy);
614614
});
615615

616+
console.log({
617+
baseStudySleuthStubs,
618+
pubmedStudies,
619+
});
620+
616621
const deduplicatedBaseStudiesWithDetails: BaseStudy[] = [];
617622
baseStudySleuthStubs.forEach((baseStudy) => {
618623
const associatedPubmedStudy =
@@ -621,6 +626,7 @@ export const applyPubmedStudyDetailsToBaseStudiesAndRemoveDuplicates = (
621626

622627
let updatedBaseStudyWithDetails: BaseStudy = {};
623628
if (!associatedPubmedStudy) {
629+
// there is no corresponding pubmed study
624630
updatedBaseStudyWithDetails = { ...baseStudy };
625631
} else {
626632
const authorString = (associatedPubmedStudy?.authors || []).reduce(

0 commit comments

Comments
 (0)