chore: prepare GoodBuddy 0.8.2
Cross-platform packages / Validate source (push) Waiting to run
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, macos, macos-15-intel) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / Publish GitHub Release (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
Cross-platform packages / Validate source (push) Waiting to run
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, macos, macos-15-intel) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / Publish GitHub Release (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
CHANNEL_SETTINGS_LIMITS,
|
||||
channelConnectionTestResultSchema,
|
||||
channelSecretUpdateSchema,
|
||||
channelSettingsApplySchema,
|
||||
channelSettingsSnapshotSchema
|
||||
} from './channel-settings-contracts'
|
||||
|
||||
describe('channel settings contracts', () => {
|
||||
it('accepts bounded strict WeCom and DingTalk updates', () => {
|
||||
expect(
|
||||
channelSettingsApplySchema.parse({
|
||||
wecom: {
|
||||
enabled: true,
|
||||
botId: ' bot-id ',
|
||||
secret: { action: 'replace', value: ' secret ' },
|
||||
allowedSenderIds: [' user-1 ', 'user-1'],
|
||||
allowGroupMessages: false
|
||||
},
|
||||
dingtalk: {
|
||||
enabled: false,
|
||||
clientId: '',
|
||||
secret: { action: 'clear' },
|
||||
allowedSenderIds: [],
|
||||
allowGroupMessages: true
|
||||
}
|
||||
})
|
||||
).toEqual({
|
||||
wecom: {
|
||||
enabled: true,
|
||||
botId: 'bot-id',
|
||||
secret: { action: 'replace', value: 'secret' },
|
||||
allowedSenderIds: ['user-1'],
|
||||
allowGroupMessages: false
|
||||
},
|
||||
dingtalk: {
|
||||
enabled: false,
|
||||
clientId: '',
|
||||
secret: { action: 'clear' },
|
||||
allowedSenderIds: [],
|
||||
allowGroupMessages: true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects unknown fields and unbounded values', () => {
|
||||
expect(() =>
|
||||
channelSecretUpdateSchema.parse({
|
||||
action: 'keep',
|
||||
value: 'must-not-be-accepted'
|
||||
})
|
||||
).toThrow()
|
||||
expect(() =>
|
||||
channelSettingsApplySchema.parse({
|
||||
wecom: {
|
||||
enabled: true,
|
||||
botId: 'x'.repeat(
|
||||
CHANNEL_SETTINGS_LIMITS.maximumIdentifierLength + 1
|
||||
),
|
||||
secret: { action: 'keep' },
|
||||
allowedSenderIds: [],
|
||||
allowGroupMessages: false
|
||||
}
|
||||
})
|
||||
).toThrow()
|
||||
expect(() => channelSettingsApplySchema.parse({})).toThrow()
|
||||
})
|
||||
|
||||
it('models public credential source and runtime status without secrets', () => {
|
||||
const snapshot = channelSettingsSnapshotSchema.parse({
|
||||
wecom: {
|
||||
enabled: true,
|
||||
botId: 'bot-id',
|
||||
secretConfigured: true,
|
||||
source: 'environment',
|
||||
readOnly: true,
|
||||
allowedSenderIds: ['user-1'],
|
||||
allowGroupMessages: false,
|
||||
status: { state: 'running' }
|
||||
},
|
||||
dingtalk: {
|
||||
enabled: false,
|
||||
clientId: '',
|
||||
secretConfigured: false,
|
||||
source: 'none',
|
||||
readOnly: false,
|
||||
allowedSenderIds: [],
|
||||
allowGroupMessages: false,
|
||||
status: {
|
||||
state: 'error',
|
||||
lastError: '连接失败'
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(JSON.stringify(snapshot)).not.toContain('secret":')
|
||||
})
|
||||
|
||||
it('requires errors only for failed connection tests', () => {
|
||||
expect(
|
||||
channelConnectionTestResultSchema.parse({
|
||||
channel: 'wecom',
|
||||
ok: true
|
||||
})
|
||||
).toEqual({ channel: 'wecom', ok: true })
|
||||
expect(() =>
|
||||
channelConnectionTestResultSchema.parse({
|
||||
channel: 'dingtalk',
|
||||
ok: false
|
||||
})
|
||||
).toThrow()
|
||||
expect(() =>
|
||||
channelConnectionTestResultSchema.parse({
|
||||
channel: 'dingtalk',
|
||||
ok: true,
|
||||
error: '不应存在'
|
||||
})
|
||||
).toThrow()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user