From 563920bd9d4c709bc24a64bba6b6cca436ced013 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Wed, 15 May 2024 14:38:57 -0400 Subject: [PATCH 1/2] Fix regression with clearing profile object caches on refresh Signed-off-by: Timothy Johnson --- .../__tests__/__unit__/profiles/ProfilesCache.unit.test.ts | 6 ++++-- packages/zowe-explorer-api/src/profiles/ProfilesCache.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts index 437a8f9303..3147f9a244 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts @@ -302,14 +302,16 @@ describe("ProfilesCache", () => { it("should remove old types from profilesByType and defaultProfileByType maps when reloading profiles", async () => { const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as zowe.imperative.Logger); jest.spyOn(profCache, "getProfileInfo").mockResolvedValue(createProfInfoMock([])); - (profCache as any).profilesByType.set("test-type", { name: "someProf" as any }); - (profCache as any).defaultProfileByType.set("test-type", { name: "someProf" as any }); + (profCache as any).profilesByType.set("base", { name: "someProf" as any }); + (profCache as any).defaultProfileByType.set("base", { name: "someProf" as any }); const promise = profCache.refresh(); expect((profCache as any).profilesByType.size).toBe(1); expect((profCache as any).defaultProfileByType.size).toBe(1); await promise; expect((profCache as any).profilesByType.size).toBe(0); expect((profCache as any).defaultProfileByType.size).toBe(0); + expect((profCache as any).allProfiles.length).toBe(0); + expect((profCache as any).allTypes).toEqual(["base"]); expect(mockLogError).not.toHaveBeenCalled(); }); }); diff --git a/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts b/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts index b65c99e23d..2ac32fca7b 100644 --- a/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts +++ b/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts @@ -175,7 +175,7 @@ export class ProfilesCache { * * @returns {IProfileLoaded[]} */ - public getProfiles(type = "zosmf"): zowe.imperative.IProfileLoaded[] { + public getProfiles(type = "zosmf"): zowe.imperative.IProfileLoaded[] | undefined { return this.profilesByType.get(type); } @@ -222,7 +222,7 @@ export class ProfilesCache { } this.allProfiles = allProfiles; this.allTypes = allTypes; - for (const oldType of [...this.profilesByType.keys()].filter((type) => !allTypes.includes(type))) { + for (const oldType of [...this.profilesByType.keys()].filter((type) => !allProfiles.some((prof) => prof.type === type))) { this.profilesByType.delete(oldType); this.defaultProfileByType.delete(oldType); } From fa5d49174517d3929284d2bffcdbac8535792381 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Wed, 15 May 2024 14:47:42 -0400 Subject: [PATCH 2/2] Update changelog Signed-off-by: Timothy Johnson --- packages/zowe-explorer-api/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zowe-explorer-api/CHANGELOG.md b/packages/zowe-explorer-api/CHANGELOG.md index 6963288f3a..05d291244d 100644 --- a/packages/zowe-explorer-api/CHANGELOG.md +++ b/packages/zowe-explorer-api/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t ### Bug fixes - Updated `@zowe/cli` dependency to fix issue where "Log out of authentication service" doesn't show in Manage Profile menu. [#2633](https://github.com/zowe/zowe-explorer-vscode/issues/2633) +- Fixed regression of issue where the `ProfilesCache` class would retain old service profiles, even if they were removed from the team config. [#2910](https://github.com/zowe/zowe-explorer-vscode/issues/2910) ## `2.15.4`