Show independent note descriptions, tags and image counts without author chrome
wiki CI and deployment / verify-and-deploy (push) Has been cancelled

This commit is contained in:
2026-10-25 23:44:55 +08:00
parent 5f1af4e9f6
commit b4f4facea0
16 changed files with 85 additions and 20 deletions
+3 -2
View File
@@ -29,9 +29,9 @@ test('real PostgreSQL + S3 library, sharing, taxonomy, uploads, range and video
const a=await sharp({create:{width:160,height:220,channels:3,background:'#b8c9af'}}).png().toBuffer();
const upload=async(kind:string,files:{data:Uint8Array;name:string;mime:string}[])=>{const form=new FormData();form.set('kind',kind);form.set('title','测试收藏 '+kind);form.set('description','可以复用的独立文字');form.set('tags',JSON.stringify([child.id]));files.forEach(f=>form.append('files',new Blob([new Uint8Array(f.data)],{type:f.mime}),f.name));const res=await fetch(base+'/api/upload',{method:'POST',body:form});assert.equal(res.status,201,await res.clone().text());return res.json();};
const first=await upload('image',[{data:a,name:'a.png',mime:'image/png'},{data:a,name:'b.png',mime:'image/png'}]);
const reused=await request('/api/posts',{kind:'image',title:'同一张图的另一种用法',assets:[{id:first.assets[0]}],tags:[root.id]});
const reused=await request('/api/posts',{kind:'image',title:'同一张图的另一种用法',description:'同一素材的独立说明',assets:[{id:first.assets[0]}],tags:[root.id]});
assert.equal((await db().query('SELECT count(*)::integer AS n FROM post_assets WHERE asset_id=$1',[first.assets[0]])).rows[0].n,2);
const filtered=await request('/api/feed?section=images&path=lines');assert.equal(filtered.posts.length,2);assert.equal((await request('/api/feed?section=images&path=lines/white')).posts.length,1);
const filtered=await request('/api/feed?section=images&path=lines');assert.equal(filtered.posts.length,2);assert.equal(filtered.posts.find((p:{id:string})=>p.id===reused.id).description,'同一素材的独立说明');assert.equal((await request('/api/feed?section=images&path=lines/white')).posts.length,1);
const empty=randomUUID();await db().query("INSERT INTO posts(id,slug,kind,title) VALUES($1,$2,'image','空对象')",[empty,empty]);assert.equal((await request('/api/feed')).posts.length,2);
assert.equal((await request('/api/feed')).contributions.length,0,'Import does not invent contribution rules');
await db().query("INSERT INTO contribution_events(id,kind,subject_type,amount) VALUES($1,'test.import','asset',2),($2,'test.edit','post',3)",[randomUUID(),randomUUID()]);assert.equal((await request('/api/feed')).contributions.reduce((n:number,c:{total:number})=>n+c.total,0),5);
@@ -66,6 +66,7 @@ test('real PostgreSQL + S3 library, sharing, taxonomy, uploads, range and video
assert.equal(status.pages.length,8,'Screenshot job state: '+JSON.stringify(status.job));
const r:Response=await fetch(base+'/api/media/'+status.pages[2].asset_id);const meta:{width?:number;height?:number}=await sharp(Buffer.from(await r.arrayBuffer())).metadata();assert.equal(meta.width,1080);assert.equal(meta.height,1440);
}
const notes=await request('/api/explore-feed');for(const slug of published.published){const post=(await request('/api/feed?section=articles')).posts.find((p:{slug:string})=>p.slug===slug);assert.equal(notes.entries.find((e:{id:string})=>e.id===post.id).imageCount,8);}
const before=await request(`/api/posts/${published.published[0]}/snapshots`);
const refresh=await fetch(base+`/api/posts/${published.published[0]}/snapshots`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({page:3})});assert.equal(refresh.status,202);
let after;for(let i=0;i<80;i++){after=await request(`/api/posts/${published.published[0]}/snapshots`);if(after.job?.status==='ready'&&after.pages[2].rendered_at!==before.pages[2].rendered_at)break;await setTimeout(500)}