@@ -103,7 +103,14 @@ function makeFakeWasmObjects() {
103103 SetOrigin : jest . fn ( async ( ) => undefined ) ,
104104 SetNormal : jest . fn ( async ( ) => undefined ) ,
105105 } ;
106- return { actor, property, widget } ;
106+ // The orientation widget is its own double, not the shared `widget`
107+ // above. Both are observed on `EndInteractionEvent`, and one double for
108+ // both cannot tell those two registrations apart: the plane's own test
109+ // asserts exactly one such registration, and would see two.
110+ const orientationWidget = {
111+ observe : jest . fn ( ) ,
112+ } ;
113+ return { actor, property, widget, orientationWidget } ;
107114}
108115
109116/**
@@ -137,13 +144,19 @@ async function makeRenderer(
137144 canvasDiv : document . createElement ( 'div' ) ,
138145 render : jest . fn ( ) ,
139146 clearObserversAndEventListeners : jest . fn ( ) ,
147+ // The tracker itself is `#private` to VtkScene, so what the renderer
148+ // can reach is this one passthrough, and this is what the orientation
149+ // registration is pinned against.
150+ noteWidgetGesture : jest . fn ( ) ,
140151 camera,
141152 getVtkObject : ( wasmId : number ) => {
142153 switch ( wasmId ) {
143154 case ACTOR_ID :
144155 return objects . actor ;
145156 case PROPERTY_ID :
146157 return objects . property ;
158+ case ORIENTATION_WIDGET_ID :
159+ return objects . orientationWidget ;
147160 default :
148161 return objects . widget ;
149162 }
@@ -156,7 +169,7 @@ async function makeRenderer(
156169 ) ;
157170 const sceneGraph = makeSceneGraphDouble ( actorIds ) ;
158171 renderer . attachSceneGraph ( sceneGraph as unknown as VisorSceneNodeExtended ) ;
159- return { renderer, camera, sceneGraph, ...objects } ;
172+ return { renderer, camera, scene , sceneGraph, ...objects } ;
160173}
161174
162175/** A sender that records its calls and resolves. */
@@ -336,3 +349,28 @@ describe('WasmRenderer reports the cross-section plane on the end-of-drag event'
336349 expect ( sender ) . not . toHaveBeenCalled ( ) ;
337350 } ) ;
338351} ) ;
352+
353+ describe ( 'WasmRenderer marks an orientation-widget move as a gesture' , ( ) => {
354+ // As above, the event does not exist under jsdom, so what is pinned is
355+ // the *registration*: which event the mark is bound to, that there is
356+ // exactly one of it on the orientation widget, and that the callback
357+ // marks and sends nothing. Whether the wasm widget invokes that event at
358+ // all is MC-I6's subject and no gate reaches it.
359+ test ( 'the orientation widget is observed once on EndInteractionEvent and the callback marks a widget gesture' , async ( ) => {
360+ const sender = makeSender ( ) ;
361+ const { scene, orientationWidget } = await makeRenderer ( sender ) ;
362+
363+ const endCalls = orientationWidget . observe . mock . calls . filter (
364+ ( call ) => call [ 0 ] === 'EndInteractionEvent'
365+ ) ;
366+ expect ( endCalls ) . toHaveLength ( 1 ) ;
367+ expect ( scene . noteWidgetGesture ) . not . toHaveBeenCalled ( ) ;
368+
369+ await endCalls [ 0 ] [ 1 ] ( ) ;
370+
371+ expect ( scene . noteWidgetGesture ) . toHaveBeenCalledTimes ( 1 ) ;
372+ // The mark carries no payload and triggers no send: the report stays
373+ // the settle's, through the unchanged sync_camera path.
374+ expect ( sender ) . not . toHaveBeenCalled ( ) ;
375+ } ) ;
376+ } ) ;
0 commit comments