@@ -279,6 +279,96 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
279279 stylePropertyTreeElement . valueElement ?. querySelectorAll ( 'devtools-link-swatch' ) ;
280280 assert . strictEqual ( animationNameSwatches ?. length , 2 ) ;
281281 } ) ;
282+
283+ describe ( 'jumping to animations panel' , ( ) => {
284+ let domModel : SDK . DOMModel . DOMModel ;
285+ beforeEach ( ( ) => {
286+ const target = createTarget ( ) ;
287+ const domModelBeforeAssertion = target . model ( SDK . DOMModel . DOMModel ) ;
288+ assert . exists ( domModelBeforeAssertion ) ;
289+ domModel = domModelBeforeAssertion ;
290+ } ) ;
291+
292+ afterEach ( ( ) => {
293+ sinon . reset ( ) ;
294+ } ) ;
295+
296+ it ( 'should render a jump-to icon when the animation with the given name exists for the node' , async ( ) => {
297+ const stubAnimationGroup = sinon . createStubInstance ( SDK . AnimationModel . AnimationGroup ) ;
298+ const getAnimationGroupForAnimationStub =
299+ sinon . stub ( SDK . AnimationModel . AnimationModel . prototype , 'getAnimationGroupForAnimation' )
300+ . resolves ( stubAnimationGroup ) ;
301+ const domNode = SDK . DOMModel . DOMNode . create ( domModel , null , false , {
302+ nodeId : 1 as Protocol . DOM . NodeId ,
303+ backendNodeId : 2 as Protocol . DOM . BackendNodeId ,
304+ nodeType : Node . ELEMENT_NODE ,
305+ nodeName : 'div' ,
306+ localName : 'div' ,
307+ nodeValue : '' ,
308+ } ) ;
309+ const stylePropertyTreeElement = getTreeElement ( 'animation-name' , 'first-keyframe, second-keyframe' ) ;
310+ sinon . stub ( stylePropertyTreeElement , 'node' ) . returns ( domNode ) ;
311+
312+ stylePropertyTreeElement . updateTitle ( ) ;
313+ await Promise . all ( getAnimationGroupForAnimationStub . returnValues ) ;
314+
315+ const jumpToIcon =
316+ stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-icon.open-in-animations-panel' ) ;
317+ assert . exists ( jumpToIcon ) ;
318+ } ) ;
319+
320+ it ( 'should clicking on the jump-to icon reveal the resolved animation group' , async ( ) => {
321+ const stubAnimationGroup = sinon . createStubInstance ( SDK . AnimationModel . AnimationGroup ) ;
322+ const revealerSpy = sinon . spy ( Common . Revealer . RevealerRegistry . instance ( ) , 'reveal' ) ;
323+ const getAnimationGroupForAnimationStub =
324+ sinon . stub ( SDK . AnimationModel . AnimationModel . prototype , 'getAnimationGroupForAnimation' )
325+ . resolves ( stubAnimationGroup ) ;
326+ const domNode = SDK . DOMModel . DOMNode . create ( domModel , null , false , {
327+ nodeId : 1 as Protocol . DOM . NodeId ,
328+ backendNodeId : 2 as Protocol . DOM . BackendNodeId ,
329+ nodeType : Node . ELEMENT_NODE ,
330+ nodeName : 'div' ,
331+ localName : 'div' ,
332+ nodeValue : '' ,
333+ } ) ;
334+ const stylePropertyTreeElement = getTreeElement ( 'animation-name' , 'first-keyframe, second-keyframe' ) ;
335+ sinon . stub ( stylePropertyTreeElement , 'node' ) . returns ( domNode ) ;
336+
337+ stylePropertyTreeElement . updateTitle ( ) ;
338+ await Promise . all ( getAnimationGroupForAnimationStub . returnValues ) ;
339+
340+ const jumpToIcon =
341+ stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-icon.open-in-animations-panel' ) ;
342+ jumpToIcon ?. dispatchEvent ( new Event ( 'mouseup' ) ) ;
343+ assert . isTrue (
344+ revealerSpy . calledWith ( stubAnimationGroup ) ,
345+ 'Common.Revealer.reveal is not called for the animation group' ) ;
346+ } ) ;
347+
348+ it ( 'should not render a jump-to icon when the animation with the given name does not exist for the node' ,
349+ async ( ) => {
350+ const getAnimationGroupForAnimationStub =
351+ sinon . stub ( SDK . AnimationModel . AnimationModel . prototype , 'getAnimationGroupForAnimation' )
352+ . resolves ( null ) ;
353+ const domNode = SDK . DOMModel . DOMNode . create ( domModel , null , false , {
354+ nodeId : 1 as Protocol . DOM . NodeId ,
355+ backendNodeId : 2 as Protocol . DOM . BackendNodeId ,
356+ nodeType : Node . ELEMENT_NODE ,
357+ nodeName : 'div' ,
358+ localName : 'div' ,
359+ nodeValue : '' ,
360+ } ) ;
361+ const stylePropertyTreeElement = getTreeElement ( 'animation-name' , 'first-keyframe, second-keyframe' ) ;
362+ sinon . stub ( stylePropertyTreeElement , 'node' ) . returns ( domNode ) ;
363+
364+ stylePropertyTreeElement . updateTitle ( ) ;
365+ await Promise . all ( getAnimationGroupForAnimationStub . returnValues ) ;
366+
367+ const jumpToIcon =
368+ stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-icon.open-in-animations-panel' ) ;
369+ assert . notExists ( jumpToIcon ) ;
370+ } ) ;
371+ } ) ;
282372 } ) ;
283373 } ) ;
284374
0 commit comments