CloudLab CI/CD / 门禁 doctor (push) Failing after 38s
CloudLab CI/CD / 单元测试 (push) Skipped
CloudLab CI/CD / 归档完整性 (push) Skipped
CloudLab CI/CD / 构建站点与归档 (push) Skipped
CloudLab CI/CD / 部署到 lab.hdtime.space(rsync) (push) Skipped
CloudLab CI/CD / 构建镜像并推送 Gitea 容器仓库 (push) Skipped
CloudLab CI/CD / 容器部署到 lab.hdtime.space (push) Skipped
CloudLab CI/CD / 发布版本(Tag) (push) Skipped
性能:
- 资料库总门户 1.3MB→0.37MB(内嵌 JSON gzip+base64 + pako 同步解压)
- 两份完全相同的 InSilicoLab 报告 MD5 一致,副本改轻量跳转入口(1.85MB→0.7KB)
- 线上 nginx 已开 gzip,纯 HTML 报告传输已压缩
功能细化:
- 阅读设置改为「按资料单独记忆」({global,docs} 结构),A± 与设置面板共用;
修复查看器 DOM 复用导致的闭包旧路径、滚动监听累积、Esc 监听累积
- 键长标签记住上次开关状态,刷新自动恢复
UI 统一(审计后修复):
- 9 个独立页(总门户/AtomLab 两工作台/InSilicoLab 报告/三个浏览器/portal_v2/设计台副本)
注入统一主题桥接:墨绿 light/dark 变量、跟随 cloudlab_theme_v1、focus-visible、
reduced-motion、窄屏规则;并把硬编码靛蓝渐变、白底改为自适应墨绿
- AtomLab/src/ui.css 与 ui_template.html 同步改造,以后生成即统一
- 验证:不变量 216/FAIL 0,全套 18 个 UI 测试全过(新增 round2 13/13、theme 10/10)
Co-Authored-By: WorkBuddy <noreply@workbuddy.ai>
94 lines
6.0 KiB
JavaScript
94 lines
6.0 KiB
JavaScript
#!/usr/bin/env node
|
||
// 验证:键长显式标注(悬停/标签/详情表) + 手机端底部遮挡修复
|
||
import { spawn } from 'node:child_process';
|
||
import { createServer } from 'node:http';
|
||
import { readFileSync, writeFileSync } from 'node:fs';
|
||
import { dirname, join, extname } from 'node:path';
|
||
import { fileURLToPath } from 'node:url';
|
||
const HERE = dirname(fileURLToPath(import.meta.url));
|
||
const ROOT = join(HERE, '..');
|
||
const OUT = join(ROOT, '..', '.workbuddy', 'shots');
|
||
const MIME = { '.html': 'text/html', '.css': 'text/css', '.js': 'text/javascript', '.svg': 'image/svg+xml', '.json': 'application/json' };
|
||
const srv = createServer((q, r) => { let p = decodeURIComponent(q.url.split('?')[0]); if (p.endsWith('/')) p += 'index.html'; let b; try { b = readFileSync(join(ROOT, p)); } catch { r.writeHead(404); r.end(); return; } r.writeHead(200, { 'Content-Type': MIME[extname(p)] || 'application/octet-stream' }); r.end(b); });
|
||
await new Promise(r => srv.listen(0, '127.0.0.1', r));
|
||
const BASE = `http://127.0.0.1:${srv.address().port}`;
|
||
const chrome = spawn('C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe', ['--headless=new', '--use-gl=swiftshader', '--enable-unsafe-swiftshader', '--remote-debugging-port=9250', '--user-data-dir=' + join(OUT, '_pb2'), '--window-size=1440,1000', 'about:blank']);
|
||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||
let targets;
|
||
for (let i = 0; i < 40; i++) { try { targets = await (await fetch('http://127.0.0.1:9250/json/list')).json(); if (targets.length) break; } catch {} await sleep(400); }
|
||
const ws = new WebSocket(targets.find(t => t.type === 'page').webSocketDebuggerUrl);
|
||
await new Promise(r => ws.onopen = r);
|
||
let id = 0; const pending = new Map();
|
||
ws.onmessage = e => { const m = JSON.parse(e.data); if (m.id && pending.has(m.id)) { pending.get(m.id)(m); pending.delete(m.id); } };
|
||
const send = (m, p = {}) => new Promise(res => { const i = ++id; pending.set(i, res); ws.send(JSON.stringify({ id: i, method: m, params: p })); });
|
||
const ev = async ex => { const r = await send('Runtime.evaluate', { expression: ex, returnByValue: true }); return r.result && r.result.result ? r.result.result.value : undefined; };
|
||
let pass = 0, fail = 0;
|
||
const check = (n, c) => { console.log((c ? ' ✅ ' : ' ❌ ') + n); c ? pass++ : fail++; };
|
||
|
||
// ---------- 1) 键长计算(纯逻辑) ----------
|
||
await send('Page.navigate', { url: BASE + '/app/browse.html' });
|
||
await sleep(2000);
|
||
// 保证从「未开启键长标签」的确定性状态开始测试
|
||
await ev(`(function(){try{localStorage.removeItem('cloudlab_bond_labels_v1');}catch(e){} return 1;})()`);
|
||
const calc = await ev(`(function(){
|
||
var geo={atoms:['C','Cl','O','H'],xyz:[[0,0,0],[1.72,0,0],[0,1.36,0],[0,1.36,0.96]],bonds:[[0,1,1],[0,2,1],[2,3,1]]};
|
||
return CL.bondLengths(geo).map(function(k){return k.text;});
|
||
})()`);
|
||
check('键长按元素对计算正确(C–Cl 1.72 Å)', Array.isArray(calc) && calc.some(t => t.indexOf('C–Cl 1.72') >= 0));
|
||
console.log(' ', calc);
|
||
|
||
// ---------- 2) 实验台分子详情:键长汇总表 ----------
|
||
await send('Page.navigate', { url: BASE + '/app/lab.html' });
|
||
await sleep(2800);
|
||
// 关闭首次访问欢迎浮层(模态),避免干扰后续布局检查
|
||
await ev(`(function(){localStorage.setItem('cloudlab_welcome_v1','1'); var w=document.getElementById('cl-welcome'); if(w){w.classList.remove('open'); w.setAttribute('aria-hidden','true');} return 1;})()`);
|
||
const bondBox = await ev(`(function(){var b=document.querySelector('.cl-bond-box'); return b?b.textContent.slice(0,120):null;})()`);
|
||
check('分子详情显示键长汇总表', !!bondBox && /\d\.\d\d\s*Å/.test(bondBox));
|
||
console.log(' ', bondBox && bondBox.replace(/\s+/g, ' ').slice(0, 90));
|
||
|
||
// 3D 键长开关按钮(依赖 3Dmol WebGL)
|
||
const lenBtn = await ev(`!!document.querySelector('.cl-mol-lenbtn')`);
|
||
check('3D 视图有「Å 显示键长」开关', lenBtn === true);
|
||
if (lenBtn) {
|
||
await ev(`(function(){var b=document.querySelector('.cl-mol-lenbtn'); b.click(); return 1;})()`);
|
||
await sleep(500);
|
||
check('点击后进入标注状态', await ev(`document.querySelector('.cl-mol-lenbtn').classList.contains('on')`));
|
||
const nLabels = await ev(`(function(){var c=document.getElementById('mol-3d'); return c && parseInt(c.dataset.bondLabels||'0',10);})()`);
|
||
check('键中点已标注键长数值(WebGL 标签)', nLabels > 0);
|
||
console.log(' 标注键数:', nLabels);
|
||
}
|
||
|
||
// ---------- 3) 手机端遮挡修复 ----------
|
||
await send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 1, mobile: true });
|
||
await send('Page.navigate', { url: BASE + '/app/lab.html' });
|
||
await sleep(2600);
|
||
const occ = await ev(`(function(){
|
||
var bar=document.querySelector('.cl-mobilebar');
|
||
var dock=document.getElementById('cl-dock');
|
||
var t=document.querySelector('.cl-ws-toggle');
|
||
if(!bar||!t) return null;
|
||
var br=bar.getBoundingClientRect(), tr=t.getBoundingClientRect();
|
||
return {
|
||
dockHidden: !dock || getComputedStyle(dock).display==='none',
|
||
barTop: Math.round(br.top), btnBottom: Math.round(tr.bottom),
|
||
overlap: tr.bottom > br.top && tr.top < br.bottom
|
||
};
|
||
})()`);
|
||
check('窄屏隐藏冗余 dock', occ && occ.dockHidden === true);
|
||
check('全屏按钮不遮挡底部导航', occ && occ.overlap === false);
|
||
console.log(' ', occ);
|
||
const hintOcc = await ev(`(function(){
|
||
var h=document.querySelector('.cl-viewer3d > .cl-3d-hint');
|
||
var t=document.querySelector('.cl-ws-toggle');
|
||
if(!h||!t) return null;
|
||
var hr=h.getBoundingClientRect(), tr=t.getBoundingClientRect();
|
||
return {overlap: hr.bottom>tr.top && hr.top<tr.bottom, hintTop:Math.round(hr.top), btnTop:Math.round(tr.top)};
|
||
})()`);
|
||
check('3D 提示不被浮动按钮遮挡', hintOcc && hintOcc.overlap === false);
|
||
|
||
const r = await send('Page.captureScreenshot', { format: 'png' });
|
||
if (r.result && r.result.data) writeFileSync(join(OUT, 'mobile-fixed.png'), Buffer.from(r.result.data, 'base64'));
|
||
|
||
console.log(`\n结果: ${pass} 通过 / ${fail} 失败`);
|
||
ws.close(); chrome.kill(); srv.close(); process.exit(fail ? 1 : 0);
|