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

feat: Add SMFID to Jobs Tree View #2629

Merged
merged 8 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- 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)
- Added z/OS System Name (SMFID) to Zowe Explorer Jobs View. [#2629](https://github.com/zowe/vscode-extension-for-zowe/issues/2629)
- PROC and PROCLIB datasets are recognized as JCL files for syntax highlighting [#2614](https://github.com/zowe/vscode-extension-for-zowe/issues/2614)

### Bug fixes
Expand Down
3 changes: 2 additions & 1 deletion packages/zowe-explorer/__mocks__/mockCreators/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { IJob, IJobFile, imperative } from "@zowe/cli";
import { removeNodeFromArray } from "./shared";
import { PersistenceSchemaEnum } from "@zowe/zowe-explorer-api";

export function createIJobObject(): IJob {
export function createIJobObject() {
return {
jobid: "JOB1234",
jobname: "TESTJOB",
Expand All @@ -42,6 +42,7 @@ export function createIJobObject(): IJob {
subsystem: "SYS",
type: "JOB",
url: "fake/url",
"exec-member": "sampleMember",
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ describe("ZoweJobNode unit tests - Function getChildren", () => {
await globalMocks.testJobsProvider.addSession("fake");

const jobs = await globalMocks.testJobsProvider.mSessionNodes[1].getChildren();

expect(jobs.length).toBe(2);
expect(jobs[0].job.jobid).toEqual(globalMocks.testIJob.jobid);
expect(jobs[0].tooltip).toEqual("TESTJOB(JOB1234)");
Expand All @@ -324,7 +323,7 @@ describe("ZoweJobNode unit tests - Function getChildren", () => {
globalMocks.testJobsProvider.mSessionNodes[1].dirty = true;
const newJobs = await globalMocks.testJobsProvider.mSessionNodes[1].getChildren();

expect(newJobs[0].label).toEqual("TESTJOB(JOB1234) - CC 0000");
expect(newJobs[0].label).toEqual("TESTJOB(JOB1234) - sampleMember - CC 0000");
});

it("Tests that getChildren retrieves only child jobs which match a provided searchId", async () => {
Expand Down Expand Up @@ -423,6 +422,31 @@ describe("ZoweJobNode unit tests - Function getChildren", () => {
const jobs = await globalMocks.testJobsProvider.mSessionNodes[1].getChildren();
expect(jobs).toEqual(expectedJob);
});

it("To check smfid field in Jobs Tree View", async () => {
const globalMocks = await createGlobalMocks();

await globalMocks.testJobsProvider.addSession("fake");
globalMocks.testJobsProvider.mSessionNodes[1].searchId = "JOB1234";
globalMocks.testJobsProvider.mSessionNodes[1].dirty = true;
globalMocks.testJobsProvider.mSessionNodes[1].filtered = true;
globalMocks.testIJob.retcode = "ACTIVE";

const jobs = await globalMocks.testJobsProvider.mSessionNodes[1].getChildren();
Comment on lines +427 to +435
Copy link
Member

@traeok traeok Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a pattern across the new tests in this file. For the future, we might benefit from a test function that condenses this pattern, calling it with the appropriate arguments:

function jobLabelWithArgs(retcode?: string, execMember?: string): string {
    const globalMocks = await createGlobalMocks();

    await globalMocks.testJobsProvider.addSession("fake");
    globalMocks.testJobsProvider.mSessionNodes[1].searchId = "JOB1234";
    globalMocks.testJobsProvider.mSessionNodes[1].dirty = true;
    globalMocks.testJobsProvider.mSessionNodes[1].filtered = true;
    globalMocks.testIJob.retcode = retcode;
    globalMocks.testIJob["exec-member"] = execMember;

    const jobs = await globalMocks.testJobsProvider.mSessionNodes[1].getChildren();
    return jobs[0].label;
}

// then one of the tests could just be:
expect(jobLabelWithArgs("ACTIVE").toEqual("TESTJOB(JOB1234) - ACTIVE");

expect(jobs[0].label).toEqual("TESTJOB(JOB1234) - sampleMember - ACTIVE");
});

it("To check smfid field is not in Jobs Tree View", async () => {
const globalMocks = await createGlobalMocks();

await globalMocks.testJobsProvider.addSession("fake");
globalMocks.testJobsProvider.mSessionNodes[1].searchId = "JOB1234";
globalMocks.testJobsProvider.mSessionNodes[1].dirty = true;
globalMocks.testJobsProvider.mSessionNodes[1].filtered = true;

const jobs = await globalMocks.testJobsProvider.mSessionNodes[1].getChildren();
expect(jobs[0].label).toEqual("TESTJOB(JOB1234) - ACTIVE");
});
});

describe("ZoweJobNode unit tests - Function flipState", () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/zowe-explorer/src/job/ZoweJobNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
jobs.forEach((job) => {
let nodeTitle: string;
if (job.retcode) {
nodeTitle = `${job.jobname}(${job.jobid}) - ${job.retcode}`;
nodeTitle = job["exec-member"]
? `${job.jobname}(${job.jobid}) - ${job["exec-member"] as string} - ${job.retcode}`
: `${job.jobname}(${job.jobid}) - ${job.retcode}`;

Check warning on line 208 in packages/zowe-explorer/src/job/ZoweJobNode.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/job/ZoweJobNode.ts#L208

Added line #L208 was not covered by tests
} else {
nodeTitle = `${job.jobname}(${job.jobid}) - ${job.status}`;
}
Expand Down Expand Up @@ -374,6 +376,7 @@
owner,
prefix,
status,
execData: "Y",
});
} else {
this.statusNotSupportedMsg(status);
Expand Down
Loading