汇总私聊与群聊本机收藏
This commit is contained in:
1 parent
a7d85f183c
commit
e08c990cc7
12 files changed
+314
-24
No files matched your search
@@ -388,6 +388,48 @@ test('Web 与 Windows 安全码校验、加密互发、离线接收和状态恢
|
||||
const address = toolbar.getByRole('textbox', { name: '网址或搜索关键词' })
|
||||
await toolbar.waitForFunction((expected) => document.querySelector('#address')?.value === expected, link)
|
||||
assert.equal(await address.inputValue(), link)
|
||||
await toolbar.close()
|
||||
|
||||
async function addFavorite(page, locator) {
|
||||
const line = page.getByRole('list', { name: '消息记录' }).getByRole('listitem').filter({ has: locator })
|
||||
await line.getByRole('button', { name: '收藏', exact: true }).click()
|
||||
await line.getByRole('button', { name: '取消收藏', exact: true }).waitFor()
|
||||
}
|
||||
await addFavorite(web, webLink)
|
||||
await addFavorite(web, web.getByRole('button', { name: '下载 ' + remainingFile, exact: true }))
|
||||
await addFavorite(windows, windows.getByRole('button', { name: '预览 加密预览.png', exact: true }))
|
||||
await addFavorite(windows, windows.getByRole('button', { name: '播放语音', exact: true }))
|
||||
await Promise.all([web, windows].map((page) => work(page).getByRole('link', { name: '收藏', exact: true }).click()))
|
||||
const webFavorites = web.getByRole('list', { name: '本机收藏' })
|
||||
const windowsFavorites = windows.getByRole('list', { name: '本机收藏' })
|
||||
await webFavorites.getByRole('link', { name: link, exact: true }).waitFor()
|
||||
assert.equal(await webFavorites.getByRole('listitem').count(), 2)
|
||||
const tracked = []
|
||||
const trackFavorites = (request) => tracked.push([request.url(), request.method(), request.postData()])
|
||||
web.on('request', trackFavorites)
|
||||
await web.getByLabel('内容类型').selectOption('link')
|
||||
assert.equal(await webFavorites.getByRole('listitem').count(), 1)
|
||||
const search = web.getByRole('searchbox', { name: '搜索本机收藏' })
|
||||
const marker = '本机收藏验收 ' + randomBytes(8).toString('hex')
|
||||
await search.fill(marker)
|
||||
await web.getByText('没有匹配的收藏。', { exact: true }).waitFor()
|
||||
await search.clear()
|
||||
await web.getByLabel('内容类型').selectOption('file')
|
||||
const favoriteDownload = web.waitForEvent('download')
|
||||
await webFavorites.getByRole('button', { name: '下载 ' + remainingFile, exact: true }).click()
|
||||
assert.deepEqual(await readFile(await (await favoriteDownload).path()), Buffer.from(remainingFile))
|
||||
await webFavorites.getByRole('button', { name: '取消收藏', exact: true }).click()
|
||||
await web.getByText('没有匹配的收藏。', { exact: true }).waitFor()
|
||||
web.off('request', trackFavorites)
|
||||
assert.ok(tracked.every(([url, method, body]) => method === 'GET' && !body && !url.includes(encodeURIComponent(marker))))
|
||||
|
||||
await windows.getByLabel('内容类型').selectOption('image')
|
||||
await windowsFavorites.getByRole('button', { name: '预览 加密预览.png', exact: true }).click()
|
||||
await windowsFavorites.getByRole('img', { name: '加密预览.png' }).waitFor()
|
||||
await windows.getByLabel('内容类型').selectOption('voice')
|
||||
await windowsFavorites.getByRole('button', { name: '播放语音', exact: true }).click()
|
||||
await windows.waitForFunction(() => document.querySelector('.favorite-card audio')?.currentTime > 0)
|
||||
assert.equal(await windowsFavorites.getByRole('link', { name: link, exact: true }).count(), 0)
|
||||
} finally {
|
||||
await desktop?.close()
|
||||
await browser.close()
|
||||
|
||||
@@ -638,6 +638,9 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
|
||||
assert.ok(originalBytes && originalBytes.length === contents.length + 16)
|
||||
|
||||
await windows.getByRole('listitem').filter({ hasText: privateFile }).getByRole('button', { name: '转发', exact: true }).click()
|
||||
const privateLine = windows.getByRole('list', { name: '消息记录' }).getByRole('listitem').filter({ hasText: privateFile })
|
||||
await privateLine.getByRole('button', { name: '收藏', exact: true }).click()
|
||||
await privateLine.getByRole('button', { name: '取消收藏', exact: true }).waitFor()
|
||||
const desktopForward = windows.getByRole('form', { name: '转发私聊消息' })
|
||||
const writes = []
|
||||
const recordWrite = (req) => { if (req.method() === 'POST' && req.url().includes('/groups/')) writes.push(req.url()) }
|
||||
@@ -710,6 +713,23 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
|
||||
}
|
||||
await windows.getByRole('button', { name: '消息系统通知', pressed: true }).click()
|
||||
await windows.getByText('已在本设备关闭消息系统通知', { exact: true }).waitFor()
|
||||
|
||||
await work(windows).getByRole('link', { name: '群组', exact: true }).click()
|
||||
await windows.getByRole('link', { name: new RegExp(targetGroup) }).click()
|
||||
await chat(windows).getByRole('button', { name: '启用本机群聊' }).click()
|
||||
const groupFile = chat(windows).getByRole('listitem').filter({ has: windows.getByRole('button', { name: '下载 ' + privateFile, exact: true }) })
|
||||
await groupFile.getByRole('button', { name: '收藏', exact: true }).click()
|
||||
await groupFile.getByRole('button', { name: '取消收藏', exact: true }).waitFor()
|
||||
await work(windows).getByRole('link', { name: '收藏', exact: true }).click()
|
||||
const collection = windows.getByRole('list', { name: '本机收藏' })
|
||||
await windows.getByRole('searchbox', { name: '搜索本机收藏' }).fill(privateFile)
|
||||
const downloads = collection.getByRole('button', { name: '下载 ' + privateFile, exact: true })
|
||||
await downloads.nth(1).waitFor()
|
||||
await windows.getByLabel('来源', { exact: true }).selectOption('group')
|
||||
assert.equal(await downloads.count(), 1)
|
||||
await collection.getByText(new RegExp(targetGroup)).waitFor()
|
||||
await windows.getByLabel('来源', { exact: true }).selectOption('private')
|
||||
assert.equal(await downloads.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 })
|
||||
|
||||
Reference in new issue
Block a user