feat: Implement Tour Schedule Engine with queue management and announcement features
- Added TourScheduleEngine class for managing user queues in a guild. - Implemented methods for joining, leaving, listing, and clearing queues. - Added functionality to promote users to speaker in a stage channel and send announcements. - Created integration tests for the TourScheduleEngine to verify FIFO behavior and announcement dispatch. test: Add unit tests for ping and sign-up commands - Created tests for ping command to ensure it replies with "Pong!". - Implemented tests for sign-up command to verify queue joining, listing, and permission checks. test: Add integration tests for mileage engine flow - Developed tests to validate mileage awarding, event persistence, and role upgrades based on mileage thresholds. chore: Update TypeScript configuration for ESLint - Added tsconfig.eslint.json for ESLint integration. - Modified tsconfig.json to exclude test files from the main compilation.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const discord_js_1 = require("discord.js");
|
||||
const tour_schedule_1 = require("../../src/tour-schedule");
|
||||
describe("TourScheduleEngine flow", () => {
|
||||
it("handles FIFO next flow and announcement dispatch", async () => {
|
||||
const send = jest.fn().mockResolvedValue(undefined);
|
||||
const guild = {
|
||||
id: "guild-1",
|
||||
members: {
|
||||
fetch: jest.fn().mockResolvedValue({
|
||||
voice: {
|
||||
channelId: "stage-1",
|
||||
setSuppressed: jest.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
}),
|
||||
},
|
||||
channels: {
|
||||
fetch: jest
|
||||
.fn()
|
||||
.mockImplementation(async (channelId) => {
|
||||
if (channelId === "stage-1") {
|
||||
return {
|
||||
type: discord_js_1.ChannelType.GuildStageVoice,
|
||||
};
|
||||
}
|
||||
if (channelId === "announce-1") {
|
||||
return {
|
||||
isSendable: () => true,
|
||||
send,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
},
|
||||
};
|
||||
const engine = new tour_schedule_1.TourScheduleEngine({
|
||||
stageChannelId: "stage-1",
|
||||
announceChannelId: "announce-1",
|
||||
});
|
||||
engine.join("guild-1", "user-a");
|
||||
engine.join("guild-1", "user-b");
|
||||
const first = await engine.next(guild);
|
||||
const second = await engine.next(guild);
|
||||
expect(first).toEqual({
|
||||
nextUserId: "user-a",
|
||||
remaining: 1,
|
||||
stageResult: "promoted",
|
||||
});
|
||||
expect(second).toEqual({
|
||||
nextUserId: "user-b",
|
||||
remaining: 0,
|
||||
stageResult: "promoted",
|
||||
});
|
||||
expect(send).toHaveBeenNthCalledWith(1, "Next up: <@user-a>. Queue remaining: 1.");
|
||||
expect(send).toHaveBeenNthCalledWith(2, "Next up: <@user-b>. Queue remaining: 0.");
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=tour-schedule-flow.test.js.map
|
||||
Reference in New Issue
Block a user