增加群聊置顶、免打扰和应用内提醒

This commit is contained in:
xhgit committed 2026-11-14 16:00:46 +08:00
1 parent ced6e9030d
commit f54077ce46
17 files changed
+228 -42

No files matched your search

+31 -4
View File
@@ -155,6 +155,25 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
await owner.getByRole('heading', { name: group }).waitFor()
await invite(owner, windows, names[1], group)
await invite(owner, removed, names[2], group)
const settings = (page, name) => page.getByRole('button', { name, exact: true })
await settings(removed, '群聊免打扰').click()
await removed.getByRole('button', { name: '群聊免打扰', pressed: true }).waitFor()
assert.equal(await settings(owner, '群聊免打扰').getAttribute('aria-pressed'), 'false')
await settings(owner, '置顶群聊').click()
await owner.getByRole('button', { name: '置顶群聊', pressed: true }).waitFor()
const ownerCompanion = await browser.newPage()
await ownerCompanion.goto(base)
await ownerCompanion.getByLabel('用户名').fill(names[0])
await ownerCompanion.getByLabel('密码', { exact: true }).fill(password)
await ownerCompanion.locator('button.primary').click()
await ownerCompanion.getByText('实时连接已建立').waitFor()
await work(ownerCompanion).getByRole('link', { name: '群组' }).click()
await ownerCompanion.getByRole('link', { name: new RegExp(group + '.*已置顶') }).click()
await settings(ownerCompanion, '群聊免打扰').click()
await owner.getByRole('button', { name: '群聊免打扰', pressed: true }).waitFor({ timeout: 4500 })
await settings(ownerCompanion, '群聊免打扰').click()
await owner.getByRole('button', { name: '群聊免打扰', pressed: false }).waitFor({ timeout: 4500 })
await ownerCompanion.close()
const codes = await Promise.all(pages.map(async (page) => {
await chat(page).getByRole('button', { name: '启用本机群聊' }).click()
const code = page.locator('.group-security-code')
@@ -180,6 +199,7 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
holdConnection = false
await owner.getByText('实时连接已建立', { exact: true }).waitFor()
await Promise.all([owner, windows].map((page) => chat(page).getByText(first, { exact: true }).waitFor({ timeout: 3500 })))
assert.equal(await removed.getByRole('link', { name: '有新的群消息' }).count(), 0)
await work(removed).getByRole('link', { name: '群组' }).click()
await removed.getByRole('link', { name: new RegExp(group) }).click()
await chat(removed).getByRole('button', { name: '启用本机群聊' }).click()
@@ -193,15 +213,18 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
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({ timeout: 3500 })
await settings(removed, '群聊免打扰').click()
await removed.getByRole('button', { name: '群聊免打扰', pressed: false }).waitFor()
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()
const edited = '已修改群消息 ' + id()
assert.equal(await send(windows, edited, '保存编辑'), epoch)
const notice = removed.getByRole('link', { name: '有新的群消息' })
await notice.waitFor({ timeout: 4500 })
const incomingEdit = chat(owner).getByRole('listitem').filter({ has: owner.getByText(edited, { exact: true }) })
await incomingEdit.getByText('已编辑', { exact: true }).waitFor()
await work(removed).getByRole('link', { name: '群组' }).click()
await removed.getByRole('link', { name: new RegExp(group) }).click()
await notice.click()
await chat(removed).getByRole('button', { name: '启用本机群聊' }).click()
await chat(removed).getByText(edited, { exact: true }).waitFor()
@@ -343,6 +366,7 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
await owner.getByLabel('群名称', { exact: true }).fill(targetGroup)
await owner.getByRole('button', { name: '创建群组' }).click()
await owner.getByRole('heading', { name: targetGroup }).waitFor()
assert.match(await owner.getByRole('complementary', { name: '群组列表' }).getByRole('link').first().textContent(), /已置顶/)
await owner.getByLabel('邀请联系人').selectOption({ label: names[1] })
await owner.getByRole('button', { name: '发送邀请' }).click()
await windows.getByRole('link', { name: new RegExp(targetGroup) }).click()
@@ -407,8 +431,11 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
await windows.getByRole('button', { name: '启用本机加密聊天' }).click()
const privateFile = '私聊文件-' + id() + '.txt'
const originalUpload = windows.waitForResponse((item) => /\/api\/v1\/attachments\//.test(item.url()) && item.request().method() === 'POST')
await windows.getByLabel('发送附件').setInputFiles({ name: privateFile, mimeType: 'text/plain', buffer: contents })
const originalFile = await originalUpload
const attachmentInput = windows.locator('input[type=file]:enabled')
const [originalFile] = await Promise.all([
originalUpload,
attachmentInput.setInputFiles({ name: privateFile, mimeType: 'text/plain', buffer: contents }),
])
assert.equal(originalFile.status(), 204)
const originalBytes = originalFile.request().postDataBuffer()
assert.ok(originalBytes && originalBytes.length === contents.length + 16)