Skip to content

Commit

Permalink
Merge branch 'main' into feat/cfg/update-schema
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Dec 11, 2023
2 parents 7b5627f + 82082c4 commit d32a273
Show file tree
Hide file tree
Showing 49 changed files with 897 additions and 393 deletions.
3 changes: 3 additions & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
### New features and enhancements

- Added new optional boolean parameter `hideFromAllTrees` to `IZoweTree.deleteSession` for specifying whether to hide from all trees or current tree. [#2567](https://github.com/zowe/vscode-extension-for-zowe/issues/2567)
- Added new optional parameter `provider` of type `IZoweTree<IZoweTreeNode>` for `IZoweTree.addSession` to specify a tree to add the profile to.
- Added optional `filter` and `actualJobs` variables to `IZoweJobTreeNode` to track local filter search.
- Added new optional record `openFiles` to `IZoweTree` to track opened files under a specific tree view. [#2597](https://github.com/zowe/vscode-extension-for-zowe/issues/2597)

### Bug fixes

Expand Down
21 changes: 20 additions & 1 deletion packages/zowe-explorer-api/src/tree/IZoweTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import * as vscode from "vscode";
import { imperative } from "@zowe/cli";
import { IZoweTreeNode } from "./IZoweTreeNode";
import { DataSetAllocTemplate, PersistenceSchemaEnum } from "../profiles/UserSettings";

Expand Down Expand Up @@ -59,18 +60,36 @@ export interface IZoweTree<T> extends vscode.TreeDataProvider<T> {
*/
copying?: Promise<unknown>;

/**
* A record of open files from this tree.
*/
openFiles?: Record<string, IZoweTreeNode>;

/**
* Adds a session to the container
* @param sessionName
* @param type e.g. zosmf
* @param provider tree provider to add to, undefined will add for all
*/
addSession(sessionName?: string, type?: string, provider?: IZoweTree<IZoweTreeNode>): Promise<void>;

/**
* Adds a single session to the tree
* @param profile the profile to add to the tree
*/
addSession(sessionName?: string, type?: string): Promise<void>;
addSingleSession(profile: imperative.IProfileLoaded): Promise<void>;

/**
* Edit a session to the container
* @param node This parameter identifies the node that needs to be called
*/
editSession(node: IZoweTreeNode, zoweFileProvider: IZoweTree<IZoweTreeNode>): Promise<void>;

/**
* Get sessions from persistent object of provider
*/
getSessions(): string[];

/**
* Add a new session to the container
* @param zoweFileProvider The tree to which the profile should be added
Expand Down
8 changes: 8 additions & 0 deletions packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ export interface IZoweJobTreeNode extends IZoweTreeNode {
* Returns whether the job node is a filtered search
*/
filtered?: boolean;
/**
* Filter method for this job search
*/
filter?: string;
/**
* Array of original filter search results job's children
*/
actualJobs?: IZoweTreeNode[];
/**
* Retrieves child nodes of this IZoweJobTreeNode
*
Expand Down
6 changes: 5 additions & 1 deletion packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Added support for hiding a Zowe profile across all trees [#2567](https://github.com/zowe/vscode-extension-for-zowe/issues/2567)
- Added support for enabling/disabling validation for a Zowe profile across all trees [#2570](https://github.com/zowe/vscode-extension-for-zowe/issues/2570)
- Added Display confirmation dialog when submitting local JCL. [#2061](https://github.com/zowe/vscode-extension-for-zowe/issues/2061)
- Added support for adding a Zowe profile across all trees [#2603](https://github.com/zowe/vscode-extension-for-zowe/issues/2603)
- Added "Filter Jobs" feature in Jobs tree view: accessible via filter icon or right-clicking on session node. [#2599](https://github.com/zowe/vscode-extension-for-zowe/issues/2599)

### Bug fixes

- Fixed dataset allocation issue when secondary space (or other numeric values that did not exists in the dataset-template) where specified [#2591](https://github.com/zowe/vscode-extension-for-zowe/issues/2591)
- Fixed issue where an opened USS file or data set could not be saved once a user changes their search pattern in the Side Bar. [#2597](https://github.com/zowe/vscode-extension-for-zowe/issues/2597)

## `2.12.2`

### Bug fixes
Expand All @@ -34,7 +39,6 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

### New features and enhancements

- Added "Sort Jobs" feature in Jobs tree view: accessible via sort icon or right-clicking on session node. [#2257](https://github.com/zowe/vscode-extension-for-zowe/issues/2257)
- Introduce a new user interface for managing profiles via right-click action "Manage Profile".
- Added new edit feature on `Edit Attributes` view for changing file tags on USS. [#2113](https://github.com/zowe/vscode-extension-for-zowe/issues/2113)
- Added new API {ZE Extender MetaData} to allow extenders to have the metadata of registered extenders to aid in team configuration file creation from a view that isn't Zowe Explorer's. [#2394](https://github.com/zowe/vscode-extension-for-zowe/issues/2394)
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/__mocks__/mockCreators/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function createJobsTree(session: imperative.Session, iJob: IJob, profile:
getSession: jest.fn(),
delete: jest.fn(),
setItem: jest.fn(),
openFiles: {},
};
testJobsTree.mSessionNodes = [];
testJobsTree.mSessionNodes.push(jobNode);
Expand Down
9 changes: 7 additions & 2 deletions packages/zowe-explorer/__mocks__/mockCreators/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ export function createTreeView(selection?): vscode.TreeView<ZoweTreeProvider> {
visible: true,
onDidChangeVisibility: jest.fn(),
dispose: jest.fn(),
addSingleSession: jest.fn(),
} as unknown as vscode.TreeView<ZoweTreeProvider>;
}

export function createTextDocument(name: string, sessionNode?: ZoweDatasetNode | ZoweUSSNode): vscode.TextDocument {
const fileName = sessionNode ? `/${sessionNode.label}/${name}` : name;
return {
fileName: sessionNode ? `/${sessionNode.label}/${name}` : name,
uri: null,
fileName,
uri: vscode.Uri.parse(fileName),
isUntitled: null,
languageId: null,
version: null,
Expand Down Expand Up @@ -594,6 +596,7 @@ export function createTreeProviders() {
deleteSession: jest.fn(),
removeSession: jest.fn(),
refresh: jest.fn(),
addSingleSession: jest.fn(),
} as any,
uss: {
mSessionNodes: [
Expand All @@ -603,6 +606,7 @@ export function createTreeProviders() {
deleteSession: jest.fn(),
removeSession: jest.fn(),
refresh: jest.fn(),
addSingleSession: jest.fn(),
} as any,
job: {
mSessionNodes: [
Expand All @@ -612,6 +616,7 @@ export function createTreeProviders() {
removeSession: jest.fn(),
deleteSession: jest.fn(),
refresh: jest.fn(),
addSingleSession: jest.fn(),
} as any,
};
}
5 changes: 5 additions & 0 deletions packages/zowe-explorer/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ export namespace window {
return Promise.resolve("");
}

export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): any {
return undefined;
}

export function showErrorMessage(message: string, ...items: string[]): undefined {
return undefined;
}
Expand Down Expand Up @@ -584,6 +588,7 @@ export class EventEmitter<T> {
*/
export namespace workspace {
export function onDidSaveTextDocument<T>(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]) {}
export function onDidCloseTextDocument<T>(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]) {}

export function getConfiguration(configuration: string) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describe("Extension Integration Tests", async () => {
it("should display an error message when openPS is passed an invalid node", async () => {
const node = new ZoweDatasetNode(pattern + ".GARBAGE", vscode.TreeItemCollapsibleState.None, sessionNode, null);
const errorMessageStub = sandbox.spy(vscode.window, "showErrorMessage");
await expect(dsActions.openPS(node, true)).to.eventually.be.rejectedWith(Error);
await expect(dsActions.openPS(node, true, testTree)).to.eventually.be.rejectedWith(Error);

const called = errorMessageStub.called;
expect(called).to.equal(true);
Expand All @@ -346,7 +346,7 @@ describe("Extension Integration Tests", async () => {
profiles[1].dirty = true;
const children = await profiles[1].getChildren();
children[1].dirty = true;
await dsActions.openPS(children[1], true);
await dsActions.openPS(children[1], true, testTree);

const changedData = "PS Upload Test";

Expand All @@ -359,7 +359,7 @@ describe("Extension Integration Tests", async () => {
await dsActions.saveFile(doc, testTree);

// Download file
await dsActions.openPS(children[1], true);
await dsActions.openPS(children[1], true, testTree);

expect(doc.getText().trim()).to.deep.equal("PS Upload Test");

Expand All @@ -377,7 +377,7 @@ describe("Extension Integration Tests", async () => {

// Test for member under PO
const childrenMembers = await testTree.getChildren(children[0]);
await dsActions.openPS(childrenMembers[0], true);
await dsActions.openPS(childrenMembers[0], true, testTree);

const changedData2 = "PO Member Upload Test";

Expand All @@ -393,7 +393,7 @@ describe("Extension Integration Tests", async () => {
await dsActions.saveFile(doc2, testTree);

// Download file
await dsActions.openPS(childrenMembers[0], true);
await dsActions.openPS(childrenMembers[0], true, testTree);

expect(doc2.getText().trim()).to.deep.equal("PO Member Upload Test");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ export async function addProfileDetails(profileName: string) {
await driverChrome.sleep(SHORTSLEEPTIME);
const responseTimeout = await driverChrome.findElement(By.xpath(DatasetsLocators.emptyInputBoxXpath));
responseTimeout.sendKeys(Key.ENTER);
await driverChrome.sleep(SHORTSLEEPTIME);
const addToAllTrees = await driverChrome.findElement(By.xpath(DatasetsLocators.emptyInputBoxXpath));
addToAllTrees.sendKeys("No");
addToAllTrees.sendKeys(Key.ENTER);
}
export async function clickOnDatasetsPanel() {
await driverChrome.findElement(By.id(DatasetsLocators.datasetsPanelId)).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Builder, By, Key, until } from "selenium-webdriver";
import * as firefox from "selenium-webdriver/firefox";
import { TheiaLocator, DatasetsLocators, UssLocators, JobsLocators } from "./Locators";

const SHORTSLEEPTIME = 2000;
const WAITTIME = 30000;
let driverFirefox: any;

Expand Down Expand Up @@ -72,6 +73,10 @@ export async function addProfileDetailsInUss(profileName: string) {
const ussProfileName = await driverFirefox.findElement(By.xpath(UssLocators.emptyInputBoxXpath));
ussProfileName.sendKeys(profileName);
ussProfileName.sendKeys(Key.ENTER);
await driverFirefox.sleep(SHORTSLEEPTIME);
const addToAllTrees = await driverFirefox.findElement(By.xpath(JobsLocators.emptyInputBoxXpath));
addToAllTrees.sendKeys("No");
addToAllTrees.sendKeys(Key.ENTER);
}

export async function addProfileDetailsInJobs(profileName: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import * as path from "path";
import { SettingsConfig } from "../../src/utils/SettingsConfig";
import { ZoweLogger } from "../../src/utils/LoggerUtils";
import { TreeProviders } from "../../src/shared/TreeProviders";
import { ProfileManagement } from "../../src/utils/ProfileManagement";

jest.mock("child_process");
jest.mock("fs");
Expand Down Expand Up @@ -573,18 +574,41 @@ describe("Profiles Unit Tests - Function createZoweSession", () => {
hide: jest.fn(),
value: "test",
} as any);
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce(new utils.FilterDescriptor("Test"));
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce(new utils.FilterDescriptor("Test1"));
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce(new utils.FilterDescriptor("Test2"));
jest.spyOn(Profiles.getInstance(), "getProfileInfo").mockResolvedValue({
usingTeamConfig: false,
} as any);
jest.spyOn(Gui, "showInputBox").mockResolvedValue("test");
jest.spyOn(Profiles.getInstance(), "createNewConnection").mockResolvedValue("Test");
const refreshSpy = jest.spyOn(Profiles.getInstance(), "refresh").mockImplementation();
jest.spyOn(ProfileManagement, "handleChangeForAllTrees").mockResolvedValue(true);
jest.spyOn(TreeProviders, "providers", "get").mockReturnValue({
ds: { addSingleSession: jest.fn(), mSessionNodes: [...globalMocks.testUSSTree.mSessionNodes], refresh: jest.fn() } as any,
uss: { addSingleSession: jest.fn(), mSessionNodes: [...globalMocks.testUSSTree.mSessionNodes], refresh: jest.fn() } as any,
jobs: { addSingleSession: jest.fn(), mSessionNodes: [...globalMocks.testUSSTree.mSessionNodes], refresh: jest.fn() } as any,
} as any);
await expect(Profiles.getInstance().createZoweSession(globalMocks.testUSSTree)).resolves.not.toThrow();
expect(refreshSpy).toBeCalledTimes(1);
expect(spyInfo).toBeCalledWith("New profile created, test.");
refreshSpy.mockClear();
spyInfo.mockClear();
jest.spyOn(Gui, "resolveQuickPick").mockReset();
});

it("Tests that createZoweSession runs successfully and uses the chosenProfile", async () => {
const globalMocks = await createGlobalMocks();
jest.spyOn(Gui, "createQuickPick").mockReturnValue({
show: jest.fn(),
hide: jest.fn(),
value: "test",
} as any);
jest.spyOn(Gui, "resolveQuickPick").mockResolvedValueOnce({ label: "test" });
const spyInfo = jest.spyOn(ZoweLogger, "info");
jest.spyOn(ProfileManagement, "handleChangeForAllTrees").mockResolvedValue(true);
await expect(Profiles.getInstance().createZoweSession(globalMocks.testUSSTree)).resolves.not.toThrow();
expect(spyInfo).toBeCalledWith("The profile test has been added to the zowe.uss.history tree.");
spyInfo.mockClear();
});

it("Tests that createZoweSession catches error and log warning", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import { SettingsConfig } from "../../../src/utils/SettingsConfig";
import { ZoweTreeProvider } from "../../../src/abstract/ZoweTreeProvider";
import { ZoweLogger } from "../../../src/utils/LoggerUtils";
import { createDatasetSessionNode } from "../../../__mocks__/mockCreators/datasets";
import { TreeProviders } from "../../../src/shared/TreeProviders";
import { createDatasetTree } from "../../../src/dataset/DatasetTree";
import * as sharedActions from "../../../src/shared/actions";

async function createGlobalMocks() {
const globalMocks = {
Expand All @@ -49,6 +52,7 @@ async function createGlobalMocks() {
testSession: createISession(),
testResponse: createFileResponse({ items: [] }),
testUSSTree: null,
testDSTree: null,
testUSSNode: null,
testSessionNode: null,
testTreeProvider: new ZoweTreeProvider(PersistenceSchemaEnum.USS, null),
Expand Down Expand Up @@ -191,13 +195,29 @@ describe("ZoweJobNode unit tests - Function editSession", () => {
it("Tests that editSession is executed successfully ", async () => {
const globalMocks = await createGlobalMocks();
const blockMocks = await createBlockMocks(globalMocks);
const checkSession = jest.spyOn(blockMocks.testJobsProvider, "editSession");
const spy = jest.spyOn(ZoweLogger, "trace");
await blockMocks.testJobsProvider.editSession(blockMocks.jobNode, globalMocks.testUSSTree);
expect(globalMocks.mockEditSession).toHaveBeenCalled();
expect(spy).toBeCalled();
spy.mockClear();
});
it("Tests that the session is edited and added to only the specific tree modified", async () => {
const globalMocks = await createGlobalMocks();
const blockMocks = await createBlockMocks(globalMocks);
const deleteSessionForProviderSpy = jest.spyOn(ZoweTreeProvider.prototype as any, "deleteSessionForProvider");
const mockJobProvider = {
addSingleSession: jest.fn(),
mSessionNodes: [blockMocks.jobNode],
refresh: jest.fn(),
removeSession: jest.fn(),
} as any;
jest.spyOn(TreeProviders, "providers", "get").mockReturnValue({ job: mockJobProvider } as any);
jest.spyOn(blockMocks.jobNode, "getSession").mockReturnValue(null);
blockMocks.jobNode.contextValue = globals.JOBS_SESSION_CONTEXT;
await blockMocks.testJobsProvider.editSession(blockMocks.jobNode, globalMocks.testUSSTree);
expect(globalMocks.mockEditSession).toHaveBeenCalled();
expect(deleteSessionForProviderSpy).toBeCalledWith(blockMocks.jobNode, mockJobProvider);
});
});

describe("Tree Provider unit tests, function getTreeItem", () => {
Expand Down Expand Up @@ -510,3 +530,26 @@ describe("Tree Provider Unit Tests - function ssoLogout", () => {
expect(blockMocks.executeCommandSpy).not.toHaveBeenCalledWith("zowe.ds.refreshAll");
});
});

describe("Tree Provider Unit Tests - function loadProfileByPersistedProfile", () => {
it("should reset validation settings and warn the user of an error when loading default", async () => {
const globalMocks = await createGlobalMocks();
globalMocks.testDSTree = createDatasetTree(imperative.Logger.getAppLogger());
globalMocks.testDSTree.mSessionNodes = [
{ label: "profile1", getProfileName: (): string => "sestest" },
{ label: "profile2", getProfileName: (): string => "sestest" },
];
globalMocks.testDSTree.getSessions = (): string[] => ["sestest"];
globalMocks.testDSTree.addSingleSession = jest.fn();

const resetValidationSettingsSpy = jest.spyOn(sharedActions, "resetValidationSettings");
resetValidationSettingsSpy.mockImplementation();

const zoweLoggerWarnSpy = jest.spyOn(ZoweLogger, "warn");

await expect(ZoweTreeProvider.prototype["loadProfileByPersistedProfile"](globalMocks.testDSTree, "zosmf", true)).resolves.not.toThrow();
expect(globalMocks.testDSTree.addSingleSession).toBeCalledTimes(1);
expect(resetValidationSettingsSpy).toBeCalledTimes(2);
expect(zoweLoggerWarnSpy).toBeCalledTimes(2);
});
});
Loading

0 comments on commit d32a273

Please sign in to comment.