diff --git a/pm-stack/aggregator/src/dns.ts b/pm-stack/aggregator/src/dns.ts index b597a9d30d..1c4e4fd7e2 100644 --- a/pm-stack/aggregator/src/dns.ts +++ b/pm-stack/aggregator/src/dns.ts @@ -112,6 +112,8 @@ export interface DnsSummary { unused: DnsEntry[]; /** Entries renewing within `days` of `now` (spend horizon). */ renewingSoon: DnsEntry[]; + /** Counts derived from the register's per-entry auto-renew values. */ + autoRenew: { on: number; off: number; unknown: number }; } export function summarizeDns(section: DnsSection, now = new Date(), soonDays = 45): DnsSummary { @@ -123,11 +125,22 @@ export function summarizeDns(section: DnsSection, now = new Date(), soonDays = 4 // vanished from nextRenewal and renewingSoon (#1684). const today = chicagoYmd(now); const cutoff = addDaysYmd(today, soonDays); + const autoRenew = entries.reduce( + (counts, entry) => { + const value = typeof entry.autoRenew === "string" ? entry.autoRenew.trim().toLowerCase() : ""; + if (value === "on") counts.on++; + else if (value === "off") counts.off++; + else counts.unknown++; + return counts; + }, + { on: 0, off: 0, unknown: 0 }, + ); return { nextRenewal: entries.find((e) => e.renewal >= today) ?? entries[0] ?? null, active: entries.filter((e) => e.status === "active"), earmarked: entries.filter((e) => e.status === "earmarked"), unused: entries.filter((e) => e.status === "unused"), renewingSoon: entries.filter((e) => e.renewal >= today && e.renewal <= cutoff), + autoRenew, }; } diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index 46ab31ece3..d2859952b3 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -3467,16 +3467,50 @@ export function renderOverviewShell(provenance: Provenance, detail?: ProvenanceD // --- DNS register page (#906 §1, data from #902) ----------------------------- -function dnsTable(entries: DnsEntry[]): string { +function dnsTable(entries: DnsEntry[], renewingSoon: Set, nextRenewal?: DnsEntry | null): string { const rows = entries .map( (e) => - `${esc(e.domain)}${esc(e.renewal)}${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}${esc(e.autoRenew)}${esc(e.plan)}${esc(e.review)}`, + `${esc(e.domain)}${esc(e.renewal)}${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}${esc(e.autoRenew)}${esc(e.plan)}${esc(e.review)}`, ) .join(""); - return `
${rows || ''}
Domain register
DomainNext renewalPrice (list)Auto-renewPlan / statusReview?
none
`; + return `
${rows || ''}
Domain register
DomainNext renewalPrice (list)Auto-renewPlan / statusReview?
none
`; } +const DNS_FILTER_SCRIPT = ``; + export function renderDns(section: DnsSection | null, provenance: Provenance, detail?: ProvenanceDetail): string { const chips = detail ? freshnessChips(detail, ["dns"]) : ""; if (!section) { @@ -3492,23 +3526,36 @@ export function renderDns(section: DnsSection | null, provenance: Provenance, de const s = summarizeDns(section); const next = s.nextRenewal; const soonTotal = Math.round(s.renewingSoon.reduce((sum, e) => sum + (e.priceUsd ?? 0), 0) * 100) / 100; + const renewingSoon = new Set(s.renewingSoon); + const filters = [ + ["all", "All", section.entries.length], + ["active", "Active", s.active.length], + ["earmarked", "Earmarked", s.earmarked.length], + ["unused", "Unused", s.unused.length], + ["renewing-soon", "Renewing soon", s.renewingSoon.length], + ] as const; + const filterChips = filters + .map( + ([filter, label, count], index) => + ``, + ) + .join(""); const body = `

DNS / domain register

${section.entries.length} domains · $${section.totalAnnualListUsd.toFixed(2)}/yr at list renewal prices · register parsed ${fmtDate(section.generatedAt)} (${esc(section.source)}). The register is maintained by the #902 pipeline — this page renders it, never edits it. Machine-first: /api/dns.json.

Next renewal
${ next - ? `${esc(next.domain)} — ${esc(next.renewal)}${next.priceUsd != null ? ` ($${next.priceUsd.toFixed(2)})` : ""}
${esc(next.plan)}` + ? `${esc(next.renewal)}${next.priceUsd != null ? ` · $${next.priceUsd.toFixed(2)}` : ""}
See its row in the renewal-sorted register.` : "—" }
-
Renewing in 45 days
${s.renewingSoon.length} domain${s.renewingSoon.length === 1 ? "" : "s"} · $${soonTotal.toFixed(2)}
Auto-renew is ON across the account portfolio — this is upcoming spend, not lapse risk.
+
Renewing in 45 days
${s.renewingSoon.length} domain${s.renewingSoon.length === 1 ? "" : "s"} · $${soonTotal.toFixed(2)} at list price
+
Auto-renew
${s.autoRenew.on} ON · ${s.autoRenew.off} OFF · ${s.autoRenew.unknown} unknown
Portfolio shape
${s.active.length} in use · ${s.earmarked.length} unused but earmarked · ${s.unused.length} completely unused
-

Next renewals

${dnsTable(section.entries.slice(0, 10))} -

In use (${s.active.length})

${dnsTable(s.active)} -

Unused but earmarked (${s.earmarked.length})

No public-facing use, but the name or plan ties them to a project family (earmark as recorded in the register).

${dnsTable(s.earmarked)} -

Completely unused (${s.unused.length})

Nothing but registrar defaults — each still auto-renews until someone decides otherwise.

${dnsTable(s.unused)} -
Full register (${section.entries.length})${dnsTable(section.entries)}
`; - return layout("DNS register", body, provenance, "/dns", "", chips); +

Domain register (${section.entries.length})

+
${filterChips}
+${dnsTable(section.entries, renewingSoon, next)}`; + return layout("DNS register", body, provenance, "/dns", DNS_FILTER_SCRIPT, chips); } // --- AA cost explorer page (ainventory import data via the fleet feed) ----- diff --git a/pm-stack/aggregator/test/slice3.test.ts b/pm-stack/aggregator/test/slice3.test.ts index c53a01bfac..508d095914 100644 --- a/pm-stack/aggregator/test/slice3.test.ts +++ b/pm-stack/aggregator/test/slice3.test.ts @@ -55,6 +55,21 @@ describe("dns register parser", () => { expect(summary.renewingSoon.map((e) => e.domain)).toEqual(["first.de"]); }); + test("auto-renew summary counts ON, OFF, and unknown values from entries", () => { + const missingAutoRenew = { + ...FIXTURE_DNS.entries[0], + autoRenew: undefined as unknown as string, + }; + const entries = [ + { ...FIXTURE_DNS.entries[0], autoRenew: "ON" }, + { ...FIXTURE_DNS.entries[1], autoRenew: "OFF" }, + { ...FIXTURE_DNS.entries[2], autoRenew: "unknown" }, + missingAutoRenew, + ]; + const summary = summarizeDns({ ...FIXTURE_DNS, entries }, new Date("2026-12-28T00:00:00Z")); + expect(summary.autoRenew).toEqual({ on: 1, off: 1, unknown: 2 }); + }); + test("summary ages renewals by the Chicago day, not UTC (#1684)", () => { // 2026-10-31T01:30:00Z is 20:30 CDT on 2026-10-30 in Chicago: // the UTC day has already rolled over, the Chicago day has not. @@ -419,14 +434,31 @@ describe("pages manifest + slice-3 renders", () => { expect(html).toContain("DNS register"); }); - test("dns page renders the three views + next renewal", () => { + test("dns page renders each domain once with status filters and data-derived auto-renew counts", () => { const html = renderDns(FIXTURE_DNS, fixtureSource().provenance()); expect(html).toContain("Next renewal"); - expect(html).toContain("1110x.de"); - expect(html).toContain("Unused but earmarked"); - expect(html).toContain("Completely unused"); - expect(html).toContain("grandnag.us"); - expect(html).toContain("security.cab"); + for (const entry of FIXTURE_DNS.entries) { + expect(html.split(entry.domain).length - 1).toBe(1); + } + expect(html).toContain('data-dns-filter="active"'); + expect(html).toContain('data-dns-filter="earmarked"'); + expect(html).toContain('data-dns-filter="unused"'); + expect(html).toContain('data-dns-filter="renewing-soon"'); + expect(html).toContain("Auto-renew
3 ON · 0 OFF · 1 unknown"); + expect(html).not.toContain("Auto-renew is ON across the account portfolio"); + expect(html).not.toContain("
Full register"); + }); + + test("dns next-renewal card links to the actual next-renewal row, not the first row", () => { + const past = { ...FIXTURE_DNS.entries[0], domain: "past.example", renewal: "2020-01-01" }; + const upcoming = { ...FIXTURE_DNS.entries[0], domain: "upcoming.example", renewal: "2999-01-01" }; + const section = { ...FIXTURE_DNS, entries: [past, upcoming] }; + const html = renderDns(section, fixtureSource().provenance()); + expect(html).not.toContain("See the first row"); + expect(html).toContain('href="#dns-next-renewal"'); + const rowStart = html.indexOf('id="dns-next-renewal"'); + expect(rowStart).toBeGreaterThan(-1); + expect(html.slice(rowStart, rowStart + 500)).toContain("upcoming.example"); }); test("dns page without a section says so honestly", () => {