From c82b479dc27ad649519a048c8c24832579c2eb5e Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Tue, 3 Sep 2024 21:34:15 -0400 Subject: [PATCH 1/2] Fix mocking Chrome API for Electron --- extension/src/app/Actions.tsx | 10 +++------- extension/src/background/index.ts | 1 + extension/src/chromeApiMock.ts | 20 +++++++++++--------- extension/test/electron/devpanel.spec.js | 10 +++++----- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/extension/src/app/Actions.tsx b/extension/src/app/Actions.tsx index 216e59afab..656bb6d67f 100644 --- a/extension/src/app/Actions.tsx +++ b/extension/src/app/Actions.tsx @@ -29,11 +29,7 @@ interface OwnProps { } type Props = StateProps & DispatchProps & OwnProps; -declare global { - interface Window { - isElectron?: boolean; - } -} +const isElectron = navigator.userAgent.includes('Electron'); function sendMessage(message: SingleMessage) { chrome.runtime.sendMessage(message); @@ -98,7 +94,7 @@ class Actions extends Component { )} - {!window.isElectron && ( + {!isElectron && ( )} - {!window.isElectron && ( + {!isElectron && (