From 9032225529e988834d47634771686e43db06604f Mon Sep 17 00:00:00 2001 From: Adolanium <94890352+Adolanium@users.noreply.github.com> Date: Mon, 27 Jul 2026 06:51:21 +0300 Subject: [PATCH 1/2] feat(bot): add /ticket-setup for support category and agent role Adds set/clear/show for support category and agent role, with null (not undefined) clears so tickets can actually be disabled. Logs guild settings write failures. Rejects @everyone and managed roles, checks Manage Channels at configure time, and defends buildTicketOverwrites against a world-readable agent overwrite. --- .../general/commands/ticket-setup.spec.ts | 220 +++++++++++++++++ .../general/commands/ticket-setup.ts | 228 ++++++++++++++++++ .../src/functions/general/commands/ticket.ts | 11 +- .../functions/music/commands/djrole.spec.ts | 2 +- .../src/functions/music/commands/djrole.ts | 3 +- .../src/services/GuildSettingsService.spec.ts | 40 ++- .../src/services/GuildSettingsService.ts | 30 ++- packages/shared/src/services/index.ts | 1 + 8 files changed, 522 insertions(+), 13 deletions(-) create mode 100644 packages/bot/src/functions/general/commands/ticket-setup.spec.ts create mode 100644 packages/bot/src/functions/general/commands/ticket-setup.ts diff --git a/packages/bot/src/functions/general/commands/ticket-setup.spec.ts b/packages/bot/src/functions/general/commands/ticket-setup.spec.ts new file mode 100644 index 000000000..25fe2ec4a --- /dev/null +++ b/packages/bot/src/functions/general/commands/ticket-setup.spec.ts @@ -0,0 +1,220 @@ +import { beforeEach, describe, expect, it, jest } from '@jest/globals' + +const requireGuildMock = jest.fn() +const interactionReplyMock = jest.fn() +const createSuccessEmbedMock = jest.fn( + (title: string, desc?: string) => ({ title, description: desc }), +) +const createErrorEmbedMock = jest.fn( + (title: string, desc?: string) => ({ title, description: desc }), +) +const createEmbedMock = jest.fn((opts: Record) => opts) +const setGuildSettingsMock = jest.fn() +const getGuildSettingsMock = jest.fn() + +jest.mock('../../../utils/command/commandValidations', () => ({ + requireGuild: (...args: unknown[]) => requireGuildMock(...args), +})) + +jest.mock('../../../utils/general/interactionReply', () => ({ + interactionReply: (...args: unknown[]) => interactionReplyMock(...args), +})) + +jest.mock('../../../utils/general/embeds', () => ({ + createSuccessEmbed: (...args: unknown[]) => createSuccessEmbedMock(...args), + createErrorEmbed: (...args: unknown[]) => createErrorEmbedMock(...args), + createEmbed: (...args: unknown[]) => createEmbedMock(...args), +})) + +jest.mock('@lucky/shared/services', () => ({ + guildSettingsService: { + setGuildSettings: (...args: unknown[]) => setGuildSettingsMock(...args), + getGuildSettings: (...args: unknown[]) => getGuildSettingsMock(...args), + }, +})) + +import ticketSetupCommand from './ticket-setup' + +function createInteraction(sub: string, overrides: Record = {}) { + return { + guildId: 'guild-1', + user: { id: 'user-1' }, + deferReply: jest.fn().mockResolvedValue(undefined), + guild: { + members: { + me: { + permissionsIn: jest + .fn() + .mockReturnValue({ has: () => true }), + }, + }, + }, + options: { + getSubcommand: jest.fn().mockReturnValue(sub), + getChannel: jest.fn().mockReturnValue({ id: 'cat-1', name: 'Support' }), + getRole: jest.fn().mockReturnValue({ id: 'role-1', name: 'Agent' }), + }, + ...overrides, + } as any +} + +describe('ticket-setup command', () => { + beforeEach(() => { + jest.clearAllMocks() + requireGuildMock.mockResolvedValue(true) + setGuildSettingsMock.mockResolvedValue(true) + getGuildSettingsMock.mockResolvedValue(null) + }) + + it('has correct name and category', () => { + expect(ticketSetupCommand.data.name).toBe('ticket-setup') + expect(ticketSetupCommand.category).toBe('general') + }) + + it('returns early when requireGuild fails', async () => { + requireGuildMock.mockResolvedValue(false) + const interaction = createInteraction('set') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(interaction.deferReply).not.toHaveBeenCalled() + }) + + describe('set subcommand', () => { + it('saves category and role and replies with success', async () => { + const interaction = createInteraction('set') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(setGuildSettingsMock).toHaveBeenCalledWith('guild-1', { + supportCategoryId: 'cat-1', + supportAgentRoleId: 'role-1', + }) + expect(createSuccessEmbedMock).toHaveBeenCalledWith( + 'Ticket Setup', + expect.stringContaining('cat-1'), + ) + }) + + it('rejects @everyone as the agent role', async () => { + const interaction = createInteraction('set', { + options: { + getSubcommand: jest.fn().mockReturnValue('set'), + getChannel: jest + .fn() + .mockReturnValue({ id: 'cat-1', name: 'Support' }), + // role id === guildId is Discord's @everyone + getRole: jest + .fn() + .mockReturnValue({ id: 'guild-1', name: '@everyone' }), + }, + }) + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(setGuildSettingsMock).not.toHaveBeenCalled() + expect(createErrorEmbedMock).toHaveBeenCalledWith( + 'Invalid role', + expect.stringContaining('@everyone'), + ) + }) + + it('rejects managed integration roles', async () => { + const interaction = createInteraction('set', { + options: { + getSubcommand: jest.fn().mockReturnValue('set'), + getChannel: jest + .fn() + .mockReturnValue({ id: 'cat-1', name: 'Support' }), + getRole: jest.fn().mockReturnValue({ + id: 'bot-role', + name: 'Some Bot', + managed: true, + }), + }, + }) + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(setGuildSettingsMock).not.toHaveBeenCalled() + expect(createErrorEmbedMock).toHaveBeenCalledWith( + 'Invalid role', + expect.stringContaining('managed'), + ) + }) + + it('rejects setup when the bot lacks Manage Channels in the category', async () => { + const interaction = createInteraction('set', { + guild: { + members: { + me: { + permissionsIn: jest + .fn() + .mockReturnValue({ has: () => false }), + }, + }, + }, + }) + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(setGuildSettingsMock).not.toHaveBeenCalled() + expect(createErrorEmbedMock).toHaveBeenCalledWith( + 'Missing permission', + expect.stringContaining('Manage Channels'), + ) + }) + + it('replies with error when persist fails', async () => { + setGuildSettingsMock.mockResolvedValue(false) + const interaction = createInteraction('set') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(createErrorEmbedMock).toHaveBeenCalledWith( + 'Error', + expect.any(String), + ) + }) + }) + + describe('clear subcommand', () => { + it('clears category and role with explicit null (not undefined omit)', async () => { + const interaction = createInteraction('clear') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(setGuildSettingsMock).toHaveBeenCalledWith('guild-1', { + supportCategoryId: null, + supportAgentRoleId: null, + }) + expect(createSuccessEmbedMock).toHaveBeenCalledWith( + 'Ticket Setup Cleared', + expect.any(String), + ) + }) + + it('replies with error when persist fails', async () => { + setGuildSettingsMock.mockResolvedValue(false) + const interaction = createInteraction('clear') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(createErrorEmbedMock).toHaveBeenCalledWith( + 'Error', + expect.any(String), + ) + }) + }) + + describe('show subcommand', () => { + it('shows configured category and role', async () => { + getGuildSettingsMock.mockResolvedValue({ + supportCategoryId: 'cat-9', + supportAgentRoleId: 'role-9', + }) + const interaction = createInteraction('show') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(createEmbedMock).toHaveBeenCalledWith( + expect.objectContaining({ + description: expect.stringContaining('cat-9'), + }), + ) + }) + + it('shows not-configured message when unset', async () => { + getGuildSettingsMock.mockResolvedValue(null) + const interaction = createInteraction('show') + await ticketSetupCommand.execute({ client: {}, interaction } as any) + expect(createEmbedMock).toHaveBeenCalledWith( + expect.objectContaining({ + description: expect.stringContaining('not configured'), + }), + ) + }) + }) +}) diff --git a/packages/bot/src/functions/general/commands/ticket-setup.ts b/packages/bot/src/functions/general/commands/ticket-setup.ts new file mode 100644 index 000000000..1398c0c42 --- /dev/null +++ b/packages/bot/src/functions/general/commands/ticket-setup.ts @@ -0,0 +1,228 @@ +import { SlashCommandBuilder } from '@discordjs/builders' +import { + ChannelType, + MessageFlags, + PermissionFlagsBits, +} from 'discord.js' +import Command from '../../../models/Command' +import { interactionReply } from '../../../utils/general/interactionReply' +import { + createEmbed, + createErrorEmbed, + createSuccessEmbed, +} from '../../../utils/general/embeds' +import { guildSettingsService } from '@lucky/shared/services' +import { requireGuild } from '../../../utils/command/commandValidations' +import type { CommandExecuteParams } from '../../../types/CommandData' +import { assertDefined } from '@lucky/shared/utils/guards' + +export default new Command({ + data: new SlashCommandBuilder() + .setName('ticket-setup') + .setDescription('Configure support tickets (category + agent role).') + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addSubcommand((sub) => + sub + .setName('set') + .setDescription( + 'Set the support category and agent role for tickets', + ) + .addChannelOption((opt) => + opt + .setName('category') + .setDescription( + 'Category where ticket channels will be created', + ) + .addChannelTypes(ChannelType.GuildCategory) + .setRequired(true), + ) + .addRoleOption((opt) => + opt + .setName('role') + .setDescription( + 'Role granted access to every open ticket', + ) + .setRequired(true), + ), + ) + .addSubcommand((sub) => + sub + .setName('clear') + .setDescription('Disable tickets by clearing category and role'), + ) + .addSubcommand((sub) => + sub + .setName('show') + .setDescription('Show the current ticket configuration'), + ), + category: 'general', + execute: async ({ interaction }: CommandExecuteParams) => { + if (!(await requireGuild(interaction))) return + const guildId = assertDefined( + interaction.guildId, + 'Guild ID required after requireGuild check', + ) + const sub = interaction.options.getSubcommand() + + await interaction.deferReply({ flags: MessageFlags.Ephemeral }) + + if (sub === 'set') { + const category = interaction.options.getChannel('category', true) + const role = interaction.options.getRole('role', true) + + // @everyone's id equals the guild id. Using it as the agent role + // collides with the channel deny overwrite and makes every ticket + // world-readable (ViewChannel + SendMessages for everyone). + if (role.id === guildId) { + await interactionReply({ + interaction, + content: { + embeds: [ + createErrorEmbed( + 'Invalid role', + 'The agent role cannot be @everyone. Pick a role assigned only to support staff so tickets stay private.', + ), + ], + }, + }) + return + } + + if ('managed' in role && role.managed) { + await interactionReply({ + interaction, + content: { + embeds: [ + createErrorEmbed( + 'Invalid role', + 'That role is managed by an integration and cannot be assigned to members, so nobody would get ticket access. Pick a normal role.', + ), + ], + }, + }) + return + } + + const me = interaction.guild?.members.me + const categoryIdForPerms = category.id + if ( + me && + !me.permissionsIn(categoryIdForPerms).has( + PermissionFlagsBits.ManageChannels, + ) + ) { + await interactionReply({ + interaction, + content: { + embeds: [ + createErrorEmbed( + 'Missing permission', + 'I need Manage Channels in that category so I can create ticket channels later. Grant it and run `/ticket-setup set` again.', + ), + ], + }, + }) + return + } + + const persisted = await guildSettingsService.setGuildSettings( + guildId, + { + supportCategoryId: category.id, + supportAgentRoleId: role.id, + }, + ) + if (!persisted) { + await interactionReply({ + interaction, + content: { + embeds: [ + createErrorEmbed( + 'Error', + 'Failed to save ticket settings. Please try again.', + ), + ], + }, + }) + return + } + await interactionReply({ + interaction, + content: { + embeds: [ + createSuccessEmbed( + 'Ticket Setup', + [ + `Category: <#${category.id}>`, + `Agent role: <@&${role.id}>`, + '', + 'Members can open tickets with `/ticket open`.', + ].join('\n'), + ), + ], + }, + }) + return + } + + if (sub === 'clear') { + // null (not undefined) so GuildSettingsService writes SQL NULL and + // actually disables tickets. undefined is stripped as "omit field". + const persisted = await guildSettingsService.setGuildSettings( + guildId, + { + supportCategoryId: null, + supportAgentRoleId: null, + }, + ) + if (!persisted) { + await interactionReply({ + interaction, + content: { + embeds: [ + createErrorEmbed( + 'Error', + 'Failed to clear ticket settings. Please try again.', + ), + ], + }, + }) + return + } + await interactionReply({ + interaction, + content: { + embeds: [ + createSuccessEmbed( + 'Ticket Setup Cleared', + 'Tickets are disabled until you run `/ticket-setup set` again.', + ), + ], + }, + }) + return + } + + const settings = await guildSettingsService.getGuildSettings(guildId) + const categoryId = settings?.supportCategoryId + const agentRoleId = settings?.supportAgentRoleId + const configured = Boolean(categoryId && agentRoleId) + await interactionReply({ + interaction, + content: { + embeds: [ + createEmbed({ + title: 'Ticket Setup', + description: configured + ? [ + `Category: <#${categoryId}>`, + `Agent role: <@&${agentRoleId}>`, + ].join('\n') + : 'Tickets are not configured. Use `/ticket-setup set` to choose a category and agent role.', + timestamp: true, + }), + ], + }, + }) + }, +}) diff --git a/packages/bot/src/functions/general/commands/ticket.ts b/packages/bot/src/functions/general/commands/ticket.ts index a8e15bd4a..83d7f3616 100644 --- a/packages/bot/src/functions/general/commands/ticket.ts +++ b/packages/bot/src/functions/general/commands/ticket.ts @@ -33,7 +33,7 @@ async function handleOpen( interaction, content: { content: - '❌ Tickets are not configured. An admin must set the support category and support-agent role first.', + '❌ Tickets are not configured. An admin must run `/ticket-setup set` first.', }, }) return @@ -163,14 +163,19 @@ function buildTicketOverwrites( PermissionFlagsBits.SendMessages, PermissionFlagsBits.ReadMessageHistory, ] - return [ + // Never allow agentRoleId to overwrite the @everyone deny. A stale config + // (or a setup path that missed the guard) would otherwise make tickets public. + const overwrites: OverwriteResolvable[] = [ { id: guild.roles.everyone.id, deny: [PermissionFlagsBits.ViewChannel], }, { id: requestorId, allow }, - { id: agentRoleId, allow }, ] + if (agentRoleId !== guild.roles.everyone.id) { + overwrites.push({ id: agentRoleId, allow }) + } + return overwrites } async function handleClose( diff --git a/packages/bot/src/functions/music/commands/djrole.spec.ts b/packages/bot/src/functions/music/commands/djrole.spec.ts index 65f92590e..2889cdc7a 100644 --- a/packages/bot/src/functions/music/commands/djrole.spec.ts +++ b/packages/bot/src/functions/music/commands/djrole.spec.ts @@ -84,7 +84,7 @@ describe('djrole command', () => { it('clears djRoleId and replies with success embed', async () => { const interaction = createInteraction('clear') await djroleCommand.execute({ client: {}, interaction } as any) - expect(setGuildSettingsMock).toHaveBeenCalledWith('guild-1', { djRoleId: undefined }) + expect(setGuildSettingsMock).toHaveBeenCalledWith('guild-1', { djRoleId: null }) expect(createSuccessEmbedMock).toHaveBeenCalledWith('🎧 DJ Role Cleared', expect.any(String)) }) diff --git a/packages/bot/src/functions/music/commands/djrole.ts b/packages/bot/src/functions/music/commands/djrole.ts index b6751d757..6242fe807 100644 --- a/packages/bot/src/functions/music/commands/djrole.ts +++ b/packages/bot/src/functions/music/commands/djrole.ts @@ -70,8 +70,9 @@ export default new Command({ }, }) } else if (sub === 'clear') { + // null clears the column; undefined would be omitted and leave the old role. const persisted = await guildSettingsService.setGuildSettings(guildId, { - djRoleId: undefined, + djRoleId: null, }) if (!persisted) { await interactionReply({ diff --git a/packages/shared/src/services/GuildSettingsService.spec.ts b/packages/shared/src/services/GuildSettingsService.spec.ts index da3585ee7..2cd0cd7aa 100644 --- a/packages/shared/src/services/GuildSettingsService.spec.ts +++ b/packages/shared/src/services/GuildSettingsService.spec.ts @@ -4,6 +4,7 @@ const mockFindUnique = jest.fn() const mockUpsert = jest.fn() const mockUpdateMany = jest.fn() const mockGetPrismaClient = jest.fn() +const mockErrorLog = jest.fn() jest.mock('../utils/database/prismaClient', () => ({ getPrismaClient: mockGetPrismaClient, @@ -18,6 +19,11 @@ jest.mock('./redis', () => ({ }, })) +jest.mock('../utils/general/log', () => ({ + infoLog: jest.fn(), + errorLog: (...args: unknown[]) => mockErrorLog(...args), +})) + import { GuildSettingsService } from './GuildSettingsService' const GUILD = 'guild-1' @@ -327,9 +333,39 @@ describe('GuildSettingsService — settings CRUD + counter methods', () => { }) }) - it('returns false on error', async () => { - sUpsert.mockRejectedValue(new Error('db')) + it('logs the error and guild context before returning false', async () => { + const error = new Error('db') + sUpsert.mockRejectedValue(error) + expect(await service.setGuildSettings(GUILD, {})).toBe(false) + expect(mockErrorLog).toHaveBeenCalledWith({ + message: 'Failed to set guild settings', + error, + data: { guildId: GUILD }, + }) + }) + + it('writes null for nullable columns so clearers can disable features', async () => { + sUpsert.mockResolvedValue({}) + await service.setGuildSettings(GUILD, { + supportCategoryId: null, + supportAgentRoleId: null, + djRoleId: null, + }) + expect(sUpsert).toHaveBeenCalledWith({ + where: { guildId: GUILD }, + create: { + guildId: GUILD, + supportCategoryId: null, + supportAgentRoleId: null, + djRoleId: null, + }, + update: { + supportCategoryId: null, + supportAgentRoleId: null, + djRoleId: null, + }, + }) }) }) diff --git a/packages/shared/src/services/GuildSettingsService.ts b/packages/shared/src/services/GuildSettingsService.ts index 6566ad4c5..408b8841a 100644 --- a/packages/shared/src/services/GuildSettingsService.ts +++ b/packages/shared/src/services/GuildSettingsService.ts @@ -43,6 +43,19 @@ export interface GuildSettings { updatedAt: Date } +/** + * Partial write for {@link GuildSettingsService.setGuildSettings}. + * `undefined` omits the column; `null` clears a nullable string column in Postgres. + */ +export type GuildSettingsPatch = Omit< + Partial, + 'djRoleId' | 'supportCategoryId' | 'supportAgentRoleId' +> & { + djRoleId?: string | null + supportCategoryId?: string | null + supportAgentRoleId?: string | null +} + /** Autoplay recommendation counter tracking for a guild. */ export interface AutoplayCounter { guildId: string @@ -148,13 +161,14 @@ export class GuildSettingsService { /** * Translates the public settings shape into Prisma column data, omitting * undefined keys (so a partial update only touches the fields provided, and - * never clobbers birthday columns this service doesn't own). + * never clobbers birthday columns this service doesn't own). Explicit `null` + * is kept so nullable columns (DJ role, ticket category/role) can be cleared. */ private toPrismaData( - settings: Partial, + settings: GuildSettingsPatch, ): Record { const data: Record = {} - const copy = (k: K) => { + const copy = (k: keyof GuildSettingsPatch) => { if (settings[k] !== undefined) data[k as string] = settings[k] } copy('defaultVolume') @@ -198,7 +212,7 @@ export class GuildSettingsService { /** Upserts guild settings (create with defaults+patch, or update in place). */ async setGuildSettings( guildId: string, - settings: Partial, + settings: GuildSettingsPatch, ): Promise { try { const prisma = getPrismaClient() @@ -211,7 +225,11 @@ export class GuildSettingsService { infoLog({ message: `Updated guild settings for ${guildId}` }) return true } catch (error) { - errorLog({ message: 'Failed to set guild settings', error }) + errorLog({ + message: 'Failed to set guild settings', + error, + data: { guildId }, + }) return false } } @@ -223,7 +241,7 @@ export class GuildSettingsService { */ async updateGuildSettings( guildId: string, - updates: Partial, + updates: GuildSettingsPatch, ): Promise { return this.setGuildSettings(guildId, updates) } diff --git a/packages/shared/src/services/index.ts b/packages/shared/src/services/index.ts index 56586917a..35483ab58 100644 --- a/packages/shared/src/services/index.ts +++ b/packages/shared/src/services/index.ts @@ -45,6 +45,7 @@ export { export { guildSettingsService, type GuildSettings, + type GuildSettingsPatch, type AutoplayCounter, } from './GuildSettingsService' export { roleManagementService } from './RoleManagementService' From f986646957420950160ee5acba0b475a159d800b Mon Sep 17 00:00:00 2001 From: Adolanium <94890352+Adolanium@users.noreply.github.com> Date: Mon, 27 Jul 2026 19:18:57 +0300 Subject: [PATCH 2/2] test(bot): cover @everyone overwrite guard and fail when me is uncached --- .../general/commands/ticket-setup.ts | 18 ++++++++++--- .../functions/general/commands/ticket.spec.ts | 25 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/bot/src/functions/general/commands/ticket-setup.ts b/packages/bot/src/functions/general/commands/ticket-setup.ts index 1398c0c42..ee24e7ea3 100644 --- a/packages/bot/src/functions/general/commands/ticket-setup.ts +++ b/packages/bot/src/functions/general/commands/ticket-setup.ts @@ -104,10 +104,22 @@ export default new Command({ } const me = interaction.guild?.members.me - const categoryIdForPerms = category.id + if (!me) { + await interactionReply({ + interaction, + content: { + embeds: [ + createErrorEmbed( + 'Bot member not cached', + 'I could not resolve my own member object to check Manage Channels in that category. Try again in a moment, or re-invite me if this keeps happening.', + ), + ], + }, + }) + return + } if ( - me && - !me.permissionsIn(categoryIdForPerms).has( + !me.permissionsIn(category.id).has( PermissionFlagsBits.ManageChannels, ) ) { diff --git a/packages/bot/src/functions/general/commands/ticket.spec.ts b/packages/bot/src/functions/general/commands/ticket.spec.ts index d5093bbba..41ff7a764 100644 --- a/packages/bot/src/functions/general/commands/ticket.spec.ts +++ b/packages/bot/src/functions/general/commands/ticket.spec.ts @@ -114,6 +114,31 @@ describe('/ticket command (smoke)', () => { ) }) + it('open: never grants the agent overwrite when agent role is @everyone', async () => { + // Stale configs (settings API before the setup guard) can store everyone. + // buildTicketOverwrites must keep the deny and skip the allow entry. + guildSettingsServiceMock.getGuildSettings.mockResolvedValue({ + supportCategoryId: 'cat-1', + supportAgentRoleId: 'everyone', + }) + const channel = makeChannel() + supportSessionServiceMock.getActiveForUser.mockResolvedValue(null) + supportSessionServiceMock.open.mockResolvedValue({ id: 's1' }) + const interaction = makeInteraction('open', channel) + + await ticketCommand.execute({ interaction } as any) + + const createArgs = interaction.guild.channels.create.mock.calls[0][0] + const overwrites = createArgs.permissionOverwrites as Array<{ + id: string + allow?: unknown + deny?: unknown + }> + expect(overwrites).toHaveLength(2) + expect(overwrites.map((o) => o.id)).toEqual(['everyone', 'u1']) + expect(overwrites.find((o) => o.id === 'everyone')?.deny).toBeDefined() + }) + it('open: rolls the channel back when recording the session fails', async () => { const channel = makeChannel() supportSessionServiceMock.getActiveForUser.mockResolvedValue(null)