增加库存流水Excel导出,支持筛选后全量下载

This commit is contained in:
summer committed 2026-10-31 14:59:30 +08:00
1 parent 49b7018f21
commit c25f529b20
10 files changed
+196 -10

No files matched your search

+8
View File
@@ -74,3 +74,11 @@ test('真实HTTP另一标签切cookie账号时原用户头阻止重试代写,
const permission=await f.send('/api/printing',{method:'POST',headers:{'Content-Type':'application/json','X-Requested-With':'maimai-ledger','Idempotency-Key':randomUUID(),'X-Ledger-User':f.users.assistant.id},body:'{}'},f.cookies.assistant);assert.equal(permission.status,403);
}
});
test('二进制Excel读取沿用账号校验与有限GET重试,HTML成功页和明确拒绝不会当作下载文件',async()=>{
const mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',h=harness((url,options,attempt)=>attempt===1?new Response('<html>temporary</html>',{status:502}):new Response('PK合成Excel',{headers:{'Content-Type':mime,'Content-Disposition':"attachment; filename*=UTF-8''test.xlsx"}}));
const result=await h.run("api('/api/inventory/movements/export.xlsx',undefined,undefined,{responseType:'xlsx'})");assert.equal(await result.blob.text(),'PK合成Excel');assert.match(result.contentDisposition,/test.xlsx/);assert.equal(h.calls.length,2);assert.ok(h.calls.every(call=>call.headers['X-Ledger-User']==='retry-user'));assert.equal(h.saved.size,0);
const html=harness(()=>new Response('<html>login</html>',{headers:{'Content-Type':'text/html'}}));await assert.rejects(html.run("api('/api/inventory/movements/export.xlsx',undefined,undefined,{responseType:'xlsx'})"),/文件格式异常/);assert.equal(html.calls.length,1);
const denied=harness(()=>httpError(403,'仅用于明确权限拒绝'));await assert.rejects(denied.run("api('/api/inventory/movements/export.xlsx',undefined,undefined,{responseType:'xlsx'})"),/明确权限拒绝/);assert.equal(denied.calls.length,1);
});