Add unit tests for channel utilities and configure testing environment

- Created a new test file `channels.test.ts` to cover utilities related to channel configurations and targets.
- Implemented tests for normalizing and grouping selected channels by type, as well as building channel targets from account data and cron history.
- Mocked necessary dependencies to isolate tests and ensure accurate results.
- Updated `vite.config.ts` to set up the testing environment with jsdom and enable global variables for tests.
This commit is contained in:
duanshuwen
2026-04-18 16:12:49 +08:00
parent ee72cf7261
commit ef46c73c3e
26 changed files with 4056 additions and 186 deletions

View File

@@ -51,6 +51,20 @@ export const messages: I18nMessages = {
scripts: 'Scripts',
settings: 'Settings',
},
channels: {
modal: {
title: 'Channel configuration',
description: 'Choose a channel type, then fill in the connection fields that are available for this template.',
typeLabel: 'Channel type',
accountIdLabel: 'Account ID',
docsLabel: 'Docs and instructions',
instructionsTitle: 'Setup instructions',
tokenHelpText: 'Paste the token, secret, or access credential required by the selected channel.',
diagnosticsNote: 'QR code and diagnostics hooks will be wired up later when the backend contract is ready.',
todoNote: 'TODO: QR and diagnostics are placeholders for now; the modal stays props-driven until the channel APIs land.',
confirm: 'Save channel',
},
},
agents: {
title: 'Agents',
subtitle: 'Create new Agents to route specific channels into different personas or workspaces.',
@@ -254,6 +268,20 @@ export const messages: I18nMessages = {
scripts: '脚本',
settings: '设置',
},
channels: {
modal: {
title: '渠道配置',
description: '先选择渠道类型,再填写这个模板可用的连接字段。',
typeLabel: '渠道类型',
accountIdLabel: 'Account ID',
docsLabel: '文档与说明',
instructionsTitle: '接入说明',
tokenHelpText: '请填写所选渠道所需的 token、密钥或访问凭证。',
diagnosticsNote: '二维码和诊断能力会在后端契约完成后再接入。',
todoNote: 'TODO二维码和诊断目前仅保留占位modal 先保持 props 驱动,等待渠道 API 落地。',
confirm: '保存渠道',
},
},
agents: {
title: 'Agents',
subtitle: '创建新的 Agent可以将特定频道路由到不同的人格配置或工作区。',
@@ -457,6 +485,20 @@ export const messages: I18nMessages = {
scripts: 'スクリプト',
settings: '設定',
},
channels: {
modal: {
title: 'チャンネル設定',
description: 'まずチャンネル種類を選び、このテンプレートで使える接続項目を入力します。',
typeLabel: 'チャンネル種類',
accountIdLabel: 'Account ID',
docsLabel: 'ドキュメントと手順',
instructionsTitle: '接続手順',
tokenHelpText: '選択したチャンネルに必要な token、secret、またはアクセス資格情報を入力してください。',
diagnosticsNote: 'QR コードと診断の導線は、バックエンド契約が整ってから接続します。',
todoNote: 'TODO: QR と診断は現在プレースホルダです。modal は引き続き props 駆動のままにしておきます。',
confirm: 'チャンネルを保存',
},
},
agents: {
title: 'Agents',
subtitle: '新しい Agent を作成し、特定のチャンネルを別の人格設定やワークスペースへ振り分けます。',