@@ -4,6 +4,7 @@ import cloneDeep from 'lodash.clonedeep'
44import { afterEach , beforeEach , describe , it , suite } from 'mocha'
55import { expect } from 'chai'
66import { restore , spy , stub } from 'sinon'
7+ import { commands , Uri } from 'vscode'
78import { buildPlots } from '../plots/util'
89import { Disposable } from '../../../extension'
910import expShowFixtureWithoutErrors from '../../fixtures/expShow/base/noErrors'
@@ -529,11 +530,53 @@ suite('Plots Test Suite', () => {
529530 expect ( mockSendTelemetryEvent ) . to . be . calledOnce
530531 expect ( mockSendTelemetryEvent ) . to . be . calledWithExactly (
531532 EventName . VIEWS_PLOTS_ZOOM_PLOT ,
532- undefined ,
533+ { isImage : false } ,
534+ undefined
535+ )
536+ } ) . timeout ( WEBVIEW_TEST_TIMEOUT )
537+
538+ it ( 'should handle a plot zoomed message from the webview for an image' , async ( ) => {
539+ const { plots } = await buildPlots ( disposable , plotsDiffFixture )
540+
541+ const webview = await plots . showWebview ( )
542+
543+ const mockSendTelemetryEvent = stub ( Telemetry , 'sendTelemetryEvent' )
544+ const mockMessageReceived = getMessageReceivedEmitter ( webview )
545+
546+ mockMessageReceived . fire ( {
547+ payload : webview . getWebviewUri ( 'a/path.jpg' ) ,
548+ type : MessageFromWebviewType . ZOOM_PLOT
549+ } )
550+
551+ expect ( mockSendTelemetryEvent ) . to . be . calledOnce
552+ expect ( mockSendTelemetryEvent ) . to . be . calledWithExactly (
553+ EventName . VIEWS_PLOTS_ZOOM_PLOT ,
554+ { isImage : true } ,
533555 undefined
534556 )
535557 } ) . timeout ( WEBVIEW_TEST_TIMEOUT )
536558
559+ it ( 'should open an image when receiving a plot zoomed message from the webview with a payload' , async ( ) => {
560+ const { plots } = await buildPlots ( disposable , plotsDiffFixture )
561+
562+ const webview = await plots . showWebview ( )
563+ const imagePath = 'some/path/image.jpg'
564+
565+ stub ( Telemetry , 'sendTelemetryEvent' )
566+ const mockExecuteCommands = stub ( commands , 'executeCommand' )
567+ const mockMessageReceived = getMessageReceivedEmitter ( webview )
568+
569+ mockMessageReceived . fire ( {
570+ payload : webview . getWebviewUri ( imagePath ) ,
571+ type : MessageFromWebviewType . ZOOM_PLOT
572+ } )
573+
574+ expect ( mockExecuteCommands ) . to . be . calledWith (
575+ 'vscode.open' ,
576+ Uri . file ( imagePath )
577+ )
578+ } ) . timeout ( WEBVIEW_TEST_TIMEOUT )
579+
537580 it ( 'should handle a custom plots reordered message from the webview' , async ( ) => {
538581 const { plots, plotsModel, messageSpy } = await buildPlots (
539582 disposable ,
0 commit comments