diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts index 57b901c912..443752486a 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts @@ -2808,27 +2808,21 @@ describe("Dataset Tree Unit Tests - Function filterPdsMembersDialog", () => { showInputBox: jest.spyOn(Gui, "showInputBox"), }); const testSession = new ZoweDatasetNode("testSession", vscode.TreeItemCollapsibleState.Collapsed, null, createISession()); + testSession.contextValue = globals.DS_SESSION_CONTEXT; const testPds = new ZoweDatasetNode("testPds", vscode.TreeItemCollapsibleState.Collapsed, testSession, createISession()); testPds.contextValue = globals.DS_PDS_CONTEXT; beforeEach(() => { - const mocks = getBlockMocks(); - mocks.getParent.mockReturnValue(testSession); - testPds.children = [ - { label: "A", stats: { user: "someUser", m4date: Date.now() }, getParent: mocks.getParent } as unknown as ZoweDatasetNode, - { - label: "B", - stats: { user: "anotherUser", m4date: Date.parse("2022-01-01T12:00:00") }, - getParent: mocks.getParent, - } as unknown as ZoweDatasetNode, - { - label: "C", - stats: { user: "someUser", m4date: Date.parse("2022-03-15T16:30:00") }, - getParent: mocks.getParent, - } as unknown as ZoweDatasetNode, - ]; + const nodeA = new ZoweDatasetNode("A", vscode.TreeItemCollapsibleState.Collapsed, testPds, createISession()); + nodeA.stats = { user: "someUser", m4date: new Date() }; + const nodeB = new ZoweDatasetNode("B", vscode.TreeItemCollapsibleState.Collapsed, testPds, createISession()); + nodeB.stats = { user: "anotherUser", m4date: new Date("2022-01-01T12:00:00") }; + const nodeC = new ZoweDatasetNode("C", vscode.TreeItemCollapsibleState.Collapsed, testPds, createISession()); + nodeC.stats = { user: "someUser", m4date: new Date("2022-03-15T16:30:00") }; + testPds.children = [nodeA, nodeB, nodeC]; testSession.children = [testPds]; testPds.filter = undefined as any; + testSession.filter = undefined as any; }); afterEach(() => { diff --git a/packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts b/packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts index 9b83a8915d..f0545c060e 100644 --- a/packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts +++ b/packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts @@ -266,7 +266,13 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod if (m4date) { temp.stats = { user: item.user, - m4date: new Date(`${m4date.replace(/\//g, "-")}T${mtime}:${msec}`), + m4date: dayjs(`${m4date} ${mtime}:${msec}`).toDate(), + }; + } else { + // missing keys from API response; check for FTP keys + temp.stats = { + user: item.user ?? item.id, + m4date: item.changed ? dayjs(item.changed).toDate() : null, }; } elementChildren[temp.label.toString()] = temp;