mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-12 11:47:11 +00:00
928a3a8343
* feat(mobile): masthead-led dashboard and 5-tab bottom nav on phones On phones (below the md breakpoint) the dashboard now renders a bespoke, masthead-led layout instead of the reflowed desktop workspace: - A status masthead leads with the overall system-health verdict, the node, and a live summary (stack counts, last sync, a "metrics stale" marker when polling stops). - A CPU hero card with a sparkline, then a memory / disk / network strip with threshold-colored bars, then a tappable stack-health list. - The bottom tab bar gains a Home tab (Home / Stacks / Fleet / Sched / Settings); the global top bar is dropped on this screen, with notifications and a "more" menu rehomed into the masthead. The health-verdict logic is extracted into a shared helper so the phone masthead and the desktop health bar read from one source, with unit tests. All changes are scoped below the md breakpoint or rendered only on the mobile shell; desktop layout is unchanged (verified against the desktop snapshot gate). * feat(mobile): bespoke fleet glance and node detail on phones On phones (below the md breakpoint) the Fleet view now renders a bespoke, masthead-led layout instead of the reflowed desktop workspace: - A fleet masthead leads with the overall fleet-health verdict and a running / cpu / mem summary band, then a list of node cards. The local node is marked with a cyan rail and a "you are here" tag; offline nodes are dimmed. - Tapping a node opens a full-screen node detail: state pill, resource bars (cpu / mem / disk), the stacks running on that node, and an Inspect action that switches to the node. Operators with the right permissions also get a Drain (cordon) action. - The screen polls the fleet overview every 30 seconds; the global top bar is dropped here, with notifications and a "more" menu in the masthead. All changes are scoped below the md breakpoint or rendered only on the mobile shell; desktop layout is unchanged. * feat(mobile): bespoke schedules and settings screens on phones On phones (below the md breakpoint) Schedules and Settings now render bespoke, masthead-led layouts instead of the reflowed desktop workspace: - Schedules: a "next up" glance leading with the next run time and countdown, then upcoming runs grouped by day with a per-action status dot and target. It is read-only on mobile; creating and editing schedules stays on desktop. - Settings: a grouped-card list of every reachable section; tapping one opens it full-screen with a back affordance and a section masthead. The section content itself is the same as on desktop. The settings section switch, lazy-loaded section chunks, and tier gating are moved into a shared component so the desktop and mobile screens render the same section content from one place. The global top bar is dropped on both screens, with notifications and a "more" menu in the masthead. All changes are scoped below the md breakpoint or rendered only on the mobile shell; desktop layout is unchanged. * fix(mobile): show notifications and more-menu on the stack detail header The full-screen stack detail on phones drops the global top bar, but its header was missing the notifications bell and the "more" navigation menu that the other mobile screens carry in their masthead, leaving no way to reach notifications or other destinations while viewing a stack. Render the same header-actions cluster in the detail header (and the loading placeholder), next to the back affordance. Desktop is unaffected.
68 lines
2.8 KiB
TypeScript
68 lines
2.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { deriveHealth } from './deriveHealth';
|
|
import type { Stats, SystemStats, NotificationItem } from './types';
|
|
|
|
const stats = (over: Partial<Stats> = {}): Stats => ({
|
|
active: 5, managed: 5, unmanaged: 0, exited: 0, total: 5, ...over,
|
|
});
|
|
|
|
// deriveHealth only reads cpu.usage, memory.usagePercent and disk?.usagePercent.
|
|
const sys = (cpu: string, ram: string, disk: string | null): SystemStats => ({
|
|
cpu: { usage: cpu, cores: 8 },
|
|
memory: { total: 100, used: 50, free: 50, usagePercent: ram },
|
|
disk: disk === null ? null : { fs: '/', mount: '/', total: 100, used: 50, free: 50, usagePercent: disk },
|
|
});
|
|
|
|
const note = (over: Partial<NotificationItem> = {}): NotificationItem => ({
|
|
id: 1, level: 'error', message: 'x', timestamp: 0, is_read: 0, ...over,
|
|
});
|
|
|
|
describe('deriveHealth', () => {
|
|
it('reports healthy when all metrics are low and nothing is wrong', () => {
|
|
const r = deriveHealth(stats(), sys('10', '20', '30'), []);
|
|
expect(r.level).toBe('healthy');
|
|
expect(r.reasons).toEqual(['All systems nominal']);
|
|
});
|
|
|
|
it('escalates to degraded at the 80 boundary but not at 79', () => {
|
|
expect(deriveHealth(stats(), sys('80', '20', '30'), []).level).toBe('degraded');
|
|
expect(deriveHealth(stats(), sys('79', '20', '30'), []).level).toBe('healthy');
|
|
});
|
|
|
|
it('escalates to critical at the 90 boundary', () => {
|
|
expect(deriveHealth(stats(), sys('20', '90', '30'), []).level).toBe('critical');
|
|
});
|
|
|
|
it('treats exited containers as degraded with a reason', () => {
|
|
const r = deriveHealth(stats({ exited: 2 }), sys('10', '20', '30'), []);
|
|
expect(r.level).toBe('degraded');
|
|
expect(r.reasons).toContain('2 exited');
|
|
});
|
|
|
|
it('escalates to critical when exits AND unread errors coincide below 90', () => {
|
|
const r = deriveHealth(stats({ exited: 1 }), sys('10', '20', '30'), [note()]);
|
|
expect(r.level).toBe('critical');
|
|
});
|
|
|
|
it('counts only unread error-level notifications, with pluralization', () => {
|
|
// A read error and an unread warning must both be ignored.
|
|
const ignored = deriveHealth(stats(), sys('10', '20', '30'), [
|
|
note({ is_read: 1 }),
|
|
note({ level: 'warning' }),
|
|
]);
|
|
expect(ignored.level).toBe('healthy');
|
|
|
|
const single = deriveHealth(stats(), sys('10', '20', '30'), [note()]);
|
|
expect(single.level).toBe('degraded');
|
|
expect(single.reasons).toContain('1 unread error');
|
|
|
|
const many = deriveHealth(stats(), sys('10', '20', '30'), [note(), note({ id: 2 })]);
|
|
expect(many.reasons).toContain('2 unread errors');
|
|
});
|
|
|
|
it('treats missing system stats and disk as zero usage', () => {
|
|
expect(deriveHealth(stats(), null, []).level).toBe('healthy');
|
|
expect(deriveHealth(stats(), sys('10', '20', null), []).level).toBe('healthy');
|
|
});
|
|
});
|