Files
NODEDC_MISSION_CORE/apps/control-station/test/liveViewport.test.mjs
T
DCCONSTRUCTIONS fa8bde584f feat(video): recover camera previews and reduce encoding and playout cost
Improve camera recovery, shared preview lifecycle and receiver playout diagnostics. Preserve qualified X4 runtime changes and restore async admission in loopback media tests.
2026-10-29 09:10:01 +03:00

24 lines
1.7 KiB
JavaScript

import assert from 'node:assert/strict';
import {after,before,test} from 'node:test';
import {createElement} from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import {createServer} from './support/vite-server.mjs';
let server,Surface;
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});({LiveViewportSurface:Surface}=await server.ssrLoadModule('../../packages/sensor-ui/src/LiveViewport.tsx'));});
after(async()=>{await server?.close();});
const device={online:true,snapshot:{acquisition:'streaming'}};
const preview={state:'Подключение просмотра',telemetry:{},error:'',live:false,hasFrame:false,sourceStalled:false};
const render=(props={})=>renderToStaticMarkup(createElement(Surface,{device,layer:'preview',video:{current:null},preview,...props}));
test('video remains mounted through idle, startup and terminal failure',()=>{
for(const props of [{device:{...device,snapshot:{acquisition:'idle'}}},{pending:true},{error:'Нет кадров'}])assert.match(render(props),/<video /);
});
test('terminal preview failure ends loading even if capture remains logically active',()=>{
const html=render({pending:true,error:'Нет кадров'});
assert.match(html,/aria-busy="false"/);assert.doesNotMatch(html,/nodedc-loading-region__status/);
assert.match(html,/Нет свежих данных/);
});
test('live frame status and expand action remain available',()=>{
const html=render({preview:{...preview,state:'Прямой эфир',live:true}});
assert.match(html,/Прямой эфир/);assert.match(html,/Развернуть просмотр/);assert.match(html,/aria-busy="false"/);
});