diff --git a/src/pages/channels.js b/src/pages/channels.js index 4894b4c..0c39819 100644 --- a/src/pages/channels.js +++ b/src/pages/channels.js @@ -146,6 +146,8 @@ const PLATFORM_REGISTRY = { { key: 'applicationId', label: 'Application ID', placeholder: '123456789012345678', required: false }, { key: 'dmPolicy', label: t('channels.dmPolicy'), type: 'select', options: DM_POLICY_OPTIONS, required: false }, { key: 'groupPolicy', label: t('channels.groupPolicy'), type: 'select', options: GROUP_POLICY_OPTIONS(t('channels.groupAllChannels')), required: false }, + { key: 'guildId', label: 'Guild ID', placeholder: 'Discord Server ID', required: false }, + { key: 'channelId', label: 'Channel ID', placeholder: 'Discord Channel ID;留空匹配整个服务器', required: false }, { key: 'allowFrom', label: 'Allow From', placeholder: t('channels.allowFromPh'), required: false, hint: t('channels.allowFromHint') }, ], configKey: 'discord', diff --git a/tests/channel-ui-registry.test.js b/tests/channel-ui-registry.test.js new file mode 100644 index 0000000..57f97ec --- /dev/null +++ b/tests/channel-ui-registry.test.js @@ -0,0 +1,19 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' + +const channelsPageSource = readFileSync(new URL('../src/pages/channels.js', import.meta.url), 'utf8') + +function getRegistryBlock(platformId) { + const start = channelsPageSource.indexOf(` ${platformId}: {`) + assert.notEqual(start, -1, `未找到 ${platformId} 渠道注册表`) + const next = channelsPageSource.indexOf('\n slack: {', start + 1) + return channelsPageSource.slice(start, next === -1 ? undefined : next) +} + +test('Discord 渠道 UI 会暴露服务器频道 allowlist 配置字段', () => { + const discordBlock = getRegistryBlock('discord') + + assert.match(discordBlock, /key:\s*'guildId'/) + assert.match(discordBlock, /key:\s*'channelId'/) +})