Skip to content

Commit

Permalink
feat: added test to check (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalee authored Aug 2, 2024
1 parent cca5459 commit 08e15f2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ describe('DoSleuthImport', () => {
beforeEach(() => {
cy.clearLocalStorage().clearSessionStorage();
cy.intercept('GET', 'https://api.appzi.io/**', { fixture: 'appzi' }).as('appziFixture');

cy.intercept('POST', `https://www.google-analytics.com/*/**`, {}).as(
'googleAnalyticsFixture'
);
});

it('should load successfully', () => {
Expand Down Expand Up @@ -429,7 +433,7 @@ describe('DoSleuthImport', () => {
});

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

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

cy.wait('@baseStudiesIngestFixture').then((baseStudiesResponse) => {
const baseStudy = baseStudiesResponse.request.body[0];

// we should still have all the data from the original base study created from the sleuth import file
expect(baseStudy.authors).equals('Gerardin E,');
expect(baseStudy.doi).equals('some-doi.org');
expect(baseStudy.name).equals('The brains default mode network.');
expect(baseStudy.year).equals(2000);
expect(baseStudy.pmid).equals('25938726');
expect(baseStudy.publication).equals('Annual review of neuroscience');
// additional data should be added from the pubmed query if it did not exist
expect(baseStudy.pmcid).equals('PMCTEST');
expect(baseStudy.description).equals(
`\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.`
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
<PublicationStatus>ppublish</PublicationStatus>
<ArticleIdList>
<ArticleId IdType="pubmed">25938726</ArticleId>
<ArticleId IdType="pmc">PMCTEST</ArticleId>
<ArticleId IdType="doi">some-doi.org</ArticleId>
</ArticleIdList>
</PubmedData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ export const applyPubmedStudyDetailsToBaseStudiesAndRemoveDuplicates = (
if (pubmedStudy.DOI) idToPubmedStudyMap.set(pubmedStudy.DOI, pubmedStudy);
});

console.log({
baseStudySleuthStubs,
pubmedStudies,
});

const deduplicatedBaseStudiesWithDetails: BaseStudy[] = [];
baseStudySleuthStubs.forEach((baseStudy) => {
const associatedPubmedStudy =
Expand All @@ -621,6 +626,7 @@ export const applyPubmedStudyDetailsToBaseStudiesAndRemoveDuplicates = (

let updatedBaseStudyWithDetails: BaseStudy = {};
if (!associatedPubmedStudy) {
// there is no corresponding pubmed study
updatedBaseStudyWithDetails = { ...baseStudy };
} else {
const authorString = (associatedPubmedStudy?.authors || []).reduce(
Expand Down

0 comments on commit 08e15f2

Please sign in to comment.