feat(router): confirm DexaFlow modes and expose the paired admin interface
This commit is contained in:
@@ -91,8 +91,8 @@ test('physical SIM labels are a profile projection, never array order or model-n
|
||||
assert.deepEqual(simChannels(device).map(x=>x.slot),[2,3,1]);assert.equal(simLabel(device,2),'SIM1');
|
||||
assert.equal(simChannels({...device,slot_map:null})[0].label,'Канал 1');
|
||||
assert.equal(routerName({...device,name:'My uplink'}),'My uplink');
|
||||
const connected={id:'a',attached:true,state:'ready'},saved={id:'b',attached:false,state:'unreachable'};
|
||||
assert.deepEqual(visibleRouters([saved,connected]),[connected]);
|
||||
const connected={id:'a',attached:true,state:'ready',observed_at:100},saved={id:'b',attached:false,state:'unreachable',observed_at:100};
|
||||
assert.deepEqual(visibleRouters({available:true,items:[saved,connected]},110000),[connected]);
|
||||
});
|
||||
test('Client API controls sort physical SIMs and preserve wire identifiers',async()=>{
|
||||
const {ClientRouterControls}=await server.ssrLoadModule('../../packages/router-ui/src/ClientRouterControls.tsx');
|
||||
@@ -135,3 +135,76 @@ test('signal scale exposes four keyboard targets, an honest current level and no
|
||||
const missing=renderToStaticMarkup(createElement(RouterSignal,{rsrp:null}));
|
||||
assert.doesNotMatch(missing,/class="router-signal-marker"/);assert.match(missing,/Уровень сигнала неизвестен/);
|
||||
});
|
||||
|
||||
|
||||
test('reopened controls retain the policy refusal above timers, despite newer inspections',async()=>{
|
||||
const {ClientRouterControls}=await server.ssrLoadModule('../../packages/router-ui/src/ClientRouterControls.tsx');
|
||||
const d={id:'x',state:'ready',active_mode:'direct',modems:[],client_api:{boot_id:'boot',revision:'r',rights:['policy','recovery'],policy:{mode:'aggregation',fail_seconds:60,recover_seconds:60,min_vpn_seconds:120},checks:[]}};
|
||||
const results=[{operation_id:'inspect',device_id:'x',action:'inspect',state:'complete',at:102},{operation_id:'policy',device_id:'x',action:'policy',state:'error',error:'router_busy',at:101}];
|
||||
const render=()=>renderToStaticMarkup(createElement(ClientRouterControls,{device:d,value:{control_version:1,runtime_id:'r',results},transport:{},ready:true}));
|
||||
for(const html of [render(),render()]){
|
||||
assert.match(html,/busy/);assert.match(html,/Сохранённый режим/);assert.doesNotMatch(html,/Не применён|Политика сохранена и применена/);
|
||||
assert.ok(html.indexOf('(busy)')<html.indexOf('Ожидание отказа, с'));
|
||||
assert.ok(html.indexOf('(busy)')<html.indexOf('Восстановление соединения'));
|
||||
}
|
||||
});
|
||||
|
||||
test('policy progress follows receipts and never turns missing or fallback routes into success',async()=>{
|
||||
const {policyFeedback}=await server.ssrLoadModule('../../packages/router-ui/src/control.ts');
|
||||
const device={selected_mode:'aggregation',active_mode:'aggregation',modems:[],client_api:{policy:{mode:'aggregation'},details:{pending:false}}};
|
||||
const receipt={operation_id:'one',device_id:'x',action:'policy',state:'queued'};
|
||||
assert.match(policyFeedback(device,true,receipt).label,/Команда отправлена/);
|
||||
assert.equal(policyFeedback(device,true,receipt).busy,true);
|
||||
assert.match(policyFeedback(device,true,{...receipt,state:'applying'}).label,/Применяются/);
|
||||
assert.equal(policyFeedback(device,true,{...receipt,state:'complete'}).tone,'success');
|
||||
assert.match(policyFeedback(device,true,{...receipt,state:'complete'}).message,/Агрегация/);
|
||||
for(const state of ['error','unknown']){
|
||||
const result=policyFeedback(device,true,{...receipt,state,error:'router_busy'});
|
||||
assert.equal(result.busy,false);assert.equal(result.tone,'warning');
|
||||
}
|
||||
const offline=policyFeedback(device,false,{...receipt,state:'applying'});
|
||||
assert.equal(offline.busy,false);assert.match(offline.label,/Нет свежих данных/);
|
||||
const fallback={...device,active_mode:'direct',active_slots:[1],client_api:{...device.client_api,details:{fallback:true}}};
|
||||
assert.equal(policyFeedback(fallback,true,{...receipt,state:'complete'}).tone,'warning');
|
||||
assert.match(policyFeedback(fallback,true,{...receipt,state:'complete'}).message,/Агрегация задана, но сейчас выход идёт через/);
|
||||
const settling={...device,client_api:{...device.client_api,details:{pending:true}}};
|
||||
assert.equal(policyFeedback(settling,true,{...receipt,state:'complete'}).tone,'warning');
|
||||
assert.equal(policyFeedback(device,false,{...receipt,state:'complete'}).tone,'warning');
|
||||
});
|
||||
|
||||
test('queued and applying policy show one canonical action loader and visible status after reopening',async()=>{
|
||||
const {ClientRouterControls}=await server.ssrLoadModule('../../packages/router-ui/src/ClientRouterControls.tsx');
|
||||
const device={id:'x',state:'ready',active_mode:'direct',modems:[],client_api:{boot_id:'b',revision:'r',rights:['policy','recovery','diagnostics','reboot'],policy:{mode:'aggregation',fail_seconds:60,recover_seconds:60,min_vpn_seconds:120},checks:[]}};
|
||||
for(const state of ['queued','applying','complete','error','unknown']){
|
||||
const results=[{operation_id:'one',device_id:'x',action:'policy',state,at:100,error:state==='error'?'router_busy':undefined}];
|
||||
const html=renderToStaticMarkup(createElement(ClientRouterControls,{device,value:{control_version:1,runtime_id:'r',results},transport:{},ready:true}));
|
||||
const pending=['queued','applying'].includes(state);
|
||||
assert.equal((html.match(/aria-busy="true"/g)||[]).length,pending?1:0);
|
||||
assert.ok(html.indexOf('role="status"')<html.indexOf('Ожидание отказа, с'));
|
||||
if(pending){assert.doesNotMatch(html,/Не применён|Изменения ещё не применены/);assert.match(html,/disabled/);}
|
||||
}
|
||||
});
|
||||
test('receipts survive out-of-order snapshots without mixing devices, actions or old successes',async()=>{
|
||||
const {latestControlReceipt,controlMessage}=await server.ssrLoadModule('../../packages/router-ui/src/control.ts');
|
||||
const base={operation_id:'old',device_id:'a',action:'policy',state:'complete',at:100};
|
||||
const refused={...base,operation_id:'new',state:'error',error:'router_busy',at:102};
|
||||
const rows=[{...refused,device_id:'other',at:500},{...base,action:'inspect',at:600},refused,base];
|
||||
assert.deepEqual(latestControlReceipt(rows,'a','policy'),refused);
|
||||
assert.deepEqual(latestControlReceipt([{...refused,state:'applying'}],'a','policy',refused),refused);
|
||||
assert.deepEqual(latestControlReceipt([refused],'a','policy',{...refused,state:'queued',at:103}),refused);
|
||||
assert.equal(latestControlReceipt(rows,'absent','policy'),null);
|
||||
assert.match(controlMessage({state:'applying',error:'receipt_pending'}),/повторная команда не отправляется/);
|
||||
assert.doesNotMatch(controlMessage({state:'unknown',action:'policy'}),/сохранена и применена/);
|
||||
});
|
||||
|
||||
test('lost control response waits for the same receipt and never replays the write',async()=>{
|
||||
const {sendControlOnce,controlBusy}=await server.ssrLoadModule('../../packages/router-ui/src/control.ts');
|
||||
const initial={operation_id:'one',device_id:'router',action:'policy',state:'queued',at:100};
|
||||
let writes=0;
|
||||
const uncertain=await sendControlOnce({control:async()=>{writes++;throw Error('response lost');}}, {operation_id:'one'},initial);
|
||||
assert.equal(writes,1);assert.equal(uncertain.operation_id,'one');assert.equal(uncertain.error,'receipt_pending');assert.equal(controlBusy(uncertain),true);
|
||||
const refused=await sendControlOnce({control:async()=>({operation_id:'one',state:'error',error:'router_busy'})},{operation_id:'one'},initial);
|
||||
assert.equal(refused.action,'policy');assert.equal(controlBusy(refused),false);
|
||||
const accepted=await sendControlOnce({control:async()=>({operation_id:'one',state:'queued'})},{operation_id:'one'},initial);
|
||||
assert.equal(controlBusy(accepted),true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user