增加群消息本机搜索和加密收藏

This commit is contained in:
xhgit committed 2026-11-14 09:30:34 +08:00
1 parent 5b7c03e4ec
commit 2e51827a07
5 files changed
+109 -13

No files matched your search

+45
View File
@@ -190,20 +190,60 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
await chat(removed).getByRole('button', { name: '启用本机群聊' }).click()
await chat(removed).getByText(edited, { exact: true }).waitFor()
const keyword = chat(owner).getByRole('searchbox', { name: '搜索本机群消息' })
const favorites = chat(owner).getByRole('checkbox', { name: '只看收藏' })
const searchedRequests = []
const trackSearch = (request) => searchedRequests.push({ url: request.url(), method: request.method() })
owner.on('request', trackSearch)
await keyword.fill(first.toUpperCase())
await chat(owner).getByRole('listitem').filter({ hasText: reply }).waitFor()
assert.equal(await incomingEdit.count(), 0)
await keyword.fill(edited)
await incomingEdit.getByRole('button', { name: '收藏', exact: true }).click()
await incomingEdit.getByRole('button', { name: '取消收藏', exact: true }).waitFor()
await favorites.check()
assert.equal(await chat(owner).getByRole('listitem').count(), 1)
const unmatched = '没有匹配的验收关键词 ' + id()
await keyword.fill(unmatched)
await chat(owner).getByText('没有匹配的群消息。').waitFor()
owner.off('request', trackSearch)
assert.ok(searchedRequests.filter(({ url }) => url.includes('/groups/')).every(({ url, method }) =>
method === 'GET' && !/search|favorite/i.test(new URL(url).pathname) && !decodeURIComponent(url).includes(unmatched)))
await work(owner).getByRole('link', { name: '联系人' }).click()
await work(owner).getByRole('link', { name: '群组' }).click()
await owner.getByRole('link', { name: new RegExp(group) }).click()
await chat(owner).getByRole('button', { name: '启用本机群聊' }).click()
await favorites.check()
await incomingEdit.getByRole('button', { name: '取消收藏', exact: true }).click()
await chat(owner).getByText('没有匹配的群消息。').waitFor()
await favorites.uncheck()
assert.equal(await chat(windows).getByRole('listitem').filter({ hasText: edited })
.getByRole('button', { name: '取消收藏', exact: true }).count(), 0)
const temporary = '待撤回群消息 ' + id()
assert.equal(await send(windows, temporary), epoch)
const outgoing = chat(windows).getByRole('listitem').filter({ hasText: temporary })
await chat(owner).getByText(temporary, { exact: true }).waitFor()
const incoming = chat(owner).getByRole('listitem').filter({ hasText: temporary })
await incoming.getByRole('button', { name: '收藏', exact: true }).click()
await incoming.getByRole('button', { name: '取消收藏', exact: true }).waitFor()
await outgoing.getByRole('button', { name: '撤回', exact: true }).click()
await chat(windows).getByRole('button', { name: '确认撤回' }).click()
for (const page of pages) {
await chat(page).getByText('消息已撤回', { exact: true }).waitFor()
assert.equal(await chat(page).getByText(temporary, { exact: true }).count(), 0)
}
await favorites.check()
await chat(owner).getByText('没有匹配的群消息。').waitFor()
await favorites.uncheck()
const contents = Buffer.from('Windows 群文件内容 ' + id() + '\n'.repeat(9000))
const filename = '群附件-' + id() + '.txt'
await sendFile(windows, filename, 'text/plain', contents)
await keyword.fill(filename.toUpperCase())
await chat(owner).getByRole('button', { name: '下载 ' + filename }).waitFor()
assert.equal(await chat(owner).getByRole('listitem').count(), 1)
await keyword.clear()
const fileDownload = owner.waitForEvent('download')
const fileResponse = owner.waitForResponse((item) => item.url().includes('/attachments/') && item.request().method() === 'GET')
await chat(owner).getByRole('button', { name: '下载 ' + filename }).click()
@@ -276,6 +316,11 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
const history = chat(windows).getByRole('listitem').filter({ hasText: edited })
assert.equal(await history.count(), 1)
assert.equal(await history.getByRole('button', { name: '编辑', exact: true }).count(), 0)
await chat(windows).getByRole('searchbox', { name: '搜索本机群消息' }).fill(edited)
await history.getByRole('button', { name: '收藏', exact: true }).click()
await chat(windows).getByRole('checkbox', { name: '只看收藏' }).check()
await history.getByRole('button', { name: '取消收藏', exact: true }).waitFor()
assert.equal(await chat(windows).getByRole('listitem').count(), 1)
} catch (error) {
const status = await Promise.all(pages.map((page) => page.locator('[role=alert], .group-chat [role=status]').allTextContents()))
throw new Error(JSON.stringify(status), { cause: error })