Skip to content

Commit

Permalink
refactor(jobs): Update contents of editor during polling / "Pull from…
Browse files Browse the repository at this point in the history
… Mainframe" (zowe#3249)

* refactor: revert contents in editor for jobs when pulling data

Signed-off-by: Trae Yelovich <[email protected]>

* chore: add ZE changelog entry

Signed-off-by: Trae Yelovich <[email protected]>

* fix: update mtime, size in fetchSpoolAtUri

Signed-off-by: Trae Yelovich <[email protected]>

* tests: resolve failing test cases

Signed-off-by: Trae Yelovich <[email protected]>

* add changelog #

Signed-off-by: Trae Yelovich <[email protected]>

---------

Signed-off-by: Trae Yelovich <[email protected]>
Signed-off-by: Billie Simmons <[email protected]>
Co-authored-by: Billie Simmons <[email protected]>
  • Loading branch information
traeok and JillieBeanSim authored Oct 17, 2024
1 parent 0435a42 commit db7f988
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

### Bug fixes

- Fixed an issue where the contents of an editor did not update when polling spool content or using the "Pull from Mainframe" action with jobs. [#3249](https://github.com/zowe/zowe-explorer-vscode/pull/3249)
- Fixed an issue where Zowe Explorer sometimes prompted the user to convert V1 profiles when changes were made to a team configuration after initialization. [#3246](https://github.com/zowe/zowe-explorer-vscode/pull/3246)

## `3.0.1`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

import { Disposable, FilePermission, FileType, Uri } from "vscode";
import { Disposable, FilePermission, FileType, Uri, window } from "vscode";
import { FsJobsUtils, FilterEntry, Gui, JobEntry, SpoolEntry, ZoweScheme } from "@zowe/zowe-explorer-api";
import { createIProfile } from "../../../__mocks__/mockCreators/shared";
import { createIJobFile, createIJobObject } from "../../../__mocks__/mockCreators/jobs";
Expand Down Expand Up @@ -91,16 +91,22 @@ describe("refreshSpool", () => {
});

it("calls fetchSpoolAtUri for a valid spool node", async () => {
const node = { resourceUri: testUris.spool, contextValue: "spool" } as any;
const editorListMock = new MockedProperty(window, "visibleTextEditors", {
value: [{ document: { uri: testUris.spool } }],
});
const fetchSpoolAtUriMock = jest.spyOn(JobFSProvider.instance, "fetchSpoolAtUri").mockImplementation();
const disposeMock = jest.fn();
const statusBarMsgMock = jest.spyOn(Gui, "setStatusBarMessage").mockReturnValue({ dispose: disposeMock });
const node = { resourceUri: testUris.spool, contextValue: "spool" } as any;
await JobFSProvider.refreshSpool(node);
expect(statusBarMsgMock).toHaveBeenCalledWith("$(sync~spin) Fetching spool file...");
expect(fetchSpoolAtUriMock).toHaveBeenCalledWith(node.resourceUri);
expect(fetchSpoolAtUriMock).toHaveBeenCalledWith(node.resourceUri, {
document: { uri: { path: "/sestest/TESTJOB(JOB1234) - ACTIVE/JES2.JESMSGLG.2", scheme: "zowe-jobs" } },
});
expect(disposeMock).toHaveBeenCalled();
fetchSpoolAtUriMock.mockRestore();
statusBarMsgMock.mockRestore();
editorListMock[Symbol.dispose]();
});
});

Expand Down
7 changes: 6 additions & 1 deletion packages/zowe-explorer/src/trees/job/JobFSProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export class JobFSProvider extends BaseProvider implements vscode.FileSystemProv
return;
}
const statusBarMsg = Gui.setStatusBarMessage(`$(sync~spin) ${vscode.l10n.t("Fetching spool file...")}`);
await JobFSProvider.instance.fetchSpoolAtUri(node.resourceUri);
await JobFSProvider.instance.fetchSpoolAtUri(
node.resourceUri,
vscode.window.visibleTextEditors.find((v) => v.document.uri.path === node.resourceUri.path)
);
statusBarMsg.dispose();
}

Expand Down Expand Up @@ -202,6 +205,8 @@ export class JobFSProvider extends BaseProvider implements vscode.FileSystemProv

this._fireSoon({ type: vscode.FileChangeType.Changed, uri });
spoolEntry.data = bufBuilder.read() ?? new Uint8Array();
spoolEntry.mtime = Date.now();
spoolEntry.size = spoolEntry.data.byteLength;
if (editor) {
await this._updateResourceInEditor(uri);
}
Expand Down

0 comments on commit db7f988

Please sign in to comment.