feat(comments) : show heart giver profiles on comments and notifications

This commit is contained in:
2026-10-13 00:45:02 +07:00 Unverified
parent f8ef86cb5e
commit d1dff1a763
8 changed files with 135 additions and 23 deletions
@@ -19,6 +19,7 @@ beforeEach(() => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true, json: async () => ({ unread: 0, nextCursor: null, items: [
{ ...item, id: 'comment', title: 'Gunshin - dev แสดงความคิดเห็นใหม่ในไกด์ Lohen', url: '/admin/comments?comment=comment' },
{ ...item, id: 'reply', title: 'Reader ตอบกลับความคิดเห็นของคุณ', url: '/lohen/comment?reply=reply', authorName: 'Reader', authorImage: null },
{ ...item, id: 'heart', title: 'คุณได้รับหัวใจจากแอดมิน', url: '/lohen/comment#comment-hearted', authorName: 'Admin', authorImage: 'https://profile.example/admin.png' },
{ ...item, id: 'commission', title: 'Commission message', url: '/commission/tickets/test', authorName: null, authorImage: null },
{ ...item, id: 'guide', title: 'มีไกด์ใหม่แล้ว!', body: 'คุณสามารถดูไกด์ Lohen ได้แล้ว!', url: '/lohen', authorName: null, authorImage: null, imageUrl: 'https://buzz-cdn.astrxl.dev/guides/lohen.png' },
] }) }));
@@ -44,6 +45,9 @@ describe('comment profile pictures in the notification bell', () => {
if (broken) expect(comment?.querySelector('[data-slot="avatar-fallback"]')?.textContent).toBe('Gu');
else expect(comment?.querySelector('img')?.getAttribute('src')).toBe('https://profile.example/author.png');
expect(document.querySelector('a[href="/lohen/comment?reply=reply"] [data-slot="avatar-fallback"]')?.textContent).toBe('Re');
const heart = document.querySelector('a[href="/lohen/comment#comment-hearted"]');
if (broken) expect(heart?.querySelector('[data-slot="avatar-fallback"]')?.textContent).toBe('Ad');
else expect(heart?.querySelector('img')?.getAttribute('src')).toBe('https://profile.example/admin.png');
expect(document.querySelector('a[href="/commission/tickets/test"] [data-slot="avatar"]')).toBeNull();
const guide = document.querySelector('a[href="/lohen"]');
expect(guide?.querySelector('[data-slot="avatar"]')).toBeNull();