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
+3 -1
View File
@@ -179,12 +179,14 @@ describeDatabase("guide comments against PostgreSQL", { timeout: 30000 }, () =>
expect((await page()).items[0].reaction).toBe(0);
});
it("restricts hearts and moderation to admins and records moderation", async () => {
const image = "https://profile.example/admin-heart.png";
await getDb().update(schema.users).set({ image }).where(eq(schema.users.id, admin.id));
const root = await post();
await expect(mutateComment(root.id, author, "heart", true)).rejects.toMatchObject({ status: 403 });
await expect(mutateComment(root.id, author, "moderation", true)).rejects.toMatchObject({ status: 403 });
await mutateComment(root.id, admin, "heart", true);
await mutateComment(root.id, admin, "reaction", 1);
expect((await page()).items[0]).toMatchObject({ hearted: true, likes: 1 });
expect((await page()).items[0]).toMatchObject({ hearted: true, likes: 1, heartedBy: { id: admin.id, name: "Admin", image } });
await mutateComment(root.id, admin, "moderation", true);
const audit = await getDb().select().from(schema.auditLog).where(eq(schema.auditLog.authorId, admin.id));
expect(audit.map((event) => event.details?.target)).toContainEqual({ type: "comment", id: root.id });