Skip to content

Commit

Permalink
Update snaps
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Feb 19, 2023
1 parent 35678fc commit 6e5947a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 36 deletions.
29 changes: 0 additions & 29 deletions products/jbrowse-web/src/tests/ExportSvg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import fs from 'fs'
import path from 'path'
import FileSaver from 'file-saver'
import volvoxConfig from '../../test_data/volvox/config.json'
import breakpointConfig from '../../test_data/breakpoint/config.json'

// locals
import { hts, createView, setup, doBeforeEach } from './util'
Expand Down Expand Up @@ -332,31 +331,3 @@ test('export svg of dotplot', async () => {
fs.writeFileSync(`${dir}/__image_snapshots__/dotplot_snapshot.svg`, svg)
expect(svg).toMatchSnapshot()
}, 45000)

test('export svg of breakpoint split view', async () => {
doBeforeEach(url => require.resolve(`../../test_data/breakpoint/${url}`))
console.warn = jest.fn()
const { findByTestId, findAllByText, findByText } =
createView(breakpointConfig)

await findByText('Help')

// the breakpoint split view requires that the view was rendered first,
// so add an arbitrary delay here. would need refactoring to fix properly
await new Promise(resolve => setTimeout(resolve, 10000))

fireEvent.click(await findByTestId('view_menu_icon'))
fireEvent.click((await findAllByText('Export SVG'))[0])
fireEvent.click(await findByText('Submit'))

await waitFor(() => expect(FileSaver.saveAs).toHaveBeenCalled(), delay)

// @ts-ignore
const svg = FileSaver.saveAs.mock.calls[0][0].content[0]
const dir = path.dirname(module.filename)
fs.writeFileSync(
`${dir}/__image_snapshots__/breakpoint_split_view_snapshot.svg`,
svg,
)
expect(svg).toMatchSnapshot()
}, 45000)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { fireEvent, waitFor } from '@testing-library/react'
import fs from 'fs'
import path from 'path'
import FileSaver from 'file-saver'
import breakpointConfig from '../../test_data/breakpoint/config.json'

// locals
import { createView, setup, doBeforeEach } from './util'

// @ts-ignore
global.Blob = (content, options) => ({ content, options })

// mock from https://stackoverflow.com/questions/44686077
jest.mock('file-saver', () => ({ saveAs: jest.fn() }))

setup()

const delay = { timeout: 40000 }

test('export svg of breakpoint split view', async () => {
doBeforeEach(url => require.resolve(`../../test_data/breakpoint/${url}`))
console.warn = jest.fn()
const { findByTestId, findAllByText, findByText } =
createView(breakpointConfig)

await findByText('Help')

// the breakpoint split view requires that the view was rendered first,
// so add an arbitrary delay here. would need refactoring to fix properly
await new Promise(resolve => setTimeout(resolve, 10000))

fireEvent.click(await findByTestId('view_menu_icon'))
fireEvent.click((await findAllByText('Export SVG'))[0])
fireEvent.click(await findByText('Submit'))

await waitFor(() => expect(FileSaver.saveAs).toHaveBeenCalled(), delay)

// @ts-ignore
const svg = FileSaver.saveAs.mock.calls[0][0].content[0]
const dir = path.dirname(module.filename)
fs.writeFileSync(
`${dir}/__image_snapshots__/breakpoint_split_view_snapshot.svg`,
svg,
)
expect(svg).toMatchSnapshot()
}, 45000)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 6e5947a

Please sign in to comment.