Skip to content

Commit

Permalink
More typescripting
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 6, 2022
1 parent 464b6a5 commit 87a1026
Show file tree
Hide file tree
Showing 17 changed files with 984 additions and 858 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ exports[`ConfigurationEditor widget renders with defaults of the PileupTrack sch
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-16-helper-text"
Expand Down Expand Up @@ -1358,7 +1357,6 @@ exports[`ConfigurationEditor widget renders with defaults of the PileupTrack sch
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-18-helper-text"
Expand Down Expand Up @@ -1435,7 +1433,6 @@ exports[`ConfigurationEditor widget renders with defaults of the PileupTrack sch
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-19-helper-text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ exports[`<AddConnectionWidget /> renders 1`] = `
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-1-helper-text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ exports[`<LinearGenomeView /> renders one track, one region 1`] = `
/>
</button>
<div
class="MuiAutocomplete-root css-16awh2u-MuiAutocomplete-root"
class="MuiAutocomplete-root css-1qqsdnr-MuiAutocomplete-root"
data-testid="autocomplete"
style="width: 200px;"
>
Expand Down Expand Up @@ -722,7 +722,7 @@ exports[`<LinearGenomeView /> renders two tracks, two regions 1`] = `
/>
</button>
<div
class="MuiAutocomplete-root css-16awh2u-MuiAutocomplete-root"
class="MuiAutocomplete-root css-1qqsdnr-MuiAutocomplete-root"
data-testid="autocomplete"
style="width: 255.27500000000003px;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ exports[`<JBrowseLinearGenomeView /> renders successfully 1`] = `
/>
</button>
<div
class="MuiAutocomplete-root mui-1auycx3-MuiAutocomplete-root"
class="MuiAutocomplete-root mui-1kxbtff-MuiAutocomplete-root"
data-testid="autocomplete"
style="width: 200px;"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react'
import { fireEvent, render } from '@testing-library/react'
import { LocalFile } from 'generic-filehandle'
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'

import { JBrowse, setup, generateReadBuffer, getPluginManager } from './util'

type LGV = LinearGenomeViewModel
setup()

beforeEach(() => {
clearCache()
clearAdapterCache()
// @ts-ignore
fetch.resetMocks()
// @ts-ignore
fetch.mockResponse(
generateReadBuffer(url => {
return new LocalFile(require.resolve(`../../test_data/volvox/${url}`))
Expand All @@ -23,43 +28,46 @@ const delay = { timeout: 15000 }

test('click and drag rubberBand, bookmarks region', async () => {
const pm = getPluginManager()
const state = pm.rootModel
const { findByTestId, findByText } = render(<JBrowse pluginManager={pm} />)
const rubberBandComponent = await findByTestId(
'rubberBand_controls',
{},
delay,
)
const state = pm.rootModel!
const session = state.session!
const view = session.views[0] as LGV

expect(state.session.views[0].bpPerPx).toEqual(0.05)
fireEvent.mouseDown(rubberBandComponent, { clientX: 100, clientY: 0 })
fireEvent.mouseMove(rubberBandComponent, { clientX: 250, clientY: 0 })
fireEvent.mouseUp(rubberBandComponent, { clientX: 250, clientY: 0 })
const rubberband = await findByTestId('rubberBand_controls', {}, delay)
expect(view.bpPerPx).toEqual(0.05)
fireEvent.mouseDown(rubberband, { clientX: 100, clientY: 0 })
fireEvent.mouseMove(rubberband, { clientX: 250, clientY: 0 })
fireEvent.mouseUp(rubberband, { clientX: 250, clientY: 0 })
const bookmarkMenuItem = await findByText('Bookmark region')
fireEvent.click(bookmarkMenuItem)
const { widgets } = state.session
// @ts-ignore
const { widgets } = session
const bookmarkWidget = widgets.get('GridBookmark')
expect(bookmarkWidget.bookmarkedRegions[0].assemblyName).toEqual('volvox')
}, 20000)

test('bookmarks current region', async () => {
const pm = getPluginManager()
const state = pm.rootModel
const state = pm.rootModel!
const session = state.session!
const { findByTestId, findByText } = render(<JBrowse pluginManager={pm} />)

fireEvent.click(await findByTestId('view_menu_icon'))
fireEvent.click(await findByText('Bookmark current region'))
const { widgets } = state.session
// @ts-ignore
const { widgets } = session
const { bookmarkedRegions } = widgets.get('GridBookmark')
expect(bookmarkedRegions[0].start).toEqual(100)
expect(bookmarkedRegions[0].end).toEqual(140)
}, 20000)

test('navigates to bookmarked region from widget', async () => {
const pm = getPluginManager()
const state = pm.rootModel

const { findByTestId, findByText } = render(<JBrowse pluginManager={pm} />)
const state = pm.rootModel!
const session = state.session!
const view = session.views[0] as LGV

// need this to complete before we can try to navigate
fireEvent.click(
Expand All @@ -75,17 +83,17 @@ test('navigates to bookmarked region from widget', async () => {
fireEvent.click(viewMenu)
fireEvent.click(await findByText('Open bookmark widget'))

const { widgets } = state.session
// @ts-ignore
const { widgets } = session
const bookmarkWidget = widgets.get('GridBookmark')
bookmarkWidget.addBookmark({
start: 200,
end: 240,
refName: 'ctgA',
assemblyName: 'volvox',
})
const view = state.session.views[0]

fireEvent.click(await findByText('ctgA:201..240'), {}, delay)
fireEvent.click(await findByText('ctgA:201..240', {}, delay))
const newRegion = view.getSelectedRegions(
view.leftOffset,
view.rightOffset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ setup()
beforeEach(() => {
clearCache()
clearAdapterCache()
// @ts-ignore
fetch.resetMocks()
// @ts-ignore
fetch.mockResponse(
generateReadBuffer(url => {
return new LocalFile(require.resolve(`../../test_data/breakpoint/${url}`))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react'
import '@testing-library/jest-dom/extend-expect'
import { fireEvent, render, waitFor } from '@testing-library/react'
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-web/src/tests/CopyAndDelete.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react'
import '@testing-library/jest-dom/extend-expect'
import { fireEvent, render, waitFor } from '@testing-library/react'
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-web/src/tests/ReadVsRef.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { LocalFile } from 'generic-filehandle'
Expand Down
12 changes: 4 additions & 8 deletions products/jbrowse-web/src/tests/StartScreen.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react'
import '@testing-library/jest-dom/extend-expect'
import { fireEvent, render } from '@testing-library/react'
Expand Down Expand Up @@ -25,37 +26,32 @@ describe('<StartScreen />', () => {
test('Add New Session', async () => {
const pluginManager = getPluginManager()
const root = pluginManager.rootModel!
const session = root.session!
const { findByText } = render(
<StartScreen rootModel={root} onFactoryReset={factoryReset} />,
)
await findByText('Start a new session')
fireEvent.click(await findByText('Empty'))
expect(session).toBeTruthy()
expect(root.session).toBeTruthy()
})

test('Add New LGV Session', async () => {
const pluginManager = getPluginManager()
const root = pluginManager.rootModel!
const session = root.session!
const { findByText } = render(
<StartScreen rootModel={root} onFactoryReset={factoryReset} />,
)
await findByText('Start a new session')
fireEvent.click(await findByText('Linear Genome View'))
expect(session).toBeTruthy()
expect(session.views.length).toBeGreaterThan(0)
expect(root.session!.views.length).toBeGreaterThan(0)
})

test('Add New SV Inspector Session', async () => {
const pluginManager = getPluginManager()
const root = pluginManager.rootModel!
const session = root.session!
const { findByText } = render(
<StartScreen rootModel={root} onFactoryReset={factoryReset} />,
)
await findByText('Start a new session')
fireEvent.click(await findByText('Structural Variant Inspector'))
expect(session).toBeTruthy()
expect(session.views.length).toBeGreaterThan(0)
expect(root.session!.views.length).toBeGreaterThan(0)
})
4 changes: 2 additions & 2 deletions products/jbrowse-web/src/tests/TextSearching.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function doSetup(val?: unknown) {
const view = state.session.views[0] as LGV
fireEvent.click(await findByText('Help'))

const autocomplete = await findByTestId('autocomplete')
const autocomplete = await findByTestId('autocomplete', {}, delay)
const input = await findByPlaceholderText('Search for location')

autocomplete.focus()
Expand Down Expand Up @@ -123,7 +123,7 @@ test(
fireEvent.change(input, { target: { value: 'ctgb' } })
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter' })
fireEvent.keyDown(autocomplete, { key: 'Enter', code: 'Enter' })
fireEvent.click((await findAllByText('Go'))[0])
fireEvent.click((await findAllByText('Go', {}, delay))[0])
await waitFor(() => expect(view.displayedRegions[0].refName).toBe('ctgB'))
},
total,
Expand Down
Loading

0 comments on commit 87a1026

Please sign in to comment.