Files
client/scripts/lib/official-ts6-runtime.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

88 lines
5.4 KiB
JavaScript

// QA-ONLY driver for the INSTALLED official TeamSpeak 6 client UI running unmodified in a hidden,
// nonfocusable, offscreen, muted Electron window (see official-ts6-runtime/main.cjs) with the
// reference-only `tsclient_internal` fixture (official-ts6-runtime/fixture.js). Screens are produced
// by the official compiled Vue components, CSS, fonts and SVG; the fixture only supplies synthetic
// local data. No account, server, matrix, network, audio device, camera or screen is reachable.
import { _electron as electron } from 'playwright-core';
import { createHash } from 'node:crypto';
import { readFileSync, mkdtempSync } from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { assertOffscreen } from './electron-app.mjs';
import { DEFAULT_OFFICIAL_DIR } from './official-ts6-reference.mjs';
const here = path.dirname(fileURLToPath(import.meta.url));
export const RUNTIME_MAIN = path.join(here, 'official-ts6-runtime', 'main.cjs');
export const RUNTIME_FIXTURE = path.join(here, 'official-ts6-runtime', 'fixture.js');
export const RUNTIME_SCENARIOS = path.join(here, 'official-ts6-runtime', 'scenarios.js');
const sha256 = data => createHash('sha256').update(data).digest('hex');
// Settings category -> index in the official settings category list (stable item order of the
// installed build; verified against the rendered label at runtime).
export const SETTINGS_CATEGORIES = ['account', 'identities', 'privacy', 'appearance', 'audio', 'video', 'keybinds', 'chats', 'whispers', 'notifications', 'filetransfer', 'os', 'remoteapps', 'about'];
/**
* @param {{ theme?: 'dark'|'light', locale?: 'en'|'ru', width?: number, height?: number, profile?: string,
* installDir?: string, scenario?: 'dashboard'|'connected', chat?: 'full'|'few'|'empty', timeout?: number }} o
*/
export async function launchOfficialRuntime({ theme = 'dark', locale = 'en', width = 1553, height = 998, profile, installDir = DEFAULT_OFFICIAL_DIR, scenario = 'connected', chat = 'full', timeout = 30000 } = {}) {
profile ??= mkdtempSync(path.join(os.tmpdir(), 'ts6-official-runtime-'));
const config = { installDir, profile, width, height, locale, fixture: { theme, locale, scenario, chat } };
const app = await electron.launch({ args: [RUNTIME_MAIN], env: { ...process.env, TS_REFERENCE_CONFIG: JSON.stringify(config) }, timeout });
const page = await app.firstWindow();
await assertOffscreen(app);
const errors = [];
page.on('pageerror', e => errors.push(String(e.stack || e).slice(0, 1000)));
page.on('console', m => { if (m.type() === 'error') errors.push(`[console] ${m.text().slice(0, 400)}`); });
await page.waitForFunction(() => window.__tsReferenceFixture?.ready === true, null, { timeout });
const ref = {
app, page, config, errors,
/** Drive the official UI to a screen; returns the screen descriptor recorded in the manifest. */
async open(screen) {
const result = await page.evaluate(s => window.__tsReferenceFixture.open(s), screen);
await page.waitForTimeout(600);
await page.evaluate(() => document.fonts.ready);
return result;
},
/** Computed boxes/styles of official elements for the given selectors. */
async styles(selectors, props = ['color', 'background-color', 'font-family', 'font-size', 'font-weight', 'line-height', 'letter-spacing', 'padding', 'margin', 'border', 'border-radius', 'box-shadow', 'opacity', 'gap']) {
return page.evaluate(([sels, ps]) => Object.fromEntries(sels.map(sel => [sel, [...document.querySelectorAll(sel)].slice(0, 8).map(el => {
const r = el.getBoundingClientRect();
const cs = getComputedStyle(el);
const after = getComputedStyle(el, '::after');
return {
box: { x: r.x, y: r.y, w: r.width, h: r.height }, text: el.innerText?.trim().slice(0, 60),
style: Object.fromEntries(ps.map(p => [p, cs.getPropertyValue(p)])),
after: after.content && after.content !== 'none' ? Object.fromEntries(['content', 'background-color', 'width', 'height', 'left', 'top', 'border-radius'].map(p => [p, after.getPropertyValue(p)])) : null,
};
})])), [selectors, props]);
},
async manifest() {
const main = await app.evaluate(() => ({ served: [...globalThis.__tsReference.served], blocked: globalThis.__tsReference.blocked, origin: globalThis.__tsReference.origin }));
const bridge = await page.evaluate(() => {
const f = window.__tsReferenceFixture;
const methods = {};
for (const c of f.calls) methods[c.method] = (methods[c.method] || 0) + 1;
return { methods, unanswered: [...new Set(f.pending.map(p => p.method + (p.args?.[0]?.cmd ? `:${p.args[0].cmd}` : '')))], events: [...f.listeners.keys()] };
});
return {
kind: 'official-ts6-runtime-reference',
referenceOnly: true,
config: { theme, locale, width, height, scenario, chat, installDir },
served: Object.fromEntries(main.served),
harness: Object.fromEntries([RUNTIME_MAIN, RUNTIME_FIXTURE, RUNTIME_SCENARIOS].map(f => [path.basename(f), sha256(readFileSync(f))])),
origin: main.origin,
blocked: main.blocked,
bridge,
errors,
};
},
/** Canonical synthetic scenario data (names, properties, fixed-timestamp chat variants). */
fixtureData: () => page.evaluate(() => window.__tsReferenceFixture.fixtureData()),
close: () => app.close(),
};
return ref;
}