diff --git a/src/js/auth.js b/src/js/auth.js index dd560140..5094d62d 100644 --- a/src/js/auth.js +++ b/src/js/auth.js @@ -336,8 +336,9 @@ export class Auth { // Mark accounts with out-of-date scopes as "needsReauth" return accounts.map((account) => { const scopesOutOfDate = - getMissingScopes(account.scope ?? "", requiredScope, optionalScope) - .length > 0; + account.scope != null && + getMissingScopes(account.scope, requiredScope, optionalScope).length > + 0; return { ...account, needsReauth: account.needsReauth || scopesOutOfDate, diff --git a/tests/unit/env.js b/tests/unit/env.js index 22216dca..7c3e510b 100644 --- a/tests/unit/env.js +++ b/tests/unit/env.js @@ -22,6 +22,21 @@ globalThis.MutationObserver = dom.window.MutationObserver; globalThis.FileReader = dom.window.FileReader; globalThis.Blob = dom.window.Blob; globalThis.getComputedStyle = dom.window.getComputedStyle; + +// Matches head.html template +globalThis.window.env = { + hostName: "localhost", + gitCommit: "test", + environment: "test", + version: "0.0.0", + pluginSdkFileName: "pluginSdk.test.js", + oauthScopes: "atproto", + oauthOptionalScopes: "", + playwright: false, + useConfidentialOauth: false, + oatproxyClientId: "", +}; + // Node has its own global navigator; alias JSDOM's so code under test and // tests (which mock properties on window.navigator) see the same object. Object.defineProperty(globalThis, "navigator", { diff --git a/tests/unit/specs/plugins/pluginBridge.test.js b/tests/unit/specs/plugins/pluginBridge.test.js index ed7f177b..696c6025 100644 --- a/tests/unit/specs/plugins/pluginBridge.test.js +++ b/tests/unit/specs/plugins/pluginBridge.test.js @@ -1,10 +1,6 @@ import { describe, it, beforeEach, afterEach } from "node:test"; import assert from "node:assert/strict"; -// PluginBridge reads window.env.playwright during loadFromSource; provide it -// so the import resolves cleanly. Individual tests avoid the real load path. -globalThis.window.env = globalThis.window.env ?? { playwright: true }; - const { PluginBridge, PluginInstance,