Improve failover status feedback and controls
This commit is contained in:
@@ -341,6 +341,8 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
|
||||
if (!prepared) return;
|
||||
const { state, policy, role } = prepared;
|
||||
const checkedAt = now().toISOString();
|
||||
const previousSnapshot = snapshot;
|
||||
publish({ ...snapshot, reason: 'checking-channels' });
|
||||
let primary;
|
||||
let reserve;
|
||||
try {
|
||||
@@ -375,7 +377,6 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
|
||||
memory: decisionMemory,
|
||||
});
|
||||
decisionMemory = decision.memory;
|
||||
const previousSnapshot = snapshot;
|
||||
const next = activeSnapshot(state, decision.status);
|
||||
next.currentRole = role;
|
||||
next.primary = {
|
||||
@@ -526,6 +527,11 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
|
||||
const capturedGeneration = generation;
|
||||
roundPromise = performRound(capturedGeneration).finally(() => {
|
||||
roundPromise = null;
|
||||
if (capturedGeneration === generation && snapshot.reason === 'checking-channels') {
|
||||
const failed = activeSnapshot(dependencies.state.read(), 'error');
|
||||
failed.reason = 'health-unknown';
|
||||
publish(failed);
|
||||
}
|
||||
const policy = dependencies.state.read().failoverPolicy;
|
||||
if (capturedGeneration === generation && policy.enabled && dependencies.state.read().appliedFailoverPolicy) {
|
||||
const decisionAt = snapshot.nextDecisionAt ? Date.parse(snapshot.nextDecisionAt) : NaN;
|
||||
@@ -634,6 +640,7 @@ export function createFailoverService(dependencies: FailoverServiceDependencies)
|
||||
generation += 1;
|
||||
clearTimer();
|
||||
const checkedAt = now().toISOString();
|
||||
publish({ ...snapshot, reason: 'checking-channels' });
|
||||
let primary;
|
||||
let reserve;
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const HARBOR_VERSIONS = Object.freeze({
|
||||
macClient: '0.29.2',
|
||||
gatewayClient: '0.30.2',
|
||||
gatewayBackend: '0.30.2',
|
||||
macClient: '0.30.0',
|
||||
gatewayClient: '0.31.0',
|
||||
gatewayBackend: '0.31.0',
|
||||
});
|
||||
|
||||
export interface ParsedVersion {
|
||||
|
||||
@@ -67,10 +67,6 @@ export function FailoverToggle({ feature, open, onToggle }: {
|
||||
}
|
||||
|
||||
const seconds = (milliseconds: number) => Math.round(milliseconds / 1000);
|
||||
const milliseconds = (value: string, fallback: number) => {
|
||||
const parsed = Number(value);
|
||||
return Number.isFinite(parsed) ? Math.round(parsed * 1000) : fallback;
|
||||
};
|
||||
|
||||
function pulseNumber(event: FormEvent<HTMLInputElement>) {
|
||||
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
@@ -80,9 +76,46 @@ function pulseNumber(event: FormEvent<HTMLInputElement>) {
|
||||
], { duration: 320, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' });
|
||||
}
|
||||
|
||||
function FailoverNumberSetting({ before, after, value, min, max, step = 10, disabled, ariaLabel, onChange, compact = false }: {
|
||||
before: string;
|
||||
after: string;
|
||||
value: number;
|
||||
min: number;
|
||||
max: number;
|
||||
step?: number;
|
||||
disabled?: boolean;
|
||||
ariaLabel: string;
|
||||
onChange: (value: number) => void;
|
||||
compact?: boolean;
|
||||
}) {
|
||||
const set = (next: number) => onChange(Math.min(max, Math.max(min, next)));
|
||||
return <div className={`client-failover-number-setting${compact ? ' is-compact' : ''}`}>
|
||||
<span>{before}</span>
|
||||
<input
|
||||
type="number"
|
||||
min={min}
|
||||
max={max}
|
||||
aria-label={ariaLabel}
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onInput={pulseNumber}
|
||||
onChange={(event) => {
|
||||
const next = Number(event.target.value);
|
||||
if (Number.isFinite(next)) onChange(next);
|
||||
}}
|
||||
/>
|
||||
<span>{after}</span>
|
||||
<span className="client-failover-number-steps">
|
||||
<button type="button" aria-label={`${ariaLabel}: уменьшить на ${step}`} disabled={disabled || value <= min} onClick={() => set(value - step)}>−{step}</button>
|
||||
<button type="button" aria-label={`${ariaLabel}: увеличить на ${step}`} disabled={disabled || value >= max} onClick={() => set(value + step)}>+{step}</button>
|
||||
</span>
|
||||
</div>;
|
||||
}
|
||||
|
||||
const reasonLabel = (reason: string | null) => ({
|
||||
'primary-healthy': 'Основной канал работает',
|
||||
'health-unknown': 'Ожидаем результаты проверки',
|
||||
'checking-channels': 'Проверяем основной и резервный каналы',
|
||||
'failure-window': 'Подтверждаем сбой основного канала',
|
||||
'reserve-not-healthy': 'Резервный канал ещё не подтверждён',
|
||||
'both-unhealthy': 'Оба канала недоступны',
|
||||
@@ -90,7 +123,7 @@ const reasonLabel = (reason: string | null) => ({
|
||||
'recovery-hold': 'Проверяем стабильность основного канала',
|
||||
'activity-unknown': 'Не удалось определить активность',
|
||||
'active-traffic': 'Ждём завершения активной работы',
|
||||
'quiet-window': 'Проверяем тишину перед переключением',
|
||||
'quiet-window': 'Ждём паузу в передаче данных',
|
||||
'primary-failed': 'Основной канал недоступен',
|
||||
'primary-recovered': 'Основной канал восстановился',
|
||||
'pending-activation': 'Изменения ожидают следующего запуска VPN',
|
||||
@@ -107,9 +140,13 @@ const reasonLabel = (reason: string | null) => ({
|
||||
function targetLabel(profiles: ProfileSnapshot[], target: { profileId: string; serverId: string }) {
|
||||
const profile = profiles.find(({ id }) => id === target.profileId);
|
||||
const server = profile?.servers.find(({ id }) => id === target.serverId);
|
||||
return profile && server ? `${profile.label} · ${server.label}` : 'Не выбран';
|
||||
return profile && server ? channelLabel(profile.label, server.label) : 'Не выбран';
|
||||
}
|
||||
|
||||
const channelLabel = (profile: string, server: string) => profile.trim() === server.trim()
|
||||
? server
|
||||
: `${profile} · ${server}`;
|
||||
|
||||
function HarborSwitch({ checked, label, disabled, onChange }: {
|
||||
checked: boolean;
|
||||
label: string;
|
||||
@@ -280,6 +317,7 @@ export function FailoverPanel({
|
||||
const [removingCheckId, setRemovingCheckId] = useState('');
|
||||
const [advancedOpen, setAdvancedOpen] = useState(false);
|
||||
const [advancedClosing, setAdvancedClosing] = useState(false);
|
||||
const [manualChecking, setManualChecking] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!dirty) setDraft(snapshot.policy);
|
||||
}, [snapshot.policy, dirty]);
|
||||
@@ -305,7 +343,7 @@ export function FailoverPanel({
|
||||
], [diagnostics.customServices]);
|
||||
const channelOptions = useMemo(() => profiles.flatMap((profile) => profile.servers.map((server) => ({
|
||||
id: `${profile.id}\u001f${server.id}`,
|
||||
label: `${profile.label} · ${server.label}`,
|
||||
label: channelLabel(profile.label, server.label),
|
||||
target: { profileId: profile.id, serverId: server.id },
|
||||
}))), [profiles]);
|
||||
const channelPickerOptions = useMemo(() => ({
|
||||
@@ -419,12 +457,17 @@ export function FailoverPanel({
|
||||
/>
|
||||
</div>
|
||||
<p>Переключает только новые соединения. Уже открытые соединения Harbor не закрывает.</p>
|
||||
{snapshot.enabled && <div className="client-failover-global-actions">
|
||||
<button type="button" disabled={blocked} onClick={() => void onPause(!snapshot.paused)}>{snapshot.paused ? 'Продолжить автоматику' : 'Приостановить автоматику'}</button>
|
||||
<small>{snapshot.paused ? 'VPN продолжает работать через текущий канал.' : 'Harbor сам проверяет оба канала.'}</small>
|
||||
</div>}
|
||||
</header>
|
||||
|
||||
<form className="client-failover-form" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void onSave(draft).then((result) => { if (result !== false) setDirty(false); });
|
||||
}}>
|
||||
<section className="client-failover-channels" aria-label="Основной и резервный каналы">
|
||||
{(['primary', 'reserve'] as const).map((channel) => {
|
||||
const health = snapshot[channel].health;
|
||||
const missing = Boolean(snapshot[channel].target.profileId) && !targetExists(snapshot[channel].target);
|
||||
@@ -444,9 +487,9 @@ export function FailoverPanel({
|
||||
: channel === 'primary' && snapshot.currentRole === 'reserve' && health === 'healthy' && snapshot.reason === 'recovery-hold'
|
||||
? 'Восстанавливается'
|
||||
: health === 'healthy' ? 'Работает' : health === 'unhealthy' ? 'Недоступен' : health === 'not-monitoring' ? 'Не проверяется' : 'Ещё не проверен';
|
||||
return <section className="client-failover-channel" data-channel={channel} key={channel}>
|
||||
return <article className="client-failover-channel" data-channel={channel} key={channel}>
|
||||
<div className="client-failover-channel-title">
|
||||
<span><b>{channel === 'primary' ? 'Основной' : 'Резервный'}</b><i aria-hidden="true">=</i></span>
|
||||
<h3>{channel === 'primary' ? 'Основной' : 'Резервный'}</h3>
|
||||
<strong className={health === 'healthy' ? 'is-healthy' : health === 'unhealthy' || missing ? 'is-unhealthy' : ''}>{healthLabel}</strong>
|
||||
</div>
|
||||
<FailoverPicker
|
||||
@@ -459,8 +502,12 @@ export function FailoverPanel({
|
||||
onOpenChange={(open) => setOpenPicker(open ? channel : '')}
|
||||
onChange={(optionId) => updateTarget(channel, optionId)}
|
||||
/>
|
||||
</section>;
|
||||
</article>;
|
||||
})}
|
||||
<div className="client-failover-checking" role="status" aria-live="polite">
|
||||
{(manualChecking || snapshot.reason === 'checking-channels' ? ['primary', 'reserve'] as const : []).map((checkingRole) => <span key={checkingRole}>Проверяется {checkingRole === 'primary' ? 'основной' : 'резервный'} канал</span>)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<fieldset className="client-failover-services">
|
||||
<legend>Что проверять</legend>
|
||||
@@ -477,21 +524,20 @@ export function FailoverPanel({
|
||||
}}
|
||||
>
|
||||
<span className="client-failover-service-name">{service?.label || 'Сервис недоступен'}</span>
|
||||
<label className="client-failover-service-timeout">
|
||||
<span>таймаут, сек</span>
|
||||
<input
|
||||
type="number"
|
||||
min="2"
|
||||
max="30"
|
||||
aria-label={`Таймаут проверки: ${service?.label || 'сервис недоступен'}`}
|
||||
<FailoverNumberSetting
|
||||
compact
|
||||
before="Ждать ответ не дольше"
|
||||
after="секунд"
|
||||
min={2}
|
||||
max={30}
|
||||
step={1}
|
||||
ariaLabel={`Время ожидания ответа: ${service?.label || 'сервис недоступен'}`}
|
||||
value={seconds(check.timeoutMs)}
|
||||
disabled={blocked || !draft.enabled}
|
||||
onInput={pulseNumber}
|
||||
onChange={(event) => updateChecks((checks) => checks.map((item) => item.serviceId === check.serviceId
|
||||
? { ...item, timeoutMs: milliseconds(event.target.value, item.timeoutMs) }
|
||||
onChange={(value) => updateChecks((checks) => checks.map((item) => item.serviceId === check.serviceId
|
||||
? { ...item, timeoutMs: value * 1_000 }
|
||||
: item))}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
className="client-failover-remove-service"
|
||||
type="button"
|
||||
@@ -532,20 +578,20 @@ export function FailoverPanel({
|
||||
</fieldset>
|
||||
|
||||
<section className="client-failover-timing" aria-label="Пороги переключения">
|
||||
<label><span>Проверять каждые, сек</span><input type="number" min="15" max="900" disabled={blocked || !draft.enabled} value={seconds(draft.intervalMs)} onInput={pulseNumber} onChange={(event) => update({ intervalMs: milliseconds(event.target.value, draft.intervalMs) })} /></label>
|
||||
<label><span>Сбой должен длиться, сек</span><input type="number" min={seconds(draft.intervalMs * 2)} max="1800" disabled={blocked || !draft.enabled} value={seconds(draft.failureWindowMs)} onInput={pulseNumber} onChange={(event) => update({ failureWindowMs: milliseconds(event.target.value, draft.failureWindowMs) })} /></label>
|
||||
<label><span>Восстановление, сек</span><input type="number" min="60" max="86400" disabled={blocked || !draft.enabled} value={seconds(draft.recoveryWindowMs)} onInput={pulseNumber} onChange={(event) => update({ recoveryWindowMs: milliseconds(event.target.value, draft.recoveryWindowMs) })} /></label>
|
||||
<FailoverNumberSetting before="Проверять каналы каждые" after="секунд" min={15} max={900} ariaLabel="Интервал проверки каналов" value={seconds(draft.intervalMs)} disabled={blocked || !draft.enabled} onChange={(value) => update({ intervalMs: value * 1_000 })} />
|
||||
<FailoverNumberSetting before="Считать основной недоступным после" after="секунд непрерывного сбоя" min={seconds(draft.intervalMs * 2)} max={1800} ariaLabel="Длительность сбоя основного канала" value={seconds(draft.failureWindowMs)} disabled={blocked || !draft.enabled} onChange={(value) => update({ failureWindowMs: value * 1_000 })} />
|
||||
<FailoverNumberSetting before="Вернуться на основной после" after="секунд стабильной работы" min={60} max={86400} ariaLabel="Время стабильной работы основного канала" value={seconds(draft.recoveryWindowMs)} disabled={blocked || !draft.enabled} onChange={(value) => update({ recoveryWindowMs: value * 1_000 })} />
|
||||
<div className="client-failover-traffic-switch">
|
||||
<span><strong>Переключение во время работы</strong><small>{draft.trafficGuard.enabled ? 'Ждать тишины перед автоматическим переключением' : 'Переключать сразу после подтверждённого сбоя'}</small></span>
|
||||
<span><strong>Не переключать во время активной работы</strong><small>{draft.trafficGuard.enabled ? 'Harbor дождётся снижения трафика, чтобы не мешать новым подключениям.' : 'Новые соединения переключатся сразу после подтверждённого сбоя.'}</small></span>
|
||||
<HarborSwitch
|
||||
checked={draft.trafficGuard.enabled}
|
||||
label={draft.trafficGuard.enabled ? 'Не ждать завершения активной работы' : 'Ждать завершения активной работы'}
|
||||
label={draft.trafficGuard.enabled ? 'Разрешить переключение во время активной работы' : 'Не переключать во время активной работы'}
|
||||
disabled={blocked || !draft.enabled}
|
||||
onChange={(enabled) => update({ trafficGuard: { ...draft.trafficGuard, enabled } })}
|
||||
/>
|
||||
</div>
|
||||
<label><span>Тишина перед переключением, сек</span><input type="number" min="5" max="600" disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} value={seconds(draft.trafficGuard.quietWindowMs)} onInput={pulseNumber} onChange={(event) => update({ trafficGuard: { ...draft.trafficGuard, quietWindowMs: milliseconds(event.target.value, draft.trafficGuard.quietWindowMs) } })} /></label>
|
||||
<label><span>Активный трафик, КБ/с</span><input type="number" min="1" max="102400" disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} value={Math.round(draft.trafficGuard.thresholdBytesPerSecond / 1024)} onInput={pulseNumber} onChange={(event) => update({ trafficGuard: { ...draft.trafficGuard, thresholdBytesPerSecond: Number(event.target.value) * 1024 } })} /></label>
|
||||
<FailoverNumberSetting before="Переключать после" after="секунд без активной передачи данных" min={5} max={600} ariaLabel="Время без активной передачи данных" value={seconds(draft.trafficGuard.quietWindowMs)} disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} onChange={(value) => update({ trafficGuard: { ...draft.trafficGuard, quietWindowMs: value * 1_000 } })} />
|
||||
<FailoverNumberSetting before="Считать работу активной при скорости от" after="КБ/с" min={1} max={102400} ariaLabel="Скорость активной работы" value={Math.round(draft.trafficGuard.thresholdBytesPerSecond / 1024)} disabled={blocked || !draft.enabled || !draft.trafficGuard.enabled} onChange={(value) => update({ trafficGuard: { ...draft.trafficGuard, thresholdBytesPerSecond: value * 1024 } })} />
|
||||
</section>
|
||||
|
||||
<section className={`client-failover-advanced${advancedOpen ? ' is-open' : ''}${advancedClosing ? ' is-closing' : ''}`}>
|
||||
@@ -563,10 +609,10 @@ export function FailoverPanel({
|
||||
setAdvancedOpen(false);
|
||||
}}
|
||||
>
|
||||
<label><span>Минимум на резерве, сек</span><input type="number" min="60" max="86400" disabled={blocked || !draft.enabled} value={seconds(draft.minimumReserveMs)} onInput={pulseNumber} onChange={(event) => update({ minimumReserveMs: milliseconds(event.target.value, draft.minimumReserveMs) })} /></label>
|
||||
<label><span>Падений до карантина</span><input type="number" min="2" max="10" disabled={blocked || !draft.enabled} value={draft.flapProtection.count} onInput={pulseNumber} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, count: Number(event.target.value) } })} /></label>
|
||||
<label><span>Окно повторных сбоев, ч</span><input type="number" min="1" max="72" disabled={blocked || !draft.enabled} value={Math.round(draft.flapProtection.windowMs / 3_600_000)} onInput={pulseNumber} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, windowMs: Number(event.target.value) * 3_600_000 } })} /></label>
|
||||
<label><span>Карантин основного, мин</span><input type="number" min="10" max="10080" disabled={blocked || !draft.enabled} value={Math.round(draft.flapProtection.quarantineMs / 60_000)} onInput={pulseNumber} onChange={(event) => update({ flapProtection: { ...draft.flapProtection, quarantineMs: Number(event.target.value) * 60_000 } })} /></label>
|
||||
<FailoverNumberSetting before="Оставаться на резервном не меньше" after="секунд" min={60} max={86400} ariaLabel="Минимальное время на резервном канале" value={seconds(draft.minimumReserveMs)} disabled={blocked || !draft.enabled} onChange={(value) => update({ minimumReserveMs: value * 1_000 })} />
|
||||
<FailoverNumberSetting before="Отправлять основной в карантин после" after="повторных сбоев" min={2} max={10} step={1} ariaLabel="Количество повторных сбоев" value={draft.flapProtection.count} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, count: value } })} />
|
||||
<FailoverNumberSetting before="Считать повторными сбои за последние" after="часов" min={1} max={72} step={1} ariaLabel="Период повторных сбоев" value={Math.round(draft.flapProtection.windowMs / 3_600_000)} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, windowMs: value * 3_600_000 } })} />
|
||||
<FailoverNumberSetting before="Не возвращаться на основной после карантина" after="минут" min={10} max={10080} ariaLabel="Длительность карантина основного канала" value={Math.round(draft.flapProtection.quarantineMs / 60_000)} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, quarantineMs: value * 60_000 } })} />
|
||||
</div>}
|
||||
</section>
|
||||
|
||||
@@ -578,7 +624,7 @@ export function FailoverPanel({
|
||||
? `При запуске VPN: ${targetLabel(profiles, draft.primary)}`
|
||||
: `После перезапуска VPN: ${targetLabel(profiles, draft.primary)}`}</span>
|
||||
{snapshot.nextDecisionAt && <span>Следующее решение не раньше чем через {seconds(Math.max(0, Date.parse(snapshot.nextDecisionAt) - Date.now()))} с</span>}
|
||||
{activity && <span>{activity.state === 'active' ? `Активный трафик · ${Math.round(activity.totalBytesPerSecond / 1024)} КБ/с · соединений: ${activity.transmittingConnections}` : activity.state === 'quiet' ? `Проверяем тишину · ${Math.min(seconds(quietElapsed), seconds(draft.trafficGuard.quietWindowMs))} из ${seconds(draft.trafficGuard.quietWindowMs)} с` : 'Не удалось определить активность · автоматическое переключение остановлено'}</span>}
|
||||
{activity && <span>{activity.state === 'active' ? `Активный трафик · ${Math.round(activity.totalBytesPerSecond / 1024)} КБ/с · соединений: ${activity.transmittingConnections}` : activity.state === 'quiet' ? `Без активной передачи данных · ${Math.min(seconds(quietElapsed), seconds(draft.trafficGuard.quietWindowMs))} из ${seconds(draft.trafficGuard.quietWindowMs)} с` : 'Не удалось определить активность · автоматическое переключение остановлено'}</span>}
|
||||
{activity?.blockers.slice(0, 2).map((blocker) => <small key={`${blocker.device}:${blocker.service}`}>{blocker.device} · {blocker.service} · {Math.round((blocker.uploadBytesPerSecond + blocker.downloadBytesPerSecond) / 1024)} КБ/с</small>)}
|
||||
{activity && activity.blockers.length > 2 && <small>Ещё {activity.blockers.length - 2}</small>}
|
||||
</div>
|
||||
@@ -591,11 +637,13 @@ export function FailoverPanel({
|
||||
</div>}
|
||||
|
||||
<div className="client-failover-actions">
|
||||
<button type="button" disabled={blocked || !snapshot.enabled || snapshot.activation !== 'active'} onClick={() => void onCheck()}>Проверить оба канала</button>
|
||||
<button type="button" disabled={blocked || manualChecking || !snapshot.enabled || snapshot.activation !== 'active'} onClick={() => {
|
||||
setManualChecking(true);
|
||||
void onCheck().finally(() => setManualChecking(false));
|
||||
}}>Проверить основной и резервный</button>
|
||||
<button type="submit" disabled={blocked || !dirty || !draftValid}>Сохранить</button>
|
||||
{snapshot.enabled && <button type="button" disabled={blocked} onClick={() => void onPause(!snapshot.paused)}>{snapshot.paused ? 'Возобновить' : 'Пауза'}</button>}
|
||||
{switchRole && snapshot.enabled && snapshot.activation === 'active' && <button type="button" disabled={blocked} aria-label={`Переключить новые соединения на ${switchRole === 'reserve' ? 'резервный' : 'основной'} сейчас`} onClick={() => void onSwitch(switchRole)}>Переключить новые сейчас</button>}
|
||||
{(snapshot.currentRole === 'primary' || snapshot.currentRole === 'reserve') && <small>Текущие соединения Harbor не закроет</small>}
|
||||
{switchRole && snapshot.enabled && snapshot.activation === 'active' && <button type="button" disabled={blocked} onClick={() => void onSwitch(switchRole)}>Переключить новые соединения на {switchRole === 'reserve' ? 'резервный' : 'основной'}</button>}
|
||||
{(snapshot.currentRole === 'primary' || snapshot.currentRole === 'reserve') && <small>Открытые соединения продолжат работать через прежний канал.</small>}
|
||||
</div>
|
||||
</form>
|
||||
</Drawer>;
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
.client-failover-header { display: grid; gap: 8px; margin: 0 8px 30px; }
|
||||
.client-failover-header > span, .client-failover-channel-title > span, .client-failover-services legend { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-header > span, .client-failover-services legend { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-heading { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-right: 52px; }
|
||||
.client-failover-header h2 { margin: 0; font: var(--type-drawer-title); letter-spacing: var(--type-drawer-title-tracking); text-transform: var(--type-drawer-title-transform); }
|
||||
.client-failover-header p { margin: 0; color: var(--client-muted); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||
.client-failover-global-actions { min-height: 30px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 16px; }
|
||||
.client-failover-global-actions > button { padding: 6px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||
.client-failover-global-actions > small { color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-form { display: grid; gap: 24px; margin: 0 8px; }
|
||||
.client-failover-switch { position: relative; flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--client-muted); cursor: pointer; }
|
||||
.client-failover-switch::before { content: ''; position: absolute; inset: 11px 1px; border-radius: 999px; background: color-mix(in oklch, var(--client-muted) 24%, transparent); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--client-muted) 24%, transparent); transition: background 240ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 240ms cubic-bezier(0.16, 1, 0.3, 1); }
|
||||
.client-failover-switch > span { position: absolute; top: 13px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: color-mix(in oklch, var(--client-text) 88%, var(--client-bg)); box-shadow: 0 2px 8px color-mix(in oklch, black 30%, transparent); transform: translateX(0); transition: background 240ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 240ms cubic-bezier(0.16, 1, 0.3, 1), transform 240ms cubic-bezier(0.16, 1, 0.3, 1); }
|
||||
.client-failover-switch[aria-checked='true']::before { background: color-mix(in oklch, var(--client-accent) 72%, transparent); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--client-accent) 58%, transparent), 0 0 14px color-mix(in oklch, var(--client-accent) 28%, transparent); }
|
||||
.client-failover-switch[aria-checked='true'] > span { background: var(--client-text); box-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 46%, transparent); transform: translateX(20px); }
|
||||
.client-failover-switch[aria-checked='true'] > span { background: var(--client-text); box-shadow: 0 0 10px color-mix(in oklch, var(--client-accent) 46%, transparent); transform: translateX(22px); }
|
||||
.client-failover-switch:disabled { cursor: default; opacity: .42; }
|
||||
.client-failover-switch:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 0; border-radius: 999px; }
|
||||
.client-failover-channel { position: relative; display: grid; grid-template-columns: 142px minmax(0, 1fr) 126px; align-items: center; gap: 14px; min-height: 52px; }
|
||||
.client-failover-channel-title { display: contents; }
|
||||
.client-failover-channel-title > span { grid-column: 1; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||
.client-failover-channel-title > span b { font: inherit; }
|
||||
.client-failover-channel-title > span i { color: var(--client-muted); font-style: normal; }
|
||||
.client-failover-channel[data-channel='primary'] .client-failover-channel-title > span b { color: var(--harbor-connect); text-shadow: 0 0 9px color-mix(in oklch, var(--harbor-connect) 30%, transparent); }
|
||||
.client-failover-channel[data-channel='reserve'] .client-failover-channel-title > span b { color: var(--harbor-gateway); text-shadow: 0 0 9px color-mix(in oklch, var(--harbor-gateway) 30%, transparent); }
|
||||
.client-failover-channel-title strong { grid-column: 3; grid-row: 1; min-width: 0; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); text-align: right; white-space: nowrap; transition: color 600ms ease, filter 600ms ease; }
|
||||
.client-failover-channels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 32px; }
|
||||
.client-failover-channel { position: relative; display: grid; align-content: start; gap: 7px; min-width: 0; }
|
||||
.client-failover-channel-title { min-height: 24px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
|
||||
.client-failover-channel-title h3 { margin: 0; font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||
.client-failover-channel[data-channel='primary'] .client-failover-channel-title h3 { color: var(--harbor-connect); text-shadow: 0 0 9px color-mix(in oklch, var(--harbor-connect) 30%, transparent); }
|
||||
.client-failover-channel[data-channel='reserve'] .client-failover-channel-title h3 { color: var(--harbor-gateway); text-shadow: 0 0 9px color-mix(in oklch, var(--harbor-gateway) 30%, transparent); }
|
||||
.client-failover-channel-title strong { min-width: 0; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); text-align: right; white-space: nowrap; transition: color 600ms ease, filter 600ms ease; }
|
||||
.client-failover-channel-title strong.is-healthy { color: var(--client-accent); }
|
||||
.client-failover-channel-title strong.is-unhealthy { color: oklch(0.68 0.15 28); }
|
||||
.client-failover-picker { position: relative; min-width: 0; z-index: 1; }
|
||||
.client-failover-channel > .client-failover-picker { grid-column: 2; grid-row: 1; }
|
||||
.client-failover-checking { grid-column: 1 / -1; min-height: 22px; display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-picker.is-open { z-index: 6; }
|
||||
.client-failover-picker-trigger { width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px; border: 0; border-bottom: 1px solid var(--client-border); background: transparent; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); text-align: left; box-shadow: 0 1px 0 transparent; cursor: pointer; transition: color 220ms ease, box-shadow 300ms ease, text-shadow 300ms ease; }
|
||||
.client-failover-picker-trigger span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
@@ -37,16 +39,19 @@
|
||||
.client-failover-picker.is-open .client-failover-picker-list button { opacity: 1; filter: blur(0); transform: translateY(0); transition-delay: calc(var(--picker-index) * 30ms); }
|
||||
.client-failover-picker-list button:hover, .client-failover-picker-list button:focus-visible, .client-failover-picker-list button[aria-selected='true'] { outline: 0; color: var(--client-accent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 38%, transparent); }
|
||||
.client-failover-picker-list button[aria-disabled='true'] { color: color-mix(in oklch, var(--client-muted) 58%, transparent); cursor: default; text-shadow: none; }
|
||||
.client-failover-timing label, .client-failover-advanced label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 48%); align-items: center; gap: 16px; min-height: 38px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-timing input, .client-failover-advanced input { min-width: 0; min-height: 38px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--client-border); border-radius: 0; background: transparent; color: var(--client-text); font: var(--type-item-title); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-item-title-tracking); text-align: center; text-transform: var(--type-item-title-transform); appearance: textfield; transition: color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, text-shadow 220ms ease; }
|
||||
.client-failover-timing input:disabled, .client-failover-advanced input:disabled { color: var(--client-muted); opacity: .45; }
|
||||
.client-failover-number-setting { display: grid; grid-template-columns: minmax(0, 1fr) 68px max-content auto; align-items: center; gap: 8px; min-height: 42px; color: var(--client-muted); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); }
|
||||
.client-failover-number-setting input { width: 68px; min-height: 34px; padding: 0 3px; border: 0; border-bottom: 1px solid var(--client-border); border-radius: 0; background: transparent; color: var(--client-text); font: var(--type-item-title); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-item-title-tracking); text-align: center; text-transform: var(--type-item-title-transform); appearance: textfield; transition: color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, text-shadow 220ms ease; }
|
||||
.client-failover-number-setting input:disabled { color: var(--client-muted); opacity: .45; }
|
||||
.client-failover-number-steps { justify-self: end; display: flex; align-items: center; gap: 10px; }
|
||||
.client-failover-number-steps button { min-width: 34px; padding: 5px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||
.client-failover-number-steps button:disabled, .client-failover-global-actions > button:disabled { color: var(--client-muted); cursor: default; opacity: .42; }
|
||||
.client-failover-services { display: grid; gap: 9px; margin: 0; padding: 0; border: 0; }
|
||||
.client-failover-services legend { margin-bottom: 10px; }
|
||||
.client-failover-service { display: grid; grid-template-columns: minmax(0, 1fr) auto 32px; align-items: center; gap: 12px; min-height: 38px; animation: failover-service-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
||||
.client-failover-service { display: grid; grid-template-columns: minmax(90px, .7fr) minmax(0, 1.3fr) 32px; align-items: center; gap: 12px; min-height: 42px; animation: failover-service-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
|
||||
.client-failover-service.is-removing { animation: failover-service-out 300ms ease both; pointer-events: none; }
|
||||
.client-failover-service-name { min-width: 0; overflow: hidden; color: var(--client-text); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-overflow: ellipsis; text-transform: var(--type-body-transform); white-space: nowrap; }
|
||||
.client-failover-service-timeout { display: flex; align-items: center; gap: 8px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-service-timeout input { width: 58px; min-height: 34px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--client-border); border-radius: 0; background: transparent; color: var(--client-text); font: var(--type-item-title); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-item-title-tracking); text-align: center; text-transform: var(--type-item-title-transform); appearance: textfield; transition: color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, text-shadow 220ms ease; }
|
||||
.client-failover-number-setting.is-compact { grid-template-columns: minmax(0, 1fr) 52px max-content auto; min-height: 38px; font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-number-setting.is-compact input { width: 52px; min-height: 32px; }
|
||||
.client-failover-remove-service { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: oklch(0.62 0.16 28); cursor: pointer; transition: color 180ms ease, filter 240ms ease; }
|
||||
.client-failover-remove-service svg { width: 19px; height: 19px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
|
||||
.client-failover-remove-lid { transform-origin: center 7px; transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1); }
|
||||
@@ -89,11 +94,11 @@
|
||||
.client-failover-actions button { padding: 7px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||
.client-failover-actions small { flex-basis: 100%; margin-top: -14px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-actions button:disabled { color: var(--client-muted); cursor: default; opacity: .45; }
|
||||
.client-failover-actions button:focus-visible, .client-failover-service-editor button:focus-visible, .client-failover-discard button:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
||||
.client-failover-actions button:focus-visible, .client-failover-service-editor button:focus-visible, .client-failover-discard button:focus-visible, .client-failover-number-steps button:focus-visible, .client-failover-global-actions > button:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
||||
.client-failover-form input:focus-visible { outline: 0; border-bottom-color: var(--client-accent); box-shadow: 0 1px 0 color-mix(in oklch, var(--client-accent) 60%, transparent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 34%, transparent); }
|
||||
@keyframes failover-service-in { from { opacity: 0; filter: blur(5px); transform: translateY(-4px); } to { opacity: 1; filter: blur(0); transform: translateY(0); } }
|
||||
@keyframes failover-service-out { from { opacity: 1; filter: blur(0); transform: translateX(0) scale(1); } to { opacity: 0; filter: blur(6px); transform: translateX(16px) scale(.96); } }
|
||||
@keyframes failover-advanced-in { from { opacity: 0; filter: blur(5px); transform: translateY(-5px); } to { opacity: 1; filter: blur(0); transform: translateY(0); } }
|
||||
@keyframes failover-advanced-out { from { opacity: 1; filter: blur(0); transform: translateY(0); } to { opacity: 0; filter: blur(5px); transform: translateY(-5px); } }
|
||||
@media (max-width: 560px) { .client-failover-heading { padding-right: 44px; } .client-failover-channel { grid-template-columns: 112px minmax(0, 1fr); gap: 5px 10px; } .client-failover-channel-title strong { grid-column: 2; grid-row: 2; text-align: left; } .client-failover-channel > .client-failover-picker { grid-column: 2; grid-row: 1; } .client-failover-timing label, .client-failover-advanced label { grid-template-columns: 1fr; gap: 4px; } .client-failover-service { grid-template-columns: minmax(0, 1fr) 32px; gap: 6px 10px; } .client-failover-service-timeout { grid-column: 1; grid-row: 2; justify-self: start; } .client-failover-remove-service { grid-column: 2; grid-row: 1 / span 2; } .client-failover-service-editor { grid-template-columns: 1fr; gap: 2px; } }
|
||||
@media (max-width: 560px) { .client-failover-heading { padding-right: 44px; } .client-failover-channels { grid-template-columns: minmax(0, 1fr); gap: 18px; } .client-failover-checking { grid-column: 1; margin-top: -6px; } .client-failover-number-setting { grid-template-columns: minmax(0, 1fr) 58px auto; gap: 5px 7px; } .client-failover-number-setting > span:first-child { grid-column: 1 / -1; } .client-failover-number-setting input { grid-column: 1; grid-row: 2; width: 58px; } .client-failover-number-setting > span:nth-child(3) { grid-column: 2; grid-row: 2; } .client-failover-number-steps { grid-column: 3; grid-row: 2; } .client-failover-service { grid-template-columns: minmax(0, 1fr) 32px; gap: 6px 10px; } .client-failover-service > .client-failover-number-setting { grid-column: 1; grid-row: 2; } .client-failover-remove-service { grid-column: 2; grid-row: 1 / span 2; } .client-failover-service-editor { grid-template-columns: 1fr; gap: 2px; } }
|
||||
@media (prefers-reduced-motion: reduce) { .client-failover-channel-title strong, .client-failover-switch::before, .client-failover-switch > span, .client-failover-picker-trigger, .client-failover-picker-trigger::before, .client-failover-picker-trigger svg, .client-failover-picker-list, .client-failover-picker-list button, .client-failover-remove-service, .client-failover-remove-lid, .client-failover-advanced > button i::before, .client-failover-advanced > button i::after { transition: none; } .client-failover-service, .client-failover-service-editor, .client-failover-advanced-options { animation: none; } }
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user