Skip to content

Commit

Permalink
Fix cancelling MVS/TSO command causing error (#3440) (#3465)
Browse files Browse the repository at this point in the history
* Fix #3422



chore: changelog



Fix failing tests

This is due to adding a new message box to say that operation was cancelled, and tests were still expecting no message



* Fix that integrated terminals were not opening



---------

Signed-off-by: JWaters02 <[email protected]>
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Co-authored-by: Fernando Rijo Cedeno <[email protected]>
Co-authored-by: Billie Simmons <[email protected]>
  • Loading branch information
3 people authored Feb 18, 2025
1 parent 7a6bdb2 commit 94e87a5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
Expand All @@ -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 });
Expand Down
4 changes: 4 additions & 0 deletions packages/zowe-explorer/src/commands/ZoweCommandProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 94e87a5

Please sign in to comment.