test(phase-5): add E2E suites for .gcoord.enc backup/CLI, AI assistant/redactor, and mobile bundle/themes

This commit is contained in:
tyuXX 2026-11-27 14:32:31 +00:00
parent 6dcfa81925
commit b12df1e2d7
3 changed files with 812 additions and 0 deletions

View file

@ -0,0 +1,78 @@
import fs from 'node:fs';
import path from 'node:path';
import zlib from 'node:zlib';
import { describe, expect, it } from 'vitest';
import { appendBoundedStreamText } from '../src/client/ts/state.js';
import { SettingsSchema, THEME_IDS } from '../src/shared/schemas/settings.schema.js';
describe('Phase 5: 8 Theme Presets, Code-Splitting Budgets & Galaxy J7 Mobile Optimization', () => {
it('supports all 8 theme presets in SettingsSchema and dist/public/themes.css', () => {
expect(THEME_IDS).toEqual([
'phosphor-green',
'amber-term',
'nord-dark',
'gruvbox-dark',
'paper-light',
'solarized-dark',
'tokyo-night',
'high-contrast',
]);
const themesCss = fs.readFileSync(path.resolve('dist/public/themes.css'), 'utf8');
for (const id of THEME_IDS) {
const parsed = SettingsSchema.parse({ theme: id });
expect(parsed.theme).toBe(id);
expect(themesCss).toMatch(new RegExp(`\\[data-theme="?${id}"?\\]`));
}
});
it('meets <50KB core gzipped bundle, splits lazy chunks, preserves PWA & mobile CSS, and caps DOM streams', () => {
const publicDir = path.resolve('dist/public');
const coreFiles = ['index.html', 'themes.css', 'base.css', 'main.js'];
let totalCoreGzip = 0;
for (const f of coreFiles) {
const buf = fs.readFileSync(path.join(publicDir, f));
totalCoreGzip += zlib.gzipSync(buf, { level: 9 }).length;
}
expect(totalCoreGzip).toBeLessThan(50 * 1024);
// Heavy/optional UI stays code-split out of main.js
const mainJs = fs.readFileSync(path.join(publicDir, 'main.js'), 'utf8');
expect(mainJs).not.toContain('ai-drawer-dialog');
expect(mainJs).not.toContain('xterm-helper-textarea');
const chunks = fs.readdirSync(path.join(publicDir, 'chunks'));
expect(chunks.some((c) => c.startsWith('ai-drawer-') && c.endsWith('.js'))).toBe(true);
expect(chunks.some((c) => c.startsWith('terminal-view-') && c.endsWith('.js'))).toBe(true);
expect(chunks.some((c) => c.startsWith('workflows-view-') && c.endsWith('.js'))).toBe(true);
expect(chunks.some((c) => c.startsWith('alerts-view-') && c.endsWith('.js'))).toBe(true);
for (const c of chunks) {
if (c.startsWith('terminal-view-')) continue;
const gzLen = zlib.gzipSync(fs.readFileSync(path.join(publicDir, 'chunks', c)), {
level: 9,
}).length;
expect(gzLen).toBeLessThan(20 * 1024);
}
const manifest = JSON.parse(fs.readFileSync(path.join(publicDir, 'manifest.json'), 'utf8')) as {
display: string;
};
expect(manifest.display).toBe('standalone');
const baseCss = fs.readFileSync(path.join(publicDir, 'base.css'), 'utf8');
expect(baseCss).toContain('overscroll-behavior:contain');
expect(baseCss).toContain('content-visibility:auto');
expect(baseCss).toContain('min-height:44px');
// Long-running log stream buffer remains strictly bounded
const mockPre = { textContent: '' };
for (let i = 0; i < 40; i++) {
appendBoundedStreamText(mockPre, `line-${i}:${'x'.repeat(200)}\n`, 1024);
}
expect(mockPre.textContent.length).toBeLessThanOrEqual(1024);
expect(mockPre.textContent).toContain('[truncated older stream output]');
expect(mockPre.textContent).toContain('line-39:');
});
});