feat(router): confirm DexaFlow modes and expose the paired admin interface
This commit is contained in:
@@ -4,9 +4,10 @@ import {createServer} from './support/vite-server.mjs';
|
||||
import {createElement} from 'react';
|
||||
import {renderToStaticMarkup} from 'react-dom/server';
|
||||
|
||||
let server,routerMode,RouterOverview,ClientRouterControls;
|
||||
let server,routerMode,RouterOverview,ClientRouterControls,RouterObservation;
|
||||
before(async()=>{
|
||||
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
||||
({RouterObservation}=await server.ssrLoadModule('/src/components/network/RouterObservation.tsx'));
|
||||
({routerMode}=await server.ssrLoadModule('../../packages/router-ui/src/mode.ts'));
|
||||
({RouterOverview}=await server.ssrLoadModule('../../packages/router-ui/src/RouterOverview.tsx'));
|
||||
({ClientRouterControls}=await server.ssrLoadModule('../../packages/router-ui/src/ClientRouterControls.tsx'));
|
||||
@@ -29,10 +30,10 @@ test('configured aggregation with three online SIMs remains a direct fallback ob
|
||||
const d=device(),m=routerMode(d,true);
|
||||
assert.equal(m.configured,'Агрегация');assert.equal(m.current,'Прямой выход · SIM3');
|
||||
assert.equal(m.activeSlot,1);assert.equal(m.fallback,true);assert.equal(m.mismatch,true);
|
||||
assert.match(m.message,/Агрегация сейчас не используется/);
|
||||
assert.match(m.message,/Агрегация задана, но сейчас выход идёт через SIM3/);
|
||||
const html=overview(d),form=controls(d);
|
||||
assert.match(html,/Сейчас: Прямой выход · SIM3/);assert.match(html,/Задано: Агрегация/);
|
||||
assert.match(form,/Сейчас: Прямой выход · SIM3/);assert.match(form,/Сохранённый режим/);
|
||||
assert.match(form,/Текущий режим: Прямой выход · SIM3/);assert.match(form,/Сохранённый режим/);
|
||||
assert.ok(form.includes(m.message));assert.ok(html.includes(m.message));
|
||||
assert.equal((html.match(/текущий выход/g)||[]).length,1);
|
||||
assert.doesNotMatch(html,/· выбран|Одна SIM-карта/);
|
||||
@@ -66,7 +67,7 @@ test('pending, stale and strategy states do not masquerade as failed or active a
|
||||
assert.equal(stale.current,'Нет свежих данных');assert.equal(stale.activeSlot,null);
|
||||
assert.equal(stale.fallback,false);assert.equal(stale.pending,false);
|
||||
const html=overview(d,false),form=controls(d,false);
|
||||
for(const x of [html,form])assert.match(x,/Сейчас: Нет свежих данных/);
|
||||
assert.match(html,/Сейчас: Нет свежих данных/);assert.match(form,/Текущий режим: Нет свежих данных/);
|
||||
assert.doesNotMatch(html,/текущий выход|Сейчас: Прямой выход/);
|
||||
for(const configured of ['whitelist','auto']){
|
||||
const m=routerMode({...d,selected_mode:configured,client_api:{...d.client_api,details:{pending:false,fallback:false}}},true);
|
||||
@@ -79,3 +80,28 @@ test('legacy adapters preserve explicit current WAN without claiming fallback',(
|
||||
assert.equal(routerMode(d,true).fallback,false);
|
||||
assert.equal(routerMode({...d,active_wan:''},true).activeSlot,null);
|
||||
});
|
||||
|
||||
test('aggregation fallback names the observed SIM and reported reason',()=>{const d=device();d.client_api.details.fallback_reason='preferred_path_unavailable_observed_other_default_route';const m=routerMode(d,true);assert.match(m.message,/Агрегация задана, но сейчас выход идёт через SIM3/);assert.match(m.message,/путь агрегации недоступен/);});
|
||||
|
||||
test('observation viewport renders three compact scales and only the effective exit',()=>{
|
||||
const d={...device(),state:'ready',attached:true,observed_at:Date.now()/1000};
|
||||
const html=renderToStaticMarkup(createElement(RouterObservation,{device:d,value:{available:true,fresh:true}}));
|
||||
assert.equal((html.match(/router-signal-scale/g)||[]).length,3);
|
||||
assert.equal((html.match(/aria-label="SIM3 · Активный канал"/g)||[]).length,1);
|
||||
assert.doesNotMatch(html,/router-scale-labels|router-metric-line/);
|
||||
assert.match(html,/Прямой выход · SIM3/);
|
||||
assert.ok(html.indexOf('SIM1')<html.indexOf('SIM2'));
|
||||
const stale=renderToStaticMarkup(createElement(RouterObservation,{device:d,value:{available:true,fresh:false}}));
|
||||
assert.doesNotMatch(stale,/Активный канал|Прямой выход/);
|
||||
assert.match(stale,/Нет свежих данных/);
|
||||
});
|
||||
|
||||
test('compact router view retains three SIM rows without scales or summary',()=>{
|
||||
const d={...device(),state:'ready',attached:true,observed_at:Date.now()/1000};
|
||||
const html=renderToStaticMarkup(createElement(RouterObservation,{device:d,value:{available:true,fresh:true},compact:true}));
|
||||
assert.equal((html.match(/<section /g)||[]).length,3);
|
||||
assert.doesNotMatch(html,/router-signal-scale|Прямой выход/);
|
||||
assert.match(html,/aria-label="SIM3 · Активный канал"/);
|
||||
assert.equal((html.match(/data-variant="indicator"/g)||[]).length,3);
|
||||
assert.ok(html.indexOf('SIM1')<html.indexOf('SIM2')&&html.indexOf('SIM2')<html.indexOf('SIM3'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user