8041a39dfd
- 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.
78 lines
2.9 KiB
JavaScript
78 lines
2.9 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const discord_js_1 = require("discord.js");
|
|
const sign_up_1 = require("../../src/commands/sign-up");
|
|
const tour_schedule_1 = require("../../src/tour-schedule");
|
|
jest.mock("../../src/tour-schedule", () => ({
|
|
getTourSchedule: jest.fn(),
|
|
}));
|
|
describe("signUpCommand", () => {
|
|
const queue = {
|
|
join: jest.fn(),
|
|
leave: jest.fn(),
|
|
list: jest.fn(),
|
|
clear: jest.fn(),
|
|
next: jest.fn(),
|
|
};
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
tour_schedule_1.getTourSchedule.mockReturnValue(queue);
|
|
});
|
|
function createInteraction(action) {
|
|
return {
|
|
inGuild: () => true,
|
|
guildId: "guild-1",
|
|
user: { id: "user-1" },
|
|
guild: { id: "guild-1" },
|
|
memberPermissions: {
|
|
has: jest.fn((permission) => permission === discord_js_1.PermissionFlagsBits.ManageChannels),
|
|
},
|
|
options: {
|
|
getSubcommand: () => action,
|
|
},
|
|
reply: jest.fn().mockResolvedValue(undefined),
|
|
};
|
|
}
|
|
it("joins queue and replies with position", async () => {
|
|
queue.join.mockReturnValue({ joined: true, position: 2 });
|
|
const interaction = createInteraction("join");
|
|
await sign_up_1.signUpCommand.execute(interaction);
|
|
expect(queue.join).toHaveBeenCalledWith("guild-1", "user-1");
|
|
expect(interaction.reply).toHaveBeenCalledWith({
|
|
content: "Added to queue at position 2.",
|
|
ephemeral: true,
|
|
});
|
|
});
|
|
it("lists queue in FIFO order", async () => {
|
|
queue.list.mockReturnValue(["user-1", "user-2"]);
|
|
const interaction = createInteraction("list");
|
|
await sign_up_1.signUpCommand.execute(interaction);
|
|
expect(interaction.reply).toHaveBeenCalledWith({
|
|
content: "1. <@user-1>\n2. <@user-2>",
|
|
ephemeral: true,
|
|
});
|
|
});
|
|
it("blocks next action when missing Manage Channels", async () => {
|
|
const interaction = createInteraction("next");
|
|
interaction.memberPermissions.has = jest.fn().mockReturnValue(false);
|
|
await sign_up_1.signUpCommand.execute(interaction);
|
|
expect(interaction.reply).toHaveBeenCalledWith({
|
|
content: "Need Manage Channels permission for this action.",
|
|
ephemeral: true,
|
|
});
|
|
});
|
|
it("advances queue and announces stage status", async () => {
|
|
queue.next.mockResolvedValue({
|
|
nextUserId: "user-7",
|
|
remaining: 3,
|
|
stageResult: "promoted",
|
|
});
|
|
const interaction = createInteraction("next");
|
|
await sign_up_1.signUpCommand.execute(interaction);
|
|
expect(interaction.reply).toHaveBeenCalledWith({
|
|
content: "Now up: <@user-7>\nQueue remaining: 3\nStage speaker promoted.",
|
|
ephemeral: false,
|
|
});
|
|
});
|
|
});
|
|
//# sourceMappingURL=sign-up.test.js.map
|