Skip to content

Jiashen/test fix #7615

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

Draft
wants to merge 2 commits into
base: custom-auth/main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions lib/msal-browser/src/app/PublicClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ export class PublicClientApplication implements IPublicClientApplication {
clearCache(logoutRequest?: ClearCacheRequest): Promise<void> {
return this.controller.clearCache(logoutRequest);
}

closeEventHandlerChannel(): void {
this.controller.closeEventHandlerChannel();
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/msal-browser/src/controllers/IController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,6 @@ export interface IController {

/** @internal */
getPerformanceClient(): IPerformanceClient;

closeEventHandlerChannel(): void;
}
4 changes: 4 additions & 0 deletions lib/msal-browser/src/controllers/NestedAppAuthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,4 +881,8 @@ export class NestedAppAuthController implements IController {
);
return this.browserStorage.hydrateCache(result, request);
}

closeEventHandlerChannel(): void {
this.eventHandler.closeBroadcastChannel();
}
}
4 changes: 4 additions & 0 deletions lib/msal-browser/src/controllers/StandardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,10 @@ export class StandardController implements IController {
);
return res;
}

closeEventHandlerChannel(): void {
this.eventHandler.closeBroadcastChannel();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,8 @@ export class UnknownOperatingContextController implements IController {
blockAPICallsBeforeInitialize(this.initialized);
blockNonBrowserEnvironment();
}

closeEventHandlerChannel(): void {
this.eventHandler.closeBroadcastChannel();
}
}
7 changes: 7 additions & 0 deletions lib/msal-browser/src/event/EventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,11 @@ export class EventHandler {
this.invokeCrossTabCallbacks
);
}

/**
* Close the broadcast channel
*/
closeBroadcastChannel(): void {
this.broadcastChannel.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class CustomAuthPublicClientApplication
return this.customAuthController.resetPassword(resetPasswordInputs);
}

close(): void {
this.closeEventHandlerChannel();
}

/**
* Validates the configuration to ensure it is a valid CustomAuthConfiguration object.
* @param config The configuration object for the PublicClientApplication.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export interface ICustomAuthPublicClientApplication {
* @returns {Promise<ResetPasswordStartResult>} A promise that resolves to ResetPasswordStartResult
*/
resetPassword(resetPasswordInputs: ResetPasswordInputs): Promise<ResetPasswordStartResult>;

close(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ describe("CustomAuthPublicClientApplication", () => {
const app = await CustomAuthPublicClientApplication.create(customAuthConfig);

expect(app).toBeInstanceOf(CustomAuthPublicClientApplication);

app.close();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe("CustomAuthStandardController", () => {
});

afterEach(() => {
controller.closeEventHandlerChannel();
jest.clearAllMocks(); // Clear mocks between tests
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("GetAccount", () => {
});

afterEach(() => {
app.close();
jest.clearAllMocks(); // Clear mocks between tests
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe("Reset password", () => {
});

afterEach(() => {
app.close(); // Close the app
jest.clearAllMocks(); // Clear mocks between tests
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe("Sign in", () => {
});

afterEach(() => {
app.close();
jest.clearAllMocks(); // Clear mocks between tests
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe("Sign up", () => {
});

afterEach(() => {
app.close();
jest.clearAllMocks(); // Clear mocks between tests
});

Expand Down
21 changes: 1 addition & 20 deletions lib/msal-custom-auth/test/test_resources/CustomAuthConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { LogLevel } from "@azure/msal-browser";
import { CustomAuthConfiguration } from "../../src/configuration/CustomAuthConfiguration.js";

export const customAuthConfig: CustomAuthConfiguration = {
Expand All @@ -23,25 +22,7 @@ export const customAuthConfig: CustomAuthConfiguration = {
system: {
loggerOptions: {
loggerCallback: (level, message, containsPii) => {
if (containsPii) {
return;
}
switch (level) {
case LogLevel.Error:
console.info(`[Error] ${message}`);
return;
case LogLevel.Info:
console.info(`[Info] ${message}`);
return;
case LogLevel.Verbose:
console.info(`[Verbose] ${message}`);
return;
case LogLevel.Warning:
console.info(`[Warning] ${message}`);
return;
default:
return;
}
return;
},
},
},
Expand Down