Skip to content

Commit

Permalink
Merge branch 'main' into fix/refresh-attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
JillieBeanSim authored Mar 3, 2025
2 parents 4afa98b + a05967b commit fe475db
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Fixed issue where deleting too many nodes at once would cause the confirmation prompt to be oversized. [#3254](https://github.com/zowe/zowe-explorer-vscode/issues/3254)
- Fixed an issue with UNIX file edit attributes refresh button not updating/reverting values correctly. [#3238](https://github.com/zowe/zowe-explorer-vscode/issues/3238)
- Fixed an issue where selecting items in table views would reset the column sort order. [#3473](https://github.com/zowe/zowe-explorer-vscode/issues/3473)
- Fixed an issue where data set migration status was incorrectly handled when the `migr` attribute was not present in the API response. [#3471](https://github.com/zowe/zowe-explorer-vscode/issues/3471)

## `3.1.1`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { DatasetFSProvider } from "../../../../src/trees/dataset/DatasetFSProvid
import { ZoweDatasetNode } from "../../../../src/trees/dataset/ZoweDatasetNode";
import { IconUtils } from "../../../../src/icons/IconUtils";
import { IconGenerator } from "../../../../src/icons/IconGenerator";
import { SharedTreeProviders } from "../../../../src/trees/shared/SharedTreeProviders";

// Missing the definition of path module, because I need the original logic for tests
jest.mock("fs");
Expand Down Expand Up @@ -925,3 +926,160 @@ describe("ZoweDatasetNode Unit Tests - function datasetMigrated", () => {
expect(dsNode.iconPath).toBe(IconGenerator.getIconById(IconUtils.IconId.migrated).path);
});
});

describe("ZoweDatasetNode Unit Tests - getChildren() migration scenarios", () => {
const session = createISession();
const profileOne: imperative.IProfileLoaded = createIProfile();

beforeEach(() => {
jest.resetAllMocks();
});

it("should handle a dataset that was migrated", async () => {
const sessionNode = new ZoweDatasetNode({
label: "sestest",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session,
profile: profileOne,
contextOverride: Constants.DS_SESSION_CONTEXT,
});

const pdsNode = new ZoweDatasetNode({
label: "TEST.PDS",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode: sessionNode,
profile: profileOne,
contextOverride: Constants.DS_PDS_CONTEXT,
});

sessionNode.pattern = "TEST.*";
sessionNode.children = [pdsNode];

jest.spyOn(SharedTreeProviders, "ds", "get").mockReturnValueOnce({
applyPatternsToChildren: jest.fn(),
} as any);
jest.spyOn(Profiles, "getInstance").mockReturnValueOnce({
loadNamedProfile: jest.fn().mockReturnValueOnce(profileOne),
} as any);
jest.spyOn(sessionNode as any, "getDatasets").mockResolvedValueOnce([
{
success: true,
apiResponse: {
items: [
{
dsname: "TEST.PDS",
migr: "YES",
dsorg: "PO",
},
],
},
},
]);

await sessionNode.getChildren();

expect(pdsNode.contextValue).toBe(Constants.DS_MIGRATED_FILE_CONTEXT);
expect(pdsNode.collapsibleState).toBe(vscode.TreeItemCollapsibleState.None);
expect(pdsNode.resourceUri).toBeUndefined();
expect(pdsNode.command).toBeUndefined();
});

it("should handle a PS that was recalled", async () => {
const sessionNode = new ZoweDatasetNode({
label: "sestest",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session,
profile: profileOne,
contextOverride: Constants.DS_SESSION_CONTEXT,
});

const dsNode = new ZoweDatasetNode({
label: "TEST.DS",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: sessionNode,
profile: profileOne,
contextOverride: Constants.DS_MIGRATED_FILE_CONTEXT,
});

sessionNode.pattern = "TEST.*";
sessionNode.children = [dsNode];

jest.spyOn(SharedTreeProviders, "ds", "get").mockReturnValueOnce({
applyPatternsToChildren: jest.fn(),
} as any);
jest.spyOn(Profiles, "getInstance").mockReturnValueOnce({
loadNamedProfile: jest.fn().mockReturnValueOnce(profileOne),
} as any);
jest.spyOn(sessionNode as any, "getDatasets").mockResolvedValueOnce([
{
success: true,
apiResponse: {
items: [
{
dsname: "TEST.DS",
migr: "NO",
dsorg: "PS",
},
],
},
},
]);

await sessionNode.getChildren();

expect(dsNode.contextValue).toBe(Constants.DS_DS_CONTEXT);
expect(dsNode.collapsibleState).toBe(vscode.TreeItemCollapsibleState.None);
expect(dsNode.resourceUri).toBeDefined();
expect(dsNode.resourceUri.path).toBe("/sestest/TEST.DS");
expect(dsNode.command).toBeDefined();
});

it("should handle a PDS that was recalled", async () => {
const sessionNode = new ZoweDatasetNode({
label: "sestest",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
session,
profile: profileOne,
contextOverride: Constants.DS_SESSION_CONTEXT,
});

const pdsNode = new ZoweDatasetNode({
label: "TEST.PDS",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: sessionNode,
profile: profileOne,
contextOverride: Constants.DS_MIGRATED_FILE_CONTEXT,
});

sessionNode.pattern = "TEST.*";
sessionNode.children = [pdsNode];

jest.spyOn(SharedTreeProviders, "ds", "get").mockReturnValueOnce({
applyPatternsToChildren: jest.fn(),
} as any);
jest.spyOn(Profiles, "getInstance").mockReturnValueOnce({
loadNamedProfile: jest.fn().mockReturnValueOnce(profileOne),
} as any);
jest.spyOn(sessionNode as any, "getDatasets").mockResolvedValueOnce([
{
success: true,
apiResponse: {
items: [
{
dsname: "TEST.PDS",
migr: "NO",
dsorg: "PO",
},
],
},
},
]);

await sessionNode.getChildren();

expect(pdsNode.contextValue).toBe(Constants.DS_PDS_CONTEXT);
expect(pdsNode.collapsibleState).toBe(vscode.TreeItemCollapsibleState.Collapsed);
expect(pdsNode.resourceUri).toBeDefined();
expect(pdsNode.resourceUri.path).toBe("/sestest/TEST.PDS");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
let tempEntry = profileEntry.entries.get(ds.dsname);
if (tempEntry == null) {
let name = ds.dsname;
if (ds.dsorg === "PO" || ds.dsorg === "PO-E") {
if (ds.dsorg?.startsWith("PO")) {
// Entry is a PDS
tempEntry = new PdsEntry(ds.dsname);
} else if (ds.dsorg === "VS") {
Expand Down
13 changes: 8 additions & 5 deletions packages/zowe-explorer/src/trees/dataset/ZoweDatasetNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
let dsNode = existingItems[item.dsname ?? item.member];
if (dsNode != null) {
elementChildren[dsNode.label.toString()] = dsNode;
if (SharedContext.isMigrated(dsNode) && item.migr?.toUpperCase() !== "YES") {
await dsNode.datasetRecalled(item.dsorg === "PO" || item.dsorg === "PO-E");
} else if (!SharedContext.isMigrated(dsNode) && item.migr?.toUpperCase() === "YES") {
dsNode.datasetMigrated();
if (item.migr) {
const migrationStatus = item.migr.toUpperCase();
if (SharedContext.isMigrated(dsNode) && migrationStatus !== "YES") {
await dsNode.datasetRecalled(item.dsorg?.startsWith("PO"));
} else if (!SharedContext.isMigrated(dsNode) && migrationStatus === "YES") {
dsNode.datasetMigrated();
}
}
} else if (item.migr && item.migr.toUpperCase() === "YES") {
// Creates a ZoweDatasetNode for a migrated dataset
Expand All @@ -320,7 +323,7 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
profile: cachedProfile,
});
elementChildren[dsNode.label.toString()] = dsNode;
} else if (item.dsorg === "PO" || item.dsorg === "PO-E") {
} else if (item.dsorg?.startsWith("PO")) {
// Creates a ZoweDatasetNode for a PDS
dsNode = new ZoweDatasetNode({
label: item.dsname,
Expand Down

0 comments on commit fe475db

Please sign in to comment.