Files
ucvl-home-vision/test_upload_tasks.js
T

20 lines
1.5 KiB
JavaScript

const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs');
test('upload task labels distinguish verification, retry, and confirmed local cleanup',async()=>{
const {taskState}=await import('./frontend/src/composables/upload-tasks.mjs');
assert.equal(taskState({id:'1',state:'pending'},{id:'1',stage:'verifying'}),'云端校验');
assert.equal(taskState({id:'1',state:'pending',error:'no connection'}),'等待重试');
assert.equal(taskState({id:'1',state:'cloud'}),'已存网盘');
assert.equal(taskState({id:'1',state:'cloud',releasedAt:123}),'已上传 · 本机已清理');
});
test('upload task sizes never display NaN or negative released space',async()=>{
const {bytes,taskQuery}=await import('./frontend/src/composables/upload-tasks.mjs');
assert.equal(bytes(-1),'0 B');assert.equal(bytes(null),'0 B');assert.equal(bytes(1e9),'1.00 GB');
assert.equal(new URLSearchParams(taskQuery({state:'pending',family:'abc',camera:''},2)).get('page'),'2');
});
test('upload dashboard polls only when visible and rejects obsolete responses',()=>{
const source=fs.readFileSync('frontend/src/components/UploadTasks.vue','utf8');
assert.match(source,/e!==epoch/);assert.match(source,/document.hidden/);assert.match(source,/onBeforeUnmount/);
assert.match(source,/clearTimeout\(timer\)/);assert.match(source,/platformAdmin/);assert.match(source,/:key="task.id"/);
assert.match(source,/releasedBytes/);assert.match(source,/云端校验/);assert.doesNotMatch(source,/v-html/);
});