379 lines
9.9 KiB
JavaScript
379 lines
9.9 KiB
JavaScript
/**
|
||
* 有效配置数据夹具
|
||
* 包含各种有效的配置组合用于测试
|
||
*/
|
||
|
||
export const validConfigs = {
|
||
// 环境变量格式的配置
|
||
envVars: {
|
||
text: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
||
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: '',
|
||
},
|
||
|
||
markdown: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test456',
|
||
INPUT_MESSAGE_TYPE: 'markdown',
|
||
INPUT_CONTENT: '# Hello\n\nThis is **markdown** content.',
|
||
INPUT_TITLE: 'Test 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: '',
|
||
},
|
||
|
||
link: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test789',
|
||
INPUT_MESSAGE_TYPE: 'link',
|
||
INPUT_CONTENT: 'This is a test link',
|
||
INPUT_TITLE: 'Test Link',
|
||
INPUT_AT_MOBILES: '',
|
||
INPUT_AT_ALL: 'false',
|
||
INPUT_LINK_URL: 'https://example.com',
|
||
INPUT_PIC_URL: '',
|
||
INPUT_BTN_ORIENTATION: '0',
|
||
INPUT_SINGLE_TITLE: '',
|
||
INPUT_SINGLE_URL: '',
|
||
INPUT_BUTTONS: '',
|
||
INPUT_FEED_LINKS: '',
|
||
},
|
||
|
||
actionCard: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test101',
|
||
INPUT_MESSAGE_TYPE: 'actionCard',
|
||
INPUT_CONTENT: 'Action card content',
|
||
INPUT_TITLE: 'Action Card 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: JSON.stringify([{ title: 'Button 1', actionURL: 'https://example.com/1' }]),
|
||
INPUT_FEED_LINKS: '',
|
||
},
|
||
|
||
feedCard: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test103',
|
||
INPUT_MESSAGE_TYPE: 'feedCard',
|
||
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: JSON.stringify([
|
||
{
|
||
title: '新闻1',
|
||
messageURL: 'https://example.com/news1',
|
||
picURL: 'https://example.com/pic1.jpg',
|
||
},
|
||
]),
|
||
},
|
||
},
|
||
|
||
// 基础文本消息配置
|
||
basicText: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
||
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: '',
|
||
},
|
||
|
||
// Markdown 消息配置
|
||
markdown: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test456',
|
||
message_type: 'markdown',
|
||
content: '## 标题\n这是一个 **Markdown** 消息',
|
||
title: 'Markdown 标题',
|
||
at_mobiles: '',
|
||
at_all: false,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '0',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: '',
|
||
feed_links: '',
|
||
},
|
||
|
||
// 链接消息配置
|
||
link: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test789',
|
||
message_type: 'link',
|
||
content: '这是一个链接消息的描述',
|
||
title: '链接标题',
|
||
at_mobiles: '',
|
||
at_all: false,
|
||
link_url: 'https://example.com',
|
||
pic_url: 'https://example.com/image.jpg',
|
||
btn_orientation: '0',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: '',
|
||
feed_links: '',
|
||
},
|
||
|
||
// 单按钮 ActionCard 配置
|
||
singleActionCard: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test101',
|
||
message_type: 'actionCard',
|
||
content: '这是一个单按钮 ActionCard',
|
||
title: 'ActionCard 标题',
|
||
at_mobiles: '',
|
||
at_all: false,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '0',
|
||
single_title: '查看详情',
|
||
single_url: 'https://example.com/detail',
|
||
buttons: '',
|
||
feed_links: '',
|
||
},
|
||
|
||
// 多按钮 ActionCard 配置
|
||
multiActionCard: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test102',
|
||
message_type: 'actionCard',
|
||
content: '这是一个多按钮 ActionCard',
|
||
title: 'ActionCard 标题',
|
||
at_mobiles: '',
|
||
at_all: false,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '1',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: JSON.stringify([
|
||
{ title: '按钮1', actionURL: 'https://example.com/action1' },
|
||
{ title: '按钮2', actionURL: 'https://example.com/action2' },
|
||
]),
|
||
feed_links: '',
|
||
},
|
||
|
||
// FeedCard 配置
|
||
feedCard: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test103',
|
||
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: 'https://example.com/news1',
|
||
picURL: 'https://example.com/pic1.jpg',
|
||
},
|
||
{
|
||
title: '新闻2',
|
||
messageURL: 'https://example.com/news2',
|
||
picURL: 'https://example.com/pic2.jpg',
|
||
},
|
||
]),
|
||
},
|
||
|
||
// 带 @ 功能的文本消息
|
||
textWithAt: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test104',
|
||
message_type: 'text',
|
||
content: '这是一个带 @ 功能的消息',
|
||
title: '',
|
||
at_mobiles: '13800138000,13900139000',
|
||
at_all: false,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '0',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: '',
|
||
feed_links: '',
|
||
},
|
||
|
||
// @ 所有人的消息
|
||
textWithAtAll: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test105',
|
||
message_type: 'text',
|
||
content: '这是一个 @ 所有人的消息',
|
||
title: '',
|
||
at_mobiles: '',
|
||
at_all: true,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '0',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: '',
|
||
feed_links: '',
|
||
},
|
||
|
||
// 复杂的 Markdown 消息
|
||
complexMarkdown: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test106',
|
||
message_type: 'markdown',
|
||
content: `# 构建报告
|
||
## 构建状态: ✅ 成功
|
||
- **项目**: dingtalk-bot
|
||
- **分支**: main
|
||
- **提交**: abc123
|
||
- **时间**: 2024-01-01 12:00:00
|
||
|
||
### 测试结果
|
||
- 单元测试: 100% 通过
|
||
- 覆盖率: 95%
|
||
|
||
[查看详细报告](https://example.com/report)`,
|
||
title: '构建报告',
|
||
at_mobiles: '13800138000',
|
||
at_all: false,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '0',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: '',
|
||
feed_links: '',
|
||
},
|
||
|
||
// 垂直排列的多按钮 ActionCard
|
||
verticalActionCard: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test107',
|
||
message_type: 'actionCard',
|
||
content: '请选择操作',
|
||
title: '操作选择',
|
||
at_mobiles: '',
|
||
at_all: false,
|
||
link_url: '',
|
||
pic_url: '',
|
||
btn_orientation: '1',
|
||
single_title: '',
|
||
single_url: '',
|
||
buttons: JSON.stringify([
|
||
{ title: '同意', actionURL: 'https://example.com/approve' },
|
||
{ title: '拒绝', actionURL: 'https://example.com/reject' },
|
||
{ title: '查看详情', actionURL: 'https://example.com/detail' },
|
||
]),
|
||
feed_links: '',
|
||
},
|
||
|
||
// 多链接 FeedCard
|
||
multiFeedCard: {
|
||
webhook_url: 'https://oapi.dingtalk.com/robot/send?access_token=test108',
|
||
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: '技术文档',
|
||
messageURL: 'https://docs.example.com',
|
||
picURL: 'https://example.com/doc.jpg',
|
||
},
|
||
{
|
||
title: 'API 参考',
|
||
messageURL: 'https://api.example.com',
|
||
picURL: 'https://example.com/api.jpg',
|
||
},
|
||
{
|
||
title: '示例代码',
|
||
messageURL: 'https://github.com/example',
|
||
picURL: 'https://example.com/code.jpg',
|
||
},
|
||
]),
|
||
},
|
||
};
|
||
|
||
// 环境变量格式的配置(用于测试 config.js)
|
||
export const envConfigs = {
|
||
basicText: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test123',
|
||
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: '',
|
||
},
|
||
|
||
markdown: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test456',
|
||
INPUT_MESSAGE_TYPE: 'markdown',
|
||
INPUT_CONTENT: '## 标题\n这是一个 **Markdown** 消息',
|
||
INPUT_TITLE: 'Markdown 标题',
|
||
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: '',
|
||
},
|
||
|
||
textWithAtAll: {
|
||
INPUT_WEBHOOK_URL: 'https://oapi.dingtalk.com/robot/send?access_token=test105',
|
||
INPUT_MESSAGE_TYPE: 'text',
|
||
INPUT_CONTENT: '这是一个 @ 所有人的消息',
|
||
INPUT_TITLE: '',
|
||
INPUT_AT_MOBILES: '',
|
||
INPUT_AT_ALL: 'true',
|
||
INPUT_LINK_URL: '',
|
||
INPUT_PIC_URL: '',
|
||
INPUT_BTN_ORIENTATION: '0',
|
||
INPUT_SINGLE_TITLE: '',
|
||
INPUT_SINGLE_URL: '',
|
||
INPUT_BUTTONS: '',
|
||
INPUT_FEED_LINKS: '',
|
||
},
|
||
};
|