From 6e5947ad7ee4085c23a7854ed241cc854021513b Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 19 Feb 2023 12:56:52 -0700 Subject: [PATCH] Update snaps --- .../jbrowse-web/src/tests/ExportSvg.test.tsx | 29 ------------ .../ExportSvgBreakpointSplitView.test.tsx | 46 +++++++++++++++++++ .../breakpoint_split_view_snapshot.svg | 2 +- .../__image_snapshots__/lgv_snapshot.svg | 2 +- .../__image_snapshots__/synteny_snapshot.svg | 2 +- .../__snapshots__/ExportSvg.test.tsx.snap | 6 +-- ...ExportSvgBreakpointSplitView.test.tsx.snap | 3 ++ 7 files changed, 54 insertions(+), 36 deletions(-) create mode 100644 products/jbrowse-web/src/tests/ExportSvgBreakpointSplitView.test.tsx create mode 100644 products/jbrowse-web/src/tests/__snapshots__/ExportSvgBreakpointSplitView.test.tsx.snap diff --git a/products/jbrowse-web/src/tests/ExportSvg.test.tsx b/products/jbrowse-web/src/tests/ExportSvg.test.tsx index ac607f6d73..946b10a6ed 100644 --- a/products/jbrowse-web/src/tests/ExportSvg.test.tsx +++ b/products/jbrowse-web/src/tests/ExportSvg.test.tsx @@ -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' @@ -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) diff --git a/products/jbrowse-web/src/tests/ExportSvgBreakpointSplitView.test.tsx b/products/jbrowse-web/src/tests/ExportSvgBreakpointSplitView.test.tsx new file mode 100644 index 0000000000..10eb52cf15 --- /dev/null +++ b/products/jbrowse-web/src/tests/ExportSvgBreakpointSplitView.test.tsx @@ -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) diff --git a/products/jbrowse-web/src/tests/__image_snapshots__/breakpoint_split_view_snapshot.svg b/products/jbrowse-web/src/tests/__image_snapshots__/breakpoint_split_view_snapshot.svg index fc5107f5a1..d92a48056c 100644 --- a/products/jbrowse-web/src/tests/__image_snapshots__/breakpoint_split_view_snapshot.svg +++ b/products/jbrowse-web/src/tests/__image_snapshots__/breakpoint_split_view_snapshot.svg @@ -1 +1 @@ -hg19chr3186,698,000186,700,000chr3186,702,000186,704,0000077HG002.hs37d5.11kbpbsv.BND.3:186700648-6:56758392T[6:56758392[pbsv.BND.3:186700648-6:56758392T[6:56758392[HG002.hs37d5.bndshg19chr656,756,00056,758,000chr656,760,00056,762,0000088HG002.hs37d5.11kbpbsv.BND.6:56758392-3:186700648]3:186700648]Tpbsv.BND.6:56758392-3:186700648]3:186700648]THG002.hs37d5.bnds \ No newline at end of file +hg19chr3186,698,000186,700,000chr3186,702,000186,704,0000077HG002.hs37d5.11kbpbsv.BND.3:186700648-6:56758392T[6:56758392[pbsv.BND.3:186700648-6:56758392T[6:56758392[HG002.hs37d5.bndshg19chr656,754,00056,756,00056,758,000chr656,758,00056,760,00056,762,0000088HG002.hs37d5.11kbpbsv.BND.6:56758392-3:186700648]3:186700648]Tpbsv.BND.6:56758392-3:186700648]3:186700648]THG002.hs37d5.bnds \ No newline at end of file diff --git a/products/jbrowse-web/src/tests/__image_snapshots__/lgv_snapshot.svg b/products/jbrowse-web/src/tests/__image_snapshots__/lgv_snapshot.svg index 9e604cbd82..c54ca7af29 100644 --- a/products/jbrowse-web/src/tests/__image_snapshots__/lgv_snapshot.svg +++ b/products/jbrowse-web/src/tests/__image_snapshots__/lgv_snapshot.svg @@ -1 +1 @@ -volvox80bpctgA020406080001111GTACAGAGTGACGCTCAAAGCvolvox-sorted.bam (ctgA, canvas) +volvox80bpctgA020406080001111GTACAGAGTGACGCTCAAAGCvolvox-sorted.bam (ctgA, canvas) \ No newline at end of file diff --git a/products/jbrowse-web/src/tests/__image_snapshots__/synteny_snapshot.svg b/products/jbrowse-web/src/tests/__image_snapshots__/synteny_snapshot.svg index 87dc8439d4..64d84f96dc 100644 --- a/products/jbrowse-web/src/tests/__image_snapshots__/synteny_snapshot.svg +++ b/products/jbrowse-web/src/tests/__image_snapshots__/synteny_snapshot.svg @@ -1 +1 @@ -volvoxctgA1,8001,9002,0002,100333619537636283334354210515volvox_inv_indelsvolvox_random_invctgA1,8001,9002,0002,1003345844231067567193728415volvox_inv_indels +volvoxctgA1,8001,9002,0002,100333619537636283334354210515volvox_inv_indelsvolvox_random_invctgA1,8001,9002,0002,1003345844231067567193728415volvox_inv_indels \ No newline at end of file diff --git a/products/jbrowse-web/src/tests/__snapshots__/ExportSvg.test.tsx.snap b/products/jbrowse-web/src/tests/__snapshots__/ExportSvg.test.tsx.snap index f967a60c4b..662394f8bf 100644 --- a/products/jbrowse-web/src/tests/__snapshots__/ExportSvg.test.tsx.snap +++ b/products/jbrowse-web/src/tests/__snapshots__/ExportSvg.test.tsx.snap @@ -1,7 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`export svg of breakpoint split view 1`] = `"hg19chr3186,698,000186,700,000chr3186,702,000186,704,0000077HG002.hs37d5.11kbpbsv.BND.3:186700648-6:56758392T[6:56758392[pbsv.BND.3:186700648-6:56758392T[6:56758392[HG002.hs37d5.bndshg19chr656,756,00056,758,000chr656,760,00056,762,0000088HG002.hs37d5.11kbpbsv.BND.6:56758392-3:186700648]3:186700648]Tpbsv.BND.6:56758392-3:186700648]3:186700648]THG002.hs37d5.bnds"`; - exports[`export svg of circular 1`] = ` "ctgActgActgBctgB