mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-12-01 14:53:45 +01:00
62 lines
3.5 KiB
JavaScript
62 lines
3.5 KiB
JavaScript
const fs = require('node:fs');
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const chat = fs.readFileSync('web/static/js/chat.js', 'utf8');
|
|
const monitor = fs.readFileSync('web/static/js/monitor.js', 'utf8');
|
|
const projects = fs.readFileSync('web/static/js/projects.js', 'utf8');
|
|
const styles = fs.readFileSync('web/static/css/style.css', 'utf8');
|
|
const template = fs.readFileSync('web/templates/index.html', 'utf8');
|
|
const zh = JSON.parse(fs.readFileSync('web/static/i18n/zh-CN.json', 'utf8'));
|
|
const en = JSON.parse(fs.readFileSync('web/static/i18n/en-US.json', 'utf8'));
|
|
|
|
test('主对话时间线不再创建用户或助手头像', () => {
|
|
assert.doesNotMatch(chat, /createMessageAvatar/);
|
|
assert.doesNotMatch(monitor, /createMessageAvatar/);
|
|
assert.doesNotMatch(chat, /message-avatar/);
|
|
assert.doesNotMatch(styles, /\.message-avatar/);
|
|
});
|
|
|
|
test('新对话使用无图标的项目欢迎空状态', () => {
|
|
assert.match(chat, /function renderChatWelcomeEmptyState\(\)/);
|
|
assert.match(chat, /chat-welcome-empty-state-title/);
|
|
assert.match(chat, /chat-welcome-empty-state-subtitle/);
|
|
assert.doesNotMatch(chat, /chat-welcome-empty-state-icon/);
|
|
assert.match(styles, /\.chat-welcome-empty-state\s*\{[\s\S]*?justify-content: center/);
|
|
assert.match(styles, /\.chat-welcome-empty-state-title/);
|
|
assert.match(styles, /\.chat-welcome-empty-state-subtitle/);
|
|
assert.match(styles, /\.chat-welcome-project-name\s*\{[\s\S]*?border-bottom: 1px dotted currentColor/);
|
|
assert.match(chat, /projectName\.className = 'chat-welcome-project-name'/);
|
|
assert.match(chat, /title\.replaceChildren\(/);
|
|
});
|
|
|
|
test('欢迎语随项目和无项目状态更新', () => {
|
|
assert.match(chat, /window\.t\('chat\.projectWelcomeMessage', \{ project \}\)/);
|
|
assert.match(chat, /window\.t\('chat\.noProjectWelcomeMessage'\)/);
|
|
assert.match(projects, /window\.refreshChatWelcomeEmptyState\(\)/);
|
|
assert.equal(
|
|
zh.chat.projectWelcomeMessage,
|
|
'当前{{project}}项目,请输入您的测试需求,系统将自动执行相应的安全测试。'
|
|
);
|
|
assert.equal(zh.chat.projectWelcomeTitlePrefix, '要在 ');
|
|
assert.equal(zh.chat.projectWelcomeTitleSuffix, ' 项目中测试什么?');
|
|
assert.equal(zh.chat.welcomeSubtitle, '请输入您的测试需求,系统将自动执行相应的安全测试。');
|
|
assert.equal(typeof en.chat.projectWelcomeMessage, 'string');
|
|
});
|
|
|
|
test('输入框顶部在同一张卡片内依次显示模式和项目', () => {
|
|
const composer = template.slice(template.indexOf('id="chat-input-container"'), template.indexOf('id="chat-input"'));
|
|
assert.match(composer, /class="chat-input-primary-row chat-composer-surface">\s*<div class="chat-composer-context"/);
|
|
assert.match(composer, /id="agent-mode-btn"[\s\S]*id="chat-project-btn"[\s\S]*class="chat-input-with-files"/);
|
|
assert.match(composer, /id="chat-project-text"[^>]*data-i18n="chat.defaultWorkspace"/);
|
|
assert.match(chat, /dataset\.projectName\?\.trim\(\)/);
|
|
assert.equal(zh.chat.defaultWorkspace, '默认工作区');
|
|
});
|
|
|
|
test('会话设置打开时提升整个输入区层级并遮住轮次导航', () => {
|
|
assert.match(chat, /function syncChatSessionSettingsLayerState\(\)/);
|
|
assert.match(chat, /inputBar\.classList\.toggle\('is-session-settings-open', open\)/);
|
|
assert.match(styles, /\.chat-input-container\.is-session-settings-open\s*\{[\s\S]*?z-index:\s*121/);
|
|
assert.match(styles, /\.chat-turn-rail\s*\{[\s\S]*?z-index:\s*20/);
|
|
});
|