接入群消息实时提醒和重连补拉

This commit is contained in:
xhgit committed 2026-11-14 14:59:24 +08:00
1 parent 5ace82b0d7
commit b2e04e8174
10 files changed
+122 -33

No files matched your search

+14 -2
View File
@@ -121,6 +121,13 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
const pages = []
try {
const [owner, removed] = await Promise.all([browser.newPage(), browser.newPage()])
let ownerSocket
let holdConnection = false
await owner.routeWebSocket('**/api/v1/realtime', (route) => {
if (holdConnection) { void route.close({ code: 1012 }); return }
ownerSocket = route
route.connectToServer()
})
await owner.context().grantPermissions(['microphone'], { origin: base })
await Promise.all([owner.goto(base), removed.goto(base)])
desktop = await _electron.launch({
@@ -163,8 +170,13 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
await Promise.all(pages.map((page) => chat(page).getByText('群加密已建立', { exact: true }).waitFor()))
const first = 'Windows 群消息 ' + id()
await work(removed).getByRole('link', { name: '联系人' }).click()
holdConnection = true
await ownerSocket.close({ code: 1012 })
await owner.getByText('正在重连', { exact: true }).waitFor()
const epoch = await send(windows, first)
await Promise.all([owner, windows].map((page) => chat(page).getByText(first, { exact: true }).waitFor()))
holdConnection = false
await owner.getByText('实时连接已建立', { exact: true }).waitFor()
await Promise.all([owner, windows].map((page) => chat(page).getByText(first, { exact: true }).waitFor({ timeout: 3500 })))
await work(removed).getByRole('link', { name: '群组' }).click()
await removed.getByRole('link', { name: new RegExp(group) }).click()
await chat(removed).getByRole('button', { name: '启用本机群聊' }).click()
@@ -177,7 +189,7 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
const reply = '加密引用回复 ' + id()
assert.equal(await send(owner, reply), epoch)
const receivedReply = chat(windows).getByRole('listitem').filter({ hasText: reply })
await receivedReply.locator('blockquote').getByText(first, { exact: true }).waitFor()
await receivedReply.locator('blockquote').getByText(first, { exact: true }).waitFor({ timeout: 3500 })
await work(removed).getByRole('link', { name: '联系人' }).click()
const own = chat(windows).getByRole('listitem').filter({ has: windows.getByText(first, { exact: true }) }).first()
await own.getByRole('button', { name: '编辑', exact: true }).click()