Files
client/scripts/smoke-connections-native.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

64 lines
3.5 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { ConnectionManager } = require('../app/main/connections');
// Explicit binary only: never resolves a packaged application or the owner's profile.
const binary = process.env.TEAMSPEACH_QA_CORE;
if (!binary || !path.isAbsolute(binary)) throw new Error('Set TEAMSPEACH_QA_CORE to the absolute rebuilt disposable QA core binary');
await fs.access(binary);
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'teamspeach-two-cores-'));
const logsDir = path.join(root, 'logs');
await fs.mkdir(logsDir);
const manager = new ConnectionManager({ resolveBinary: () => ({ path: binary }), dataDir: path.join(root, 'profile'), logsDir });
const events = [];
manager.on('event', (id, event) => events.push({ id, event: event.event }));
function ready(id) {
if (manager.get(id)?.status.status === 'ready') return Promise.resolve();
return new Promise((resolve, reject) => {
const timer = setTimeout(() => finish(new Error(`Core ${id} did not become ready`)), 20000);
const listener = (target, status) => {
if (target !== id || status.status === 'starting') return;
finish(status.status === 'ready' ? null : new Error(`${id}: ${JSON.stringify(status)}`));
};
function finish(error) { clearTimeout(timer); manager.off('status', listener); error ? reject(error) : resolve(); }
manager.on('status', listener);
});
}
try {
const a = manager.create().connection.id;
const b = manager.create().connection.id;
await Promise.all([ready(a), ready(b)]);
const pidA = manager.get(a).core.child.pid;
const pidB = manager.get(b).core.child.pid;
assert.notEqual(pidA, pidB);
assert.ok(pidA > 0 && pidB > 0);
const created = await manager.request(a, 'profile_create', { nickname: 'Disposable two-core proof' });
assert.equal(created.ok, true, JSON.stringify(created));
const profiles = await Promise.all([manager.request(a, 'profile_get'), manager.request(b, 'profile_get')]);
assert.equal(profiles[0].ok, true); assert.equal(profiles[1].ok, true);
assert.equal(profiles[0].result.uid, profiles[1].result.uid);
assert.equal(profiles[0].result.nickname, profiles[1].result.nickname);
// Both children remain simultaneously running while the same canonical identity is read.
process.kill(pidA, 0); process.kill(pidB, 0);
const rejected = await manager.request(b, 'join_channel', { channel_id: 1 });
assert.equal(rejected.ok, false); assert.equal(rejected.error.code, 'not_connected');
await manager.close(a);
assert.equal((await manager.request(a, 'profile_get')).error.code, 'connection_closed');
const c = manager.create().connection.id;
await ready(c);
assert.notEqual(c, a); assert.notEqual(c, b);
assert.equal(manager.get(b).core.child.pid, pidB);
const reopened = await manager.request(c, 'profile_get');
assert.equal(reopened.ok, true); assert.equal(reopened.result.uid, profiles[1].result.uid);
const runtimeFiles = await fs.readdir(path.join(root, 'profile', 'connections'), { recursive: true });
assert.equal(runtimeFiles.some((file) => /(?:identity|profile)\.json$/i.test(file)), false);
console.log(JSON.stringify({ ok: true, root, binary, pids: [pidA, pidB], ids: [a, b, c], simultaneousCanonicalIdentity: true, runtimePrivateKeyCopies: 0, serverConnectionsAttempted: 0, observedEvents: events.length }));
} finally {
await manager.stopAll();
await fs.rm(root, { recursive: true, force: true });
}