mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-07-06 22:31:08 +08:00
- Register QuickAssistant in windowRegistry (singleton, show:false, showInDock:false, macReapplyAlwaysOnTop quirk). QuickAssistantService now creates the BrowserWindow via wm.create() and sets up listeners directly after creation; no global onWindowCreated subscription needed since we own the window. - Instantiate windowStateKeeper before wm.create() and inject persisted x/y/w/h via OpenWindowArgs.options. manage() only attaches outbound listeners and does not retroactively apply persisted bounds. - Set the initial alwaysOnTop level once after creation; the macReapplyAlwaysOnTop quirk handles re-application across hide/show. - closeQuickWindow now hides instead of destroying. Quick window is a high-frequency toggle; destroy+recreate would blank-flash on next show and waste preload work. Final teardown stays in WindowManager.onDestroy. - Rename WindowType.Mini -> QuickAssistant, IpcChannel.MiniWindow_* -> QuickAssistant_*, IpcChannel.ShowMiniWindow -> QuickAssistant_Shown, preload window.api.miniWindow -> quickAssistant, log window source 'MiniWindow' -> 'QuickAssistant'. Drop dead QuickAssistant_Hidden IPC (no listener exists anywhere in the tree). - Cross-process contracts retained: miniWindow.html entry and miniWindow-state.json bounds file are kept verbatim to avoid a build layout change and to preserve every user's saved window bounds. - Update renderer call sites (HomeWindow, QuickAssistantSettings, entryPoint) and an e2e fixture comment to the new namespace.
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import type { ElectronApplication, Page } from '@playwright/test'
|
|
import { _electron as electron, test as base } from '@playwright/test'
|
|
|
|
/**
|
|
* Custom fixtures for Electron e2e testing.
|
|
* Provides electronApp and mainWindow to all tests.
|
|
*/
|
|
export type ElectronFixtures = {
|
|
electronApp: ElectronApplication
|
|
mainWindow: Page
|
|
}
|
|
|
|
export const test = base.extend<ElectronFixtures>({
|
|
electronApp: async ({}, use) => {
|
|
// Launch Electron app from project root
|
|
// The args ['.'] tells Electron to load the app from current directory
|
|
const electronApp = await electron.launch({
|
|
args: ['.'],
|
|
env: {
|
|
...process.env,
|
|
NODE_ENV: 'development'
|
|
},
|
|
timeout: 60000
|
|
})
|
|
|
|
await use(electronApp)
|
|
|
|
// Cleanup: close the app after test
|
|
await electronApp.close()
|
|
},
|
|
|
|
mainWindow: async ({ electronApp }, use) => {
|
|
// Wait for the main window (title: "Cherry Studio", not "Quick Assistant")
|
|
// On Mac, the app may create the QuickAssistant window with a different title
|
|
const mainWindow = await electronApp.waitForEvent('window', {
|
|
predicate: async (window) => {
|
|
const title = await window.title()
|
|
return title === 'Cherry Studio'
|
|
},
|
|
timeout: 60000
|
|
})
|
|
|
|
// Wait for React app to mount
|
|
await mainWindow.waitForSelector('#root', { state: 'attached', timeout: 60000 })
|
|
|
|
// Wait for initial content to load
|
|
await mainWindow.waitForLoadState('domcontentloaded')
|
|
|
|
await use(mainWindow)
|
|
}
|
|
})
|
|
|
|
export { expect } from '@playwright/test'
|