docs(tests): clarify media fixtures and response timeout coverage

This commit is contained in:
2026-11-12 17:14:54 +08:00
parent 81055e14a1
commit 2dbe68c6aa
4 changed files with 14 additions and 5 deletions
+2
View File
@@ -12,6 +12,7 @@ const source='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB';
const id='77777777-7777-4777-8777-777777777777';
const asset={id,url:`https://api.foundry.entroia.com/projects/endoleap/workspaces/w/assets/${id}`,width:1,height:1,bytes:24,mime_type:'image/png'};
// 首例直接比对 FormData.image 原字节、上传路径、POST 和幂等键形状,返回值保留服务资产元数据。
// 键的正则只检查 36 位字符集合,不完整校验 UUID 分段;替身返回固定元数据,不证明服务器实际解码成功。
test('attachment upload sends the original file bytes',async()=>{
const bytes=Buffer.from(source.split(',')[1],'base64');let calls=0;
const result=await uploadCanvasImage(async(path,options)=>{
@@ -32,6 +33,7 @@ test('uncertain upload retries the exact bytes with the same idempotency key',as
await uploadCanvasImage(async(_path,options)=>{calls++;if(!key)key=options.headers['Idempotency-Key'];assert.equal(options.headers['Idempotency-Key'],key);if(calls===1)throw new TypeError('connection lost');return asset;},'w',new Blob(['test'],{type:'image/png'}),'test.png');assert.equal(calls,2);
});
// 受管原始 URL 转同源认证代理,preview 仅加显示变体参数;普通外部图片地址保持原样。
// 这里仅比对字符串,不请求代理,也不验证登录鉴权或预览图片内容。
test('preview URLs are renderer-only and do not replace original managed references',()=>{
assert.equal(managedImageSource(asset.url),`/api/foundry/workspaces/w/assets/${id}`);assert.equal(managedImageSource(asset.url,true),`/api/foundry/workspaces/w/assets/${id}?variant=preview`);
assert.equal(managedImageSource('https://example.com/photo.png',true),'https://example.com/photo.png');