Skip to content

Commit

Permalink
Run pnpm --filter vscode-extension-for-zowe vscode:prepublish
Browse files Browse the repository at this point in the history
Signed-off-by: likhithanimma1 <[email protected]>
  • Loading branch information
likhithanimma1 committed Jan 13, 2025
1 parent d8edfaa commit 739ad19
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,8 @@ describe("Dataset Actions Unit Tests - Function showAttributes", () => {
describe("Dataset Actions Unit Tests - Function copyDataSets", () => {
function createBlockMocks() {
const session = createISession();
const sessionWithoutCredentials = createISessionWithoutCredentials();
const imperativeProfile = createIProfile();
const profileInstance = createInstanceOfProfile(imperativeProfile);
const zosmfSession = createSessCfgFromArgs(imperativeProfile);
const treeView = createTreeView();
const datasetSessionNode = createDatasetSessionNode(session, imperativeProfile);
const testDatasetTree = createDatasetTree(datasetSessionNode, treeView);
Expand All @@ -1162,35 +1160,16 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => {
profile: profileInstance,
});
pdsSessionNode.contextValue = Constants.DS_PDS_CONTEXT;
const pdsMemberNode = new ZoweDatasetNode({
label: "sestest",
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
parentNode: pdsSessionNode,
session,
profile: profileInstance,
});
pdsMemberNode.contextValue = Constants.DS_MEMBER_CONTEXT;
bindMvsApi(mvsApi);

const pds = new ZoweDatasetNode({ label: "parent", collapsibleState: vscode.TreeItemCollapsibleState.None, parentNode: datasetSessionNode });
pds.contextValue = Constants.DS_PDS_CONTEXT;
const memberChild = new ZoweDatasetNode({ label: "child", collapsibleState: vscode.TreeItemCollapsibleState.None, parentNode: pds });
memberChild.contextValue = Constants.DS_MEMBER_CONTEXT;

return {
session,
sessionWithoutCredentials,
zosmfSession,
treeView,
imperativeProfile,
datasetSessionNode,
mvsApi,
profileInstance,
testDatasetTree,
pdsSessionNode,
pdsMemberNode,
pds,
memberChild,
};
}

Expand All @@ -1216,7 +1195,6 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => {
it("Checking copy the label of a member to the clipboard via quickkeys", async () => {
createGlobalMocks();
const blockMocks = createBlockMocks();

const parent = new ZoweDatasetNode({
label: "parent",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
Expand Down Expand Up @@ -1252,10 +1230,9 @@ describe("Dataset Actions Unit Tests - Function copyDataSets", () => {
describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
function createBlockMocks() {
const session = createISession();
const sessionWithoutCredentials = createISessionWithoutCredentials();
const imperativeProfile = createIProfile();
const profileInstance = createInstanceOfProfile(imperativeProfile);
const zosmfSession = createSessCfgFromArgs(imperativeProfile);
const profileInstance = createInstanceOfProfile(imperativeProfile);
const treeView = createTreeView();
const datasetSessionNode = createDatasetSessionNode(session, imperativeProfile);
const testDatasetTree = createDatasetTree(datasetSessionNode, treeView);
Expand All @@ -1268,35 +1245,18 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
profile: profileInstance,
});
pdsSessionNode.contextValue = Constants.DS_PDS_CONTEXT;
const pdsMemberNode = new ZoweDatasetNode({
label: "sestest",
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
parentNode: pdsSessionNode,
session,
profile: profileInstance,
});
pdsMemberNode.contextValue = Constants.DS_MEMBER_CONTEXT;
bindMvsApi(mvsApi);

const pds = new ZoweDatasetNode({ label: "parent", collapsibleState: vscode.TreeItemCollapsibleState.None, parentNode: datasetSessionNode });
pds.contextValue = Constants.DS_PDS_CONTEXT;
const memberChild = new ZoweDatasetNode({ label: "child", collapsibleState: vscode.TreeItemCollapsibleState.None, parentNode: pds });
memberChild.contextValue = Constants.DS_MEMBER_CONTEXT;

return {
session,
sessionWithoutCredentials,
zosmfSession,
treeView,
imperativeProfile,
zosmfSession,
datasetSessionNode,
mvsApi,
profileInstance,
testDatasetTree,
pdsSessionNode,
pdsMemberNode,
pds,
memberChild,
};
}

Expand Down Expand Up @@ -1324,12 +1284,6 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
options.validateInput("nodeCopyCpy");
return Promise.resolve("nodeCopyCpy");
});
const allocateSpy = jest.spyOn(blockMocks.mvsApi, "allocateLikeDataSet");
allocateSpy.mockResolvedValue({
success: true,
commandResponse: "response",
apiResponse: {},
});
const copySpy = jest.spyOn(blockMocks.mvsApi, "copyDataSet");
copySpy.mockResolvedValue({
success: true,
Expand All @@ -1343,36 +1297,7 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, node)).resolves.not.toThrow();
});

it("If copyDataSet() is not present in mvsapi", async () => {
createGlobalMocks();
const blockMocks = createBlockMocks();
const node = new ZoweDatasetNode({
label: "HLQ.TEST.DATASET",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.datasetSessionNode,
});
node.contextValue = Constants.DS_DS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
dataSetName: "HLQ.TEST.BEFORE.NODE",
profileName: blockMocks.imperativeProfile.name,
contextValue: Constants.DS_DS_CONTEXT,
},
])
);
mocked(vscode.window.showInputBox).mockImplementationOnce((options) => {
options.validateInput("nodeCopyCpy");
return Promise.resolve("nodeCopyCpy");
});

blockMocks.mvsApi.copyDataSet = null as any;
const errorSpy = jest.spyOn(Gui, "errorMessage").mockResolvedValue("Copying data sets is not supported.");
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, node)).resolves.not.toThrow();
expect(errorSpy).toHaveBeenCalled();
});

it("Testing copySequentialDatasets() successfully runs cross profile", async () => {
it("Testing copySequentialDatasets() successfully runs on cross profile", async () => {
const globalMocks = createGlobalMocks();
const blockMocks = createBlockMocks();
const node = new ZoweDatasetNode({
Expand Down Expand Up @@ -1411,39 +1336,6 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, node)).resolves.not.toThrow();
});

it("If isCancellationRequested is true", async () => {
const globalMocks = createGlobalMocks();
const blockMocks = createBlockMocks();
const node = new ZoweDatasetNode({
label: "HLQ.TEST.DATASET",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.datasetSessionNode,
});
node.contextValue = Constants.DS_DS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
dataSetName: "HLQ.TEST.BEFORE.NODE",
profileName: "sestest1",
contextValue: Constants.DS_DS_CONTEXT,
},
])
);
mocked(vscode.window.withProgress).mockImplementation((progLocation, callback) => {
const progress = {
report: jest.fn(),
};
const token = {
isCancellationRequested: true,
onCancellationRequested: jest.fn(),
};
return callback(progress, token);
});
globalMocks.showInputBox.mockResolvedValueOnce("CopyNode");
jest.spyOn(DatasetActions, "determineReplacement").mockResolvedValueOnce("notFound");
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, node)).resolves.not.toThrow();
});

it("Testing copyPartitionedDatasets() successfully runs within same profile", async () => {
createGlobalMocks();
const blockMocks = createBlockMocks();
Expand Down Expand Up @@ -1491,7 +1383,7 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, dsNode)).resolves.not.toThrow();
});

it("Testing copyPartitionedDatasets() successfully runs cross profile", async () => {
it("Testing copyPartitionedDatasets() successfully runs on cross profile", async () => {
const globalMocks = createGlobalMocks();
const blockMocks = createBlockMocks();
const parentNode = new ZoweDatasetNode({
Expand Down Expand Up @@ -1537,46 +1429,6 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, dsNode)).resolves.not.toThrow();
});

it("Testing isCancellationRequested true on copyPartitionedDatasets()", async () => {
const globalMocks = createGlobalMocks();
const blockMocks = createBlockMocks();
const parentNode = new ZoweDatasetNode({
label: "parent",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.datasetSessionNode,
});
const dsNode = new ZoweDatasetNode({
label: "dsNode",
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
parentNode,
session: blockMocks.zosmfSession,
profile: blockMocks.imperativeProfile,
});
dsNode.contextValue = Constants.DS_PDS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
dataSetName: "HLQ.TEST.BEFORE.NODE",
profileName: "sestest1",
contextValue: Constants.DS_PDS_CONTEXT,
},
])
);
mocked(vscode.window.withProgress).mockImplementation((progLocation, callback) => {
const progress = {
report: jest.fn(),
};
const token = {
isCancellationRequested: true,
onCancellationRequested: jest.fn(),
};
return callback(progress, token);
});
globalMocks.showInputBox.mockResolvedValueOnce("pdsTest");
jest.spyOn(DatasetActions, "determineReplacement").mockResolvedValueOnce("notFound");
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, dsNode)).resolves.not.toThrow();
});

it("Testing copyDatasetMembers() succesfully runs", async () => {
createGlobalMocks();
const blockMocks = createBlockMocks();
Expand Down Expand Up @@ -1663,29 +1515,31 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, memberNode)).resolves.not.toThrow();
});

it("if isCancellationRequested is true for copyDatasetMembers()", async () => {
createGlobalMocks();
it("Testing isCancellationRequested true", async () => {
const globalMocks = createGlobalMocks();
const blockMocks = createBlockMocks();
const memberNode = new ZoweDatasetNode({
label: "memberNode",
const parentNode = new ZoweDatasetNode({
label: "parent",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.pdsSessionNode,
parentNode: blockMocks.datasetSessionNode,
});
const dsNode = new ZoweDatasetNode({
label: "dsNode",
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
parentNode,
session: blockMocks.zosmfSession,
profile: blockMocks.imperativeProfile,
});
memberNode.contextValue = Constants.DS_MEMBER_CONTEXT;
dsNode.contextValue = Constants.DS_PDS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
memberName: "TEST",
profileName: "sesTest1",
contextValue: Constants.DS_MEMBER_CONTEXT,
dataSetName: "HLQ.TEST.BEFORE.NODE",
profileName: "sestest1",
contextValue: Constants.DS_PDS_CONTEXT,
},
])
);
mocked(vscode.window.showInputBox).mockImplementationOnce((options) => {
options.validateInput("pdsTest");
return Promise.resolve("pdsTest");
});
mocked(vscode.window.withProgress).mockImplementation((progLocation, callback) => {
const progress = {
report: jest.fn(),
Expand All @@ -1696,13 +1550,47 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
};
return callback(progress, token);
});
globalMocks.showInputBox.mockResolvedValueOnce("pdsTest");
jest.spyOn(DatasetActions, "determineReplacement").mockResolvedValueOnce("notFound");
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, dsNode)).resolves.not.toThrow();

//for sequential copy
dsNode.contextValue = Constants.DS_DS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
dataSetName: "HLQ.TEST.BEFORE.NODE",
profileName: "sestest1",
contextValue: Constants.DS_DS_CONTEXT,
},
])
);
globalMocks.showInputBox.mockResolvedValueOnce("CopyNode");
jest.spyOn(DatasetActions, "determineReplacement").mockResolvedValueOnce("notFound");
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, dsNode)).resolves.not.toThrow();

//for DataSetMember Copy
dsNode.contextValue = Constants.DS_MEMBER_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
memberName: "TEST",
profileName: "sesTest1",
contextValue: Constants.DS_MEMBER_CONTEXT,
},
])
);
mocked(vscode.window.showInputBox).mockImplementationOnce((options) => {
options.validateInput("pdsTest");
return Promise.resolve("pdsTest");
});
const allmembersspy = jest.spyOn(blockMocks.mvsApi, "allMembers");
allmembersspy.mockResolvedValue({
success: true,
commandResponse: "",
apiResponse: { items: [{ member: "PDSTEST" }] },
});
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, memberNode)).resolves.not.toThrow();
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, dsNode)).resolves.not.toThrow();
});

it("Should ask to replace the sequential and partitioned dataset if it already exists", async () => {
Expand Down Expand Up @@ -1804,14 +1692,15 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
expect(refreshSpy).toHaveBeenCalled();
});

it("If copyDataSetCrossLpar is not present in mvsapi", async () => {
it("If copyDataSetCrossLpar, copyDataSet is not present in mvsapi", async () => {
createGlobalMocks();
const blockMocks = createBlockMocks();
const node = new ZoweDatasetNode({
label: "HLQ.TEST.DATASET",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.datasetSessionNode,
});
node.contextValue = Constants.DS_DS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
Expand All @@ -1826,7 +1715,27 @@ describe("Dataset Actions Unit Tests - Function pasteDataSet", () => {
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, node)).resolves.not.toThrow();
expect(errorSpy).toHaveBeenCalled();

//for partitioned
//if copyDataSet() is not present in mvsapi
clipboard.writeText(
JSON.stringify([
{
dataSetName: "HLQ.TEST.BEFORE.NODE",
profileName: blockMocks.imperativeProfile.name,
contextValue: Constants.DS_DS_CONTEXT,
},
])
);
mocked(vscode.window.showInputBox).mockImplementationOnce((options) => {
options.validateInput("nodeCopyCpy");
return Promise.resolve("nodeCopyCpy");
});
blockMocks.mvsApi.copyDataSet = null as any;
const errorCopySpy = jest.spyOn(Gui, "errorMessage").mockResolvedValue("Copying data sets is not supported.");
await expect(DatasetActions.pasteDataSet(blockMocks.testDatasetTree, node)).resolves.not.toThrow();
expect(errorCopySpy).toHaveBeenCalled();

//for partitioned copyDataSetCrossLpar is not present in mvsapi
node.contextValue = Constants.DS_PDS_CONTEXT;
clipboard.writeText(
JSON.stringify([
{
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer/src/trees/uss/USSTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class USSTree extends ZoweTreeProvider<IZoweUSSTreeNode> implements Types

private async crossLparMove(sourceNode: IZoweUSSTreeNode, sourceUri: vscode.Uri, destUri: vscode.Uri, recursiveCall?: boolean): Promise<void> {
const destinationInfo = FsAbstractUtils.getInfoForUri(destUri, Profiles.getInstance());

if (SharedContext.isUssDirectory(sourceNode)) {
if (!UssFSProvider.instance.exists(destUri)) {
// create directory on remote FS
Expand Down

0 comments on commit 739ad19

Please sign in to comment.