test_s7_highlight.py
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""RED test for S7: 代码高亮 + 暗色模式
Tests:
TC1: highlight.js CDN exists in aichat.html
TC2: hljs.highlight*() called in renderMsg or after loadMessages
TC3: Dark theme CSS for code blocks
"""
import sys, subprocess
def main():
errors = []
r = subprocess.run(["su", "-c", "cat /data/data/com.termux/files/home/wechat-viewer/templates/aichat.html"],
capture_output=True, text=True, timeout=10)
html = r.stdout
# TC1: highlight.js import
has_hljs_css = 'highlight.js' in html or 'hljs' in html
if not has_hljs_css:
errors.append("TC1: No highlight.js CDN import (CSS/JS)")
# TC2: highlight call
has_hl = 'hljs.highlight' in html or 'highlightElement' in html or 'highlightAll' in html
if not has_hl:
errors.append("TC2: No hljs.highlight*() call in renderMsg")
# TC3: Dark mode code styling
has_dark = '.msg-bubble pre' in html and ('background' in html or 'rgba(0,0,0' in html.lower())
if not has_dark:
errors.append("TC3: No dark background for code blocks")
if errors:
print(f"RED: {len(errors)} failures")
for e in errors: print(f" ✗ {e}")
sys.exit(1)
else:
print("GREEN: All passed")
sys.exit(0)
main()