Skip to content

Commit

Permalink
Merge branch 'main' into webviewlocalization
Browse files Browse the repository at this point in the history
  • Loading branch information
likhithanimma1 authored Oct 11, 2024
2 parents 40cdaae + 67b0471 commit 9448f1c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ describe("ZoweDatasetNode Unit Tests", () => {
profile: profileOne,
});
jest.spyOn(zosfiles.List, "allMembers").mockRejectedValueOnce(new Error(subNode.label as string));
// Populate node with children from previous search to ensure they are removed
subNode.children = [
new ZoweDatasetNode({ label: "old", collapsibleState: vscode.TreeItemCollapsibleState.None, session, profile: profileOne }),
];
subNode.dirty = true;
const response = await subNode.getChildren();
expect(response).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Profiles } from "../../../../src/configuration/Profiles";
import { ZoweExplorerApiRegister } from "../../../../src/extending/ZoweExplorerApiRegister";
import { ZoweLocalStorage } from "../../../../src/tools/ZoweLocalStorage";
import { JobFSProvider } from "../../../../src/trees/job/JobFSProvider";
import { ZoweJobNode } from "../../../../src/trees/job/ZoweJobNode";
import { ZoweJobNode, ZoweSpoolNode } from "../../../../src/trees/job/ZoweJobNode";
import { SharedContext } from "../../../../src/trees/shared/SharedContext";
import { SharedTreeProviders } from "../../../../src/trees/shared/SharedTreeProviders";
import { JobInit } from "../../../../src/trees/job/JobInit";
Expand Down Expand Up @@ -392,6 +392,15 @@ describe("ZoweJobNode unit tests - Function getChildren", () => {
jest.spyOn(ZoweExplorerApiRegister, "getJesApi").mockReturnValueOnce({
getSpoolFiles: jest.fn().mockResolvedValue(new Error("Response Fail")),
} as any);
// Populate node with children from previous search to ensure they are removed
globalMocks.testJobNode.children = [
new ZoweSpoolNode({
label: "old",
collapsibleState: vscode.TreeItemCollapsibleState.None,
session: globalMocks.testSession,
profile: globalMocks.testProfile,
}),
];
globalMocks.testJobNode.dirty = true;
const spools = await globalMocks.testJobNode.getChildren();
expect(spools).toEqual([]);
Expand Down Expand Up @@ -442,6 +451,15 @@ describe("ZoweJobNode unit tests - Function getChildren", () => {
it("should return empty list if there is error retrieving jobs", async () => {
const globalMocks = await createGlobalMocks();
await globalMocks.testJobsProvider.addSession("fake");
// Populate node with children from previous search to ensure they are removed
globalMocks.testJobsProvider.mSessionNodes[1].children = [
new ZoweJobNode({
label: "old",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session: globalMocks.testSession,
profile: globalMocks.testProfile,
}),
];
globalMocks.testJobsProvider.mSessionNodes[1].filtered = true;
globalMocks.mockGetJobsByParameters.mockRejectedValue(new Error("Response Fail"));
jest.spyOn(ZoweExplorerApiRegister, "getJesApi").mockReturnValueOnce({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,7 @@ describe("USSTree Unit Tests - Function crossLparMove", () => {
profile: ussDirNode.getProfile(),
}),
];
ussDirNode.dirty = false;

const deleteMock = jest.spyOn(UssFSProvider.instance, "delete").mockResolvedValue(undefined);
const readFileMock = jest.spyOn(UssFSProvider.instance, "readFile").mockResolvedValue(new Uint8Array([1, 2, 3]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
createInstanceOfProfile,
createValidIProfile,
} from "../../../__mocks__/mockCreators/shared";
import { createUSSTree } from "../../../__mocks__/mockCreators/uss";
import { createUSSNode, createUSSTree } from "../../../__mocks__/mockCreators/uss";
import { Constants } from "../../../../src/configuration/Constants";
import { ZoweLocalStorage } from "../../../../src/tools/ZoweLocalStorage";
import { UssFSProvider } from "../../../../src/trees/uss/UssFSProvider";
Expand Down Expand Up @@ -846,6 +846,8 @@ describe("ZoweUSSNode Unit Tests - Function node.getChildren()", () => {
const globalMocks = createGlobalMocks();
const blockMocks = createBlockMocks(globalMocks);

// Populate node with children from previous search to ensure they are removed
blockMocks.childNode.children = [createUSSNode(globalMocks.session, globalMocks.profileOne)];
blockMocks.childNode.contextValue = Constants.USS_SESSION_CONTEXT;
blockMocks.childNode.fullPath = "Throw Error";
blockMocks.childNode.dirty = true;
Expand All @@ -854,7 +856,8 @@ describe("ZoweUSSNode Unit Tests - Function node.getChildren()", () => {
throw new Error("Throwing an error to check error handling for unit tests!");
});

await blockMocks.childNode.getChildren();
const response = await blockMocks.childNode.getChildren();
expect(response).toEqual([]);
expect(globalMocks.showErrorMessage.mock.calls.length).toEqual(1);
expect(globalMocks.showErrorMessage.mock.calls[0][0]).toEqual(
"Retrieving response from USS list API Error: Throwing an error to check error handling for unit tests!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
const cachedProfile = Profiles.getInstance().loadNamedProfile(this.getProfileName());
const responses = await this.getDatasets(cachedProfile);
if (responses == null) {
return this.children;
return [];
}

// push nodes to an object with property names to avoid duplicates
Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer/src/trees/job/ZoweJobNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class ZoweJobNode extends ZoweTreeNode implements IZoweJobTreeNode {
// Fetch spool files under job node
const spools = await this.getSpoolFiles(this.job);
if (spools == null) {
return this.children;
return [];
} else if (!spools.length) {
const noSpoolNode = new ZoweSpoolNode({
label: vscode.l10n.t("No spool files found"),
Expand Down Expand Up @@ -192,7 +192,7 @@ export class ZoweJobNode extends ZoweTreeNode implements IZoweJobTreeNode {
// Fetch jobs under session node
const jobs = await this.getJobs(this._owner, this._prefix, this._searchId, this._jobStatus);
if (jobs == null) {
return this.children;
return [];
} else if (jobs.length === 0) {
const noJobsNode = new ZoweJobNode({
label: vscode.l10n.t("No jobs found"),
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/trees/uss/ZoweUSSNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class ZoweUSSNode extends ZoweTreeNode implements IZoweUSSTreeNode {
const cachedProfile = Profiles.getInstance().loadNamedProfile(this.getProfileName());
const response = await this.getUssFiles(cachedProfile);
if (!response.success) {
return this.children;
return [];
}

// If search path has changed, invalidate all children
Expand Down

0 comments on commit 9448f1c

Please sign in to comment.