Files
client/scripts/smoke-ui-integration.mjs
T
omar e6464bc4ed feat: checkpoint account-free client workflows and source-matched UI
Preserve accumulated client implementation since v0.1.4, including local identities, multi-server state, chat, administration, audio and streaming controls. Refine official-source layout, original artwork, responsive composer overflow, settings navigation and chat scroll anchoring.

Current verification: Node suite passes; isolated packaged chat and responsive control smokes pass without device capture. Native core is reused, not rebuilt in this pass. Strict whole-screen visual parity remains incomplete; no 1:1 or cross-platform acceptance claim. Local checkpoint only; no release or push.
2026-11-01 19:43:18 +03:00

92 lines
5.0 KiB
JavaScript

// Disposable Electron integration checks for main-owned preferences and the native avatar chooser.
// The real dialog's answer is substituted with fixture paths; no server is connected or avatar uploaded.
// node scripts/smoke-ui-integration.mjs --out <directory> [--exe <packaged executable>]
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { launchApp } from './lib/electron-app.mjs';
const argv = process.argv.slice(2);
const opt = (key) => argv.includes(`--${key}`) ? argv[argv.indexOf(`--${key}`) + 1] : undefined;
const out = path.resolve(opt('out') ?? 'smoke-out/ui-integration');
const exe = opt('exe');
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-ui9-integration-'));
mkdirSync(out, { recursive: true });
const result = { startedAt: new Date().toISOString(), exe: exe ?? null, fixture: 'Native dialog answers only; no upload, server or capture', steps: [], pageErrors: [] };
const record = (name, details = {}) => { result.steps.push({ name, ...details }); console.log(`[ui-integration] ${name}`, JSON.stringify(details)); };
let app;
let page;
let failed;
try {
app = await launchApp({ exe, profile });
page = await app.firstWindow();
page.on('pageerror', (error) => result.pageErrors.push(error.message));
await page.waitForSelector('#view-onboarding', { state: 'visible' });
const initial = await page.evaluate(() => window.teamspeach.getPrefs());
assert.equal(initial.sidebarWidth, 0);
assert.equal(initial.streamStageRatio, 0.42);
assert.equal(initial.streamStageCollapsed, false);
assert.deepEqual(initial.collapsedChannels, []);
const expected = { sidebarWidth: 430, streamStageRatio: 0.65, streamStageCollapsed: true, collapsedChannels: [{ server: 'fixture.invalid:9987', channels: [10, 20] }] };
const saved = await page.evaluate((prefs) => window.teamspeach.setPrefs(prefs), expected);
assert.equal(saved.ok, true);
for (const [key, value] of Object.entries(expected)) assert.deepEqual(saved.prefs[key], value);
for (const invalid of [{ sidebarWidth: 1601 }, { streamStageRatio: 0.81 }, { streamStageCollapsed: 'true' }, { collapsedChannels: [{ server: 'fixture.invalid', channels: [10, 10] }] }]) {
const response = await page.evaluate((prefs) => window.teamspeach.setPrefs(prefs), invalid);
assert.equal(response.ok, false);
}
record('real prefs IPC validates layout schema', { expected });
const valid = path.join(profile, 'fixture.png');
const invalid = path.join(profile, 'invalid.png');
const oversized = path.join(profile, 'oversized.png');
const bytes = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a2ioAAAAASUVORK5CYII=', 'base64');
writeFileSync(valid, bytes);
writeFileSync(invalid, 'not an image');
writeFileSync(oversized, Buffer.alloc(128 * 1024 + 1));
const choose = async (file) => {
await app.evaluate(({ dialog }, selected) => {
dialog.showOpenDialog = async (_window, options) => {
globalThis.__avatarDialogOptions = options;
return { canceled: selected === null, filePaths: selected === null ? [] : [selected] };
};
}, file);
return page.evaluate(() => window.teamspeach.chooseAvatar());
};
assert.deepEqual(await choose(null), { ok: true, canceled: true });
const avatar = await choose(valid);
assert.equal(avatar.ok, true);
assert.equal(avatar.data, bytes.toString('base64'));
assert.equal(Object.hasOwn(avatar, 'path'), false);
for (const file of [invalid, oversized, path.join(profile, 'missing.png'), profile]) {
const response = await choose(file);
assert.equal(response.ok, false);
assert.equal(response.error.code, 'invalid_avatar');
assert.equal(Object.hasOwn(response, 'data'), false);
}
const dialogOptions = await app.evaluate(() => globalThis.__avatarDialogOptions);
assert.deepEqual(dialogOptions.filters[0].extensions, ['png', 'jpg', 'jpeg']);
assert.deepEqual(dialogOptions.properties, ['openFile']);
record('native chooser accepts bounded image and rejects malformed/oversized/missing/directory fixtures', { bytes: bytes.length, pathExposed: false });
await app.close();
app = await launchApp({ exe, profile });
page = await app.firstWindow();
page.on('pageerror', (error) => result.pageErrors.push(error.message));
await page.waitForSelector('#view-onboarding', { state: 'visible' });
const restored = await page.evaluate(() => window.teamspeach.getPrefs());
for (const [key, value] of Object.entries(expected)) assert.deepEqual(restored[key], value);
record('layout preferences survive real process restart');
assert.deepEqual(result.pageErrors, []);
} catch (error) {
failed = error;
record('FAILED', { error: String(error.stack ?? error) });
} finally {
if (app) await app.close().catch(() => {});
rmSync(profile, { recursive: true, force: true });
result.finishedAt = new Date().toISOString();
result.ok = !failed;
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
}
process.exitCode = failed ? 1 : 0;