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 regression with clearing profile object caches on refresh #2917

Merged
merged 2 commits into from
May 16, 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
1 change: 1 addition & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
Loading