mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 20:12:38 +08:00
* feat: implement message editing and resend functionality with block management * fix: move start_time_millsec initialization to onChunk for accurate timing * feat: refactor message update thunks to separate block addition and updates * feat: enhance MessageBlockEditor with toolbar buttons and attachment functionality * refactor: implement message editing context and integrate with message operations * style: adjust padding in MessageBlockEditor and related components * refactor: remove MessageEditingContext and integrate editing logic directly in Message component * refactor: streamline message rendering logic by using conditional rendering for MessageEditor and MessageContent * refactor: remove redundant ipcRenderer variable in useMCPServers hook * fix: Add mock for electron's ipcRenderer to support testing * test: Update mocks for ipcRenderer and remove redundant window.electron mock * fix: enhance file handling in MessageEditor with new Electron API - Added support for file dragging with visual feedback. - Improved file type validation during drag-and-drop and clipboard pasting. - Displayed user notifications for unsupported file types. - Refactored file handling logic for better clarity and maintainability.
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { vi } from 'vitest'
|
|
|
|
vi.mock('electron-log/renderer', () => {
|
|
return {
|
|
default: {
|
|
info: console.log,
|
|
error: console.error,
|
|
warn: console.warn,
|
|
debug: console.debug,
|
|
verbose: console.log,
|
|
silly: console.log,
|
|
log: console.log,
|
|
transports: {
|
|
console: {
|
|
level: 'info'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
vi.stubGlobal('window', {
|
|
electron: {
|
|
ipcRenderer: {
|
|
on: vi.fn(), // Mocking ipcRenderer.on
|
|
send: vi.fn() // Mocking ipcRenderer.send
|
|
}
|
|
},
|
|
api: {
|
|
file: {
|
|
read: vi.fn().mockResolvedValue('[]'), // Mock file.read to return an empty array (you can customize this)
|
|
writeWithId: vi.fn().mockResolvedValue(undefined) // Mock file.writeWithId to do nothing
|
|
}
|
|
}
|
|
})
|
|
|
|
vi.mock('axios', () => ({
|
|
default: {
|
|
get: vi.fn().mockResolvedValue({ data: {} }), // Mocking axios GET request
|
|
post: vi.fn().mockResolvedValue({ data: {} }) // Mocking axios POST request
|
|
// You can add other axios methods like put, delete etc. as needed
|
|
}
|
|
}))
|
|
|
|
vi.stubGlobal('window', {
|
|
...global.window, // Copy other global properties
|
|
addEventListener: vi.fn(), // Mock addEventListener
|
|
removeEventListener: vi.fn() // You can also mock removeEventListener if needed
|
|
})
|