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

Fix downloading spool files failing to match tree nodes #2943

Merged
merged 6 commits into from
Jun 12, 2024
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"vscode": "^1.53.2"
},
"dependencies": {
"@zowe/cli": "7.26.0",
"@zowe/cli": "7.26.1",
"vscode-nls": "4.1.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@types/vscode": "^1.53.2",
"@zowe/cli": "7.26.0",
"@zowe/cli": "7.26.1",
"@zowe/secrets-for-zowe-sdk": "7.18.6",
"handlebars": "^4.7.7",
"semver": "^7.5.3"
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

- Update dependencies for technical currency purposes.
- Fix issue Right-click-delete option deleting the currently open/selected file and not the file which is right-clicked when members having same name [#2941](https://github.com/zowe/zowe-explorer-vscode/issues/2941)
- Fixed issue where Download Spool action could fail to find spool files to download. [#2943](https://github.com/zowe/zowe-explorer-vscode/pull/2943)

## `2.16.1`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,20 @@ describe("SpoolProvider Unit Tests", () => {

describe("matchSpool", () => {
it("should match spool to the selected node", () => {
const spool: zowe.IJobFile = { ...iJobFile, stepname: "test", ddname: "dd", "record-count": 1, procstep: "proc" };
let match = matchSpool(spool, { label: "test:dd - 1" } as any);
const spool: zowe.IJobFile = { ...iJobFile };
let match = matchSpool(spool, { spool } as any);
expect(match).toBe(true);

match = matchSpool(spool, { label: "test:dd - proc" } as any);
expect(match).toBe(true);

// Different record-count
match = matchSpool(spool, { label: "test:dd - 2" } as any);
expect(match).toBe(false);

// Different procstep
match = matchSpool(spool, { label: "test:dd - abc" } as any);
// Different job id
match = matchSpool(spool, { spool: { ...spool, jobid: "101" } } as any);
expect(match).toBe(false);

// Different stepname
match = matchSpool(spool, { label: "other:dd - 1" } as any);
// Different spool id
match = matchSpool(spool, { spool: { ...spool, id: 101 } } as any);
expect(match).toBe(false);

// Different ddname
match = matchSpool(spool, { label: "test:new - proc" } as any);
// Missing spool property
match = matchSpool(spool, { label: "missingSpool" } as any);
expect(match).toBe(false);
});
});
Expand Down
20 changes: 12 additions & 8 deletions packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function createGlobalMocks() {
Object.defineProperty(Gui, "showMessage", { value: jest.fn(), configurable: true });
Object.defineProperty(Gui, "warningMessage", { value: jest.fn(), configurable: true });
Object.defineProperty(Gui, "errorMessage", { value: jest.fn(), configurable: true });
Object.defineProperty(Gui, "infoMessage", { value: jest.fn(), configurable: true });
Object.defineProperty(Gui, "showOpenDialog", { value: jest.fn(), configurable: true });
Object.defineProperty(sharedUtils, "getDefaultUri", { value: jest.fn(), configurable: true });
Object.defineProperty(vscode.window, "showWarningMessage", { value: jest.fn(), configurable: true });
Expand Down Expand Up @@ -324,12 +325,14 @@ describe("Jobs Actions Unit Tests - Function downloadSingleSpool", () => {
const blockMocks = createGlobalMocks();
const iJobFile = createIJobFile();
const jobs: IZoweJobTreeNode[] = [];
const node = new ZoweJobNode({
const spool: zowe.IJobFile = { ...iJobFile, stepname: "test", ddname: "dd", "record-count": 1 };
const node = new ZoweSpoolNode({
label: "test:dd - 1",
collapsibleState: vscode.TreeItemCollapsibleState.None,
session: blockMocks.session,
profile: blockMocks.imperativeProfile,
job: blockMocks.iJob,
spool,
});
const fileUri = {
fsPath: "/tmp/foo",
Expand All @@ -339,33 +342,35 @@ describe("Jobs Actions Unit Tests - Function downloadSingleSpool", () => {
path: "",
query: "",
};
jobs.push(node);
jobs.push(node, node);
traeok marked this conversation as resolved.
Show resolved Hide resolved
mocked(Gui.showOpenDialog).mockResolvedValue([fileUri as vscode.Uri]);
const downloadFileSpy = jest.spyOn(blockMocks.jesApi, "downloadSingleSpool");
const spool: zowe.IJobFile = { ...iJobFile, stepname: "test", ddname: "dd", "record-count": 1 };
const getSpoolFilesSpy = jest.spyOn(SpoolProvider, "getSpoolFiles").mockResolvedValue([spool]);
const downloadFileSpy = jest.spyOn(blockMocks.jesApi, "downloadSingleSpool").mockResolvedValue(undefined);
const getSpoolFilesSpy = jest.spyOn(SpoolProvider, "getSpoolFiles").mockResolvedValueOnce([spool]).mockResolvedValueOnce([]);

await jobActions.downloadSingleSpool(jobs, true);
expect(mocked(Gui.showOpenDialog)).toBeCalled();
expect(getSpoolFilesSpy).toHaveBeenCalledWith(node);
expect(downloadFileSpy).toBeCalled();
expect(downloadFileSpy).toHaveBeenCalledTimes(1);
expect(downloadFileSpy.mock.calls[0][0]).toEqual({
jobFile: spool,
binary: true,
outDir: fileUri.fsPath,
});
expect(mocked(Gui.infoMessage)).toBeCalled();
});

it("should fail to download single spool files if the extender has not implemented the operation", async () => {
const blockMocks = createGlobalMocks();
const iJobFile = createIJobFile();
const jobs: IZoweJobTreeNode[] = [];
const node = new ZoweJobNode({
const spool: zowe.IJobFile = { ...iJobFile, stepname: "test", ddname: "dd", "record-count": 1 };
const node = new ZoweSpoolNode({
label: "test:dd - 1",
collapsibleState: vscode.TreeItemCollapsibleState.None,
session: blockMocks.session,
profile: blockMocks.imperativeProfile,
job: blockMocks.iJob,
spool,
});
const fileUri = {
fsPath: "/tmp/foo",
Expand All @@ -378,7 +383,6 @@ describe("Jobs Actions Unit Tests - Function downloadSingleSpool", () => {
jobs.push(node);
mocked(Gui.showOpenDialog).mockResolvedValue([fileUri as vscode.Uri]);
blockMocks.jesApi.downloadSingleSpool = undefined;
const spool: zowe.IJobFile = { ...iJobFile, stepname: "test", ddname: "dd", "record-count": 1 };
const getSpoolFilesSpy = jest.spyOn(SpoolProvider, "getSpoolFiles").mockResolvedValue([spool]);

await jobActions.downloadSingleSpool(jobs, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"downloadSpool.select": "Select",
"downloadSingleSpool.error": "Download Single Spool operation not implemented by extender. Please contact the extension developer(s).",
"downloadSingleSpool.notFound": "No spool files found for {0}",
"jobActions.openSpoolFile": "$(sync~spin) Opening spool file...",
"zowe.polling.statusBar": "$(sync~spin) Polling: {0}...",
"jobActions.fetchSpoolFile": "$(sync~spin) Fetching spool files...",
Expand Down
7 changes: 3 additions & 4 deletions packages/zowe-explorer/src/SpoolProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ZoweExplorerApiRegister } from "./ZoweExplorerApiRegister";
import { Profiles } from "./Profiles";
import { ZoweLogger } from "./utils/LoggerUtils";
import { IZoweJobTreeNode } from "@zowe/zowe-explorer-api";
import type { ZoweSpoolNode } from "./job/ZoweJobNode";

export default class SpoolProvider implements vscode.TextDocumentContentProvider {
// Track files that have been opened previously through the SpoolProvider
Expand Down Expand Up @@ -145,10 +146,8 @@ export async function getSpoolFiles(node: IZoweJobTreeNode): Promise<zowe.IJobFi
* @returns true if the selected node matches the spool file, false otherwise
*/
export function matchSpool(spool: zowe.IJobFile, node: IZoweJobTreeNode): boolean {
return (
`${spool.stepname}:${spool.ddname} - ${spool["record-count"]}` === node.label.toString() ||
`${spool.stepname}:${spool.ddname} - ${spool.procstep}` === node.label.toString()
);
const nodeSpool = (node as ZoweSpoolNode).spool;
traeok marked this conversation as resolved.
Show resolved Hide resolved
return nodeSpool != null && spool.jobid === nodeSpool.jobid && spool.id === nodeSpool.id;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/zowe-explorer/src/job/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export async function downloadSingleSpool(nodes: IZoweJobTreeNode[], binary?: bo
if (dirUri !== undefined) {
for (const node of nodes) {
const spools = (await getSpoolFiles(node)).filter((spool: zowe.IJobFile) => matchSpool(spool, node));
if (!spools.length) {
await Gui.infoMessage(localize("downloadSingleSpool.notFound", "No spool files found for {0}", node.label as string));
}
for (const spool of spools) {
await ZoweExplorerApiRegister.getJesApi(nodes[0].getProfile()).downloadSingleSpool({
jobFile: spool,
Expand Down
2 changes: 1 addition & 1 deletion samples/uss-profile-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"watch": "tsc -watch -p ./"
},
"dependencies": {
"@zowe/cli": "7.26.0",
"@zowe/cli": "7.26.1",
"@zowe/zowe-explorer-api": "file:../../packages/zowe-explorer-api",
"ssh2-sftp-client": "^9.1.0"
},
Expand Down
58 changes: 29 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2728,21 +2728,21 @@
resolved "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==

"@zowe/cli@7.26.0":
version "7.26.0"
resolved "https://registry.npmjs.org/@zowe/cli/-/cli-7.26.0.tgz#3b3a7581e96b67af5a28415f9ba730581da0eab0"
integrity sha512-kuP1Om8CAJfl/N5YnDLSwV99H6Havf1rI6bxYzQeB42J4eN/Vr6xFOfN8YAVbL2x7/7MusjkEMMcC8ySA+VgOw==
"@zowe/cli@7.26.1":
version "7.26.1"
resolved "https://registry.npmjs.org/@zowe/cli/-/cli-7.26.1.tgz#c14c817e7d198bbbb477740a8691b91e2235f124"
integrity sha512-GplVBp5cK1MuhVwH4LAcvlnbCAy176uc9waXzeWw5HopDLPXThIb60rNcRTy1UR4akrM2vzoZW9He7FnIRC1rQ==
dependencies:
"@zowe/core-for-zowe-sdk" "7.25.2"
"@zowe/imperative" "5.24.0"
"@zowe/provisioning-for-zowe-sdk" "7.25.2"
"@zowe/zos-console-for-zowe-sdk" "7.25.2"
"@zowe/zos-files-for-zowe-sdk" "7.26.0"
"@zowe/zos-jobs-for-zowe-sdk" "7.26.0"
"@zowe/zos-files-for-zowe-sdk" "7.26.1"
"@zowe/zos-jobs-for-zowe-sdk" "7.26.1"
"@zowe/zos-logs-for-zowe-sdk" "7.25.2"
"@zowe/zos-tso-for-zowe-sdk" "7.25.2"
"@zowe/zos-uss-for-zowe-sdk" "7.24.3"
"@zowe/zos-workflows-for-zowe-sdk" "7.26.0"
"@zowe/zos-workflows-for-zowe-sdk" "7.26.1"
"@zowe/zosmf-for-zowe-sdk" "7.25.2"
find-process "1.4.7"
get-stream "6.0.1"
Expand Down Expand Up @@ -2819,10 +2819,10 @@
resolved "https://registry.npmjs.org/@zowe/zos-console-for-zowe-sdk/-/zos-console-for-zowe-sdk-7.25.2.tgz#151edeb7189c36c4fc8a6039467e278e585b4d03"
integrity sha512-G+898bxMQGrC9upSIeXhkplQqClyt2QPOp6NnZ3dWi/XkRmxhYeJo+Ck5JCZEH8uprvKOsnIb5K1Ll/JsTraPQ==

"@zowe/zos-files-for-zowe-sdk@7.26.0":
version "7.26.0"
resolved "https://registry.npmjs.org/@zowe/zos-files-for-zowe-sdk/-/zos-files-for-zowe-sdk-7.26.0.tgz#c3d93b94e17468f08ef1caa1a8e533e5633ab379"
integrity sha512-XWbDItZTzhdOtI6f7LKcdHzrRyDPYlCSFrbE/d+XGmb0tysfEQJhPpSjtnCeA9WNE7O9n3sK0NPgciARcgbffw==
"@zowe/zos-files-for-zowe-sdk@7.26.1":
version "7.26.1"
resolved "https://registry.npmjs.org/@zowe/zos-files-for-zowe-sdk/-/zos-files-for-zowe-sdk-7.26.1.tgz#1b4a6d50cad665a0e5b8bb666eb346837be3771f"
integrity sha512-Impd7s6Ux5WMnioJZpjGJkGR7PBDgpLo/EYZ5KnNNx9n+pqFr7QJ6qX3c38bFsYfXItOE6l/qJ8dkQguG4uv7g==
dependencies:
minimatch "5.0.1"

Expand All @@ -2833,12 +2833,12 @@
dependencies:
zos-node-accessor "1.0.16"

"@zowe/zos-jobs-for-zowe-sdk@7.26.0":
version "7.26.0"
resolved "https://registry.npmjs.org/@zowe/zos-jobs-for-zowe-sdk/-/zos-jobs-for-zowe-sdk-7.26.0.tgz#16ccfa9656d9e8495e6fb26dfbcfd705965a3ac7"
integrity sha512-t73yuP6kKO35N8r8UYx0J4DDJ1rXBjiC4NPlwtTZMycu4eVAqNs6ynAwsdogUs6uWgOSSSDV2qEDf0m0M/V4kw==
"@zowe/zos-jobs-for-zowe-sdk@7.26.1":
version "7.26.1"
resolved "https://registry.npmjs.org/@zowe/zos-jobs-for-zowe-sdk/-/zos-jobs-for-zowe-sdk-7.26.1.tgz#922db1f8f215033b599cca397902b8cae0c15a81"
integrity sha512-9sJfMLUB4XpNZVRQA4F8pwRdPs76dASVZDi+SPR1P2Lxx/Rex2dmvX20eHwo39nhtGsC4r1LozTr3fOsN6t3LQ==
dependencies:
"@zowe/zos-files-for-zowe-sdk" "7.26.0"
"@zowe/zos-files-for-zowe-sdk" "7.26.1"

"@zowe/zos-logs-for-zowe-sdk@7.25.2":
version "7.25.2"
Expand All @@ -2859,12 +2859,12 @@
dependencies:
ssh2 "1.15.0"

"@zowe/zos-workflows-for-zowe-sdk@7.26.0":
version "7.26.0"
resolved "https://registry.npmjs.org/@zowe/zos-workflows-for-zowe-sdk/-/zos-workflows-for-zowe-sdk-7.26.0.tgz#dc4053a8ec6aaef458e9f3e903605276e1360fba"
integrity sha512-dls+QuqymFJMm8HjGt7rxufdatSl5OQXmaOsXq2h/Xl7e93VjWjSrL+RvdKtd1eLdCJFS2c/btLpHgyCXHjBRA==
"@zowe/zos-workflows-for-zowe-sdk@7.26.1":
version "7.26.1"
resolved "https://registry.npmjs.org/@zowe/zos-workflows-for-zowe-sdk/-/zos-workflows-for-zowe-sdk-7.26.1.tgz#2a834a197d7796e9268ef945cd60e51205231b7e"
integrity sha512-7NMwttq5N7AWnMg0K5Cw1OuGpcFDvAobIbcclGrJgAYpTjr6qXDcy/sQ0hFnm5L0rW8XED7aJNapDtdXM9lLVQ==
dependencies:
"@zowe/zos-files-for-zowe-sdk" "7.26.0"
"@zowe/zos-files-for-zowe-sdk" "7.26.1"

"@zowe/zosmf-for-zowe-sdk@7.25.2":
version "7.25.2"
Expand Down Expand Up @@ -3570,11 +3570,11 @@ braces@^2.3.1, braces@^2.3.2:
to-regex "^3.0.1"

braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

brorand@^1.0.1, brorand@^1.1.0:
version "1.1.0"
Expand Down Expand Up @@ -5600,10 +5600,10 @@ fill-range@^4.0.0:
repeat-string "^1.6.1"
to-regex-range "^2.1.0"

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down
Loading