增加群附件多选和拖拽批量发送
This commit is contained in:
1 parent
47b76080c6
commit
dfeb5bfefa
6 files changed
+138
-22
No files matched your search
@@ -390,6 +390,48 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员
|
||||
await historyView(windows, '消息').click()
|
||||
await player.waitFor({ state: 'detached' })
|
||||
|
||||
const firstBatch = '批量一-' + id() + '.txt'
|
||||
const secondBatch = '批量二-' + id() + '.txt'
|
||||
const payload = (name) => ({ name, mimeType: 'text/plain', buffer: Buffer.from(name) })
|
||||
const ownerDrop = chat(owner).getByRole('region', { name: '群附件发送区' })
|
||||
await ownerDrop.locator('input:enabled').setInputFiles([payload(firstBatch), payload(secondBatch)])
|
||||
const queue = ownerDrop.getByRole('list', { name: '待发附件' })
|
||||
assert.equal(await queue.getByRole('listitem').count(), 2)
|
||||
const uploadMatcher = (url) => url.pathname.includes('/groups/') && url.pathname.includes('/attachments/') && url.searchParams.has('epoch')
|
||||
let uploadAttempts = 0
|
||||
const interruptSecondUpload = async (route) => {
|
||||
uploadAttempts++
|
||||
if (uploadAttempts === 2) await route.fulfill({ status: 503, json: { error: { message: '测试上传暂不可用' } } })
|
||||
else await route.continue()
|
||||
}
|
||||
await owner.route(uploadMatcher, interruptSecondUpload)
|
||||
await ownerDrop.getByRole('button', { name: '发送群附件', exact: true }).click()
|
||||
await chat(windows).getByRole('button', { name: '下载 ' + firstBatch, exact: true }).waitFor()
|
||||
await chat(owner).getByRole('alert').getByText('测试上传暂不可用').waitFor()
|
||||
assert.equal(await queue.getByRole('listitem').count(), 1)
|
||||
assert.equal(await queue.getByText(secondBatch, { exact: true }).count(), 1)
|
||||
await owner.unroute(uploadMatcher, interruptSecondUpload)
|
||||
await ownerDrop.getByRole('button', { name: '发送群附件', exact: true }).click()
|
||||
await chat(windows).getByRole('button', { name: '下载 ' + secondBatch, exact: true }).waitFor()
|
||||
assert.equal(await chat(windows).getByRole('button', { name: '下载 ' + firstBatch, exact: true }).count(), 1)
|
||||
await queue.waitFor({ state: 'detached' })
|
||||
|
||||
const dropped = '拖入附件-' + id() + '.txt'
|
||||
const rejected = '移出附件-' + id() + '.txt'
|
||||
const transfer = await windows.evaluateHandle((names) => {
|
||||
const data = new DataTransfer()
|
||||
for (const name of names) data.items.add(new File([name], name, { type: 'text/plain' }))
|
||||
return data
|
||||
}, [dropped, rejected])
|
||||
const desktopDrop = chat(windows).getByRole('region', { name: '群附件发送区' })
|
||||
await desktopDrop.dispatchEvent('dragover', { dataTransfer: transfer })
|
||||
await desktopDrop.dispatchEvent('drop', { dataTransfer: transfer })
|
||||
await transfer.dispose()
|
||||
await desktopDrop.getByRole('button', { name: '移除 ' + rejected, exact: true }).click()
|
||||
await desktopDrop.getByRole('button', { name: '发送群附件', exact: true }).click()
|
||||
await chat(owner).getByRole('button', { name: '下载 ' + dropped, exact: true }).waitFor()
|
||||
assert.equal(await chat(owner).getByRole('button', { name: '下载 ' + rejected, exact: true }).count(), 0)
|
||||
|
||||
const voiceUploads = []
|
||||
windows.on('request', (request) => {
|
||||
if (request.method() === 'POST' && request.url().includes('/attachments/')) voiceUploads.push(request.url())
|
||||
|
||||
Reference in new issue
Block a user