407 lines
9.7 KiB
JavaScript
407 lines
9.7 KiB
JavaScript
/**
|
|
* 无效配置数据夹具
|
|
* 包含各种无效的配置组合用于测试错误处理
|
|
*/
|
|
|
|
export const invalidConfigs = {
|
|
// 环境变量格式的无效配置
|
|
envVars: {
|
|
missingWebhook: {
|
|
INPUT_WEBHOOK_URL: '',
|
|
INPUT_MESSAGE_TYPE: 'text',
|
|
INPUT_CONTENT: 'Hello World',
|
|
INPUT_TITLE: '',
|
|
INPUT_AT_MOBILES: '',
|
|
INPUT_AT_ALL: 'false',
|
|
INPUT_LINK_URL: '',
|
|
INPUT_PIC_URL: '',
|
|
INPUT_BTN_ORIENTATION: '0',
|
|
INPUT_SINGLE_TITLE: '',
|
|
INPUT_SINGLE_URL: '',
|
|
INPUT_BUTTONS: '',
|
|
INPUT_FEED_LINKS: ''
|
|
},
|
|
|
|
invalidWebhook: {
|
|
INPUT_WEBHOOK_URL: 'not-a-valid-url',
|
|
INPUT_MESSAGE_TYPE: 'text',
|
|
INPUT_CONTENT: 'Hello World',
|
|
INPUT_TITLE: '',
|
|
INPUT_AT_MOBILES: '',
|
|
INPUT_AT_ALL: 'false',
|
|
INPUT_LINK_URL: '',
|
|
INPUT_PIC_URL: '',
|
|
INPUT_BTN_ORIENTATION: '0',
|
|
INPUT_SINGLE_TITLE: '',
|
|
INPUT_SINGLE_URL: '',
|
|
INPUT_BUTTONS: '',
|
|
INPUT_FEED_LINKS: ''
|
|
},
|
|
|
|
emptyContent: {
|
|
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
INPUT_MESSAGE_TYPE: 'text',
|
|
INPUT_CONTENT: '',
|
|
INPUT_TITLE: '',
|
|
INPUT_AT_MOBILES: '',
|
|
INPUT_AT_ALL: 'false',
|
|
INPUT_LINK_URL: '',
|
|
INPUT_PIC_URL: '',
|
|
INPUT_BTN_ORIENTATION: '0',
|
|
INPUT_SINGLE_TITLE: '',
|
|
INPUT_SINGLE_URL: '',
|
|
INPUT_BUTTONS: '',
|
|
INPUT_FEED_LINKS: ''
|
|
}
|
|
},
|
|
|
|
// 缺少 webhook_url
|
|
missingWebhookUrl: {
|
|
webhook_url: '',
|
|
message_type: 'text',
|
|
content: 'Hello, World!',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// 无效的 webhook_url
|
|
invalidWebhookUrl: {
|
|
webhook_url: 'not-a-valid-url',
|
|
message_type: 'text',
|
|
content: 'Hello, World!',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// 不支持的消息类型
|
|
unsupportedMessageType: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'unsupported',
|
|
content: 'Hello, World!',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// 空的消息内容
|
|
emptyContent: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'text',
|
|
content: '',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// Markdown 消息缺少标题
|
|
markdownMissingTitle: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'markdown',
|
|
content: '## 内容',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// Link 消息缺少 URL
|
|
linkMissingUrl: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'link',
|
|
content: '链接描述',
|
|
title: '链接标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// Link 消息无效的 URL
|
|
linkInvalidUrl: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'link',
|
|
content: '链接描述',
|
|
title: '链接标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: 'not-a-valid-url',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// ActionCard 缺少标题
|
|
actionCardMissingTitle: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '按钮',
|
|
single_url: 'https://example.com',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// ActionCard 既没有单按钮也没有多按钮
|
|
actionCardNoButtons: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: 'ActionCard 标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// ActionCard 单按钮缺少 URL
|
|
actionCardSingleMissingUrl: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: 'ActionCard 标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '按钮',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// ActionCard 多按钮格式错误
|
|
actionCardInvalidButtons: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: 'ActionCard 标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: 'invalid-json',
|
|
feed_links: ''
|
|
},
|
|
|
|
// ActionCard 多按钮为空数组
|
|
actionCardEmptyButtons: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: 'ActionCard 标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '[]',
|
|
feed_links: ''
|
|
},
|
|
|
|
// ActionCard 按钮缺少必需字段
|
|
actionCardButtonMissingFields: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: 'ActionCard 标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: JSON.stringify([
|
|
{ title: '按钮1' }, // 缺少 actionURL
|
|
{ actionURL: 'https://example.com' } // 缺少 title
|
|
]),
|
|
feed_links: ''
|
|
},
|
|
|
|
// FeedCard 缺少链接
|
|
feedCardMissingLinks: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'feedCard',
|
|
content: '',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// FeedCard 链接格式错误
|
|
feedCardInvalidLinks: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'feedCard',
|
|
content: '',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: 'invalid-json'
|
|
},
|
|
|
|
// FeedCard 空链接数组
|
|
feedCardEmptyLinks: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'feedCard',
|
|
content: '',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: '[]'
|
|
},
|
|
|
|
// FeedCard 链接缺少必需字段
|
|
feedCardLinkMissingFields: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'feedCard',
|
|
content: '',
|
|
title: '',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: JSON.stringify([
|
|
{ title: '链接1' }, // 缺少 messageURL
|
|
{ messageURL: 'https://example.com' } // 缺少 title
|
|
])
|
|
},
|
|
|
|
// 无效的手机号格式
|
|
invalidMobileFormat: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'text',
|
|
content: 'Hello, World!',
|
|
title: '',
|
|
at_mobiles: 'invalid-mobile',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '0',
|
|
single_title: '',
|
|
single_url: '',
|
|
buttons: '',
|
|
feed_links: ''
|
|
},
|
|
|
|
// 无效的按钮方向
|
|
invalidBtnOrientation: {
|
|
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
message_type: 'actionCard',
|
|
content: 'ActionCard 内容',
|
|
title: 'ActionCard 标题',
|
|
at_mobiles: '',
|
|
at_all: false,
|
|
link_url: '',
|
|
pic_url: '',
|
|
btn_orientation: '2', // 只支持 0 和 1
|
|
single_title: '按钮',
|
|
single_url: 'https://example.com',
|
|
buttons: '',
|
|
feed_links: ''
|
|
}
|
|
};
|
|
|
|
// 环境变量格式的无效配置
|
|
export const invalidEnvConfigs = {
|
|
missingWebhookUrl: {
|
|
INPUT_WEBHOOK_URL: '',
|
|
INPUT_MESSAGE_TYPE: 'text',
|
|
INPUT_CONTENT: 'Hello, World!'
|
|
},
|
|
|
|
unsupportedMessageType: {
|
|
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
INPUT_MESSAGE_TYPE: 'unsupported',
|
|
INPUT_CONTENT: 'Hello, World!'
|
|
},
|
|
|
|
emptyContent: {
|
|
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
|
INPUT_MESSAGE_TYPE: 'text',
|
|
INPUT_CONTENT: ''
|
|
}
|
|
}; |