mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 16:42:19 +00:00
- 在脚本配置中添加 targetGroups 字段用于指定动态组路径 - 更新工具规范定义以支持动态组路径参数 - 实现组范围的连接脚本动态继承功能 - 更新 CLI 适配器以支持 --target-groups 参数 - 添加测试用例验证动态组路径映射和解析 - 更新国际化资源文件添加相关提示文本 - 重构脚本目标匹配逻辑分离显式主机和组路径匹配 - 实现组路径变更时的重映射和删除处理逻辑 - 更新 UI 组件支持组路径选择和显示功能 - 修改文档描述更新动态组路径使用说明
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import React from 'react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { SnippetTargetsSection } from './SnippetTargetsSection';
|
|
|
|
const t = (key: string) => ({
|
|
'snippets.targets.title': 'Targets',
|
|
'snippets.targets.selectHosts': 'Select hosts',
|
|
'snippets.targets.selectGroups': 'Select groups',
|
|
'snippets.targets.add': 'Add targets',
|
|
'snippets.targets.allHosts': 'All hosts',
|
|
'snippets.targets.allHostsShort': 'All hosts',
|
|
'snippets.targets.allHostsActive': 'Every host',
|
|
}[key] ?? key);
|
|
|
|
test('renders dynamic group targets separately from explicit hosts', () => {
|
|
const markup = renderToStaticMarkup(
|
|
<SnippetTargetsSection
|
|
t={t}
|
|
targetHosts={[]}
|
|
targetGroups={['Production/Web']}
|
|
onEditTargets={() => undefined}
|
|
onEditGroups={() => undefined}
|
|
/>,
|
|
);
|
|
assert.match(markup, /Production\/Web/);
|
|
assert.match(markup, /Select hosts/);
|
|
assert.match(markup, /Select groups/);
|
|
});
|
|
|
|
test('all-host mode hides host and group pickers', () => {
|
|
const markup = renderToStaticMarkup(
|
|
<SnippetTargetsSection
|
|
t={t}
|
|
targetHosts={[]}
|
|
targetGroups={['Production']}
|
|
onEditTargets={() => undefined}
|
|
onEditGroups={() => undefined}
|
|
targetsAllHosts
|
|
onTargetsAllHostsChange={() => undefined}
|
|
/>,
|
|
);
|
|
assert.doesNotMatch(markup, /Select hosts/);
|
|
assert.doesNotMatch(markup, /Select groups/);
|
|
assert.match(markup, /Every host/);
|
|
});
|