Files
MyNote/apps/desktop/tests/e2e/transparency-check.spec.ts
hunter-dev c0ba8df9b6 perf(renderer): 整体优化响应速度 — rAF 合并编辑器刷新/自动保存缓存/粒子引擎空闲自停
同时: 不透明窗口 + 精简主题(8到2)、TabBar 简化、图谱宽松布局、MoreActions 层级修复
2026-09-10 00:41:24 +08:00

37 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test, expect } from '@playwright/test';
import { _electron as electron } from 'playwright';
import { promises as fs } from 'node:fs';
import nodePath from 'node:path';
import os from 'node:os';
const MAIN_JS = nodePath.join(process.cwd(), 'dist-electron/main/index.js');
// UI 重新设计:窗口不透明(transparent:false + backgroundColor 空间底色),根背景应为不透明的 L0 空间色
test('窗口不透明:根背景为 L0 空间底色(alpha=1,非透明)', async () => {
const tmp = await fs.mkdtemp(nodePath.join(os.tmpdir(), 'hn-tr-'));
const ud = nodePath.join(tmp, 'ud'); const v = nodePath.join(tmp, 'v');
await fs.mkdir(ud, { recursive: true }); await fs.mkdir(v, { recursive: true });
const app = await electron.launch({ args: ['--user-data-dir=' + ud, MAIN_JS] });
const page = await app.firstWindow();
await page.waitForLoadState('domcontentloaded');
await page.evaluate(({ root }) => (globalThis as any).dsh.invoke('vault:switch', { root }), { root: v });
await page.waitForTimeout(500);
const rootBg = await page.evaluate(() => {
const root = document.querySelector('#root > div') as HTMLElement;
if (!root) return null;
return getComputedStyle(root).backgroundColor;
});
console.log('ROOT_BG', rootBg);
expect(rootBg).not.toBeNull();
// 窗口不透明:根背景为不透明空间底色(alpha=1,非 rgba(...,0) / transparent)
const m = rootBg!.match(/rgba\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)|^rgb\(([\d.]+),\s*([\d.]+),\s*([\d.]+)\)$/);
expect(m).not.toBeNull();
// 不透明:要么是 rgb(...)(隐式 alpha=1),要么 rgba alpha=1
if (rootBg!.startsWith('rgba')) {
const alpha = parseFloat(m![4]);
expect(alpha).toBe(1);
} else {
expect(rootBg!.startsWith('rgb(')).toBe(true);
}
await app.close();
});