@@ -12,6 +12,7 @@ import { ExperimentType } from '../../../../experiments/model'
1212import { UNSELECTED } from '../../../../experiments/model/status'
1313import {
1414 bypassProcessManagerDebounce ,
15+ bypassProgressCloseDelay ,
1516 getFirstArgOfLastCall ,
1617 getMockNow ,
1718 getTimeSafeDisposer ,
@@ -345,6 +346,99 @@ suite('Experiments Tree Test Suite', () => {
345346 )
346347 } )
347348
349+ it ( 'should be able to push an experiment with dvc.views.experimentsTree.pushExperiment' , async ( ) => {
350+ bypassProgressCloseDelay ( )
351+ const mockExperimentId = 'exp-to-push'
352+ const mockExperiment = {
353+ dvcRoot : dvcDemoPath ,
354+ id : mockExperimentId ,
355+ type : ExperimentType . EXPERIMENT
356+ }
357+
358+ const mockExpPush = stub ( DvcExecutor . prototype , 'expPush' ) . resolves ( '' )
359+
360+ stubPrivatePrototypeMethod (
361+ ExperimentsTree ,
362+ 'getSelectedExperimentItems'
363+ ) . returns ( [ mockExperiment ] )
364+
365+ await commands . executeCommand (
366+ 'dvc.views.experimentsTree.pushExperiment' ,
367+ mockExperiment
368+ )
369+
370+ expect ( mockExpPush ) . to . be . calledWithExactly ( dvcDemoPath , mockExperimentId )
371+ } )
372+
373+ it ( 'should be able to push the provided experiment with dvc.views.experimentsTree.pushExperiment (if no experiments are selected)' , async ( ) => {
374+ bypassProgressCloseDelay ( )
375+ const mockExperiment = 'exp-to-push'
376+
377+ const mockExpPush = stub ( DvcExecutor . prototype , 'expPush' ) . resolves ( '' )
378+
379+ stubPrivatePrototypeMethod (
380+ ExperimentsTree ,
381+ 'getSelectedExperimentItems'
382+ ) . returns ( [ ] )
383+
384+ await commands . executeCommand (
385+ 'dvc.views.experimentsTree.pushExperiment' ,
386+ {
387+ dvcRoot : dvcDemoPath ,
388+ id : mockExperiment ,
389+ type : ExperimentType . EXPERIMENT
390+ }
391+ )
392+
393+ expect ( mockExpPush ) . to . be . calledWithExactly ( dvcDemoPath , mockExperiment )
394+ } )
395+
396+ it ( 'should be able to push multiple experiments with dvc.views.experimentsTree.pushExperiment' , async ( ) => {
397+ bypassProgressCloseDelay ( )
398+ const mockFirstExperimentId = 'first-exp-pushed'
399+ const mockSecondExperimentId = 'second-exp-pushed'
400+ const mockQueuedExperimentLabel = 'queued-excluded'
401+
402+ const mockExpPush = stub ( DvcExecutor . prototype , 'expPush' ) . resolves ( '' )
403+
404+ stubPrivatePrototypeMethod (
405+ ExperimentsTree ,
406+ 'getSelectedExperimentItems'
407+ ) . returns ( [
408+ dvcDemoPath ,
409+ {
410+ dvcRoot : dvcDemoPath ,
411+ label : mockQueuedExperimentLabel ,
412+ type : ExperimentType . QUEUED
413+ } ,
414+ {
415+ dvcRoot : dvcDemoPath ,
416+ id : mockFirstExperimentId ,
417+ type : ExperimentType . EXPERIMENT
418+ } ,
419+ {
420+ dvcRoot : dvcDemoPath ,
421+ id : 'workspace-excluded' ,
422+ type : ExperimentType . WORKSPACE
423+ }
424+ ] )
425+
426+ await commands . executeCommand (
427+ 'dvc.views.experimentsTree.pushExperiment' ,
428+ {
429+ dvcRoot : dvcDemoPath ,
430+ id : mockSecondExperimentId ,
431+ type : ExperimentType . EXPERIMENT
432+ }
433+ )
434+
435+ expect ( mockExpPush ) . to . be . calledWithExactly (
436+ dvcDemoPath ,
437+ mockFirstExperimentId ,
438+ mockSecondExperimentId
439+ )
440+ } )
441+
348442 it ( 'should be able to apply an experiment to the workspace with dvc.views.experiments.applyExperiment' , async ( ) => {
349443 const { experiments } = buildExperiments ( disposable )
350444
0 commit comments