diff --git a/extension/src/cli/runner.ts b/extension/src/cli/runner.ts index 12a1f622a2..7220657c7b 100644 --- a/extension/src/cli/runner.ts +++ b/extension/src/cli/runner.ts @@ -108,8 +108,8 @@ export class CliRunner extends Disposable implements ICli { ) } - public runExperimentReset(dvcRoot: string) { - return this.runExperiment(dvcRoot, ExperimentFlag.RESET) + public runExperimentReset(dvcRoot: string, ...args: Args) { + return this.runExperiment(dvcRoot, ExperimentFlag.RESET, ...args) } public runExperimentQueue(dvcRoot: string) { diff --git a/extension/src/experiments/index.ts b/extension/src/experiments/index.ts index e235fc2564..b84a6850f6 100644 --- a/extension/src/experiments/index.ts +++ b/extension/src/experiments/index.ts @@ -24,6 +24,7 @@ import { CommandId, InternalCommands } from '../commands/internal' +import { Args } from '../cli/constants' import { ExperimentsOutput } from '../cli/reader' import { ViewKey } from '../webview/constants' import { BaseRepository } from '../webview/repository' @@ -420,7 +421,7 @@ export class Experiments extends BaseRepository { ) } - private async runCommand(commandId: CommandId, ...args: string[]) { + private async runCommand(commandId: CommandId, ...args: Args) { await Toast.showOutput( this.internalCommands.executeCommand(commandId, this.dvcRoot, ...args) ) diff --git a/extension/src/experiments/workspace.ts b/extension/src/experiments/workspace.ts index a8999f3c09..18f35c9843 100644 --- a/extension/src/experiments/workspace.ts +++ b/extension/src/experiments/workspace.ts @@ -1,6 +1,7 @@ import { EventEmitter, Memento } from 'vscode' import { Experiments } from '.' import { TableData } from './webview/contract' +import { Args } from '../cli/constants' import { CommandId, InternalCommands } from '../commands/internal' import { ResourceLocator } from '../resourceLocator' import { Toast } from '../vscode/toast' @@ -209,7 +210,7 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews< commandId: CommandId, cwd: string, title: Title, - ...args: string[] + ...args: Args ) { const input = await getInput(title) if (input) { @@ -217,7 +218,7 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews< } } - public runCommand(commandId: CommandId, cwd: string, ...args: string[]) { + public runCommand(commandId: CommandId, cwd: string, ...args: Args) { return Toast.showOutput( this.internalCommands.executeCommand(commandId, cwd, ...args) ) diff --git a/extension/src/test/suite/experiments/index.test.ts b/extension/src/test/suite/experiments/index.test.ts index 64f315cff4..7692208fae 100644 --- a/extension/src/test/suite/experiments/index.test.ts +++ b/extension/src/test/suite/experiments/index.test.ts @@ -60,6 +60,7 @@ import * as Telemetry from '../../../telemetry' import { EventName } from '../../../telemetry/constants' import * as VscodeContext from '../../../vscode/context' import { Title } from '../../../vscode/title' +import { ExperimentFlag } from '../../../cli/constants' suite('Experiments Test Suite', () => { const disposable = Disposable.fn() @@ -549,8 +550,10 @@ suite('Experiments Test Suite', () => { }) it("should be able to handle a message to modify an experiment's params reset and run a new experiment", async () => { - const { experiments, mockExecuteCommand } = - setupExperimentsAndMockCommands() + const { experiments, cliRunner } = buildExperiments( + disposable, + expShowFixture + ) const mockModifiedParams = [ '-S', @@ -560,6 +563,9 @@ suite('Experiments Test Suite', () => { ] stub(experiments, 'pickAndModifyParams').resolves(mockModifiedParams) + const mockRunExperiment = stub(cliRunner, 'runExperiment').resolves( + undefined + ) const webview = await experiments.showWebview() const mockMessageReceived = getMessageReceivedEmitter(webview) @@ -572,10 +578,10 @@ suite('Experiments Test Suite', () => { }) await tableChangePromise - expect(mockExecuteCommand).to.be.calledOnce - expect(mockExecuteCommand).to.be.calledWithExactly( - AvailableCommands.EXPERIMENT_RESET_AND_RUN, + expect(mockRunExperiment).to.be.calledOnce + expect(mockRunExperiment).to.be.calledWithExactly( dvcDemoPath, + ExperimentFlag.RESET, ...mockModifiedParams ) })