feat: 刷新消息列表时间改为350ms

This commit is contained in:
Wxw-Gu
2026-08-31 23:27:22 +08:00
parent e59332b514
commit f65dc4ac32
5 changed files with 169 additions and 8 deletions
+38
View File
@@ -229,6 +229,44 @@ test('CHAT-01 archive More menu is keyboard-safe and keeps the page usable', asy
}
})
test('CHAT-REALTIME-01 archive refreshes from a native message-shard event', async () => {
const fixture = await launchTestApp()
const pageErrors: Error[] = []
fixture.page.on('pageerror', (error) => pageErrors.push(error))
try {
await fixture.setWindowContentSize({ width: 820, height: 600 })
await fixture.page.getByText('产品测试群', { exact: true }).click()
await expect(fixture.page.getByText('这是一条脱敏测试消息', { exact: true })).toBeVisible()
const result = await fixture.page.evaluate(() =>
window.electron.ipcRenderer.invoke('test:messageChange', {
md5: 'group-regular-md5',
event: { db: 'message_0.db', table: 'message', action: 'update' },
message: {
id: 'msg-monitor',
localId: 999,
from: 'user',
type: '普通文本',
datetime: '2026-08-31 12:00:00',
content: '消息',
isSender: false,
name: '测试成员',
senderId: 'wxid_fixture_member',
createTime: Math.floor(Date.now() / 1000),
contentData: { type: 'text', content: '消息' }
}
})
)
expect(result).toEqual({ success: true })
await expect(fixture.page.getByText('消息', { exact: true })).toBeVisible({
timeout: 3_000
})
expect(pageErrors).toEqual([])
} finally {
await fixture.close()
}
})
test('CHAT-02 personal WeChat send dialog is keyboard-safe and fits the viewport', async () => {
test.skip(process.platform !== 'darwin', 'Personal WeChat sending is currently macOS-only')
const fixture = await launchTestApp()
+13
View File
@@ -606,6 +606,19 @@ handle('db:getMessages', (md5, startTime, endTime, options) => {
if (options && options.limit) messages = messages.slice(-options.limit)
return messages
})
handle('test:messageChange', (payload = {}) => {
const md5 = String(payload.md5 || '')
const message = payload.message
if (md5 && message && Array.isArray(fixture.messages[md5])) {
fixture.messages[md5].push(message)
}
const event = payload.event || { db: 'message_0.db', table: 'message', action: 'update' }
const json = typeof event === 'string' ? event : JSON.stringify(event)
for (const window of BrowserWindow.getAllWindows()) {
if (!window.isDestroyed()) window.webContents.send('wcdb-change', { type: 'update', json })
}
return { success: true }
})
handle('db:getGroupSnapshot', (md5) =>
md5.startsWith('group-')
? {