@@ -3,7 +3,9 @@ import React from 'react'
33import { render , waitFor , screen , fireEvent } from '@testing-library/react'
44import '@testing-library/jest-dom/extend-expect'
55
6- import StudyGeneField , { getIsInvalidQuery , getIsEligibleForPathwayExplore } from 'components/explore/StudyGeneField'
6+ import StudyGeneField , {
7+ getIsInvalidQuery , getIsEligibleForPathwayExplore , finalFilterOptions
8+ } from 'components/explore/StudyGeneField'
79import * as UserProvider from '~/providers/UserProvider'
810import { logStudyGeneSearch } from '~/lib/search-metrics'
911import * as MetricsApi from '~/lib/metrics-api'
@@ -152,5 +154,22 @@ describe('Search query display text', () => {
152154 )
153155
154156 } )
157+
158+ it ( 'handles unexpected pathway data structures' , ( ) => {
159+ // This tests pathway autocomplete handling for edge-case issues in
160+ // upstreams WikiPathway data, which can occur upon upgrading Ideogram.js library
161+ // to a new version that updates interactions cache data. The resulting bug
162+ // breaks the Explore page when the search box autocompletes an affected gene
163+ // (e.g. TCF4) -- a low incidence, high severity bug.
164+
165+ const rawInput = 'TCF4'
166+ const option = {
167+ label : undefined ,
168+ value : 'WP5523' ,
169+ data : { value : 'WP5523' , isGene : false }
170+ }
171+ const isPathway = finalFilterOptions ( option , rawInput )
172+ expect ( isPathway ) . toBe ( true )
173+ } )
155174} )
156175
0 commit comments