add disconnectEverything function. add new test where playwright sees

existing page tab
This commit is contained in:
Tommy D. Rossi
2025-11-22 23:49:40 +01:00
parent 7025836f7e
commit 6b6ac216f2
2 changed files with 78 additions and 5 deletions
+25
View File
@@ -68,6 +68,30 @@ async function toggleExtensionForActiveTab(): Promise<{ isConnected: boolean; st
return { isConnected, state }
}
// @ts-ignore
globalThis.disconnectEverything = disconnectEverything
async function disconnectEverything() {
const { connectedTabs, connection } = useExtensionStore.getState()
// Disconnect all tabs
for (const tabId of connectedTabs.keys()) {
await disconnectTab(tabId)
}
// Force close connection if it still exists
const state = useExtensionStore.getState()
if (state.connection) {
state.connection.close('Manual full disconnect')
useExtensionStore.setState({
connection: undefined,
connectionState: 'disconnected',
connectedTabs: new Map(),
errorText: undefined
})
}
}
// @ts-ignore
globalThis.getExtensionState = () => useExtensionStore.getState()
@@ -75,6 +99,7 @@ declare global {
var state: typeof useExtensionStore
var toggleExtensionForActiveTab: () => Promise<{ isConnected: boolean; state: ExtensionState }>
var getExtensionState: () => ExtensionState
var disconnectEverything: () => Promise<void>
}
async function resetDebugger() {