feat(M08-B): 补保洁照片上传和自动建单
This commit is contained in:
@@ -64,6 +64,13 @@ const app = await buildApp({
|
||||
calls.push(['start', input]);
|
||||
return task('STARTED');
|
||||
},
|
||||
async rework(input) {
|
||||
calls.push(['rework', input]);
|
||||
return task('STARTED');
|
||||
},
|
||||
async assertCanUploadPhoto(input) {
|
||||
calls.push(['assertCanUploadPhoto', input]);
|
||||
},
|
||||
async submit(input) {
|
||||
calls.push(['submit', input]);
|
||||
return { ...task('SUBMITTED'), photoUrls: input.photoUrls };
|
||||
@@ -72,6 +79,20 @@ const app = await buildApp({
|
||||
calls.push(['stats', input]);
|
||||
return { byStatus: { SUBMITTED: 2 }, pendingSettlementCents: 1200 };
|
||||
}
|
||||
},
|
||||
mediaStorage: {
|
||||
async storeImage(input) {
|
||||
calls.push(['storeImage', input]);
|
||||
return {
|
||||
storagePath: 'tenants/7/shared/cleaning.webp',
|
||||
publicUrl: 'https://api.txyundm.cn/uploads/tenants/7/shared/cleaning.webp',
|
||||
mimeType: 'image/webp',
|
||||
byteSize: input.body.length,
|
||||
width: 640,
|
||||
height: 480,
|
||||
checksumSha256: 'abc'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -112,6 +133,30 @@ const start = await app.inject({
|
||||
assert.equal(start.statusCode, 200);
|
||||
assert.equal(calls.at(-1)[0], 'start');
|
||||
|
||||
const rework = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/app-api/cleaning/tasks/101/rework',
|
||||
headers: { authorization: `Bearer ${token}` }
|
||||
});
|
||||
assert.equal(rework.statusCode, 200);
|
||||
assert.equal(calls.at(-1)[0], 'rework');
|
||||
|
||||
const photo = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/app-api/cleaning/tasks/101/photos',
|
||||
headers: {
|
||||
authorization: `Bearer ${token}`,
|
||||
'content-type': 'application/octet-stream',
|
||||
'x-file-name': 'cleaning.jpg',
|
||||
'x-image-content-type': 'image/jpeg'
|
||||
},
|
||||
payload: Buffer.from('fake-image')
|
||||
});
|
||||
assert.equal(photo.statusCode, 201);
|
||||
assert.equal(photo.json().data.publicUrl, 'https://api.txyundm.cn/uploads/tenants/7/shared/cleaning.webp');
|
||||
assert.equal(calls.at(-2)[0], 'assertCanUploadPhoto');
|
||||
assert.equal(calls.at(-1)[0], 'storeImage');
|
||||
|
||||
const submit = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/app-api/cleaning/tasks/101/submit',
|
||||
|
||||
Reference in New Issue
Block a user