149 行
6.8 KiB
Python
149 行
6.8 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""
|
||
去 AI 味(文案与排版)专项自动化测试用例
|
||
严格遵循 TDD 模式:验证全站文本杜绝 AI 假大空对仗口号,排版具备大厂专业左对齐与严谨网格。
|
||
"""
|
||
import os
|
||
import re
|
||
import unittest
|
||
|
||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
|
||
class TestNoAiFlavor(unittest.TestCase):
|
||
|
||
def setUp(self):
|
||
self.index_html_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/index.html')
|
||
self.service_page_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_product/service_page.html')
|
||
self.product_page_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_product/product_page.html')
|
||
self.cases_page_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_case_show/list.html')
|
||
self.about_page_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/single.html')
|
||
self.about_mobile_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/single_e.html')
|
||
self.contact_page_path = os.path.join(ROOT_DIR, 'addons/official/view/web/official_online_message/list.html')
|
||
self.css_path = os.path.join(ROOT_DIR, 'public/assets/addons/official/css/modern_nhc.css')
|
||
|
||
with open(self.index_html_path, 'r', encoding='utf-8') as f:
|
||
self.index_html = f.read()
|
||
with open(self.service_page_path, 'r', encoding='utf-8') as f:
|
||
self.service_page = f.read()
|
||
with open(self.product_page_path, 'r', encoding='utf-8') as f:
|
||
self.product_page = f.read()
|
||
with open(self.cases_page_path, 'r', encoding='utf-8') as f:
|
||
self.cases_page = f.read()
|
||
with open(self.about_page_path, 'r', encoding='utf-8') as f:
|
||
self.about_page = f.read()
|
||
with open(self.about_mobile_path, 'r', encoding='utf-8') as f:
|
||
self.about_mobile = f.read()
|
||
with open(self.contact_page_path, 'r', encoding='utf-8') as f:
|
||
self.contact_page = f.read()
|
||
with open(self.css_path, 'r', encoding='utf-8') as f:
|
||
self.css = f.read()
|
||
|
||
def test_forbidden_ai_buzzwords_in_index(self):
|
||
"""首页必须彻底杜绝 AI 假大空对仗套话"""
|
||
forbidden_words = [
|
||
'铸造数字生产力',
|
||
'格物致知',
|
||
'经纬分明',
|
||
'架构严谨立骨',
|
||
'严审磐石',
|
||
'笃行护航',
|
||
'成巨流',
|
||
'海纳百川以成巨流',
|
||
'聚智能以启新元'
|
||
]
|
||
for word in forbidden_words:
|
||
self.assertNotIn(word, self.index_html, f"首页 index.html 仍包含 AI 味词汇: '{word}'")
|
||
|
||
def test_forbidden_ai_buzzwords_in_services(self):
|
||
"""服务页必须杜绝 AI 假大空标题与步骤套话"""
|
||
forbidden_words = [
|
||
'经纬立骨铸基石',
|
||
'全栈自主赋生产',
|
||
'格物致知',
|
||
'架构严谨立骨',
|
||
'严审磐石',
|
||
'修己守信',
|
||
]
|
||
for word in forbidden_words:
|
||
self.assertNotIn(word, self.service_page, f"服务页 service_page.html 仍包含 AI 味词汇: '{word}'")
|
||
|
||
def test_forbidden_ai_buzzwords_in_products(self):
|
||
"""产品页必须杜绝 AI 假大空口号"""
|
||
forbidden_words = [
|
||
'积厚流光成重器',
|
||
'矩阵赋能拓坦途',
|
||
]
|
||
for word in forbidden_words:
|
||
self.assertNotIn(word, self.product_page, f"产品页 product_page.html 仍包含 AI 味词汇: '{word}'")
|
||
|
||
def test_forbidden_ai_buzzwords_in_about(self):
|
||
"""关于我们(PC与移动端)必须杜绝空洞口号"""
|
||
forbidden_words = [
|
||
'海纳百川,有容乃大;壁立千仞,无欲则刚',
|
||
'格物致知 · 自主可控',
|
||
'格物求真',
|
||
'慎终如始',
|
||
]
|
||
for word in forbidden_words:
|
||
self.assertNotIn(word, self.about_page, f"关于我们 PC 页仍包含 AI 味词汇: '{word}'")
|
||
self.assertNotIn(word, self.about_mobile, f"关于我们移动端页仍包含 AI 味词汇: '{word}'")
|
||
|
||
def test_forbidden_ai_committee_and_fake_buzzwords(self):
|
||
"""全站必须彻底剔除虚假委员会、生硬TDD、白盒、受控等AI套话"""
|
||
fake_buzzwords = [
|
||
'研发委员会',
|
||
'技术委员会',
|
||
'原创技术资产',
|
||
'白盒源码',
|
||
'白盒交付',
|
||
'工程受控说明',
|
||
'带病代码',
|
||
'带病交付',
|
||
'杜绝系统带病上线',
|
||
'西南数谷',
|
||
]
|
||
all_templates = (
|
||
self.index_html + "\n" +
|
||
self.service_page + "\n" +
|
||
self.product_page + "\n" +
|
||
self.cases_page + "\n" +
|
||
self.about_page + "\n" +
|
||
self.about_mobile + "\n" +
|
||
self.contact_page
|
||
)
|
||
for word in fake_buzzwords:
|
||
self.assertNotIn(word, all_templates, f"全站模板严禁包含虚假AI口味词汇: '{word}'")
|
||
|
||
def test_enterprise_engineering_keywords(self):
|
||
"""全站必须具备真实软件工程与业务术语"""
|
||
required_in_index = ['源码交付', '微服务', '私有化部署', '代码审查']
|
||
for kw in required_in_index:
|
||
self.assertIn(kw, self.index_html, f"首页缺少工程关键词: '{kw}'")
|
||
|
||
required_in_services = ['源码', '微服务', 'API', 'SLA', '私有化']
|
||
for kw in required_in_services:
|
||
self.assertIn(kw, self.service_page, f"服务页缺少工程关键词: '{kw}'")
|
||
|
||
def test_layout_enterprise_left_aligned_hero(self):
|
||
"""首屏与二级页排版验证:左对齐大厂排版与严谨留白"""
|
||
self.assertIn('text-align: left;', self.css, "CSS 中应包含 text-align: left")
|
||
# 确保 hero-content 是左对齐
|
||
hero_content_match = re.search(r'(?:\r?\n)\.nhc-hero-content\s*\{([^}]+)\}', self.css)
|
||
self.assertTrue(hero_content_match, "必须包含 .nhc-hero-content 样式块")
|
||
self.assertIn('text-align: left', hero_content_match.group(1))
|
||
|
||
# 确保二级页面 Hero 支持左对齐大厂风
|
||
page_hero_match = re.search(r'\.nhc-page-hero\s*\{([^}]+)\}', self.css)
|
||
self.assertTrue(page_hero_match, "必须包含 .nhc-page-hero 样式块")
|
||
self.assertIn('text-align: left', page_hero_match.group(1), "二级页 Hero 推荐大厂左对齐排版")
|
||
|
||
def test_typography_and_color_tokens(self):
|
||
"""规范中的设计令牌:纯净背景、科技蓝主色、严禁霓虹炫目"""
|
||
self.assertIn('--primary: #2563EB;', self.css)
|
||
self.assertIn('--bg-primary: #FFFFFF;', self.css)
|
||
self.assertIn('--bg-secondary: #F8FAFC;', self.css)
|
||
self.assertIn('--text-primary: #0F172A;', self.css)
|
||
|
||
if __name__ == '__main__':
|
||
unittest.main()
|