Skip to content

Commit def2112

Browse files
committed
Test numeric annotations or mouse not eligible for pathways
1 parent ffcabf7 commit def2112

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

app/javascript/components/explore/ExploreDisplayTabs.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ export default function ExploreDisplayTabs({
523523
queries = exploreParams.genes
524524
}
525525

526-
console.log('in ExploreDisplayTabs')
526+
// eslint-disable-next-line no-unused-vars
527527
const [_, selectedAnnotation] = getSelectedClusterAndAnnot(exploreInfo, exploreParams)
528528

529529
return (

app/javascript/components/explore/StudyGeneField.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function getQueriesFromSearchOptions(newQueryArray, speciesList, selectedAnnotat
6464
}
6565

6666
/** Indicate whether pathway view should be available for this study */
67-
function getIsEligibleForPathwayExplore(speciesList, selectedAnnotation) {
67+
export function getIsEligibleForPathwayExplore(speciesList, selectedAnnotation) {
6868
const isEligibleForPathwayExplore = (
6969
speciesList.length === 1 && speciesList[0] === 'Homo sapiens' &&
7070
selectedAnnotation.type === 'group' &&
@@ -104,12 +104,10 @@ export default function StudyGeneField({
104104
}) {
105105
const [inputText, setInputText] = useState('')
106106

107-
console.log('selectedAnnotation', selectedAnnotation)
108107
const includePathways = getIsEligibleForPathwayExplore(speciesList, selectedAnnotation)
109108
const rawSuggestions = getAutocompleteSuggestions(inputText, allGenes, includePathways)
110109
const searchOptions = getSearchOptions(rawSuggestions, speciesList, selectedAnnotation)
111110

112-
113111
let enteredQueryArray = []
114112
if (inputText.length === 0 && queries && queries.length > 0) {
115113
const queriesSearchOptions = getSearchOptions(queries, speciesList, selectedAnnotation)
@@ -232,7 +230,7 @@ export default function StudyGeneField({
232230
if (queries.join(',') !== queryArray.map(opt => opt.value).join(',')) {
233231
// the genes have been updated elsewhere -- resync
234232
const queriesSearchOptions = getSearchOptions(queries, speciesList, selectedAnnotation)
235-
const newQueryArray = getQueryArrayFromSearchOptions(queriesSearchOptions, speciesList)
233+
const newQueryArray = getQueryArrayFromSearchOptions(queriesSearchOptions, speciesList, selectedAnnotation)
236234
setQueryArray(newQueryArray)
237235
setInputText('')
238236
setNotPresentQueries(new Set([]))

test/js/explore/study-gene-keyword.test.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import { render, waitFor, screen, fireEvent } from '@testing-library/react'
44
import '@testing-library/jest-dom/extend-expect'
55

6-
import StudyGeneField, { getIsInvalidQuery } from 'components/explore/StudyGeneField'
6+
import StudyGeneField, { getIsInvalidQuery, getIsEligibleForPathwayExplore } from 'components/explore/StudyGeneField'
77
import * as UserProvider from '~/providers/UserProvider'
88
import { interestingNames, interactionCacheCsn1s1 } from './../visualization/pathway.test-data'
99

@@ -67,7 +67,10 @@ describe('Search query display text', () => {
6767
})
6868

6969
const { container } = render(
70-
<StudyGeneField queries={[]} queryFn={() => {}} allGenes={['PTEN']} speciesList={['Homo sapiens']} />
70+
<StudyGeneField
71+
queries={[]} queryFn={() => {}} allGenes={['PTEN']}
72+
speciesList={['Homo sapiens']} selectedAnnotation={{ type: 'group' }}
73+
/>
7174
)
7275

7376
// Find the input field inside react-select
@@ -97,5 +100,26 @@ describe('Search query display text', () => {
97100
const pathwayIsInvalid = getIsInvalidQuery('CSN1S1', ['PTEN'])
98101
expect(pathwayIsInvalid).toBe(false)
99102
})
103+
104+
it('determines if view is eligible for pathway exploration', async () => {
105+
jest
106+
.spyOn(UserProvider, 'getFeatureFlagsWithDefaults')
107+
.mockReturnValue({
108+
show_pathway_expression: true
109+
})
110+
111+
// Confirm mouse is not eligible
112+
const isMouseEligible = getIsEligibleForPathwayExplore(['Mus musculus'], { type: 'group' })
113+
expect(isMouseEligible).toBe(false)
114+
115+
// Confirm numeric annotation is not eligible
116+
const isNumericAnnotationEligible = getIsEligibleForPathwayExplore(['Homo sapiens'], { type: 'numeric' })
117+
expect(isNumericAnnotationEligible).toBe(false)
118+
119+
// Confirm group annotation for human is eligible
120+
const isHumanGroupAnnotationEligible = getIsEligibleForPathwayExplore(['Homo sapiens'], { type: 'group' })
121+
expect(isHumanGroupAnnotationEligible).toBe(true)
122+
})
123+
100124
})
101125

0 commit comments

Comments
 (0)