chore(test): 完善审计门禁和后台验收诊断
This commit is contained in:
1 parent
3d7e551838
commit
3a7aed0800
5 files changed
+18
-7
No files matched your search
+2
-2
@@ -34,7 +34,7 @@ function readVersion() {
|
||||
|
||||
/** 找不到 docfx 时给出可照抄的安装命令,而不是一句 spawn ENOENT */
|
||||
function ensureDocfx() {
|
||||
const probe = spawnSync('docfx', ['--version'], { encoding: 'utf8', shell: process.platform === 'win32' });
|
||||
const probe = spawnSync('docfx', ['--version'], { encoding: 'utf8' });
|
||||
if (probe.status === 0) return probe.stdout.trim();
|
||||
|
||||
console.error('[docs] 找不到 docfx。docfx 是 .NET 工具,安装方式:');
|
||||
@@ -50,7 +50,7 @@ function ensureDocfx() {
|
||||
|
||||
function run(command, args, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(command, args, { stdio: 'inherit', shell: process.platform === 'win32', ...options });
|
||||
const child = spawn(command, args, { stdio: 'inherit', ...options });
|
||||
child.on('error', reject);
|
||||
child.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`${command} 退出码 ${code}`))));
|
||||
});
|
||||
|
||||
+2
-1
@@ -16,7 +16,7 @@
|
||||
"build": "pnpm build:shared && pnpm --filter @classhelper/server build && pnpm --filter @classhelper/web-admin build && pnpm --filter @classhelper/desktop-client build",
|
||||
"build:desktop": "pnpm build:shared && pnpm --filter @classhelper/desktop-client build",
|
||||
"check:icons": "node scripts/check-icons.mjs",
|
||||
"typecheck": "pnpm build:shared && pnpm -r --no-bail typecheck",
|
||||
"typecheck": "pnpm build:shared && pnpm -r --workspace-concurrency=1 --no-bail typecheck",
|
||||
"lint": "node scripts/check-authz.mjs && eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"format": "prettier --write \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
|
||||
@@ -59,6 +59,7 @@
|
||||
"verify:desktop:visual": "node packages/desktop-client/scripts/smoke.mjs --visual",
|
||||
"verify:desktop:online": "node packages/desktop-client/scripts/smoke.mjs --online",
|
||||
"verify:authz": "node scripts/verify-authz.mjs",
|
||||
"verify:audit": "node scripts/verify-authz.mjs --audit && node scripts/verify-web-worker.mjs",
|
||||
"check:authz": "node scripts/check-authz.mjs",
|
||||
"verify:server-bootstrap": "node scripts/verify-server-bootstrap.mjs"
|
||||
},
|
||||
|
||||
@@ -392,7 +392,9 @@ export async function verifyResidentSmoke(
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const immediate = (await waitForCourse()) && Date.now() - started < 600;
|
||||
const ready = await waitForCourse();
|
||||
const latencyMs = Date.now() - started;
|
||||
const immediate = ready && latencyMs < 600;
|
||||
const aligned = await win.webContents.executeJavaScript(`(() => {
|
||||
const name=document.querySelector('.resident-compact .schedule strong')?.getBoundingClientRect(), time=document.querySelector('.resident-compact .lesson-time')?.getBoundingClientRect();
|
||||
return Boolean(name&&time&&time.left>=name.right&&Math.abs(time.top+time.height/2-name.top-name.height/2)<=2);
|
||||
@@ -405,7 +407,12 @@ export async function verifyResidentSmoke(
|
||||
island.syncCustomLayout();
|
||||
await pause(800);
|
||||
island.setClassState({ inClass: true, currentPeriodEnd: null, week: 1, schedules: [] });
|
||||
return immediate && aligned && restored && snapshot[0]?.course?.name === '实时课程';
|
||||
const snapshotMatches = snapshot[0]?.course?.name === '实时课程';
|
||||
if (!immediate || !aligned || !restored || !snapshotMatches)
|
||||
throw new Error(
|
||||
`课表同步检查:${JSON.stringify({ ready, latencyMs, aligned, restored, snapshotMatches })}`,
|
||||
);
|
||||
return true;
|
||||
});
|
||||
await check('常驻岛开合复用固定画布,动画中没有滚动容器或旧胶囊形变', async () => {
|
||||
const bounds = new Set<string>();
|
||||
|
||||
@@ -442,6 +442,10 @@ async function main() {
|
||||
|
||||
win.on('show', () => record('后台验证禁止显示窗口', false, '出现 show 事件'));
|
||||
win.on('focus', () => record('后台验证禁止抢占焦点', false, '出现 focus 事件'));
|
||||
win.webContents.session.webRequest.onErrorOccurred((details) => {
|
||||
// 仅记录测试浏览器的失败请求;去除查询参数,便于区分换页取消和真实接口故障。
|
||||
console.log(`[ui-network] ${details.error} ${new URL(details.url).pathname}`);
|
||||
});
|
||||
// 把渲染进程的报错转发到控制台(兼容 Electron 新旧事件签名)
|
||||
win.webContents.on('console-message', (...args) => {
|
||||
const first = args[0];
|
||||
|
||||
+1
-2
@@ -4,8 +4,7 @@
|
||||
*
|
||||
* ## 为什么要这个脚本
|
||||
*
|
||||
* 这个仓库里**同一个版本号写在 12 处(10 个文件)**:5 份 package.json、运行时常量、两个 compose 文件、
|
||||
* 官网页面上三处手写的版本号、下载页那一处兜底值。
|
||||
* 同一个版本号需要同步 workspace 包、部署清单与官网兜底值,具体落点以本脚本的目标清单为准。
|
||||
* 手工改必然漏一处,
|
||||
* 而漏掉的那处**不会报错**,只会在某个不常走的分支上表现为"版本号对不上":
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user