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.
55 lines
3.7 KiB
JavaScript
55 lines
3.7 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { collectStreamStats, streamIssues } from '../app/renderer/js/stream/stats.js';
|
|
import { tileLayout } from '../app/renderer/js/stream/layout.js';
|
|
|
|
test('RTC counters use milliseconds and real deltas, absent metrics stay unavailable', () => {
|
|
const previous = new Map();
|
|
const report = row => new Map([['v', { id: 'v', type: 'outbound-rtp', kind: 'video', ...row }]]);
|
|
let samples = collectStreamStats(report({ timestamp: 1000, bytesSent: 100, framesEncoded: 10, totalEncodeTime: .1 }), previous);
|
|
assert.equal(samples[0].bitrate, null); assert.equal(samples[0].jitter, null);
|
|
samples = collectStreamStats(report({ timestamp: 2000, bytesSent: 1100, framesEncoded: 30, totalEncodeTime: .3 }), previous);
|
|
assert.equal(samples[0].bitrate, 8000); assert.ok(Math.abs(samples[0].encodeTime - .01) < 1e-9);
|
|
samples = collectStreamStats(report({ timestamp: 3000, bytesSent: 10, framesEncoded: 1, totalEncodeTime: .01 }), previous);
|
|
assert.equal(samples[0].bitrate, null); assert.equal(samples[0].encodeTime, null);
|
|
});
|
|
|
|
test('official issue thresholds preserve strict boundaries and pause suppresses encoder issues', () => {
|
|
assert.deepEqual(streamIssues({ fractionLost: .001, jitter: .1, rtt: .3, packetDelay: 5, retransmitBps: 0 }), []);
|
|
const sample = { direction: 'outbound', kind: 'video', fractionLost: .051, jitter: .101, rtt: .601, packetDelay: 5.1,
|
|
retransmitBps: 1, width: 320, height: 180, fps: 10, encodeTime: .06, limitReason: 'cpu' };
|
|
const target = { width: 1280, height: 720, fps: 30 };
|
|
const issues = streamIssues(sample, target);
|
|
assert.equal(issues.length, 8); assert.equal(issues.find(issue => issue.name === 'fps').severity, 'major');
|
|
assert.equal(streamIssues(sample, target, false).length, 5);
|
|
});
|
|
|
|
test('official fixed-aspect cards paginate; focused source keeps aspect alongside strip', () => {
|
|
const tiles = Array.from({ length: 12 }, (_, index) => ({ id: String(index), aspect: index % 2 ? 9 / 16 : 16 / 9 }));
|
|
const result = tileLayout(tiles, 640, 360, 0);
|
|
assert.ok(result.pages > 1);
|
|
for (const tile of result.items) {
|
|
assert.ok(tile.x >= 0 && tile.y >= 0 && tile.x + tile.width <= 640.001 && tile.y + tile.height <= 360.001);
|
|
assert.ok(Math.abs(tile.width / tile.height - 16 / 9) < 1e-9);
|
|
}
|
|
assert.notDeepEqual(tileLayout(tiles, 640, 360, 1).items.map(tile => tile.id), result.items.map(tile => tile.id));
|
|
const focused = tileLayout(tiles, 640, 360, 0, '9');
|
|
assert.ok(focused.items.length > 1);
|
|
const main = focused.items.find(tile => tile.id === '9');
|
|
assert.ok(Math.abs(main.width / main.height - 9 / 16) < 1e-9);
|
|
assert.ok(focused.pages > 1);
|
|
assert.equal(tileLayout(tiles, 640, 360, 99).page, result.pages - 1);
|
|
});
|
|
|
|
test('in-tile PiP uses source aspect, margins and collision/cycle fallback without hiding streams', () => {
|
|
const tiles = [{ id: 'host', aspect: 16 / 9 }, { id: 'a', aspect: 9 / 16 }, { id: 'b', aspect: 16 / 9 }];
|
|
const result = tileLayout(tiles, 800, 500, 0, null, [{ id: 'a', host: 'host', corner: 'top-left' }, { id: 'b', host: 'host', corner: 'top-left' }]);
|
|
const host = result.items.find(tile => tile.id === 'host'), pip = result.items.find(tile => tile.id === 'a');
|
|
assert.equal(pip.pip, true); assert.equal(pip.x, host.x + 8); assert.equal(pip.y, host.y + 8);
|
|
assert.ok(pip.width <= 420 && pip.width <= host.width / 3 + 1);
|
|
assert.deepEqual(result.inactivePlacements, ['b']);
|
|
assert.equal(result.items.find(tile => tile.id === 'b').pip, undefined);
|
|
const cycle = tileLayout(tiles, 800, 500, 0, null, [{ id: 'a', host: 'b', corner: 'top-left' }, { id: 'b', host: 'a', corner: 'bottom-left' }]);
|
|
assert.equal(cycle.items.length, 3); assert.equal(cycle.items.some(tile => tile.pip), false);
|
|
});
|