@@ -606,6 +606,61 @@ suite('Workspace Experiments Test Suite', () => {
606606 } )
607607 } )
608608
609+ describe ( 'dvc.shareExperimentAsCommit' , ( ) => {
610+ it ( 'should be able to share an experiment as a commit' , async ( ) => {
611+ const { experiments } = buildExperiments ( disposable )
612+ await experiments . isReady ( )
613+
614+ const testExperiment = 'exp-83425'
615+ const mockCommit = 'this is the best experiment ever!'
616+ const inputEvent = getInputBoxEvent ( mockCommit )
617+
618+ stub ( window , 'showQuickPick' ) . resolves ( {
619+ value : { id : testExperiment , name : testExperiment }
620+ } as QuickPickItemWithValue < { id : string ; name : string } > )
621+
622+ const mockExperimentApply = stub (
623+ DvcExecutor . prototype ,
624+ 'experimentApply'
625+ ) . resolves (
626+ `Changes for experiment '${ testExperiment } ' have been applied to your current workspace.`
627+ )
628+ const mockPush = stub ( DvcExecutor . prototype , 'push' ) . resolves (
629+ '191232423 files updated.'
630+ )
631+ const mockStageAndCommit = stub (
632+ GitExecutor . prototype ,
633+ 'stageAndCommit'
634+ ) . resolves ( '' )
635+ const mockGitPush = stub ( GitExecutor . prototype , 'pushBranch' )
636+ const branchPushedToRemote = new Promise ( resolve =>
637+ mockGitPush . callsFake ( ( ) => {
638+ resolve ( undefined )
639+ return Promise . resolve ( `${ mockCommit } pushed to remote` )
640+ } )
641+ )
642+
643+ stubWorkspaceExperimentsGetters ( dvcDemoPath , experiments )
644+
645+ await commands . executeCommand (
646+ RegisteredCliCommands . EXPERIMENT_SHARE_AS_COMMIT
647+ )
648+
649+ await inputEvent
650+ await branchPushedToRemote
651+ expect ( mockExperimentApply ) . to . be . calledWithExactly (
652+ dvcDemoPath ,
653+ testExperiment
654+ )
655+ expect ( mockStageAndCommit ) . to . be . calledWithExactly (
656+ dvcDemoPath ,
657+ mockCommit
658+ )
659+ expect ( mockPush ) . to . be . calledWithExactly ( dvcDemoPath )
660+ expect ( mockGitPush ) . to . be . calledWithExactly ( dvcDemoPath )
661+ } )
662+ } )
663+
609664 describe ( 'dvc.removeExperiment' , ( ) => {
610665 it ( 'should ask the user to pick an experiment and then remove that experiment from the workspace' , async ( ) => {
611666 const mockExperiment = 'exp-to-remove'
0 commit comments