mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Kludge fix for application crash when quitting (#7463)
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
04fbcd4eee
commit
1195c82a5e
@ -12,11 +12,15 @@ const resolveSystemProxyFromElectronInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const withErrorLoggingFor = di.inject(withErrorLoggingInjectable);
|
||||
const withErrorLogging = withErrorLoggingFor(() => "Error resolving proxy");
|
||||
|
||||
|
||||
return withErrorLogging(async (url: string) => {
|
||||
const helperWindow = await di.inject(resolveSystemProxyWindowInjectable);
|
||||
|
||||
return await helperWindow.webContents.session.resolveProxy(url);
|
||||
const proxy = await helperWindow.webContents.session.resolveProxy(url);
|
||||
|
||||
helperWindow.close();
|
||||
|
||||
return proxy;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@ -27,12 +27,17 @@ describe("technical: resolve-system-proxy-from-electron", () => {
|
||||
});
|
||||
|
||||
describe("given there are no unexpected issues, when called with URL", () => {
|
||||
let closeMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
resolveSystemProxyMock = asyncFn();
|
||||
closeMock = jest.fn();
|
||||
|
||||
di.override(
|
||||
resolveSystemProxyWindowInjectable,
|
||||
async () => ({
|
||||
close: closeMock,
|
||||
|
||||
webContents: {
|
||||
session: {
|
||||
resolveProxy: resolveSystemProxyMock,
|
||||
@ -58,10 +63,26 @@ describe("technical: resolve-system-proxy-from-electron", () => {
|
||||
expect(promiseStatus.fulfilled).toBe(false);
|
||||
});
|
||||
|
||||
it("when call for proxy, resolves with the proxy", async () => {
|
||||
resolveSystemProxyMock.resolve("some-proxy");
|
||||
it("does not close the window yet", () => {
|
||||
expect(closeMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
expect(await actualPromise).toBe("some-proxy");
|
||||
describe("when call for proxy resolves", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
await resolveSystemProxyMock.resolve("some-proxy");
|
||||
|
||||
});
|
||||
|
||||
it("closes the window", () => {
|
||||
expect(closeMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("resolves with the proxy", async () => {
|
||||
const actual = await actualPromise;
|
||||
|
||||
expect(actual).toBe("some-proxy");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -81,6 +102,8 @@ describe("technical: resolve-system-proxy-from-electron", () => {
|
||||
},
|
||||
} as unknown as Session,
|
||||
} as unknown as WebContents,
|
||||
|
||||
close: () => {},
|
||||
} as unknown as BrowserWindow),
|
||||
);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { BrowserWindow } from "electron";
|
||||
import electronAppInjectable from "../../electron-app/electron-app.injectable";
|
||||
|
||||
@ -22,6 +22,9 @@ const resolveSystemProxyWindowInjectable = getInjectable({
|
||||
|
||||
return window;
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.transient,
|
||||
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user