Improve failover status feedback and controls
Build and Deploy Gateway / build-and-push (push) Successful in 26s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-08-20 01:32:03 +03:00
parent 9055934e92
commit 74227ae38c
7 changed files with 174 additions and 87 deletions
+22
View File
@@ -295,6 +295,7 @@ test('an in-flight observation is discarded after failover is disabled', async (
await testHarness.service.reconcile();
const round = testHarness.service.runRound();
await new Promise((resolve) => setImmediate(resolve));
assert.equal(testHarness.service.snapshot().reason, 'checking-channels');
await testHarness.service.save({ ...enabled, enabled: false });
for (const probe of pending) probe.resolve({ vpn: { sites: [{ status: probe.role === 'reserve' ? 'available' : 'unavailable' }] } });
await round;
@@ -320,6 +321,27 @@ test('one channel probe failure does not erase the other channel health', async
await testHarness.service.checkNow();
assert.equal(testHarness.service.snapshot().primary.health, 'unknown');
assert.equal(testHarness.service.snapshot().reserve.health, 'healthy');
assert.notEqual(testHarness.service.snapshot().reason, 'checking-channels');
});
test('manual check exposes both in-flight channel roles and clears them after completion', async () => {
const pending = [];
const testHarness = harness(serviceState(), {
dataplane: {
checkConfig: async () => ({}),
runFailoverProbe: (role) => new Promise((resolve) => pending.push({ role, resolve })),
readFailoverSelector: async () => ({ role: 'primary' }),
selectFailoverRole: async (role) => ({ role }),
setFailoverActivityEnabled: async () => {},
readFailoverActivity: async () => ({ activity: { state: 'quiet', observedAt: new Date().toISOString() } }),
},
});
const check = testHarness.service.checkNow();
await new Promise(setImmediate);
assert.equal(testHarness.service.snapshot().reason, 'checking-channels');
for (const probe of pending) probe.resolve({ vpn: { sites: [{ status: 'available' }] } });
await check;
assert.notEqual(testHarness.service.snapshot().reason, 'checking-channels');
});
test('monitoring wakes at an earlier decision deadline instead of waiting a full interval', async () => {
+14 -9
View File
@@ -16,19 +16,22 @@ test('reserve is a Gateway-only drawer immediately after subscriptions', () => {
assert.match(feature, /Уже открытые соединения Harbor не закрывает/);
});
test('failover settings use Harbor switches, two pair pickers and added check rows', () => {
test('failover settings use Harbor switches, a two-column channel table and plain-language controls', () => {
assert.match(feature, /client-failover-heading[\s\S]*<h2>Резервный канал<\/h2>[\s\S]*<HarborSwitch/);
assert.match(feature, /role="switch"[\s\S]*aria-checked=\{checked\}/);
assert.doesNotMatch(feature, /type="checkbox"|<select/);
assert.match(feature, /\['primary', 'reserve'\][\s\S]*client-failover-\$\{channel\}-options[\s\S]*updateTarget\(channel, optionId\)/);
assert.match(feature, /profile\.label} · \$\{server\.label/);
assert.match(feature, /channelLabel[\s\S]*profile\.trim\(\) === server\.trim\(\)[\s\S]*`\$\{profile} · \$\{server}`/);
assert.match(feature, /client-failover-channels[\s\S]*<article className="client-failover-channel"[\s\S]*<h3>\{channel === 'primary' \? 'Основной' : 'Резервный'}/);
assert.match(feature, /snapshot\.reason === 'checking-channels'[\s\S]*Проверяется \{checkingRole === 'primary' \? 'основной' : 'резервный'} канал/);
assert.match(feature, /ArrowDown[\s\S]*Home[\s\S]*End[\s\S]*Escape/);
assert.match(feature, /role="listbox"[\s\S]*role="option"/);
assert.match(feature, /Что проверять/);
assert.match(feature, /min="2"[\s\S]*max="30"[\s\S]*Таймаут проверки:/);
assert.match(feature, /Проверять каждые, сек[\s\S]*Сбой должен длиться, сек[\s\S]*Восстановление, сек/);
assert.match(feature, /Переключение во время работы[\s\S]*Ждать тишины перед автоматическим переключением[\s\S]*Тишина перед переключением[\s\S]*Активный трафик, КБ\/с/);
assert.match(feature, /Защита от повторных сбоев[\s\S]*Окно повторных сбоев[\s\S]*Карантин основного/);
assert.match(feature, /before="Ждать ответ не дольше"[\s\S]*min=\{2}[\s\S]*max=\{30}/);
assert.match(feature, /Проверять каналы каждые[\s\S]*Считать основной недоступным после[\s\S]*Вернуться на основной после/);
assert.match(feature, /Не переключать во время активной работы[\s\S]*Переключать после[\s\S]*без активной передачи данных[\s\S]*Считать работу активной при скорости от/);
assert.match(feature, /Защита от повторных сбоев[\s\S]*Считать повторными сбои за последние[\s\S]*Не возвращаться на основной после карантина/);
assert.match(feature, /client-failover-number-steps[\s\S]*уменьшить на[\s\S]*увеличить на/);
assert.match(feature, /label="Добавить проверку"/);
assert.match(feature, /Новый HTTPS-сервис…/);
assert.match(feature, /Убрать проверку:/);
@@ -40,12 +43,14 @@ test('failover settings use Harbor switches, two pair pickers and added check ro
assert.doesNotMatch(feature, /<details|<summary|Нет данных|текущий канал вне настроенной пары/);
assert.doesNotMatch(page, /Текущий канал вне резервной пары/);
assert.match(page, /Резерв применится после перезапуска VPN/);
assert.match(feature, /Проверить оба канала/);
assert.match(feature, /Приостановить автоматику[\s\S]*Проверить основной и резервный[\s\S]*Переключить новые соединения на/);
assert.match(feature, /beforeunload/);
assert.match(styles, /\.client-failover-switch\[aria-checked='true'\][\s\S]*translateX\(20px\)/);
assert.match(styles, /\.client-failover-switch\[aria-checked='true'\][\s\S]*translateX\(22px\)/);
assert.match(styles, /\.client-failover-channels \{[^}]*grid-template-columns:\s*repeat\(2, minmax\(0, 1fr\)\)/);
assert.match(styles, /@media \(max-width: 560px\)[\s\S]*\.client-failover-channels \{ grid-template-columns:\s*minmax\(0, 1fr\)/);
assert.match(styles, /\.client-failover-picker-list[\s\S]*opacity:\s*0[\s\S]*\.client-failover-picker\.is-open[\s\S]*opacity:\s*1/);
assert.match(styles, /failover-service-out 300ms[\s\S]*failover-advanced-out[\s\S]*@media \(prefers-reduced-motion: reduce\)/);
assert.match(styles, /appearance:\s*textfield[\s\S]*text-align:\s*center/);
assert.match(styles, /\.client-failover-number-setting input \{[^}]*text-align:\s*center[^}]*appearance:\s*textfield/);
});
test('runtime status keeps fixed geometry and explains active traffic without motion dependence', () => {
+14 -14
View File
@@ -39,26 +39,26 @@ const expectedImports = [
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
const acceptedLedger = {
counts: {
cascadeEdges: 1060,
cascadeEdges: 1055,
customProperties: 106,
declarations: 4099,
declarations: 4125,
important: 0,
keyframes: 52,
media: 17,
rules: 1111,
variableReferences: 1030,
rules: 1119,
variableReferences: 1040,
},
hashes: {
cascadeEdges: '8ec691911ca42f8b0d57a8449999e423686001d3b8ea52706aaa4eac96b4e323',
cascadeEdges: '6e8798a1cde16b738dae383fde679c1b8213f31acbd9efe75d594ad772cde118',
customProperties: 'fd6f16069f9fe3526f09d4d574431ddae67150d8e7a8a40e04c9fd2d179ec7ac',
declarations: 'c171ffe2c526b92b49c501cce0e38ee46c790433aaf98892309cbee36aebdd63',
declarations: '8f988bf6c61167f0c48de91022c31746d92fa533f15625ba9c9588f39dc13e0e',
duplicateKeyframes: '4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945',
duplicateSelectors: '8982145dba05b33bf1c93b2d54cfbe76305b276ff3c657aa020144016ada5848',
keyframes: 'afdfc9691f8ef629fd5f263f3eebecf2373b54f0940d8deedd5e74497d55d0f3',
ruleDeclarationSequences: '850acd4eca4c74643d0e325025108462ed16f2cc6a2e91b3b539157cfd090d38',
selectors: '12d7e3921cd5ebddbe3a0fb10a1113ca3165a7c5597c8e80d3917d19df5737e9',
variableReferences: 'e70f638b46142b1cf78cc9d82410735d9f72a32a9711bc1f0eac34e13fd653c4',
witnesses: 'a033ac2b7b6c297c6876e68818a6566a0eb95095494d45af6423c85476918061',
ruleDeclarationSequences: '67f9ae4cb44ff42eb5ad17f54fea56f0c46be77bc5a7c83fefcae098cf8c8dde',
selectors: 'a001c0b9877970aa2e9b6de091dbff7d4a46933aa1230f434fa4d63b28637c58',
variableReferences: '3f739dbe02bbbe70377b56e9068c04ef6d4e4b1c4ffb2dd15373469ceac34e19',
witnesses: 'd2b5c2e84458ef49e686ba6987e8933d569188eaa626f74929b246981e2b465c',
},
};
@@ -211,7 +211,7 @@ test('client typography uses the shared semantic scale outside the token owner',
test('accepted stylesheet has pinned declaration, selector, keyframe, variable, and cascade ledgers', () => {
const witnesses = readStyleWitnesses(root);
assert.equal(witnesses.length, 1031);
assert.equal(witnesses.length, 1074);
assert.equal(witnesses.filter((witness) => witness.unknown || witness.ancestorUnknown).length, 0);
const ledger = createStyleLedger(readStyleSource(root), { witnesses });
assert.deepEqual(ledger.counts, acceptedLedger.counts);
@@ -407,8 +407,8 @@ test('main owns one public stylesheet and the regrouped production CSS is determ
assert.equal((main.match(/import ['"][^'"]+\.css['"]/g) || []).length, 1);
const assets = fs.readdirSync(path.join(root, 'dist/assets')).filter((file) => file.endsWith('.css'));
assert.deepEqual(assets, ['index-xefTODRY.css']);
assert.deepEqual(assets, ['index-C5YGJNIP.css']);
const built = fs.readFileSync(path.join(root, 'dist/assets', assets[0]));
assert.equal(built.byteLength, 155730);
assert.equal(sha256(built), '01b3820d2be82e0d364fc2319ef8833f1ad4edc1129f66aa5d9ac04de54b89aa');
assert.equal(built.byteLength, 156575);
assert.equal(sha256(built), '31ddd5c13fd60949dd74009a690f4b7d7828a5d250856e38752529b682bb6e17');
});