Files
harbor-net/test/web/failover-feature-contract.test.js
T
dokril daec12e013
Build and Deploy Gateway / build-and-push (push) Failing after 14s
Build and Deploy Gateway / deploy (push) Has been skipped
Update Harbor client and gateway integration workflows
2026-08-19 18:16:10 +03:00

42 lines
2.9 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
const root = path.resolve(import.meta.dirname, '../..');
const page = fs.readFileSync(path.join(root, 'src/web/components/ClientOverviewPage.tsx'), 'utf8');
const feature = fs.readFileSync(path.join(root, 'src/web/features/failover/FailoverFeature.tsx'), 'utf8');
const styles = fs.readFileSync(path.join(root, 'src/web/styles/features/failover.css'), 'utf8');
test('reserve is a Gateway-only drawer immediately after subscriptions', () => {
assert.match(page, /<SubscriptionToggle[\s\S]*\{isGateway && <FailoverToggle[\s\S]*<InstructionsToggle/);
assert.match(page, /\{isGateway && hasSubscription && <FailoverPanel/);
assert.match(page, /DRAWER_ORDER = \['subscription', 'failover'/);
assert.match(feature, /label="Резерв"/);
assert.match(feature, /Уже открытые соединения Harbor не закрывает/);
});
test('failover settings expose an off switch, channel targets, checks and per-service timeouts', () => {
assert.match(feature, /Использовать резерв[\s\S]*Полностью пассивен/);
assert.match(feature, /\['primary', 'reserve'\][\s\S]*Подписка[\s\S]*Сервер/);
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]*Активный трафик, КБ\/с/);
assert.match(feature, /Защита от повторных сбоев[\s\S]*Окно повторных сбоев[\s\S]*Карантин основного/);
assert.match(feature, /Добавить HTTPS-сервис/);
assert.match(feature, /Проверить оба канала/);
assert.match(feature, /beforeunload/);
});
test('runtime status keeps fixed geometry and explains active traffic without motion dependence', () => {
assert.match(feature, /Ждём завершения активной работы/);
assert.match(feature, /Активный трафик ·[\s\S]*transmittingConnections/);
assert.match(feature, /activity\?\.blockers\.slice\(0, 2\)\.map/);
assert.match(feature, /Ещё \{activity\.blockers\.length - 2\}/);
assert.match(feature, /Нестабилен ·[\s\S]*Следующее решение не раньше чем через/);
assert.match(feature, /switchRole && snapshot\.enabled && snapshot\.activation === 'active'/);
assert.match(styles, /\.client-failover-runtime \{[^}]*min-height:\s*132px/);
assert.match(styles, /@media \(prefers-reduced-motion: reduce\)[\s\S]*transition:\s*none/);
});