56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
|
|
import type { App } from "../types/appops.ts";
|
|
import { buildAppFocusSummary, filterAppsByFocus } from "./appFocusView.ts";
|
|
|
|
const app = (overrides: Partial<App> = {}): App => ({
|
|
id: "app-1",
|
|
name: "Healthy App",
|
|
category: "Media",
|
|
status: "healthy",
|
|
criticality: "low",
|
|
connectorStatus: "connected",
|
|
containerStatus: "running",
|
|
voiceEnabled: false,
|
|
protected: false,
|
|
discoveryStatus: "managed",
|
|
needsReview: false,
|
|
connector_type: "sonarr",
|
|
app_type: "media",
|
|
...overrides,
|
|
});
|
|
|
|
describe("appFocusView", () => {
|
|
it("summarizes operator attention without counting healthy connected apps as noise", () => {
|
|
const apps = [
|
|
app(),
|
|
app({ id: "review", name: "Review", needsReview: true }),
|
|
app({ id: "unknown", name: "Unknown", category: "Unknown", app_type: "unknown", connectorStatus: "disconnected" }),
|
|
app({ id: "missing", name: "Missing Config", connectorStatus: "missing_config" }),
|
|
app({ id: "unhealthy", name: "Unhealthy", status: "unhealthy" }),
|
|
];
|
|
|
|
const summary = buildAppFocusSummary(apps);
|
|
|
|
assert.equal(summary.total, 5);
|
|
assert.equal(summary.attention, 4);
|
|
assert.equal(summary.healthyConnected, 1);
|
|
assert.equal(summary.needsReview, 1);
|
|
assert.equal(summary.unknown, 1);
|
|
assert.equal(summary.missingConfig, 1);
|
|
assert.equal(summary.unhealthy, 1);
|
|
});
|
|
|
|
it("defaults the focus list to actionable apps and keeps all apps available", () => {
|
|
const apps = [
|
|
app({ id: "ok" }),
|
|
app({ id: "needs-review", needsReview: true }),
|
|
app({ id: "unknown", category: "Unknown", app_type: "unknown", connectorStatus: "disconnected" }),
|
|
];
|
|
|
|
assert.deepEqual(filterAppsByFocus(apps, "attention").map(item => item.id), ["needs-review", "unknown"]);
|
|
assert.deepEqual(filterAppsByFocus(apps, "all").map(item => item.id), ["ok", "needs-review", "unknown"]);
|
|
});
|
|
});
|