feat : comment feature
CI / Verify (push) Successful in 2m30s
CI / Build immutable images and deploy (push) Successful in 3m9s

This commit is contained in:
2026-10-08 01:40:08 +07:00 Unverified
parent 8c8815cda5
commit 5812d99715
65 changed files with 27013 additions and 10 deletions
+17
View File
@@ -0,0 +1,17 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("server-only", () => ({}));
const redis = vi.hoisted(() => ({ publish: vi.fn(), get: vi.fn() }));
vi.mock("@/lib/redis/client", () => ({ getRedisClient: redis.get, redisEventChannel: (topic: string) => `test:${topic}` }));
import { notifyCommentChange } from "./events";
describe("comment invalidation events", () => {
beforeEach(() => { redis.publish.mockReset().mockResolvedValue(1); redis.get.mockReset().mockResolvedValue(redis); });
it("notifies the target and admin inbox without exposing comment content", async () => {
await notifyCommentChange("stygian:123");
expect(redis.publish.mock.calls).toEqual([["test:comments:stygian:123", "changed"], ["test:comments:admin", "changed"]]);
});
it("does not fail a committed mutation when Redis is unavailable", async () => {
redis.get.mockRejectedValue(new Error("offline"));
await expect(notifyCommentChange("stygian:123")).resolves.toBeUndefined();
});
});