✨ feat(frontend): 新增上传中断并联动历史回收状态
This commit is contained in:
1 parent
a962f7aec7
commit
e7918e9317
20 files changed
+275
-71
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import assert from 'node:assert/strict'
|
||||
export async function runCancelUploadCheck(page, base='http://127.0.0.1:5180/theme-assets/') {
|
||||
let cleanup=0,completes=0,requests=0,startedResolve
|
||||
const started=new Promise(resolve=>startedResolve=resolve)
|
||||
await page.route('**/api/v1/config',r=>r.fulfill({json:{code:200,detail:{config:{name:'test',expireStyle:['day'],max_save_seconds:0,openUpload:1,enableChunk:1,uploadSize:1073741824}}}}))
|
||||
await page.route('**/chunk/upload/init/**',r=>r.fulfill({json:{code:200,detail:{upload_id:'isolated-cancel',chunk_size:1048576,uploaded_chunks:[]}}}))
|
||||
await page.route('**/chunk/upload/raw/**',async r=>{requests++;startedResolve();await new Promise(resolve=>setTimeout(resolve,1500));try{await r.fulfill({json:{code:200}})}catch{}})
|
||||
await page.route('**/chunk/upload/complete/**',r=>{completes++;return r.fulfill({json:{code:200,detail:{code:'UNEXPECTED'}}})})
|
||||
await page.route('**/chunk/upload/isolated-cancel',r=>{assert.equal(r.request().method(),'DELETE');cleanup++;return r.fulfill({json:{code:200,detail:{cancelled:true}}})})
|
||||
await page.goto(base+'#/send')
|
||||
await page.locator('input[type=file]').setInputFiles({name:'cancel.txt',mimeType:'text/plain',buffer:Buffer.alloc(3*1024*1024,97)})
|
||||
await page.locator('button[type=submit]').click();await started
|
||||
await page.getByRole('button',{name:'中断上传',exact:true}).click()
|
||||
await page.getByText('上传已中断,临时分片已清理,可重新发送',{exact:true}).waitFor()
|
||||
assert.equal(cleanup,1);assert.equal(requests,1);assert.equal(completes,0)
|
||||
assert.equal(await page.locator('button[type=submit]').isEnabled(),true)
|
||||
console.log('browser cancellation: stopped raw request, cleaned once, no subsequent chunks/publication')
|
||||
}
|
||||
Reference in new issue
Block a user