同步新版首页文案关键词并更新测试以匹配 v2/v3 视觉改版;部署脚本增加未同步改动保护
这个提交包含在:
@@ -1,53 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
全站独立页面精美视觉配图规范专项测试 (Dedicated Page Illustrations Test)
|
||||
严格遵循 TDD 模式:
|
||||
1. 验证软件定制独立页、APP定制独立页、智能体独立页、联系我们页均配有专属高品质现代中式矢量视窗图;
|
||||
2. 验证所有图片文件真实存在于资源目录且尺寸有效;
|
||||
3. 验证图片符合浅色专业风规范(背景 #FFFFFF/#F8FAFC、主色 #2563EB、无 emoji、有印章点缀与细线窗棂)。
|
||||
1. 验证软件定制独立页、APP定制独立页、智能体独立页、联系我们页均配有专属高品质视窗图;
|
||||
2. 验证新版服务页摄影配图真实存在、尺寸满足首屏展示要求,并提供 WebP 兼容版本;
|
||||
3. 验证联系我们页矢量配图符合浅色专业风规范。
|
||||
"""
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from PIL import Image
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
RASTER_ROOT = os.path.join(ROOT_DIR, 'public', 'assets', 'addons', 'official', 'images')
|
||||
SHOWCASE_ROOT = os.path.join(RASTER_ROOT, 'showcases')
|
||||
|
||||
SERVICE_HEROES = {
|
||||
'software': ('software/structure-v2.jpg', 1440, 960),
|
||||
'app': ('app/terminals.jpg', 1440, 960),
|
||||
'agent': ('agent/landscape-v2.jpg', 1920, 640),
|
||||
}
|
||||
|
||||
|
||||
class TestDedicatedPageIllustrations(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.img_dir = os.path.join(ROOT_DIR, 'public/assets/addons/official/images/showcases')
|
||||
self.template_dir = os.path.join(ROOT_DIR, 'addons/official/view/web')
|
||||
|
||||
def test_illustration_assets_exist(self):
|
||||
"""测试 4 张专属精美视觉插图文件存在且内容有效"""
|
||||
required_images = [
|
||||
'service_software_hero.svg',
|
||||
'service_app_hero.svg',
|
||||
'service_agent_hero.svg',
|
||||
'contact_headquarters.svg',
|
||||
]
|
||||
for img_name in required_images:
|
||||
path = os.path.join(self.img_dir, img_name)
|
||||
self.assertTrue(os.path.exists(path), f"缺少专属精美配图: {img_name}")
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
self.assertIn('<svg', content, f"{img_name} 必须是有效矢量 SVG")
|
||||
self.assertIn('#2563EB', content, f"{img_name} 必须包含主色 #2563EB 科技蓝")
|
||||
self.assertIn('nhc-seal', content, f"{img_name} 必须包含现代中式印章点缀")
|
||||
"""测试专属配图文件存在、格式有效且尺寸满足展示要求"""
|
||||
for key, (relative_path, minimum_width, minimum_height) in SERVICE_HEROES.items():
|
||||
with self.subTest(page=key):
|
||||
jpg_path = os.path.join(RASTER_ROOT, relative_path)
|
||||
webp_path = os.path.splitext(jpg_path)[0] + '.webp'
|
||||
self.assertTrue(os.path.isfile(jpg_path), f"缺少专属精美配图: {relative_path}")
|
||||
self.assertTrue(os.path.isfile(webp_path), f"缺少 WebP 兼容版本: {relative_path}")
|
||||
with Image.open(jpg_path) as hero:
|
||||
width, height = hero.size
|
||||
self.assertGreaterEqual(width, minimum_width, f"{relative_path} 宽度不足首屏要求")
|
||||
self.assertGreaterEqual(height, minimum_height, f"{relative_path} 高度不足首屏要求")
|
||||
self.assertGreater(os.path.getsize(jpg_path), 50_000, f"{relative_path} 文件过小")
|
||||
|
||||
contact_path = os.path.join(SHOWCASE_ROOT, 'contact_headquarters.svg')
|
||||
with open(contact_path, encoding='utf-8') as stream:
|
||||
contact_content = stream.read()
|
||||
self.assertIn('<svg', contact_content, 'contact_headquarters.svg 必须是有效矢量 SVG')
|
||||
|
||||
def test_pages_embed_dedicated_illustrations(self):
|
||||
"""测试各独立页面均正确嵌入对应的精美配图"""
|
||||
pages = {
|
||||
'software': ('official_product/service_software.html', 'service_software_hero.svg'),
|
||||
'app': ('official_product/service_app.html', 'service_app_hero.svg'),
|
||||
'agent': ('official_product/service_agent.html', 'service_agent_hero.svg'),
|
||||
'software': ('official_product/service_software.html', 'images/software/structure-v2.jpg'),
|
||||
'app': ('official_product/service_app.html', 'images/app/terminals.jpg'),
|
||||
'agent': ('official_product/service_agent.html', 'images/agent/landscape-v2.jpg'),
|
||||
'contact_pc': ('official_online_message/list.html', 'contact_headquarters.svg'),
|
||||
'contact_m': ('official_online_message/list_e.html', 'contact_headquarters.svg'),
|
||||
}
|
||||
for key, (tpl_rel, img_name) in pages.items():
|
||||
tpl_path = os.path.join(self.template_dir, tpl_rel)
|
||||
with open(tpl_path, 'r', encoding='utf-8') as f:
|
||||
html = f.read()
|
||||
self.assertIn(img_name, html, f"页面 {tpl_rel} 必须正确引用专属配图 {img_name}")
|
||||
template_dir = os.path.join(ROOT_DIR, 'addons', 'official', 'view', 'web')
|
||||
for key, (template_relative_path, image_name) in pages.items():
|
||||
with self.subTest(page=key):
|
||||
template_path = os.path.join(template_dir, template_relative_path)
|
||||
with open(template_path, encoding='utf-8') as stream:
|
||||
html = stream.read()
|
||||
self.assertIn(image_name, html, f"页面 {template_relative_path} 必须正确引用专属配图 {image_name}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
在新工单中引用
屏蔽一个用户