mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-10-03 18:33:14 +08:00
feat: 抽离保留进程功能到设置里
This commit is contained in:
@@ -143,6 +143,7 @@ describe('PersonalWechatSendDialog', () => {
|
||||
renderDialog()
|
||||
await startComposer()
|
||||
expect(screen.getByRole('dialog')).toHaveTextContent('文字转语音')
|
||||
expect(screen.queryByRole('switch', { name: '保留 OneBot 进程' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('验证消息能力')).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: '生成语音' })).toBeDisabled()
|
||||
})
|
||||
|
||||
@@ -19,6 +19,8 @@ const cancelRuntimeDownload = vi.fn()
|
||||
const removeRuntime = vi.fn()
|
||||
const openRuntimeDirectory = vi.fn()
|
||||
const rebindSender = vi.fn()
|
||||
const getKeepOneBotProcess = vi.fn()
|
||||
const setKeepOneBotProcess = vi.fn()
|
||||
|
||||
const senderStatus = {
|
||||
state: 'online' as const,
|
||||
@@ -88,6 +90,8 @@ describe('PersonalWechatSendPage on macOS', () => {
|
||||
})
|
||||
openRuntimeDirectory.mockReset().mockResolvedValue({ success: true })
|
||||
rebindSender.mockReset().mockResolvedValue(senderStatus)
|
||||
getKeepOneBotProcess.mockReset().mockResolvedValue(false)
|
||||
setKeepOneBotProcess.mockReset().mockImplementation(async (keep: boolean) => keep)
|
||||
vi.spyOn(window, 'confirm').mockReturnValue(true)
|
||||
Object.defineProperty(window, 'api', {
|
||||
configurable: true,
|
||||
@@ -100,7 +104,9 @@ describe('PersonalWechatSendPage on macOS', () => {
|
||||
cancelPersonalWechatRuntimeDownload: cancelRuntimeDownload,
|
||||
removePersonalWechatRuntime: removeRuntime,
|
||||
openPersonalWechatRuntimeDirectory: openRuntimeDirectory,
|
||||
rebindPersonalWechatSender: rebindSender
|
||||
rebindPersonalWechatSender: rebindSender,
|
||||
getPersonalWechatKeepOneBotProcess: getKeepOneBotProcess,
|
||||
setPersonalWechatKeepOneBotProcess: setKeepOneBotProcess
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -123,6 +129,18 @@ describe('PersonalWechatSendPage on macOS', () => {
|
||||
expect(versionsDialog).toHaveTextContent('4.1.11.53')
|
||||
})
|
||||
|
||||
it('keeps the OneBot process setting on the macOS WeChat send page', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(<PersonalWechatSendPage onNotice={vi.fn()} />)
|
||||
|
||||
const keepProcess = await screen.findByRole('switch', { name: '保留 OneBot 进程' })
|
||||
expect(keepProcess).not.toBeChecked()
|
||||
await user.click(keepProcess)
|
||||
|
||||
await waitFor(() => expect(setKeepOneBotProcess).toHaveBeenCalledWith(true))
|
||||
expect(keepProcess).toBeChecked()
|
||||
})
|
||||
|
||||
it('downloads a missing macOS runtime from the send page', async () => {
|
||||
getRuntimeStatus.mockResolvedValue({
|
||||
...readyRuntime,
|
||||
|
||||
@@ -191,4 +191,11 @@ describe('PersonalWechatSendPage on Windows', () => {
|
||||
expect(screen.queryByText(/OneBot/i)).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('微信发送组件')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('does not show the macOS process setting on the Windows WeChat send page', async () => {
|
||||
render(<PersonalWechatSendPage onNotice={vi.fn()} />)
|
||||
|
||||
expect(await screen.findByRole('spinbutton', { name: '微信发送能力端口' })).toBeVisible()
|
||||
expect(screen.queryByRole('switch', { name: '保留 OneBot 进程' })).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user