Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open Favorited Job Search #2930

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

### Bug fixes

- To add the ability to open a Favorited Job Search under Favorites [#2630](https://github.com/zowe/zowe-explorer-vscode/pull/2930)

## `2.16.0`

### New features and enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as vscode from "vscode";
import * as zowe from "@zowe/cli";
import * as globals from "../../../src/globals";
import * as utils from "../../../src/utils/ProfilesUtils";
import { Gui, IZoweJobTreeNode, ProfilesCache, ValidProfileEnum } from "@zowe/zowe-explorer-api";
import { Gui, IZoweJobTreeNode, ProfilesCache, ValidProfileEnum, JobSortOpts, SortDirection } from "@zowe/zowe-explorer-api";
import { createIJobFile, createIJobObject, createJobFavoritesNode, createJobSessionNode, MockJobDetail } from "../../../__mocks__/mockCreators/jobs";
import { ZoweJobNode, ZoweSpoolNode } from "../../../src/job/ZoweJobNode";
import { ZoweExplorerApiRegister } from "../../../src/ZoweExplorerApiRegister";
Expand Down Expand Up @@ -378,10 +378,9 @@ describe("ZosJobsProvider unit tests - Function initializeFavChildNodeForProfile
favProfileNode.contextValue = globals.FAV_PROFILE_CONTEXT;
const node = new ZoweJobNode({
label: "Owner:USER Prefix:*",
collapsibleState: vscode.TreeItemCollapsibleState.None,
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode: favProfileNode,
});
node.command = { command: "zowe.jobs.search", title: "", arguments: [node] };
node.contextValue = globals.JOBS_SESSION_CONTEXT + globals.FAV_SUFFIX;
const targetIcon = getIconByNode(node);
if (targetIcon) {
Expand Down Expand Up @@ -418,7 +417,6 @@ describe("ZosJobsProvider unit tests - Function initializeFavChildNodeForProfile
if (targetIcon) {
node.iconPath = targetIcon.path;
}
// node.command = undefined;

const favChildNodeForProfile = await testTree.initializeFavChildNodeForProfile("testJob(JOB123)", globals.JOBS_JOB_CONTEXT, favProfileNode);

Expand All @@ -442,6 +440,30 @@ describe("ZosJobsProvider unit tests - Function initializeFavChildNodeForProfile
expect(favChildNodeForProfile.label).toEqual("testJob(JOB456)");
expect(favChildNodeForProfile.command).toBeUndefined();
});

it("To set proper values to node to display jobs when clicked on favorited job search label", async () => {
await createGlobalMocks();
const blockMocks = createBlockMocks();
const testTree = new ZosJobsProvider();

const favProfileNode = new ZoweJobNode({
label: "testProfile",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode: blockMocks.jobFavoritesNode,
});
favProfileNode.contextValue = globals.FAV_PROFILE_CONTEXT;

const favChildNodeForProfile = await testTree.initializeFavChildNodeForProfile(
"Owner: testUser | Prefix: * | Status: *",
globals.JOBS_JOB_CONTEXT,
favProfileNode
);

expect(favChildNodeForProfile.label).toEqual("Owner: testUser | Prefix: * | Status: *");
expect(favChildNodeForProfile.command).toBeUndefined();
expect(favChildNodeForProfile.collapsibleState).not.toEqual(vscode.TreeItemCollapsibleState.None);
expect(favChildNodeForProfile.sort).toEqual({ method: JobSortOpts.Id, direction: SortDirection.Ascending });
});
});

describe("ZosJobsProvider unit tests - Function loadProfilesForFavorites", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,24 @@ describe("ZoweJobNode unit tests - Function addFavorite", () => {
expect(profileNodeInFavs.children[0].label).toEqual("Owner: myHLQ | Prefix: * | Status: *");
expect(profileNodeInFavs.children[0].contextValue).toEqual(globals.JOBS_SESSION_CONTEXT + globals.FAV_SUFFIX);
});

it("Tests that addFavorite correctly sets properties when favorites a search", async () => {
const globalMocks = await createGlobalMocks();
await createBlockMocks(globalMocks);
globalMocks.testJobsProvider.mFavorites = [];
globalMocks.testJobsProvider.mSessionNodes[1].owner = "testUser";
globalMocks.testJobsProvider.mSessionNodes[1].prefix = "*";
globalMocks.testJobsProvider.mSessionNodes[1].contextValue = globals.JOBS_SESSION_CONTEXT;

await globalMocks.testJobsProvider.addFavorite(globalMocks.testJobsProvider.mSessionNodes[1]);
const profileNodeInFavs: IZoweJobTreeNode = globalMocks.testJobsProvider.mFavorites[0];

expect(profileNodeInFavs.children.length).toEqual(1);
expect(profileNodeInFavs.children[0].label).toEqual("Owner: testUser | Prefix: * | Status: *");
expect(profileNodeInFavs.children[0].sort).toEqual({ method: JobSortOpts.Id, direction: SortDirection.Ascending });
expect(profileNodeInFavs.children[0].collapsibleState).not.toEqual(vscode.TreeItemCollapsibleState.None);
expect(profileNodeInFavs.children[0].contextValue).toEqual(globals.JOBS_SESSION_CONTEXT + globals.FAV_SUFFIX);
});
});

describe("ZoweJobNode unit tests - Function removeFavorite", () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/zowe-explorer/src/job/ZosJobsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,9 @@ export class ZosJobsProvider extends ZoweTreeProvider implements IZoweTree<IZowe
// for search
favJob = new ZoweJobNode({
label,
collapsibleState: vscode.TreeItemCollapsibleState.None,
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode,
});
favJob.command = { command: "zowe.jobs.search", title: "", arguments: [favJob] };
favJob.contextValue = globals.JOBS_SESSION_CONTEXT + globals.FAV_SUFFIX;
}
const icon = getIconByNode(favJob);
Expand Down Expand Up @@ -513,14 +512,13 @@ export class ZosJobsProvider extends ZoweTreeProvider implements IZoweTree<IZowe
// Favorite a search/session
favJob = new ZoweJobNode({
label: this.createSearchLabel(node.owner, node.prefix, node.searchId, node.status),
collapsibleState: vscode.TreeItemCollapsibleState.None,
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode: profileNodeInFavorites,
session: node.getSession(),
profile: node.getProfile(),
job: node.job,
});
favJob.contextValue = globals.JOBS_SESSION_CONTEXT + globals.FAV_SUFFIX;
favJob.command = { command: "zowe.jobs.search", title: "", arguments: [favJob] };
this.saveSearch(favJob);
} else {
// Favorite a job
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/job/ZoweJobNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
export class ZoweJobNode extends ZoweTreeNode implements IZoweJobTreeNode {
public children: IZoweJobTreeNode[] = [];
public dirty = true;
public sort: NodeSort;
public sort: NodeSort = { method: JobSortOpts.Id, direction: SortDirection.Ascending };
private _owner: string;
private _prefix: string;
private _searchId: string;
Expand Down
Loading