diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 3498c2a626..2244d852ff 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### Bug fixes - Fixed an issue where a TypeError occurred when applying VS Code proxy settings to an invalid session. [#3425](https://github.com/zowe/zowe-explorer-vscode/issues/3425) +- Fixed an issue where cancelling Unix, MVS or TSO command still submits the command. [#3422](https://github.com/zowe/zowe-explorer-vscode/issues/3422) - Fixed a bug where edit history does not show the correct information. [#3432](https://github.com/zowe/zowe-explorer-vscode/issues/3432) ## `3.1.0` diff --git a/packages/zowe-explorer/__tests__/__unit__/commands/MvsCommandHandler.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/commands/MvsCommandHandler.unit.test.ts index 25b09ae5b0..f843e6216a 100644 --- a/packages/zowe-explorer/__tests__/__unit__/commands/MvsCommandHandler.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/commands/MvsCommandHandler.unit.test.ts @@ -332,7 +332,7 @@ describe("mvsCommandActions unit testing", () => { ignoreFocusOut: true, placeHolder: "Select the profile to use to submit the MVS command", }); - expect(showInformationMessage.mock.calls.length).toBe(0); + expect(showInformationMessage.mock.calls.length).toBe(1); }); it("tests the issueMvsCommand function user escapes the MVS command box", async () => { @@ -371,7 +371,7 @@ describe("mvsCommandActions unit testing", () => { placeHolder: "Select the profile to use to submit the MVS command", }); expect(showInputBox.mock.calls.length).toBe(1); - expect(showInformationMessage.mock.calls.length).toBe(0); + expect(showInformationMessage.mock.calls.length).toBe(1); }); it("tests the issueMvsCommand function user starts typing a value in quick pick", async () => { diff --git a/packages/zowe-explorer/__tests__/__unit__/commands/TsoCommandHandler.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/commands/TsoCommandHandler.unit.test.ts index 53e9fd831a..b7992d178b 100644 --- a/packages/zowe-explorer/__tests__/__unit__/commands/TsoCommandHandler.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/commands/TsoCommandHandler.unit.test.ts @@ -371,7 +371,7 @@ describe("TsoCommandHandler unit testing", () => { placeHolder: "Select the profile to use to submit the TSO command", }); expect(showInputBox.mock.calls.length).toBe(1); - expect(showInformationMessage.mock.calls.length).toBe(0); + expect(showInformationMessage.mock.calls.length).toBe(1); }); it("tests the issueTsoCommand function user starts typing a value in quick pick", async () => { diff --git a/packages/zowe-explorer/__tests__/__unit__/commands/UnixCommandHandler.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/commands/UnixCommandHandler.unit.test.ts index 367f4e581d..0d0f68ebea 100644 --- a/packages/zowe-explorer/__tests__/__unit__/commands/UnixCommandHandler.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/commands/UnixCommandHandler.unit.test.ts @@ -359,7 +359,7 @@ describe("UnixCommand Actions Unit Testing", () => { placeHolder: "Select the profile to use to submit the Unix command", }); expect(showInputBox.mock.calls.length).toBe(1); - expect(showInformationMessage.mock.calls.length).toBe(0); + expect(showInformationMessage.mock.calls.length).toBe(1); }); it("tests the issueUnixCommand function user escapes the commandbox", async () => { @@ -389,7 +389,7 @@ describe("UnixCommand Actions Unit Testing", () => { placeHolder: "Select the profile to use to submit the Unix command", }); expect(showInputBox.mock.calls.length).toBe(2); - expect(showInformationMessage.mock.calls.length).toBe(0); + expect(showInformationMessage.mock.calls.length).toBe(1); }); it("tests the issueUnixCommand function - issueUnixCommand throws an error", async () => { diff --git a/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts index 7dc9bda8bc..8ac54504d5 100644 --- a/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/commands/ZoweCommandProvider.unit.test.ts @@ -109,6 +109,8 @@ describe("ZoweCommandProvider Unit Tests", () => { runCommand: jest.fn().mockRejectedValue(testError), }; const testProfile: any = { name: "test", profile: { user: "firstName", password: "12345" } }; + const showInformationMessage = jest.fn(); + Object.defineProperty(vscode.window, "showInformationMessage", { value: showInformationMessage }); it("should not create a terminal if the profile or the command is undefined", async () => { const createTerminal = jest.fn().mockReturnValue({ show: jest.fn() }); @@ -120,6 +122,17 @@ describe("ZoweCommandProvider Unit Tests", () => { expect(createTerminal).not.toHaveBeenCalled(); }); + it("should not create a terminal if user escapes the input box and useIntegratedTerminals is false", async () => { + jest.spyOn(SettingsConfig, "getDirectValue").mockImplementation( + (setting) => setting !== Constants.SETTINGS_COMMANDS_INTEGRATED_TERMINALS + ); + const createTerminal = jest.fn().mockReturnValue({ show: jest.fn() }); + Object.defineProperty(vscode.window, "createTerminal", { value: createTerminal, configurable: true }); + await ZoweCommandProvider.prototype.issueCommand.call(mockCmdProvider, testProfile, ""); + expect(createTerminal).not.toHaveBeenCalled(); + expect(showInformationMessage.mock.calls.length).toBe(1); + }); + it("should create an integrated terminal", async () => { const createTerminal = jest.fn().mockReturnValue({ show: jest.fn() }); Object.defineProperty(vscode.window, "createTerminal", { value: createTerminal, configurable: true }); diff --git a/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts b/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts index e43ab75fa8..279cfb8901 100644 --- a/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts +++ b/packages/zowe-explorer/src/commands/ZoweCommandProvider.ts @@ -125,6 +125,10 @@ export abstract class ZoweCommandProvider { this.terminal = vscode.window.createTerminal({ name: `(${profile.name}) ${this.terminalName}`, pty: this.pseudoTerminal }); this.terminal.show(); } else { + if (command.length === 0) { + Gui.showMessage(this.operationCancelled); + return; + } this.outputChannel ??= Gui.createOutputChannel(this.terminalName); this.outputChannel.appendLine(this.formatCommandLine(command, profile)); const response = await Gui.withProgress(