test: await persisted state and exercise expanded desktop panels

This commit is contained in:
omar committed 2026-11-01 22:16:17 +03:00
1 parent cf42de67e2
commit 7108026544
12 files changed
+439 -35

No files matched your search

+12
View File
@@ -10,6 +10,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { readFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import { setTimeout as delay } from 'node:timers/promises';
export const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
@@ -68,3 +69,14 @@ export async function launchApp({ exe, profile, args = [], env = {}, colorScheme
await app.evaluate(() => globalThis.__teamspeachCreateWindow());
return assertOffscreen(app);
}
/** Playwright's in-page waitForFunction treats a Promise as truthy; await IPC/import predicates explicitly. */
export async function waitForAsync(page, predicate, argument, { timeout = 30000 } = {}) {
const deadline = Date.now() + timeout;
do {
const value = await page.evaluate(predicate, argument);
if (value) return value;
if (Date.now() >= deadline) throw new Error(`Async condition did not become true within ${timeout}ms`);
await delay(50);
} while (true);
}
@@ -47,7 +47,7 @@
{ id: 5, channel: '5', nickname: 'Robin' },
],
};
const uid = id => `reference-uid-${id}=`;
const uid = id => btoa(`reference-client-${id}`);
const clientProps = c => ({ nickname: c.nickname, uniqueIdentifier: uid(c.id), databaseId: String(c.id + 10), channelGroupId: '8', serverGroups: '7', talkPower: 0, platform: 'Windows', version: '6.0.0', inputHardware: true, outputHardware: true });
// capabilityExtensions: HTTP file transfer + P2P/SFU streaming (TS6 server features the bundle
// checks); no MATRIXCHAT, so the channel chat is the classic server chat.
+12 -6
View File
@@ -24,7 +24,7 @@
// [--official-only] [--fixture <fixture-data.json>] [--self-test | --no-self-test] [--official-from <earlier --out dir>]
// [--hold <screen>:<theme>:<locale>:<WxH>] keep a product window staged with a CDP endpoint
// until <out>/release exists (hold-ready.json).
import { launchApp } from './lib/electron-app.mjs';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
import { launchOfficialRuntime } from './lib/official-ts6-runtime.mjs';
import { decodePng, encodePng, crop, compare, bestShift, palette, sideBySide, blank } from './lib/png.mjs';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
@@ -40,9 +40,9 @@ const out = path.resolve(option('out', 'smoke-out/official-pair'));
const exe = option('exe');
const themes = list(option('themes'), ['dark', 'light']);
const locales = list(option('locales'), ['en', 'ru']);
const sizes = list(option('sizes'), ['1553x998', '1280x800', '860x800']).map(s => s.split('x').map(Number));
const sizes = list(option('sizes'), ['1553x998', '1280x800', '880x800']).map(s => s.split('x').map(Number));
const screens = list(option('screens'), ['main', 'main@few', 'main@empty', 'menu', 'broadcast', 'private', 'private-info', 'server-info', 'channel-edit', 'server-bans', 'server-clients', 'server-permissions', 'settings:audio', 'settings:appearance']);
const fixturePath = path.resolve(option('fixture', 'C:/Users/Admin/tmp/teamspeach-exact-design-20261101/official-runtime-matrix-v2/fixture-data.json'));
const fixturePath = path.resolve(option('fixture', 'C:/Users/Admin/tmp/teamspeach-exact-design-20261101/expanded-reference/fixture-data.json'));
const selfTestOnly = argv.includes('--self-test');
const hold = option('hold');
const officialFrom = option('official-from') ? path.resolve(option('official-from')) : null;
@@ -446,13 +446,14 @@ async function stageProduct(page, screen) {
// Server admin sub-views through the product's own server pane controls.
await page.click('#btn-server-admin');
await page.waitForSelector('#channel-info-view', { state: 'visible' });
// Manage card order (admin.js manageCard): Permissions, Bans, Privilege Keys, Passwords, Clients, Snapshots.
await page.locator('#channel-info-view .adm-manage .adm-link').nth({ 'server-permissions': 0, 'server-bans': 1, 'server-clients': 4 }[name]).click();
const actionLabel = await page.evaluate(key => import('./js/i18n.js').then(({ t }) => t(`admin.${key}`)), { 'server-permissions': 'permissions', 'server-bans': 'bans', 'server-clients': 'clients' }[name]);
await page.locator('#channel-info-view .adm-manage').getByRole('button', { name: actionLabel, exact: true }).click();
await page.waitForTimeout(300);
}
if (name === 'settings') {
await page.click('#btn-settings');
await page.locator(`#settings-nav [data-panel="${arg}"]`).evaluate(node => node.click());
const panel = { identities: 'identity', keybinds: 'keys', filetransfer: 'transfers' }[arg] ?? arg;
await page.locator(`#settings-nav [data-panel="${panel}"]`).evaluate(node => node.click());
await page.evaluate(() => { const s = document.querySelector('.settings-scroll'); if (s) s.scrollTop = 0; });
}
// Focus state as the official client presents each screen: opening a chat focuses its composer.
@@ -556,6 +557,7 @@ function comparePair(cfg, spec) {
const clip = (side, region) => { const limit = r.clipAbove && side.regions[r.clipAbove]?.rect; return region && limit ? { ...region, rect: { ...region.rect, height: Math.min(region.rect.height, limit.y - region.rect.y) } } : region; };
const o = clip(oJson, oJson.regions[r.name]), p = clip(pJson, pJson.regions[r.name]);
const entry = { region: r.name, excluded: r.exclude, official: o && { rect: o.rect, style: o.style }, product: p && { rect: p.rect, style: p.style } };
if (!o && !p) return { ...entry, verdict: r.exclude ? 'excluded' : 'pass', reason: 'absent in both captures' };
if (!o || !p) return { ...entry, verdict: r.exclude ? 'excluded' : 'fail', reason: `${o ? '' : 'absent in official '}${p ? '' : 'absent in product'}`.trim() };
const a = crop(A, o.rect), b = crop(B, p.rect);
const ignore = excludedRects.flatMap(rect => [a, b].map(image => ({ ...rect, x: rect.x - image.rect.x, y: rect.y - image.rect.y })));
@@ -598,6 +600,10 @@ async function selfTest() {
let main, settings;
try {
await ref.open('main');
let falsePredicateRejected = false;
try { await waitForAsync(ref.page, async () => false, undefined, { timeout: 100 }); }
catch (error) { falsePredicateRejected = /Async condition did not become true/.test(error.message); }
ok('An asynchronous false predicate is never accepted as a satisfied wait', falsePredicateRejected, {});
main = path.join(dir, 'official-main.png'); await ref.page.screenshot({ path: main });
await ref.open('settings:audio');
settings = path.join(dir, 'official-settings.png'); await ref.page.screenshot({ path: settings });
+2 -2
View File
@@ -1,5 +1,5 @@
// Hidden renderer + real main-process persistence. Synthetic messages only; no connection/capture/dialog/OS actions.
import { launchApp } from './lib/electron-app.mjs';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
@@ -87,7 +87,7 @@ try {
assert.ok(Number.isFinite(Date.parse(integrated.systemRow.time))); assert.equal(integrated.systemRow.images, 0);
result.checks.push({ integrated });
// Wait for all queued renderer history writes before closing the owned helper.
await page.waitForFunction(async () => {
await waitForAsync(page, async () => {
const page = await window.teamspeach.chatHistoryPage({ identity: 'Self=', server: 'ServerA=', kind: 'channel', key: '7' }, -1, 1);
return page.total === 510;
}, null, { timeout: 60000 });
+41 -1
View File
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { launchApp } from './lib/electron-app.mjs';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
const args = process.argv.slice(2);
const option = key => args.includes(`--${key}`) ? args[args.indexOf(`--${key}`) + 1] : undefined;
const out = path.resolve(option('out') ?? 'smoke-out/identity-offscreen');
@@ -30,6 +30,26 @@ try {
await page.waitForFunction(() => document.querySelector('#identity-list')?.options.length === 2 && !document.querySelector('#identity-save').disabled);
const second = await page.inputValue('#identity-list');
assert.notEqual(second, initial);
await page.evaluate(async uid => {
const result = await window.teamspeach.setPrefs({
savedServers: [
{ id: 'implicit1', name: 'Implicit identity', address: 'implicit.invalid' },
{ id: 'explicit1', name: 'Explicit identity', address: 'explicit.invalid', identity_id: uid },
{ id: 'nested001', name: 'Nested identity', address: 'nested.invalid', identity_id: uid, folder: 'folder001' },
],
bookmarkFolders: [{ id: 'folder001', name: 'Nested folder' }],
bookmarkOrder: ['implicit1', 'explicit1', 'folder001', 'nested001'],
});
if (!result.ok) throw new Error(JSON.stringify(result.error));
(await import('./js/state.js')).S.prefs = result.prefs;
await (await import('./js/identities.js')).refreshIdentities();
}, second);
assert.deepEqual(await page.locator('#identity-bookmarks .ts-identity-bookmark').allTextContents(), ['Explicit identity', 'Nested identity']);
assert.equal(await page.locator('#identity-bookmarks .ts-identity-bookmark-explicit').count(), 2);
await page.selectOption('#identity-list', initial);
assert.deepEqual(await page.locator('#identity-bookmarks .ts-identity-bookmark').allTextContents(), ['Implicit identity']);
await page.selectOption('#identity-list', second);
result.checks.push('Related bookmarks include nested explicit assignments and implicit assignments only for the default identity');
await page.fill('#identity-name', 'Edited identity name');
await page.fill('#identity-nickname', 'EditedNickname');
await page.click('#identity-save');
@@ -42,6 +62,7 @@ try {
result.checks.push('Actual create and clicked Save persist dirty name/nickname through native CLI');
await page.click('#identity-default');
await page.waitForFunction(() => document.querySelector('#identity-default').disabled && document.querySelector('#identity-delete').disabled && !document.querySelector('#identity-save').disabled);
assert.deepEqual(await page.locator('#identity-bookmarks .ts-identity-bookmark').allTextContents(), ['Implicit identity', 'Explicit identity', 'Nested identity']);
const deletion = await page.evaluate(uid => window.teamspeach.identityRequest('delete', { uid, confirm_uid: uid }), second);
assert.equal(deletion.ok, false);
result.checks.push('Default deletion disabled in UI and rejected by real backend');
@@ -66,6 +87,25 @@ try {
const nativeState = await page.evaluate(() => window.teamspeachDiagnostics.snapshot());
assert.equal(nativeState.conn, 'disconnected');
assert.equal(nativeState.voice.capturing, false);
await page.fill('#identity-name', 'Fallback identity');
await page.fill('#identity-nickname', '');
await page.click('#identity-save');
await waitForAsync(page, async uid => {
const response = await window.teamspeach.identityRequest('list', {});
const identity = response.result.identities.find(item => item.uid === uid);
return identity?.name === 'Fallback identity' && identity.nickname === '';
}, initial);
await app.close();
app = await launchApp({ profile, exe: option('exe') });
const reopened = await app.firstWindow();
reopened.on('pageerror', error => result.errors.push(error.message));
await reopened.waitForSelector('#view-app', { state: 'visible' });
const restored = await reopened.evaluate(() => window.teamspeach.identityRequest('list', {}));
assert.equal(restored.result.default_id, initial);
assert.equal(restored.result.identities[0].uid, initial);
assert.equal(restored.result.identities[0].nickname, '');
assert.equal(restored.result.identities[0].name, 'Fallback identity');
result.checks.push('Cleared nickname and unchanged default UID persist across process restart');
assert.deepEqual(result.errors, []);
result.ok = true;
} catch (error) { result.ok = false; result.failure = error.stack; process.exitCode = 1; }
+66
View File
@@ -0,0 +1,66 @@
// Real hidden Electron navigation: packaged changelog/license lists, license detail and focus restoration.
// Disposable profile; no server, device, native dialog or external navigation.
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
const args = process.argv.slice(2);
const option = name => args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : undefined;
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-information-qa-'));
const out = path.resolve(option('out') ?? 'smoke-out/information');
mkdirSync(out, { recursive: true });
const result = { checks: [], errors: [], scope: 'Actual packaged local documents and UI navigation; disposable offscreen profile, no server or physical capture.' };
let app;
try {
app = await launchApp({ exe: option('exe'), profile });
const page = await app.firstWindow();
page.on('pageerror', error => result.errors.push(error.message));
await page.waitForSelector('#view-onboarding', { state: 'visible' });
await page.fill('#onboarding-nick', 'Information QA');
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible' });
await page.click('#btn-settings');
await page.click('[data-panel="about"]');
const changelog = await page.evaluate(() => window.teamspeach.getChangelog());
assert.equal(changelog.ok, true);
const released = changelog.entries.find(entry => !entry.unreleased);
assert.ok(released, 'installation contains a released changelog entry');
await page.locator('.ts-changelog-show-more').click();
await waitForAsync(page, version => [...document.querySelectorAll('.ts-about-changelog-list .ts-widget-section-header')].some(node => node.textContent.includes(version)), released.version);
const entryText = await page.locator('.ts-about-changelog-list').innerText();
assert.equal(entryText.includes('[object HTML'), false);
assert.ok(entryText.includes(released.changes[0].replace(/`([^`]+)`/g, '$1')));
await page.screenshot({ path: path.join(out, 'changelog.png') });
result.checks.push('Show More renders released headings and change text as real DOM content, not stringified elements');
await page.locator('.settings-subpage-back').click();
assert.equal(await page.evaluate(() => document.activeElement?.classList.contains('ts-changelog-show-more')), true);
await page.locator('.ts-about-oss-license-entrypoint').click();
await page.locator('.ts-about-oss-list:not([aria-busy])').waitFor();
const noto = page.locator('.ts-about-oss-license').filter({ hasText: 'Noto' }).first();
await noto.locator('button').click();
await page.locator('.ts-about-oss-detail pre:not([aria-busy])').waitFor();
assert.match(await page.locator('.ts-about-oss-detail pre').innerText(), /SIL OPEN FONT LICENSE/);
await page.screenshot({ path: path.join(out, 'license-detail.png') });
await page.locator('.settings-subpage-back').click();
await waitForAsync(page, () => document.activeElement?.classList.contains('ts-about-oss-license-open'));
assert.ok((await page.evaluate(() => document.activeElement.closest('[data-license-id]').textContent)).includes('Noto'));
result.checks.push('License list opens the bundled OFL text and Back restores the selected license-row focus');
assert.deepEqual(result.errors, []);
result.ok = true;
} catch (error) {
result.ok = false;
result.error = error.stack;
process.exitCode = 1;
if (app) {
const page = await app.firstWindow();
result.visibleText = await page.locator('#about-information').innerText().catch(() => '');
await page.screenshot({ path: path.join(out, 'failure.png') }).catch(() => {});
}
} finally {
if (app) await app.close();
rmSync(profile, { recursive: true, force: true });
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));
}
+2 -2
View File
@@ -2,7 +2,7 @@ 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';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
const args=process.argv.slice(2),opt=k=>args.includes(`--${k}`)?args[args.indexOf(`--${k}`)+1]:undefined;
const profile=mkdtempSync(path.join(tmpdir(),'teamspeach-onboarding-qa-')),out=path.resolve(opt('out')??'smoke-out/onboarding');mkdirSync(out,{recursive:true});
const result={checks:[],errors:[],scope:'Actual disposable first-run theme persistence and native identity creation; delayed/rejected preference fixture only, no dialog or server'};let app;
@@ -12,7 +12,7 @@ try{
assert.equal((await page.evaluate(()=>window.teamspeach.getPrefs())).theme,'dark');
for(const theme of ['system','dark','light']){
await page.locator(`label:has(#onboarding-theme-${theme})`).click();
await page.waitForFunction(async theme=>(await window.teamspeach.getPrefs()).theme===theme&&!document.querySelector('#onboarding-submit').disabled,theme);
await waitForAsync(page, async theme=>(await window.teamspeach.getPrefs()).theme===theme&&!document.querySelector('#onboarding-submit').disabled,theme);
assert.equal(await app.evaluate(({nativeTheme})=>nativeTheme.themeSource),theme);
}
result.checks.push('System/Dark/Light first-run choices persist through real preferences and native theme');
+2 -2
View File
@@ -1,6 +1,6 @@
// Actual application CSS + generated WebRTC, exclusively in a disposable offscreen Electron window.
// No native focus/input, PiP/fullscreen, capture devices, clipboard, server or audible output.
import { launchApp } from './lib/electron-app.mjs';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
import { GENERATED_STREAM_COMMANDS, installGeneratedStreams, relayGeneratedStreamCommand, watchGeneratedStream } from './lib/generated-stream.mjs';
import { checkStreamExtras } from './lib/stream-extras-checks.mjs';
import { checkStreamPopout } from './lib/stream-popout-checks.mjs';
@@ -260,7 +260,7 @@ try {
await key('ArrowUp', 'ArrowUp', 38);
check((await layout()).grid.height < resized.grid.height, 'keyboard divider shrinks available stage');
await key('Enter', 'Enter', 13);
await page.waitForFunction(async () => (await import('./js/state.js')).S.prefs.streamStageRatio === 0.55);
await waitForAsync(page, async () => (await import('./js/state.js')).S.prefs.streamStageRatio === 0.55);
const frameBefore = await page.evaluate(() => window.teamspeachDiagnostics.snapshot().watches[0]);
await click('#stream-collapse');
check(await page.locator('#stream-grid').isHidden(), 'collapse hides stage');
+3 -3
View File
@@ -4,7 +4,7 @@ import assert from 'node:assert/strict';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { launchApp, root } from './lib/electron-app.mjs';
import { launchApp, root, waitForAsync } from './lib/electron-app.mjs';
const args = process.argv.slice(2);
const out = path.resolve(root, args.includes('--out') ? args[args.indexOf('--out') + 1] : 'smoke-out/tree-layout');
@@ -125,7 +125,7 @@ try {
await shot('03-narrow-clamped-dark.png');
await separator.press('Enter');
assert.equal(await width(), 280);
await page.waitForFunction(async () => (await (await import('./js/core.js')).tp.getPrefs()).sidebarWidth === 0);
await waitForAsync(page, async () => (await (await import('./js/core.js')).tp.getPrefs()).sidebarWidth === 0);
await page.setViewportSize({ width: 1280, height: 800 });
await page.waitForTimeout(100);
assert.equal(await width(), 346);
@@ -139,7 +139,7 @@ try {
await separator.press('ArrowRight');
await collapse().click();
await unchanged();
await page.waitForFunction(async () => (await (await import('./js/core.js')).tp.getPrefs()).sidebarWidth === 296);
await waitForAsync(page, async () => (await (await import('./js/core.js')).tp.getPrefs()).sidebarWidth === 296);
result.steps.push('Pointer capture drag, Home/End/arrow/Enter/double-click, narrow resize clamp, copyable composer, no AudioContext rebuild');
await page.evaluate(async () => {
const { tp } = await import('./js/core.js');
+39 -18
View File
@@ -2,27 +2,34 @@ 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';
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
const args = process.argv.slice(2);
const option = key => args.includes(`--${key}`) ? args[args.indexOf(`--${key}`) + 1] : undefined;
const out = path.resolve(option('out') ?? 'smoke-out/whisper-offscreen');
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-whisper-qa-'));
mkdirSync(out, { recursive: true });
const result = { scope: 'Real isolated local whisper/keybind persistence + native disconnected rejection; no global hooks, server, capture, or audible output', checks: [], errors: [] };
let app;
let app, page;
try {
app = await launchApp({ profile, exe: option('exe') });
let page = await app.firstWindow();
page = await app.firstWindow();
page.on('pageerror', e => result.errors.push(e.message));
await page.waitForSelector('#view-onboarding', { state: 'visible' });
await page.fill('#onboarding-nick', 'Whisper QA'); await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible' });
await page.click('#btn-settings');
await page.click('#settings-nav [data-panel="whispers"]');
await page.locator('#whisper-settings .form-actions button').click();
await page.locator('#whisper-list-editor form input').first().fill('Isolated local list');
await page.locator('#whisper-list-editor button[type="submit"]').click();
await page.waitForFunction(() => document.querySelector('.whisper-lists')?.textContent.includes('Isolated local list'));
// Official manage-whisper-lists: "+" turns the Whisperlist cell into the "New Whisper List Name" editor (Enter commits).
await page.locator('#whisper-settings .tsv-whisper-entry-row .is-constructive').click();
await page.locator('#whisper-settings .ts-whisper-list-cell .ts-input').fill('Isolated local list');
await page.keyboard.press('Enter');
await page.waitForFunction(() => document.querySelector('#whisper-settings .ts-whisper-list-cell .tsv-item-text')?.textContent === 'Isolated local list');
// Live Preview starts on; without a connected server there is no input connection, so no "Switch to Server and
// Overlay" and no preview highlight anywhere; the status bar history button stays hidden (no received whisper).
assert.equal(await page.locator('#whisper-settings .tsv-whisper-list-card input[role="switch"]').isChecked(), true);
assert.equal(await page.locator('#whisper-settings .switch-to-overlay-button').count(), 0);
assert.equal(await page.locator('#whisper-history-btn').isHidden(), true);
assert.equal(await page.locator('.tsv-highlight-whisper-preview').count(), 0);
const saved = await page.evaluate(() => window.teamspeach.getWhisper());
assert.equal(saved.ok, true); assert.equal(saved.lists.length, 1);
const uuid = saved.lists[0].list_uuid;
@@ -30,17 +37,27 @@ try {
assert.equal(await receive.count(), 2);
assert.equal(await receive.nth(0).getAttribute('aria-checked'), 'true');
await receive.nth(1).click();
await page.waitForFunction(async () => (await window.teamspeach.getWhisper()).receiveMode === 'deny_all');
await waitForAsync(page, async () => (await window.teamspeach.getWhisper()).receiveMode === 'deny_all');
await page.waitForFunction(() => document.querySelectorAll('#whisper-settings [role="radio"]')[1]?.getAttribute('aria-checked') === 'true');
result.checks.push('Real UI creates local list and saves deny-all receive mode through the Allow/Deny radio group without sending');
await page.click('#settings-nav [data-panel="keys"]');
await page.locator('#keybind-settings form select').first().selectOption('whisper_list');
await page.locator('#keybind-settings form select').nth(1).selectOption(uuid);
await page.locator('#keybind-settings form button[type="button"]').click();
await page.keyboard.press('F9');
await page.locator('#keybind-settings form button[type="submit"]').click();
await page.waitForFunction(async () => (await window.teamspeach.getKeybinds()).bindings.length === 1);
const bindings = await page.evaluate(() => window.teamspeach.getKeybinds());
// Official first run: "No Profile"; "+" turns the profile cell into the inline "New Profile Name" editor.
await page.locator('#keybind-settings .tsv-settings-keybinds-profile .tsv-bar-item:last-child button').click();
await page.locator('#keybind-settings .ts-keybinds-profile-cell .ts-input').fill('QA profile');
await page.keyboard.press('Enter');
await waitForAsync(page, async () => (await window.teamspeach.getKeybinds()).profiles.length === 1);
const listGroup = page.locator('#keybind-settings .ts-keybinds-hotkeys-group').nth(7); // Whisper to List
await listGroup.locator('select').selectOption(uuid);
await listGroup.locator('.ts-keybinds-hotkeys-entry-unset button').click({ force: true });
const systemShortcut = page.locator('.keybind-menu .menu-item').first();
if (await systemShortcut.count()) await systemShortcut.click();
await page.keyboard.down('F9'); await page.keyboard.up('F9');
await waitForAsync(page, async () => (await window.teamspeach.getKeybinds()).profiles[0]?.bindings.length === 1);
await page.locator('#keybind-settings .ts-keybinds-scope').click(); // Global → In this window
await waitForAsync(page, async () => (await window.teamspeach.getKeybinds()).profiles[0]?.bindings[0]?.global === false);
const keys = await page.evaluate(() => window.teamspeach.getKeybinds());
const bindings = { bindings: keys.profiles[0].bindings, status: keys.status };
assert.equal(keys.activeProfile, keys.profiles[0].id);
assert.equal(bindings.bindings[0].global, false); assert.equal(bindings.bindings[0].code, 'F9');
assert.equal(bindings.bindings[0].target, uuid); assert.equal(bindings.status.global, false);
await page.screenshot({ path: path.join(out, 'whisper-local-keybind.png') });
@@ -59,11 +76,15 @@ try {
await page.waitForSelector('#view-app', { state: 'visible' });
const restored = await page.evaluate(async () => ({ whisper: await window.teamspeach.getWhisper(), keys: await window.teamspeach.getKeybinds() }));
assert.equal(restored.whisper.lists[0].list_uuid, uuid); assert.equal(restored.whisper.receiveMode, 'deny_all');
assert.deepEqual(restored.keys.bindings, bindings.bindings);
assert.equal((await page.evaluate(() => window.teamspeach.setKeybinds([]))).ok, true);
assert.deepEqual(restored.keys.profiles[0].bindings, bindings.bindings);
assert.equal((await page.evaluate(id => window.teamspeach.setKeybinds(id, []), restored.keys.profiles[0].id)).ok, true);
assert.equal((await page.evaluate(id => window.teamspeach.deleteWhisperList(id), uuid)).ok, true);
assert.equal((await page.evaluate(() => window.teamspeach.getWhisper())).lists.length, 0);
result.checks.push('Process restart preserves list/receive/binding; explicit delete removes local state');
assert.deepEqual(result.errors, []); result.ok = true;
} catch (error) { result.ok = false; result.failure = error.stack; process.exitCode = 1; }
} catch (error) {
result.ok = false; result.failure = error.stack; process.exitCode = 1;
result.state = await page?.evaluate(async () => ({ keys: await window.teamspeach.getKeybinds(), panel: document.querySelector('#keybind-settings')?.innerText })).catch(() => null);
await page?.screenshot({ path: path.join(out, 'failure.png') }).catch(() => {});
}
finally { if (app) await app.close().catch(() => {}); rmSync(profile, { recursive: true, force: true }); writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2)); console.log(JSON.stringify(result)); }
+176
View File
@@ -0,0 +1,176 @@
// Whisper live preview / overlay switch / received-whisper history through the real (hidden, offscreen) UI.
// Presentation acceptance only: core events and snapshots are SYNTHETIC renderer input sent by this script;
// no server is contacted and nothing here proves whisper routing or delivery. Input and output stay muted,
// device capture and every network request are refused, and no key is sent to a global shortcut.
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { launchApp, root, waitForAsync } from './lib/electron-app.mjs';
const args = process.argv.slice(2);
const option = (key) => (args.includes(`--${key}`) ? args[args.indexOf(`--${key}`) + 1] : undefined);
const out = path.resolve(root, option('out') ?? 'smoke-out/whisper-preview');
mkdirSync(out, { recursive: true });
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-whisper-preview-'));
const result = { scope: 'Disposable offscreen Electron; synthetic snapshots/events; presentation only, no routing or live-server claims', checks: [], errors: [] };
// Protocol-shaped identities: base64 of a 20-byte SHA-1, like TeamSpeak client and virtual server UIDs.
const uid = (seed) => createHash('sha1').update(`teamspeach-whisper-fixture:${seed}`).digest('base64');
const SERVER = uid('server'), ME = uid('me'), ALICE = uid('alice'), BOB = uid('bob'), CAROL = uid('carol'), MALLORY = uid('mallory'), LATE = uid('late');
let app, page, revision = 0;
const send = (event) => app.evaluate(({ BrowserWindow }, value) => BrowserWindow.getAllWindows()[0].webContents.send('core:event', { ...value, connectionId: 'c1' }), event);
const member = (id, u, nickname, channel_id, extra = {}) => ({ id, uid: u, nickname, channel_id, client_type: 'normal', talk_power: 0, is_self: id === 1,
input_hardware: true, input_muted: true, output_muted: true, server_groups: [], channel_group_id: 8, ...extra });
const snapshot = (clients) => ({
event: 'snapshot', rev: ++revision, own_client_id: 1, own_channel_id: 10,
server: { uid: SERVER, name: 'Local whisper fixture — not a live server', version: 'fixture', welcome_message: '' }, server_groups: [], channel_groups: [],
channels: [
{ id: 10, parent_id: 0, depth: 0, name: 'Lobby', max_clients: -1, codec: 'opus_voice' },
{ id: 11, parent_id: 10, depth: 1, name: 'Talk', max_clients: -1, codec: 'opus_voice' },
{ id: 12, parent_id: 0, depth: 0, name: 'Other', max_clients: -1, codec: 'opus_voice' },
],
clients,
});
const base = () => [member(1, ME, 'Whisper Probe', 10), member(2, ALICE, 'Alice', 12), member(3, BOB, 'Bob', 11), member(4, CAROL, 'Carol', 10)];
const highlighted = () => page.evaluate(() => [...document.querySelectorAll('#tree .tsv-highlight-whisper-preview')]
.map((el) => (el.dataset.cid ? `c${el.dataset.cid}` : `u${el.dataset.clid}`)).sort());
const waitHighlighted = (expected) => page.waitForFunction((want) => JSON.stringify([...document.querySelectorAll('#tree .tsv-highlight-whisper-preview')]
.map((el) => (el.dataset.cid ? `c${el.dataset.cid}` : `u${el.dataset.clid}`)).sort()) === JSON.stringify(want), expected, { timeout: 10000 });
const shot = (name) => page.screenshot({ path: path.join(out, name) });
try {
app = await launchApp({ profile, exe: option('exe') });
const safety = await app.evaluate(({ BrowserWindow, session }) => {
const win = BrowserWindow.getAllWindows()[0];
win.webContents.setAudioMuted(true);
session.defaultSession.setPermissionRequestHandler((_w, _p, done) => done(false));
session.defaultSession.setPermissionCheckHandler(() => false);
session.defaultSession.setDevicePermissionHandler?.(() => false);
globalThis.__whisperBlocked = [];
session.defaultSession.webRequest.onBeforeRequest({ urls: ['http://*/*', 'https://*/*', 'ws://*/*', 'wss://*/*'] }, (details, done) => { globalThis.__whisperBlocked.push(details.url); done({ cancel: true }); });
return { visible: win.isVisible(), focused: win.isFocused(), offscreen: win.webContents.isOffscreen(), muted: win.webContents.isAudioMuted() };
});
if (safety.visible || safety.focused || !safety.offscreen || !safety.muted) throw new Error(`Unsafe window ${JSON.stringify(safety)}`);
page = await app.firstWindow();
page.on('pageerror', (e) => result.errors.push(String(e.stack || e).slice(0, 800)));
await page.evaluate(() => {
window.__forbiddenMedia = [];
for (const key of ['getUserMedia', 'getDisplayMedia']) navigator.mediaDevices[key] = async () => { window.__forbiddenMedia.push(key); throw new DOMException('Device capture forbidden in whisper QA', 'NotAllowedError'); };
});
await page.waitForSelector('#view-onboarding', { state: 'visible' });
await page.fill('#onboarding-nick', 'Whisper Probe');
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible' });
await page.setViewportSize({ width: 1280, height: 800 });
// Synthetic connected session on c1, muted in and out.
await send({ event: 'state', state: 'connecting', address: 'fixture.invalid:9987' });
await send({ event: 'audio_state', input_muted: true, output_muted: true, transmitting: false });
await send(snapshot(base()));
await page.waitForSelector('#tree [data-clid="3"]');
// Real channel context menu → Settings > Whispers with the pending channel entry; "+" creates the list with it.
await page.locator('#tree [data-cid="11"] > .row-btn').click({ button: 'right' });
await page.waitForSelector('#whisper-settings .tsv-whisper-pending-entry');
await page.locator('#whisper-settings .tsv-whisper-entry-row .is-constructive').click();
await page.locator('#whisper-settings .ts-whisper-list-cell .ts-input').fill('Fixture list');
await page.keyboard.press('Enter');
await waitForAsync(page, async () => (await window.teamspeach.getWhisper()).lists[0]?.whisper_entry_list.length === 1);
// Client entry: the same call the client menu's "Add to Whisperlist" makes, then the pending-entry button.
await page.evaluate(async (alice) => (await import('./js/whisper.js')).showWhisperTargetMenu({ type: 1, uuid: alice, name: 'Alice' }), ALICE);
await page.locator('#whisper-settings .tsv-whisper-pending-entry button').click();
await waitForAsync(page, async () => (await window.teamspeach.getWhisper()).lists[0]?.whisper_entry_list.length === 2);
const stored = (await page.evaluate(() => window.teamspeach.getWhisper())).lists[0];
assert.deepEqual(stored.whisper_entry_list.map((e) => [e.type, e.name]), [[2, 'Lobby/Talk'], [1, 'Alice']]);
assert.equal(stored.whisper_entry_list[0].uuid, SERVER);
assert.equal(await page.locator('#whisper-settings .ts-whisper-keybinds-edit').count(), 1);
result.checks.push('Channel context menu and Add to Whisperlist build a stored list (channel path on this server UID + client UID)');
// Key Bindings → Edit opens the existing Key Bindings panel.
await page.locator('#whisper-settings .ts-whisper-keybinds-edit').click();
await page.waitForSelector('.settings-panel[data-panel="keys"]:not([hidden])');
await page.click('#settings-nav [data-panel="whispers"]');
result.checks.push('Whisper manager Key Bindings → Edit navigates to Settings > Key Bindings');
// Switch to Server and Overlay picks the input connection even while another tab is viewed.
await page.click('#btn-new-connection');
await waitForAsync(page, async () => {
const { S } = await import('./js/state.js');
return S.viewId !== 'c1';
});
if (await page.locator('#settings-view').isHidden()) await page.click('#btn-settings');
await page.click('#settings-nav [data-panel="whispers"]');
assert.equal(await page.locator('#whisper-settings .tsv-highlight-whisper-preview').count(), 0);
await page.locator('#whisper-settings .switch-to-overlay-button').click();
await page.waitForSelector('#whisper-overlay', { state: 'visible' });
assert.equal(await page.locator('#settings-view').isHidden(), true);
assert.equal(await page.evaluate(async () => (await import('./js/state.js')).S.viewId), 'c1');
await waitHighlighted(['c11', 'u2', 'u3']);
assert.equal(await page.evaluate(() => [...document.querySelectorAll('#whisper-overlay ul')].every(list => getComputedStyle(list).listStyleType === 'none')), true, 'overlay lists must not show browser-default bullets');
await shot('overlay-preview.png');
result.checks.push('Switch leaves settings, views c1 (the input connection) and highlights channel Talk, Bob in it and Alice by UID; never self or Carol');
// Live Preview off/on in the overlay.
await page.locator('#whisper-overlay .ts-toggle-wrapper').first().click();
await waitHighlighted([]);
await page.locator('#whisper-overlay .ts-toggle-wrapper').first().click();
await waitHighlighted(['c11', 'u2', 'u3']);
result.checks.push('Live Preview toggle clears and restores the tree highlight');
// Recycled id: client id 2 now belongs to another UID.
await send(snapshot([member(1, ME, 'Whisper Probe', 10), member(2, MALLORY, 'Mallory', 12), member(3, BOB, 'Bob', 11), member(4, CAROL, 'Carol', 10)]));
await waitHighlighted(['c11', 'u3']);
// Session change: disconnect clears everything; the next session resolves Alice under her new id.
await send({ event: 'state', state: 'disconnected' });
await waitHighlighted([]);
await send({ event: 'state', state: 'connecting', address: 'fixture.invalid:9987' });
await send({ event: 'audio_state', input_muted: true, output_muted: true, transmitting: false });
await send(snapshot([member(1, ME, 'Whisper Probe', 10), member(5, ALICE, 'Alice', 12), member(3, BOB, 'Bob', 11)]));
await waitHighlighted(['c11', 'u3', 'u5']);
result.checks.push('A recycled id with another UID is not highlighted; after a session change only the new snapshot ids are');
// History: only received whisper events; a not-yet-known speaker resolves on the next snapshot.
assert.equal(await page.locator('#whisper-history-btn').isHidden(), true);
await send({ event: 'whisper_received', client_id: 5 });
await page.waitForSelector('#whisper-history-btn', { state: 'visible' });
await page.click('#whisper-history-btn');
await page.waitForSelector('.ts-whisper-history-entry');
await send({ event: 'whisper_received', client_id: 9 });
await send(snapshot([member(1, ME, 'Whisper Probe', 10), member(5, ALICE, 'Alice', 12), member(3, BOB, 'Bob', 11), member(9, LATE, 'Late', 10)]));
await page.waitForFunction(() => document.querySelectorAll('.ts-whisper-history-entry').length === 2);
await send(snapshot([member(1, ME, 'Whisper Probe', 10), member(3, BOB, 'Bob', 11), member(9, LATE, 'Late', 10)]));
await page.waitForFunction(() => document.querySelector('.ts-whisper-history-entry.muted')?.textContent.includes('Alice'));
const rows = await page.locator('.ts-whisper-history-entry .tsv-item-text').allTextContents();
assert.equal(rows[0], 'Late');
assert.match(rows[1], /^Alice \(.+\)$/);
await shot('history-menu.png');
await page.click('.ts-whisper-history-clear');
await page.waitForSelector('.ts-whisper-history-popup', { state: 'detached' });
assert.equal(await page.locator('#whisper-history-btn').isHidden(), true);
result.checks.push('History lists received whispers newest first, resolves a late speaker, marks a departed one, and Delete clears it');
// Closing the overlay removes the preview.
await page.locator('#whisper-overlay .tsv-whisper-overlay-header .icon-btn').click();
await waitHighlighted([]);
assert.equal(await page.locator('#whisper-overlay').isHidden(), true);
result.checks.push('Closing the overlay removes every preview highlight');
result.forbiddenMedia = await page.evaluate(() => window.__forbiddenMedia);
result.blockedRequests = await app.evaluate(() => globalThis.__whisperBlocked);
result.voice = (await page.evaluate(() => window.teamspeachDiagnostics?.snapshot()))?.voice ?? null;
assert.deepEqual(result.errors, []);
result.ok = true;
} catch (error) {
result.ok = false;
result.failure = error.stack;
process.exitCode = 1;
result.highlighted = await highlighted().catch(() => null);
await page?.screenshot({ path: path.join(out, 'failure.png') }).catch(() => {});
} finally {
if (app) await app.close().catch(() => {});
rmSync(profile, { recursive: true, force: true });
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(JSON.stringify(result));
}