@@ -24,10 +24,7 @@ import plotsDiffFixture from '../../../fixtures/plotsDiff/output'
2424import expShowFixture from '../../../fixtures/expShow/output'
2525import { Operator } from '../../../../experiments/model/filterBy'
2626import { joinColumnPath } from '../../../../experiments/columns/paths'
27- import {
28- ExperimentItem ,
29- ExperimentsTree
30- } from '../../../../experiments/model/tree'
27+ import { ExperimentsTree } from '../../../../experiments/model/tree'
3128import { buildExperiments , buildSingleRepoExperiments } from '../util'
3229import { ResourceLocator } from '../../../../resourceLocator'
3330import { InternalCommands } from '../../../../commands/internal'
@@ -42,6 +39,7 @@ import { Param } from '../../../../experiments/model/modify/collect'
4239import { WorkspaceExperiments } from '../../../../experiments/workspace'
4340import { ColumnType } from '../../../../experiments/webview/contract'
4441import { copyOriginalColors } from '../../../../experiments/model/status/colors'
42+ import { ExperimentItem } from '../../../../experiments/model/collect'
4543
4644suite ( 'Experiments Tree Test Suite' , ( ) => {
4745 const disposable = Disposable . fn ( )
@@ -465,16 +463,53 @@ suite('Experiments Tree Test Suite', () => {
465463 } )
466464
467465 it ( 'should be able to remove an experiment with dvc.views.experimentsTree.removeExperiment' , async ( ) => {
466+ const mockExperimentId = 'exp-to-remove'
467+ const mockExperiment = {
468+ dvcRoot : dvcDemoPath ,
469+ id : mockExperimentId ,
470+ type : ExperimentType . EXPERIMENT
471+ }
472+
473+ const mockExperimentRemove = stub (
474+ CliExecutor . prototype ,
475+ 'experimentRemove'
476+ ) . resolves ( '' )
477+
478+ stub (
479+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
480+ ( ExperimentsTree as any ) . prototype ,
481+ 'getSelectedExperimentItems'
482+ ) . returns ( [ mockExperiment ] )
483+
484+ await commands . executeCommand (
485+ RegisteredCommands . EXPERIMENT_TREE_REMOVE ,
486+ mockExperiment
487+ )
488+
489+ expect ( mockExperimentRemove ) . to . be . calledWithExactly (
490+ dvcDemoPath ,
491+ mockExperimentId
492+ )
493+ } )
494+
495+ it ( 'should be able to remove the provided experiment with dvc.views.experimentsTree.removeExperiment (if no experiments are selected)' , async ( ) => {
468496 const mockExperiment = 'exp-to-remove'
469497
470498 const mockExperimentRemove = stub (
471499 CliExecutor . prototype ,
472500 'experimentRemove'
473501 ) . resolves ( '' )
474502
503+ stub (
504+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
505+ ( ExperimentsTree as any ) . prototype ,
506+ 'getSelectedExperimentItems'
507+ ) . returns ( [ ] )
508+
475509 await commands . executeCommand ( RegisteredCommands . EXPERIMENT_TREE_REMOVE , {
476510 dvcRoot : dvcDemoPath ,
477- id : mockExperiment
511+ id : mockExperiment ,
512+ type : ExperimentType . EXPERIMENT
478513 } )
479514
480515 expect ( mockExperimentRemove ) . to . be . calledWithExactly (
@@ -483,6 +518,51 @@ suite('Experiments Tree Test Suite', () => {
483518 )
484519 } )
485520
521+ it ( 'should be able to remove multiple experiments with dvc.views.experimentsTree.removeExperiment' , async ( ) => {
522+ const mockExperimentId = 'exp-removed'
523+ const mockQueuedExperimentLabel = 'queued-removed'
524+
525+ const mockExperimentRemove = stub (
526+ CliExecutor . prototype ,
527+ 'experimentRemove'
528+ ) . resolves ( '' )
529+
530+ stub (
531+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
532+ ( ExperimentsTree as any ) . prototype ,
533+ 'getSelectedExperimentItems'
534+ ) . returns ( [
535+ dvcDemoPath ,
536+ {
537+ dvcRoot : dvcDemoPath ,
538+ label : mockQueuedExperimentLabel ,
539+ type : ExperimentType . QUEUED
540+ } ,
541+ {
542+ dvcRoot : dvcDemoPath ,
543+ id : 'checkpoint-excluded' ,
544+ type : ExperimentType . CHECKPOINT
545+ } ,
546+ {
547+ dvcRoot : dvcDemoPath ,
548+ id : 'workspace-excluded' ,
549+ type : ExperimentType . WORKSPACE
550+ }
551+ ] )
552+
553+ await commands . executeCommand ( RegisteredCommands . EXPERIMENT_TREE_REMOVE , {
554+ dvcRoot : dvcDemoPath ,
555+ id : mockExperimentId ,
556+ type : ExperimentType . EXPERIMENT
557+ } )
558+
559+ expect ( mockExperimentRemove ) . to . be . calledWithExactly (
560+ dvcDemoPath ,
561+ mockQueuedExperimentLabel ,
562+ mockExperimentId
563+ )
564+ } )
565+
486566 it ( 'should be able to apply an experiment to the workspace with dvc.views.experimentsTree.applyExperiment' , async ( ) => {
487567 const mockExperiment = 'exp-to-apply'
488568
0 commit comments