feat: split text and voice channel selection
Separate text moderation and voice recording guild/channel state so each workflow can persist and operate independently. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
47
tests/routes/syncRoutes.test.ts
Normal file
47
tests/routes/syncRoutes.test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { Request, Response } from "express";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { createSyncRoutes } from "../../src/routes/syncRoutes";
|
||||
|
||||
const syncSelectedChannelBacklog = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../../src/moderation/backlogSync", () => ({
|
||||
syncSelectedChannelBacklog,
|
||||
}));
|
||||
|
||||
describe("createSyncRoutes", () => {
|
||||
beforeEach(() => {
|
||||
syncSelectedChannelBacklog.mockReset();
|
||||
});
|
||||
|
||||
it("syncs the selected guild and channel from the request", async () => {
|
||||
syncSelectedChannelBacklog.mockResolvedValue(3);
|
||||
const router = createSyncRoutes({} as never);
|
||||
const route = router.stack.find(
|
||||
(layer) => layer.route?.path === "/backlog-sync",
|
||||
);
|
||||
const handler = route?.route?.stack[0]?.handle;
|
||||
|
||||
const json = vi.fn();
|
||||
const next = vi.fn();
|
||||
|
||||
await handler?.(
|
||||
{
|
||||
body: { guildId: "selected-guild", channelId: "selected-channel" },
|
||||
} as Request,
|
||||
{ json } as unknown as Response,
|
||||
next,
|
||||
);
|
||||
|
||||
expect(syncSelectedChannelBacklog).toHaveBeenCalledWith(
|
||||
{},
|
||||
"selected-guild",
|
||||
"selected-channel",
|
||||
);
|
||||
expect(json).toHaveBeenCalledWith({
|
||||
success: true,
|
||||
channelId: "selected-channel",
|
||||
messagesSync: 3,
|
||||
});
|
||||
expect(next).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user