feat(about): 实现大公司品牌级关于我们独立页(东方工程哲学、十年技术发展历程、专家团队与资质资产体系)
这个提交包含在:
132
tests/AboutPageTest.php
普通文件
132
tests/AboutPageTest.php
普通文件
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* 关于我们独立页改版规范与内容完整性测试 (TDD 模式)
|
||||
* 验证关于我们必备板块:品牌、团队、资质,以及色彩体系、去AI味道与禁止项
|
||||
*/
|
||||
|
||||
class AboutPageTest
|
||||
{
|
||||
private $passed = 0;
|
||||
private $failed = 0;
|
||||
private $htmlContent = '';
|
||||
private $mobileHtmlContent = '';
|
||||
private $cssContent = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$baseDir = dirname(__DIR__);
|
||||
$singleFile = $baseDir . '/addons/official/view/web/official_home/single.html';
|
||||
$mobileSingleFile = $baseDir . '/addons/official/view/web/official_home/single_e.html';
|
||||
$cssFile = $baseDir . '/public/assets/addons/official/css/modern_nhc.css';
|
||||
|
||||
if (file_exists($singleFile)) {
|
||||
$this->htmlContent = file_get_contents($singleFile);
|
||||
}
|
||||
if (file_exists($mobileSingleFile)) {
|
||||
$this->mobileHtmlContent = file_get_contents($mobileSingleFile);
|
||||
}
|
||||
if (file_exists($cssFile)) {
|
||||
$this->cssContent = file_get_contents($cssFile);
|
||||
}
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
echo "=== 开始执行关于我们独立页设计规范与内容完整性测试 (TDD) ===\n";
|
||||
|
||||
// 1. 品牌名称必须为纳海川
|
||||
$this->testBrandName();
|
||||
|
||||
// 2. 必备板块测试:品牌、团队、资质 (AGENTS.md 规范)
|
||||
$this->testEssentialSections();
|
||||
|
||||
// 3. 去除 AI 味道:真实工程哲学、技术委员会成员、具体软著资质
|
||||
$this->testNoAiCharacteristics();
|
||||
|
||||
// 4. 禁止项测试(严禁 emoji)
|
||||
$this->testForbiddenElements();
|
||||
|
||||
// 5. 色彩与设计规范
|
||||
$this->testDesignTokens();
|
||||
|
||||
// 6. 移动端模板完整性
|
||||
$this->testMobileTemplate();
|
||||
|
||||
echo "\n测试结果: {$this->passed} 通过, {$this->failed} 失败\n";
|
||||
if ($this->failed > 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function assert($condition, $message)
|
||||
{
|
||||
if ($condition) {
|
||||
echo " [PASS] {$message}\n";
|
||||
$this->passed++;
|
||||
} else {
|
||||
echo " [FAIL] {$message}\n";
|
||||
$this->failed++;
|
||||
}
|
||||
}
|
||||
|
||||
public function testBrandName()
|
||||
{
|
||||
$this->assert(strpos($this->htmlContent, '纳海川') !== false, "关于我们页面必须明确包含品牌名称【纳海川】");
|
||||
$hasWrongAbbr = preg_match('/纳川(?![海])/u', $this->htmlContent);
|
||||
$this->assert(!$hasWrongAbbr, "关于我们页面严禁错误简称为【纳川】");
|
||||
}
|
||||
|
||||
public function testEssentialSections()
|
||||
{
|
||||
// 按照 AGENTS.md 规范:关于我们含品牌、团队、资质
|
||||
$hasBrand = (strpos($this->htmlContent, 'nhc-about-brand') !== false || strpos($this->htmlContent, '品牌') !== false || strpos($this->htmlContent, '工程哲学') !== false);
|
||||
$this->assert($hasBrand, "关于我们必须包含【品牌】(品牌渊源与东方工程哲学)板块");
|
||||
|
||||
$hasTeam = (strpos($this->htmlContent, 'nhc-about-team') !== false || strpos($this->htmlContent, '技术委员会') !== false || strpos($this->htmlContent, '核心团队') !== false);
|
||||
$this->assert($hasTeam, "关于我们必须包含【团队】(技术委员会专家与核心团队)板块");
|
||||
|
||||
$hasCerts = (strpos($this->htmlContent, 'nhc-about-qualifications') !== false || strpos($this->htmlContent, '软件著作权') !== false || strpos($this->htmlContent, '合规体系') !== false);
|
||||
$this->assert($hasCerts, "关于我们必须包含【资质】(权威资质、软著资产与安全合规体系)板块");
|
||||
}
|
||||
|
||||
public function testNoAiCharacteristics()
|
||||
{
|
||||
// 必须具备真实的工程价值观与发展里程碑年份
|
||||
$hasMilestones = (strpos($this->htmlContent, '2016') !== false || strpos($this->htmlContent, '2019') !== false || strpos($this->htmlContent, '2024') !== false || strpos($this->htmlContent, '发展历程') !== false);
|
||||
$this->assert($hasMilestones, "去AI味道:必须展示具体的企业发展里程碑或演进历程");
|
||||
|
||||
// 团队阵容必须具备具体专业背景(如微服务、高可用、大模型等专业技术深度)
|
||||
$hasTechDepth = (strpos($this->htmlContent, '架构师') !== false || strpos($this->htmlContent, '全栈') !== false || strpos($this->htmlContent, '智能体') !== false);
|
||||
$this->assert($hasTechDepth, "去AI味道:团队阵容必须展示真实严谨的技术职称与专业领域");
|
||||
|
||||
// 资质具有具体软著和体系认证(ISO、等保、软著等)
|
||||
$hasConcreteCerts = (strpos($this->htmlContent, 'ISO') !== false || strpos($this->htmlContent, '著作权') !== false || strpos($this->htmlContent, '等保') !== false);
|
||||
$this->assert($hasConcreteCerts, "去AI味道:资质板块必须展示具体真实的行业认证体系与软著资产");
|
||||
}
|
||||
|
||||
public function testForbiddenElements()
|
||||
{
|
||||
$hasEmoji = preg_match('/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{2600}-\x{26FF}\x{2700}-\x{27BF}]/u', $this->htmlContent);
|
||||
$this->assert(!$hasEmoji, "关于我们页面严禁使用任何 emoji 表情符号");
|
||||
}
|
||||
|
||||
public function testDesignTokens()
|
||||
{
|
||||
$hasSerif = (stripos($this->cssContent, 'SimSun') !== false || stripos($this->cssContent, 'Songti') !== false || stripos($this->cssContent, 'Noto Serif SC') !== false);
|
||||
$this->assert($hasSerif, "必须沿用宋体标题规范");
|
||||
|
||||
$hasPrimary = (stripos($this->cssContent, '#2563EB') !== false || stripos($this->cssContent, '#2563eb') !== false);
|
||||
$this->assert($hasPrimary, "必须沿用科技蓝 #2563EB 主色规范");
|
||||
}
|
||||
|
||||
public function testMobileTemplate()
|
||||
{
|
||||
$this->assert(!empty($this->mobileHtmlContent), "移动端关于我们模板 single_e.html 文件必须存在");
|
||||
$this->assert(strpos($this->mobileHtmlContent, '纳海川') !== false, "移动端模板必须包含品牌名【纳海川】");
|
||||
$this->assert(strpos($this->mobileHtmlContent, '团队') !== false || strpos($this->mobileHtmlContent, '专家') !== false, "移动端模板必须包含核心团队介绍");
|
||||
$this->assert(strpos($this->mobileHtmlContent, '资质') !== false || strpos($this->mobileHtmlContent, '著作权') !== false, "移动端模板必须包含资质认证板块");
|
||||
}
|
||||
}
|
||||
|
||||
$test = new AboutPageTest();
|
||||
$test->run();
|
||||
@@ -139,12 +139,51 @@ def test_nav_megamenu():
|
||||
res.assert_true('.nhc-has-dropdown:hover' in css, "CSS 包含鼠标悬停触发规则")
|
||||
return res.summary()
|
||||
|
||||
def test_about_page():
|
||||
res = TestResult("关于我们独立页 (AboutPage)")
|
||||
single_path = os.path.join(BASE_DIR, 'addons', 'official', 'view', 'web', 'official_home', 'single.html')
|
||||
single_e_path = os.path.join(BASE_DIR, 'addons', 'official', 'view', 'web', 'official_home', 'single_e.html')
|
||||
css_path = os.path.join(BASE_DIR, 'public', 'assets', 'addons', 'official', 'css', 'modern_nhc.css')
|
||||
|
||||
html = open(single_path, 'r', encoding='utf-8').read() if os.path.exists(single_path) else ''
|
||||
mobile_html = open(single_e_path, 'r', encoding='utf-8').read() if os.path.exists(single_e_path) else ''
|
||||
css = open(css_path, 'r', encoding='utf-8').read() if os.path.exists(css_path) else ''
|
||||
|
||||
res.assert_true('纳海川' in html, "PC 关于我们页必须明确包含品牌名称【纳海川】")
|
||||
res.assert_true(not re.search(r'纳川(?!海)', html), "PC 关于我们页严禁错误简称为【纳川】")
|
||||
|
||||
has_brand = 'nhc-about-brand' in html or '工程哲学' in html or '品牌' in html
|
||||
res.assert_true(has_brand, "必须包含【品牌】(品牌渊源与东方工程哲学)板块")
|
||||
has_team = 'nhc-about-team' in html or '技术委员会' in html or '核心团队' in html
|
||||
res.assert_true(has_team, "必须包含【团队】(技术委员会专家与核心团队)板块")
|
||||
has_certs = 'nhc-about-qualifications' in html or '软件著作权' in html or '合规体系' in html
|
||||
res.assert_true(has_certs, "必须包含【资质】(权威资质、软著资产与安全合规体系)板块")
|
||||
|
||||
has_milestones = '2016' in html or '2019' in html or '2024' in html or '发展历程' in html
|
||||
res.assert_true(has_milestones, "去AI味道:展示具体发展历程或里程碑")
|
||||
has_tech = '架构师' in html or '全栈' in html or '智能体' in html
|
||||
res.assert_true(has_tech, "去AI味道:展示严谨技术职称与专业领域")
|
||||
has_certs_concrete = 'ISO' in html or '著作权' in html or '等保' in html
|
||||
res.assert_true(has_certs_concrete, "去AI味道:展示具体行业认证体系与软著资产")
|
||||
|
||||
has_emoji = bool(re.search(r'[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\u2600-\u26FF\u2700-\u27BF]', html))
|
||||
res.assert_true(not has_emoji, "严禁使用任何 emoji 表情符号")
|
||||
|
||||
res.assert_true(bool(mobile_html), "移动端关于我们模板 single_e.html 必须存在")
|
||||
if mobile_html:
|
||||
res.assert_true('纳海川' in mobile_html, "移动端模板包含品牌名【纳海川】")
|
||||
res.assert_true('团队' in mobile_html or '专家' in mobile_html, "移动端模板包含核心团队介绍")
|
||||
res.assert_true('资质' in mobile_html or '著作权' in mobile_html, "移动端模板包含资质认证板块")
|
||||
|
||||
return res.summary()
|
||||
|
||||
def main():
|
||||
results = [
|
||||
test_cases_page(),
|
||||
test_services_page(),
|
||||
test_products_page(),
|
||||
test_nav_megamenu()
|
||||
test_nav_megamenu(),
|
||||
test_about_page()
|
||||
]
|
||||
sys.exit(0 if all(results) else 1)
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户