Give the invoice detail and a domain claim's records pages of their own, and refuse a back link

Two member views opened in place of a region and offered "← Back to …"
to return. The invoice detail swapped into the Billing page under the
"Billing" title, and a claim's DNS records swapped into whatever opened
them; on the dashboard, "Back to domains" left the whole claims table
where the pending-domain notice had been.

Both are now member pages with their own trail. An invoice is at
/billing/invoices/{id} ("Home / Billing / Invoice 0042"), and each
number in the Billing list links to it. A claim's records are at
/domains/claims/{id} ("Home / {domain}"), where the status still
refreshes every 5 seconds and Check now and Cancel verification work in
place. The dashboard notice links to it, and in the sites card's claims
table each domain is the link, replacing the DNS records and Details
buttons. A foreign, unknown or malformed id answers the styled 404 page;
a failed read answers the styled 500 and is logged.

On a page below its rail entry, the rail marks that entry as the
section, not as the current page, so screen readers hear one current
page. A long domain wraps in the title and the trail, breaking at its
dots first. In the records table the purpose cell and the status badges
wrap, so the names keep their width at 390px; the table had been about
11,000px tall there. The claim page loads the copy script, whose buttons
had no handler unless the FedWiki card's script was loaded.

The lint gains back-link: "Back to" or a left-pointing mark in any
template's text or attributes fails, and comments are not read. The
operator invoice requirement that still asked for a back affordance now
asks for its trail.

Closes #321.
This commit is contained in:
2026-11-06 01:35:51 -06:00
parent 0c70620cc4
commit bbbd529b6b
66 changed files with 1859 additions and 292 deletions
+1 -1
View File
@@ -443,7 +443,7 @@ func collectMounts(integs []integrations.Integration) mounts {
}
// domainsPolicyFromConfig reads the claim lifecycle policy (design D6) once,
// to be carried on server.Config → server.Deps, so core's Domains page and
// to be carried on server.Config → server.Deps, so core's claim pages and
// every integration surface that claims names allocate under one policy.
// The Temporal worker needs none of it — every policy decision is made
// in the registry at allocation time. Unset keys leave the matching
+2 -2
View File
@@ -428,7 +428,7 @@ therefore read "Operator / Products". The two surface roots — the operator
overview, the member dashboard — carry no trail at all (design D18, round
2). Mechanism: the `pageHeader` part (§6) renders the root crumb from a
`surfaceRoot` template function that each surface's constructor registers,
so no page constructor names it and no handler registers one; `PageHeader.NoTrail` suppresses the whole trail on the two roots.
so no page constructor names it and no handler registers one; `PageHeader.NoTrail` suppresses the whole trail on the two roots. A view that would otherwise replace a region of its page, and offer a link back, is a page with its own address and trail instead (the member invoice and the domain claim are).
### Below `lg`
@@ -619,7 +619,7 @@ What holds it: `member-console lint` fails a template that renders an
`<h1>`, an `<h2>` (`raw-section-title`, everywhere but
`ui_section_header.html` and the shell's confirm dialog), a `.badge`, or a
centered empty block outside the parts, an
`hx-confirm`, a load-triggered fetch, an em dash in copy, a heading skip, a page body without the header,
`hx-confirm`, a load-triggered fetch, an em dash in copy, a heading skip, a back link (`back-link`: "Back to" or a left-pointing mark in a template's text or attribute values), a page body without the header,
an alert class, a `role="alert"` or a `data-bs-dismiss="alert"` outside the
notice part (`raw-notice`), or an Actions column without its treatment (`actions-column`: the table's
`align-middle`, `text-end` on the header and on every cell holding a
+6 -4
View File
@@ -203,7 +203,8 @@ While a claim is pending:
and stops the polling workflow — a mistyped domain no longer squats the
name for the full window.
- The instructions stay reachable from the sites list's pending banner and
from the Domains page; at most 5 claims may be pending per workspace.
from the Domains section's claims list, where each claim's root links to
its page; at most 5 claims may be pending per workspace.
Walking this flow against a real zone (and the wildcard-record trap that makes a
correct setup look broken) is documented in
@@ -250,9 +251,10 @@ never held past its window by an accident of the console's own. It runs once at
every boot regardless of whether Temporal is configured, and on the interval
above wherever it is.
The **Domains page** (`/domains`) lists the workspace's claims with
per-claim status and placement counts, hosts the DNS instructions, and
releases claims that no longer hold any site. Name policy (reserved,
The **Domains section** of the sites card lists the workspace's claims with
per-claim status and placement counts and releases claims that no longer hold
any site; each claim's root links to its own page (`/domains/claims/{id}`),
which hosts the DNS instructions. `/domains` itself redirects to the section. Name policy (reserved,
blocked, and premium labels under shared domains, plus a built-in
single-letter guard) is operator data in `domains.name_rules`; members see
policy refusals as a plain "unavailable".
+2 -1
View File
@@ -323,7 +323,8 @@ checks, and `make lint-templates` is a sixth that runs on its own:
`raw-page-title`, `raw-section-title`, `raw-badge`, `raw-empty-state`,
`raw-form-control`, `form-without-part`, `disabled-outside-part`,
`table-without-list-controls`, `actions-column`, `hx-confirm`,
`load-fetch`, `heading-skip`, `raw-notice` (a notice written outside the
`load-fetch`, `heading-skip`, `back-link` (a "Back to" or a left-pointing mark in a
template's text or attribute values), `raw-notice` (a notice written outside the
notice part, in a template or a Go literal; it has no allowlist).
Templates not yet rebuilt on the parts are listed in
`internal/lint/anatomy_allowlist.txt`, which only shrinks:
+10
View File
@@ -855,6 +855,9 @@ legend.form-label {
* a section summary keeps the disclosure marker beside its heading. */
.app-page-header-text {
min-width: 0;
/* A long name, such as a domain, has no break opportunity of its own; it
wraps inside the viewport instead of running past it. */
overflow-wrap: anywhere;
}
.app-section-header > summary,
summary.app-section-header {
@@ -930,3 +933,10 @@ a.card:hover {
.app-rules-table .app-rules-group:hover > * {
--bs-table-bg-state: transparent;
}
/* The records table's badges wrap, so a status badge does not set the Status
column's width at 390px and leave the names a narrow column. */
.domain-records-table .badge {
white-space: normal;
text-align: start;
}
+1 -1
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
// Copy-to-clipboard for `.js-copy` buttons, loaded by the Domains page only
// Copy-to-clipboard for `.js-copy` buttons, loaded by the claim page
// (domains-registry D9).
//
// Delegated on document so it survives the claim status view's 5s HTMX
+2 -4
View File
@@ -40,10 +40,8 @@
<div class="container-xxl px-0">
{{ template "pageHeader" .Header }}
<!-- Composed on the server (page-anatomy "A page arrives complete");
the id stays the swap target, and the region titles itself
(Invoices list or one invoice's detail) so the heading follows
the swap. -->
<!-- Composed on the server (page-anatomy "A page arrives complete"):
the region holds the invoices list. -->
<div id="billing-content">{{ .Invoices }}</div>
</div>
</main>
@@ -0,0 +1,54 @@
{{- /* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial */ -}}
{{- /* SPDX-FileCopyrightText: 2025-2026 Christian Galo */ -}}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ .Detail.Title }} - {{ deploymentName }}</title>
<meta name="description" content="Console for {{ deploymentName }} members">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="htmx-config" content='{"includeIndicatorCSS": false, "noSwap": [204, 304, 403, "5xx"], "defaultSettleDelay": 0}'>
<link href="/static/bootstrap.css" rel="stylesheet">
<script defer src="/static/bootstrap.bundle.js"></script>
<script defer src="/static/shell.js"></script>
<script defer src="/static/htmx.min.js"></script>
<script defer src="/static/error-handler.js"></script>
<script defer src="/static/success-toast.js"></script>
<script defer src="/static/confirm-action-modal.js"></script>
<script defer src="/static/help-init.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="manifest" href="/static/site.webmanifest">
<link href="/static/app.css" rel="stylesheet">
</head>
<body class="d-flex flex-column vh-100">
{{ template "shell_topbar.html" .Shell }}
<div class="d-flex flex-column flex-lg-row flex-grow-1">
{{ template "shell_rail_member.html" .Shell }}
<!-- Main Content (page-anatomy "Every page has one main landmark") -->
<main id="member-main" class="flex-fill p-4">
<div class="container-xxl px-0">
{{ template "pageHeader" .Header }}
{{ template "member_invoice_detail.html" .Detail }}
</div>
</main>
</div>
{{ template "shell_toasts.html" .Shell }}
{{ template "shell_confirm_modal.html" . }}
</body>
</html>
@@ -0,0 +1,55 @@
{{- /* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial */ -}}
{{- /* SPDX-FileCopyrightText: 2025-2026 Christian Galo */ -}}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ .Claim.Domain }} - {{ deploymentName }}</title>
<meta name="description" content="Console for {{ deploymentName }} members">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="htmx-config" content='{"includeIndicatorCSS": false, "noSwap": [204, 304, 403, "5xx"], "defaultSettleDelay": 0}'>
<link href="/static/bootstrap.css" rel="stylesheet">
<script defer src="/static/bootstrap.bundle.js"></script>
<script defer src="/static/shell.js"></script>
<script defer src="/static/htmx.min.js"></script>
<script defer src="/static/error-handler.js"></script>
<script defer src="/static/success-toast.js"></script>
<script defer src="/static/confirm-action-modal.js"></script>
<script defer src="/static/help-init.js"></script>
<script defer src="/static/copy-button.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="manifest" href="/static/site.webmanifest">
<link href="/static/app.css" rel="stylesheet">
</head>
<body class="d-flex flex-column vh-100">
{{ template "shell_topbar.html" .Shell }}
<div class="d-flex flex-column flex-lg-row flex-grow-1">
{{ template "shell_rail_member.html" .Shell }}
<!-- Main Content (page-anatomy "Every page has one main landmark") -->
<main id="member-main" class="flex-fill p-4">
<div class="container-xxl px-0">
{{ template "pageHeader" .Header }}
{{ template "member_domains_claim.html" .Claim }}
</div>
</main>
</div>
{{ template "shell_toasts.html" .Shell }}
{{ template "shell_confirm_modal.html" . }}
</body>
</html>
+4 -5
View File
@@ -54,11 +54,10 @@
{{/* Pending domain claims (dissolve-member-domains): the durable
re-entry point for an in-flight DNS verification now that the
standalone Domains page is gone. Server-side conditional: no
empty chrome when there is nothing pending. Opening a claim swaps
the claim-status partial into this .domains-surface wrapper, which
the notice no longer is; reopening mints nothing (pure read). */}}
empty chrome when there is nothing pending. The notice links to each
claim's page; reopening mints nothing (pure read). */}}
{{ if not .PendingClaimsNotice.Empty }}
<div class="domains-surface mt-3">{{ template "notice" .PendingClaimsNotice }}</div>
<div class="mt-3">{{ template "notice" .PendingClaimsNotice }}</div>
{{ end }}
{{ template "sectionHeader" .AccountHeader }}
<div class="card mb-3">
@@ -131,4 +130,4 @@
{{ define "checkoutReturnWords" }}<strong>Thanks!</strong> We're finalizing your upgrade; this can take a moment. <a href="/products">View your plan on the Products page</a>.{{ if .Shown }}<div class="mt-1">{{ range $i, $s := .Sentences }}{{ if $i }} {{ end }}{{ $s }}{{ end }}</div>{{ end }}{{ end }}
{{/* The pending claims' words: the bold lead and one row per claim. */}}
{{ define "pendingClaimsWords" }}<strong>Domain verification in progress.</strong>{{ range . }}<div class="mt-1"><code class="text-break">{{ .Root }}</code> <button type="button" class="btn btn-link" hx-get="{{ routeURL "/partials/domains/claims/{claimID}" .ClaimID }}" hx-target="closest .domains-surface" hx-swap="innerHTML">View DNS records</button></div>{{ end }}{{ end }}
{{ define "pendingClaimsWords" }}<strong>Domain verification in progress.</strong>{{ range . }}<div class="mt-1"><code class="text-break">{{ .Root }}</code> <a class="btn btn-link" href="{{ routeURL "/domains/claims/{claimID}" .ClaimID }}">View DNS records</a></div>{{ end }}{{ end }}
@@ -2,10 +2,9 @@
{{- /* SPDX-FileCopyrightText: 2025-2026 Christian Galo */ -}}
<!-- Workspace domain claims (dissolve-member-domains): rendered at point of
use — embedded by any host that wraps it in a .domains-surface container
(the sites surface today, the dashboard's pending notice). Every action
targets `closest .domains-surface`, so multiple hosts can coexist on one
page and the host never reloads. Adding an external domain is NOT
use, inside the sites card's .domains-surface container, which Release
swaps the claims list into. Each claim's root links to its page, where
the DNS records and status live. Adding an external domain is NOT
offered here — it starts only from the site-creation flow. The release
button is hx-post: a native form POST would fail CSRF (Origin is null
under the no-referrer policy), while HTMX inherits the page's
@@ -29,16 +28,11 @@
<tbody>
{{ range .Claims }}
<tr>
<th scope="row"><code class="text-break">{{ .Root }}</code></th>
<th scope="row"><a href="{{ routeURL "/domains/claims/{claimID}" .ClaimID }}"><code class="text-break">{{ .Root }}</code></a></th>
<td>{{ template "statusBadge" .KindBadge }}</td>
<td>{{ template "statusBadge" .StatusBadge }}</td>
<td>{{ .Placements }}</td>
<td class="text-end">
{{ if .External }}
<button type="button" class="btn btn-outline-secondary btn-sm ms-1"
hx-get="{{ routeURL "/partials/domains/claims/{claimID}" .ClaimID }}" hx-target="closest .domains-surface"
hx-swap="innerHTML">{{ if .Pending }}DNS records{{ else }}Details{{ end }}</button>
{{ end }}
{{ if .CanRelease }}
<!-- Release is offered only for a claim holding no name; the
registry re-checks under its lock, so a placement created in
@@ -2,30 +2,22 @@
{{- /* SPDX-FileCopyrightText: 2025-2026 Christian Galo */ -}}
<!-- One claim's DNS instructions and per-record probe state (domains-registry
D9); the same view pattern integration create flows embed. While the
claim is pending this element polls its own GET route every 5s and swaps
itself (outerHTML) — the established in-place pattern: no page reload, no
inline script, and the mutating buttons inherit the page's
cross-origin protection, which needs no token. Reopening this view is a pure read: it
re-initiates nothing and mints no new records. -->
D9): the body of the claim page (domain_claim.html), which carries the
domain as its title, and the swap target of its own refresh and buttons.
While the claim is pending this element polls its own GET route every 5s
and swaps itself (outerHTML) — the established in-place pattern: no page
reload, no inline script, and the mutating buttons inherit the page's
cross-origin protection, which needs no token. Reopening this view is a
pure read: it re-initiates nothing and mints no new records. -->
<div class="domain-claim-status" {{ if .Polling }}hx-get="{{ routeURL "/partials/domains/claims/{claimID}" .ClaimID }}"
hx-trigger="every 5s" hx-swap="outerHTML" {{ end }}>
<div class="mb-3">
<button type="button" class="btn btn-link p-0 text-decoration-none" hx-get="/partials/domains/claims"
hx-target="closest .domains-surface" hx-swap="innerHTML">&larr; Back to domains</button>
{{/* An instance title inside the sites card's domains surface, under
that card's own section header, so it is an h3.h6, the composite's
pool-card idiom (overview-consistency D9). */}}
<h3 class="mt-2 mb-0 h6"><code class="text-break">{{ .Domain }}</code></h3>
</div>
{{ template "notice" .Error }}
{{ if not .Outcome.Empty }}{{ template "notice" .Outcome }}
{{ else }}
<p>To connect <strong>{{ .Domain }}</strong>, add these records at your DNS provider:</p>
<div class="table-responsive">
<table class="table table-sm align-middle mb-2">
<table class="table table-sm align-middle mb-2 domain-records-table">
<thead>
<tr>
<th scope="col">Record</th>
@@ -36,14 +28,14 @@
<tbody>
{{ range .Records }}
<tr>
<td class="text-nowrap">
<td>
{{ template "statusBadge" .RecordKindBadge }}
<div class="form-text">{{ .Purpose }}</div>
</td>
<td>
<div class="small text-muted">Name</div>
<div class="d-flex align-items-start gap-1">
<code class="text-break">{{ .Name }}</code>
<code class="text-break">{{ breakAtDots .Name }}</code>
<button type="button" class="btn btn-link btn-sm p-0 js-copy" data-copy="{{ .Name }}" title="Copy"
aria-label="Copy record name">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16"><path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1z"/><path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0z"/></svg>
@@ -51,7 +43,7 @@
</div>
<div class="small text-muted mt-1">Value</div>
<div class="d-flex align-items-start gap-1">
<code class="text-break">{{ .Value }}</code>
<code class="text-break">{{ breakAtDots .Value }}</code>
<button type="button" class="btn btn-link btn-sm p-0 js-copy" data-copy="{{ .Value }}" title="Copy"
aria-label="Copy record value">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16"><path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1z"/><path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0z"/></svg>
@@ -2,17 +2,11 @@
{{- /* SPDX-FileCopyrightText: 2025-2026 Christian Galo */ -}}
{{/* member_invoice_detail.html
One invoice's detail, swapped into #billing-content in place of the
invoices list. It replaces the Invoices section, so its title is that
section's title and comes from sectionHeader (overview-consistency
D9); the status badge sits on the line below with the Stripe number
and the period. The back control is a swap, not navigation (the URL
never changes), so it stays a link-styled button rather than a
location trail. States render through statusBadge. */}}
One invoice's detail, the body of the invoice page (billing_invoice.html),
which carries the title and the location trail. The status badge sits
first with the Stripe number and the period. States render through
statusBadge. */}}
<div class="mb-3">
<button type="button" class="btn btn-link p-0 text-decoration-none" hx-get="/partials/member/invoices"
hx-target="#billing-content" hx-swap="innerHTML">&larr; Back to invoices</button>
{{ template "sectionHeader" .Header }}
<div class="d-flex flex-wrap align-items-center gap-2">
{{ template "statusBadge" .StatusBadge }}
{{ if .StripeInvoiceNumber }}<span class="text-body-secondary small">Stripe invoice {{ .StripeInvoiceNumber }}</span>{{ end }}
@@ -2,9 +2,8 @@
{{- /* SPDX-FileCopyrightText: 2025-2026 Christian Galo */ -}}
{{/* member_invoices.html
The member Billing page's invoices region, swapped into
#billing-content (the region titles itself so the heading follows
the list/detail swaps). Rows navigate through the invoice number
The member Billing page's invoices region, composed server-side into
#billing-content (the region titles itself). Rows navigate through the invoice number
(chrome-conventions "Row navigation is the primary column's link");
an unissued invoice navigates through "Unnumbered", matching the
operator list. States render through statusBadge via the same
@@ -31,9 +30,9 @@
<tr>
<th scope="row">
{{ if .InvoiceNumber }}
<a href="#" hx-get="{{ routeURL "/partials/member/invoices/{invoiceID}" .InvoiceID }}" hx-target="#billing-content" hx-swap="innerHTML">{{ .InvoiceNumber }}</a>
<a href="{{ routeURL "/billing/invoices/{invoiceID}" .InvoiceID }}">{{ .InvoiceNumber }}</a>
{{ else }}
<a href="#" hx-get="{{ routeURL "/partials/member/invoices/{invoiceID}" .InvoiceID }}" hx-target="#billing-content" hx-swap="innerHTML">Unnumbered</a> {{ template "helpIcon" (helpIcon "Unnumbered" "A reference number is assigned when the invoice is issued.") }}
<a href="{{ routeURL "/billing/invoices/{invoiceID}" .InvoiceID }}">Unnumbered</a> {{ template "helpIcon" (helpIcon "Unnumbered" "A reference number is assigned when the invoice is issued.") }}
{{ end }}
</th>
<td>{{ .Period }}</td>
@@ -12,7 +12,9 @@
the shared shell_rail_account.html (mobile-shell-menu D1, D8); at lg
and up it is hidden and the static rail carries task destinations and
the switch only. The entry list's padding lives on the offcanvas body,
so both lists sit at one inset. */}}
so both lists sit at one inset. The Active entry carries aria-current="page"
on the page it names and aria-current="true" on a page below it (the
entry is the current section, not the current page). */}}
<aside id="app-rail" class="app-sidebar offcanvas-lg offcanvas-start bg-light border-end flex-shrink-0" tabindex="-1" aria-labelledby="app-rail-label">
<div class="offcanvas-header">
<span class="offcanvas-title" id="app-rail-label">{{ deploymentName }}</span>
@@ -20,9 +22,9 @@
</div>
<div class="offcanvas-body p-3">
<ul class="nav flex-column">
<li class="nav-item"><a class="nav-link{{ if eq .Active "dashboard" }} active{{ end }}" {{ if eq .Active "dashboard" }}aria-current="page" {{ end }}href="/">Dashboard</a></li>
<li class="nav-item"><a class="nav-link{{ if eq .Active "products" }} active{{ end }}" {{ if eq .Active "products" }}aria-current="page" {{ end }}href="/products">Products</a></li>
<li class="nav-item"><a class="nav-link{{ if eq .Active "billing" }} active{{ end }}" {{ if eq .Active "billing" }}aria-current="page" {{ end }}href="/billing">Billing</a></li>
<li class="nav-item"><a class="nav-link{{ if eq .Active "dashboard" }} active{{ end }}" {{ if eq .Active "dashboard" }}aria-current="{{ if .BelowActive }}true{{ else }}page{{ end }}" {{ end }}href="/">Dashboard</a></li>
<li class="nav-item"><a class="nav-link{{ if eq .Active "products" }} active{{ end }}" {{ if eq .Active "products" }}aria-current="{{ if .BelowActive }}true{{ else }}page{{ end }}" {{ end }}href="/products">Products</a></li>
<li class="nav-item"><a class="nav-link{{ if eq .Active "billing" }} active{{ end }}" {{ if eq .Active "billing" }}aria-current="{{ if .BelowActive }}true{{ else }}page{{ end }}" {{ end }}href="/billing">Billing</a></li>
{{ if .IsOperator }}
<li class="nav-item app-rail-switch"><a class="nav-link" href="/operator">Operator panel</a></li>
{{ end }}
@@ -17,9 +17,9 @@
<div class="app-page-header-text">
{{ if not .NoTrail }}<nav aria-label="breadcrumb"><ol class="breadcrumb small mb-1">
{{ with surfaceRoot }}<li class="breadcrumb-item"><a href="{{ .URL }}">{{ .Label }}</a></li>{{ end }}{{ range .Crumbs }}<li class="breadcrumb-item"><a href="{{ .URL }}">{{ .Label }}</a></li>{{ end }}
<li class="breadcrumb-item active" aria-current="page">{{ .Title }}</li>
<li class="breadcrumb-item active" aria-current="page">{{ breakAtDots .Title }}</li>
</ol></nav>{{ end }}
<h1 class="h2 mb-0">{{ .Title }}</h1>
<h1 class="h2 mb-0">{{ breakAtDots .Title }}</h1>
{{ if .Lead }}<p class="text-body-secondary mb-0">{{ .Lead }}</p>{{ end }}
</div>
{{/* A page header's action navigates, so it is always outline-secondary
@@ -16,7 +16,7 @@
{{ else }}
<p>To connect <strong>{{ .Domain }}</strong>, add these records at your DNS provider:</p>
<div class="table-responsive">
<table class="table table-sm align-middle mb-2">
<table class="table table-sm align-middle mb-2 domain-records-table">
<thead>
<tr>
<th scope="col">Record</th>
@@ -27,21 +27,21 @@
<tbody>
{{ range .Records }}
<tr>
<td class="text-nowrap">
<td>
{{ template "statusBadge" .RecordKindBadge }}
<div class="form-text">{{ .Purpose }}</div>
</td>
<td>
<div class="small text-muted">Name</div>
<div class="d-flex align-items-start gap-1">
<code class="text-break">{{ .Name }}</code>
<code class="text-break">{{ breakAtDots .Name }}</code>
<button type="button" class="btn btn-link btn-sm p-0 js-copy" data-copy="{{ .Name }}" title="Copy" aria-label="Copy record name">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16"><path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1z"/><path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0z"/></svg>
</button>
</div>
<div class="small text-muted mt-1">Value</div>
<div class="d-flex align-items-start gap-1">
<code class="text-break">{{ .Value }}</code>
<code class="text-break">{{ breakAtDots .Value }}</code>
<button type="button" class="btn btn-link btn-sm p-0 js-copy" data-copy="{{ .Value }}" title="Copy" aria-label="Copy record value">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16"><path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1z"/><path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0z"/></svg>
</button>
@@ -200,8 +200,8 @@
managed where sites live, under their own labeled, addressable section —
id="domains" is the fragment anchor /domains redirects to. The container
holds the core claims partial and is the .domains-surface wrapper
its actions re-target, so kind/status/placement rows, DNS-instruction
links, and the placement-guarded release all work inline here. Adding an
its actions re-target: the claims list and the placement-guarded release
stay in the card, and each claim's root links to its page. Adding an
external domain stays in the create form above. The surface is composed
on the server from core's /partials/domains/claims (page-anatomy "A page
arrives complete"); the wrapper class is what its actions re-target. -->
+38 -10
View File
@@ -28,9 +28,9 @@ import (
// and every form through the two form parts (spec form-library); these
// rules fail a template that renders them any other way, plus the copy
// rules the design system states (no hx-confirm, no em dashes in copy, no
// filler phrases, no heading skips) and the record-table treatment of an
// Actions column (actions-column). Templates listed in the allowlist are
// reported, not failed, until they are rebuilt on the parts; the allowlist
// filler phrases, no heading skips, no back link) and the record-table
// treatment of an Actions column (actions-column). Templates listed in the
// allowlist are reported, not failed, until they are rebuilt on the parts; the allowlist
// only shrinks, and is empty once every page is (forms-library, 2026-09).
const (
@@ -87,11 +87,17 @@ var (
// attribute that happens to contain the substring) does not false-fire.
buttonTagRe = regexp.MustCompile(`<button\b[^>]*>`)
disabledTokenRe = regexp.MustCompile(`(^|[^\w-])disabled($|[^\w-])`)
hxConfirmRe = regexp.MustCompile(`\bhx-confirm=`)
hxDisinheritRe = regexp.MustCompile(`\bhx-disinherit=`)
htmx2CompatRe = regexp.MustCompile(`htmx-2-compat`)
htmxOldEventRe = regexp.MustCompile(`htmx:[a-z]+[A-Z][a-zA-Z]*`)
loadFetchRe = regexp.MustCompile(`hx-trigger="[^"]*\bload\b`)
// backLinkRe is the words of a back link: "Back" and "To" or "to"
// separated by whitespace, a non-breaking space (which RE2's \s does not
// match) or a line break, at a word boundary so "Feedback to the team"
// does not fire. The left-pointing marks, the back link's other half, are
// matched as characters in backLink.
backLinkRe = regexp.MustCompile(`\bBack[\s\x{00A0}]+[Tt]o\b`)
hxConfirmRe = regexp.MustCompile(`\bhx-confirm=`)
hxDisinheritRe = regexp.MustCompile(`\bhx-disinherit=`)
htmx2CompatRe = regexp.MustCompile(`htmx-2-compat`)
htmxOldEventRe = regexp.MustCompile(`htmx:[a-z]+[A-Z][a-zA-Z]*`)
loadFetchRe = regexp.MustCompile(`hx-trigger="[^"]*\bload\b`)
// (?s) so a multi-line {{/* comment */}} or {{ if ... }} block strips as
// one unit: html.Tokenizer has no notion of Go template syntax, so a
// comment spanning several source lines is otherwise left partly in the
@@ -273,7 +279,7 @@ var bodyTemplateRe = regexp.MustCompile(`BodyTemplate\s*[:=]\s*"([a-z_]+\.html)"
// memberRootPages are the member surface's page templates, parsed from the
// templates root rather than named by a BodyTemplate.
var memberRootPages = []string{"index.html", "products.html", "billing.html"}
var memberRootPages = []string{"index.html", "products.html", "billing.html", "billing_invoice.html", "domain_claim.html"}
// pageBodyTemplates returns the set of template base names that render as a
// page: every BodyTemplate literal in Go source under the given dirs plus
@@ -478,7 +484,11 @@ func anatomyViolations(path, src string, isPageBody bool) []Violation {
}
}
}
(&templateTokenRules{add: add}).scan(src)
// The tokenizer has no notion of {{/* */}}, so a template comment that
// quotes a tag would be split at the tag and its words read as text; the
// copy blanks every comment first, keeping newlines so lines hold.
uncommented, _ := blankComments(src)
(&templateTokenRules{add: add}).scan(uncommented)
return v
}
@@ -603,6 +613,7 @@ func (r *templateTokenRules) scan(src string) {
func (r *templateTokenRules) text(line int, raw string) {
text := templateActRe.ReplaceAllString(raw, "")
r.backLink(line, html.UnescapeString(text))
if emDashCopy(text) {
r.add(line, "em-dash-copy", emDashCopyMsg)
}
@@ -623,6 +634,7 @@ func (r *templateTokenRules) tag(line int, tz *html.Tokenizer) {
for hasAttr {
key, val, more := tz.TagAttr()
text := templateActRe.ReplaceAllString(string(val), "")
r.backLink(line, text)
if emDashCopy(text) {
r.add(line, "em-dash-copy", fmt.Sprintf("%s copy uses an em dash; write it as a semicolon, colon, or comma", string(key)))
}
@@ -633,6 +645,22 @@ func (r *templateTokenRules) tag(line int, tz *html.Tokenizer) {
}
}
// backLinkMarks are the left-pointing marks that make a back link.
const backLinkMarks = "←⟵⇐‹«"
// backLinkMsg is back-link's message.
const backLinkMsg = `renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page`
// backLink reports back-link once for a text node or attribute value that
// reads "Back to" or carries a left-pointing mark. The caller hands it the
// text with template actions removed and character references decoded, so
// "&larr;" and "&laquo;" count as marks.
func (r *templateTokenRules) backLink(line int, text string) {
if backLinkRe.MatchString(text) || strings.ContainsAny(text, backLinkMarks) {
r.add(line, "back-link", backLinkMsg)
}
}
// --- copy -------------------------------------------------------------------
// emDashCopyMsg is em-dash-copy's message for a text node and a Go literal;
+12
View File
@@ -7,6 +7,18 @@ templates/partials/operator_actions.html:6: [actions-column] renders a button in
templates/partials/operator_actions_open.html:2: [actions-column] heads an Actions column that is not the table's last; verbs render in the trailing column (chrome-conventions "Row navigation is the primary column's link")
templates/partials/operator_actions_open.html:4: [actions-column] holds a row's control in a cell without text-end; the Actions cells are right-aligned (design-system.md §6)
templates/partials/operator_actions_open.html:4: [actions-column] renders a button in an Actions cell without ms-1; buttons in an Actions cell are spaced with ms-1 (design-system.md §6)
templates/partials/operator_back_link.html:1: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:2: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:3: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:4: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:5: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:13: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:14: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:16: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:17: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:18: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:19: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_back_link.html:20: [back-link] renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page
templates/partials/operator_copy.html:1: [raw-page-title] renders an <h1> outside the pageHeader part; build a server.PageHeader and {{ template "pageHeader" ... }} (design-system.md §6)
templates/partials/operator_copy.html:14: [hx-confirm] uses hx-confirm; the shared confirm modal is the rule (design-system.md §3)
templates/partials/operator_copy.html:15: [load-fetch] fetches first-paint content after load; compose the region on the server with server.Include (page-anatomy "A page arrives complete"); polling (`every Ns`) is the exception
+23
View File
@@ -49,6 +49,29 @@ var verdictTemplates = map[string]string{
</div>
<h5
class="h6">Two levels down, on a tag over two lines</h5>
`,
// back-link: the words and the arrow, in text and in attribute values,
// reported once per node; comments and look-alikes stay silent.
"partials/operator_back_link.html": `<button type="button" class="btn btn-link" hx-get="/partials/x">&larr; Back to things</button>
<a href="/x">&larr; Things</a>
<span>← Things</span>
<a href="/x" aria-label="← Things">x</a>
<span title="Back to list">x</span>
{{/* Back to the list */}}
<!-- &larr; Back to top -->
<p>Feedback to the team</p>
<p>back to back</p>
<a href="/">{{ "Back to the dashboard" }}</a>
{{/* the old <button> read "Back to domains" */}}
{{/* removed: the <h3> and the &larr; arrow */}}
<a href="/a">Back&nbsp;to invoices</a>
<a href="/b">Back
to invoices</a>
<a href="/d">Back To Invoices</a>
<a href="/e">&laquo; Invoices</a>
<a href="/f">&lsaquo; Invoices</a>
<a href="/g">⟵ Invoices</a>
<a href="/h">&lArr; Invoices</a>
`,
// The parts render what they own.
"partials/ui_page_header.html": `{{ define "pageHeader" }}<h1 class="h2 mb-0">{{ .Title }}</h1>{{ end }}`,
+27 -14
View File
@@ -64,9 +64,9 @@ type Link struct {
}
// PageHeader is what the pageHeader part renders: the page title at the one
// size, an optional back affordance above it, an optional one-sentence lead
// below it, and one right-hand slot holding either a muted count or one
// action control.
// size, an optional location trail above it, an optional
// one-sentence lead below it, and one right-hand slot holding either a muted
// count or one action control.
type PageHeader struct {
Title string
Lead string
@@ -1397,7 +1397,9 @@ func (q DeliveryQueue) DeadLetterReadout() Readout {
// Member pages are titled by pageHeader. The dashboard is the member
// surface's root (with OperatorPageData.LandingHeader, one of exactly two
// pages that carry no trail); Products and Billing are rail-entry pages and
// carry the trail rooted at the surface (design D18).
// carry the trail rooted at the surface (design D18). The invoice page sits
// below Billing and the domain claim page below the dashboard, so their
// trails run one crumb past the entry.
func (IndexPageData) Header() PageHeader {
// Workspaces are deliberately absent from the lead: the feature is not
@@ -1444,9 +1446,8 @@ func (BillingPageData) Header() PageHeader {
return PageHeader{Title: "Billing", Lead: "Your invoice and payment history."}
}
// Member invoices region (swapped into #billing-content, so the region
// titles itself and the title survives the list/detail swaps as part of
// each partial).
// Member invoices region (composed server-side into #billing-content, so the
// region titles itself as part of its partial).
func (d MemberInvoicesData) Header() SectionHeader {
h := SectionHeader{Title: "Invoices"}
@@ -1471,15 +1472,27 @@ func (d MemberInvoiceDetailData) StatusBadge() Badge {
return StatusBadge(d.StatusState)
}
// Header titles the detail view. The detail replaces the Invoices section
// inside #billing-content, so its title is that section's title
// (overview-consistency D9). An invoice with no number yet is titled plain
// "Invoice", with the help icon carrying when the number arrives.
func (d MemberInvoiceDetailData) Header() SectionHeader {
// Title is the invoice page's title: "Invoice" and the invoice's number, or
// plain "Invoice" before the invoice has a number.
func (d MemberInvoiceDetailData) Title() string {
if d.InvoiceNumber == "" {
return SectionHeader{Title: "Invoice", Help: "Assigned when the invoice is issued."}
return "Invoice"
}
return SectionHeader{Title: "Invoice " + d.InvoiceNumber}
return "Invoice " + d.InvoiceNumber
}
// Header is the invoice page's header. It produces the trail
// "Home / Billing / Invoice {number}": the surface root, the Billing rail
// entry as the one intermediate crumb, and the title as the current page.
func (d MemberInvoicePageData) Header() PageHeader {
return PageHeader{Title: d.Detail.Title(), Crumbs: []Link{{Label: "Billing", URL: "/billing"}}}
}
// Header is the claim page's header: the claim's root is the title, and with
// no Crumbs the trail reads "Home / {root}", because the claim sits under the
// surface root itself.
func (d MemberDomainClaimPageData) Header() PageHeader {
return PageHeader{Title: d.Claim.Domain}
}
func (MemberInvoiceDetailData) LineItemsHeader() SectionHeader {
+1 -1
View File
@@ -298,7 +298,7 @@ func TestMemberInvoicesListedByIssueAcrossAccounts(t *testing.T) {
t.Errorf("member invoices are not in issue order across both accounts:\n%s", list)
}
detail := get("/partials/member/invoices/" + mayID)
detail := get("/billing/invoices/" + mayID)
if !strings.Contains(detail, "May 3, 2026") {
t.Errorf("the payment is not dated by its paid time:\n%s", detail)
}
+21 -13
View File
@@ -208,10 +208,11 @@ func TestOrgCompositeBillingSummaryRendersInvoiceNumber(t *testing.T) {
// TestMemberInvoiceTemplatesRenderNumber covers member-invoice-history: the
// list leads each row with the platform-assigned invoice number (including
// a grandfathered Stripe-format one, rendered the same way), and the detail
// heading is "Invoice {number}" with Stripe's own number, when the mapping
// carries one, as a secondary "Stripe invoice ..." line; both fall back to
// the empty-value marker and tooltip before issuance.
// a grandfathered Stripe-format one, rendered the same way) as a link to the
// invoice's page, and the page is titled "Invoice {number}" with Stripe's own
// number, when the mapping carries one, as a secondary "Stripe invoice ..."
// line; the list falls back to the empty-value marker and tooltip before
// issuance, and the page to the title "Invoice".
func TestMemberInvoiceTemplatesRenderNumber(t *testing.T) {
tmpl := MemberSet(t)
@@ -230,17 +231,21 @@ func TestMemberInvoiceTemplatesRenderNumber(t *testing.T) {
{InvoiceID: "inv-3", InvoiceNumber: "A1B2C3D4-0001", Period: "Jul 1, 2026 – Jul 31, 2026", AmountDue: "USD 20.00", AmountPaid: "USD 20.00", Currency: "USD", Status: "paid", StatusState: "paid"},
},
})
if !strings.Contains(listOut, `hx-target="#billing-content" hx-swap="innerHTML">0042</a>`) {
if !strings.Contains(listOut, `href="/billing/invoices/inv-1">0042</a>`) {
t.Errorf("populated invoice number must lead the row as the row's link (chrome-conventions row navigation), got:\n%s", listOut)
}
if !strings.Contains(listOut, `hx-target="#billing-content" hx-swap="innerHTML">A1B2C3D4-0001</a>`) {
if !strings.Contains(listOut, `href="/billing/invoices/inv-3">A1B2C3D4-0001</a>`) {
t.Errorf("a grandfathered Stripe-format number must lead the row as the link too, got:\n%s", listOut)
}
if !strings.Contains(listOut, `>Unnumbered</a>`) || !strings.Contains(listOut, `data-bs-content="A reference number is assigned when the invoice is issued."`) {
if !strings.Contains(listOut, `href="/billing/invoices/inv-2">Unnumbered</a>`) || !strings.Contains(listOut, `data-bs-content="A reference number is assigned when the invoice is issued."`) {
t.Errorf("missing invoice number must render the Unnumbered link with its disclosure popover, got:\n%s", listOut)
}
detailWithNumber := render("member_invoice_detail.html", MemberInvoiceDetailData{
page := func(detail MemberInvoiceDetailData) string {
shell := Shell{Surface: ShellMember, Active: "billing", BelowActive: true}
return render("billing_invoice.html", MemberInvoicePageData{Shell: shell, Detail: detail})
}
detailWithNumber := page(MemberInvoiceDetailData{
InvoiceID: "inv-1",
InvoiceNumber: "0042",
StripeInvoiceNumber: "A1B2C3D4-0001",
@@ -251,14 +256,14 @@ func TestMemberInvoiceTemplatesRenderNumber(t *testing.T) {
Currency: "USD",
Period: "May 1, 2026 – May 31, 2026",
})
if !strings.Contains(detailWithNumber, "0042") || strings.Contains(detailWithNumber, "<code>0042</code>") {
t.Errorf("detail heading must be \"Invoice {number}\" with the platform number as plain text, got:\n%s", detailWithNumber)
if !strings.Contains(detailWithNumber, "<title>Invoice 0042 - ") || !strings.Contains(detailWithNumber, ">Invoice 0042</h1>") || strings.Contains(detailWithNumber, "<code>0042</code>") {
t.Errorf("page title must be \"Invoice {number}\" with the platform number as plain text, got:\n%s", detailWithNumber)
}
if !strings.Contains(detailWithNumber, "Stripe invoice A1B2C3D4-0001") {
t.Errorf("Stripe's number must render as a secondary \"Stripe invoice ...\" line, got:\n%s", detailWithNumber)
}
detailWithoutNumber := render("member_invoice_detail.html", MemberInvoiceDetailData{
detailWithoutNumber := page(MemberInvoiceDetailData{
InvoiceID: "inv-2",
Status: "open",
StatusState: "open",
@@ -267,8 +272,11 @@ func TestMemberInvoiceTemplatesRenderNumber(t *testing.T) {
Currency: "USD",
Period: "Jun 1, 2026 – Jun 30, 2026",
})
if !strings.Contains(detailWithoutNumber, `data-bs-content="Assigned when the invoice is issued."`) {
t.Errorf("absent invoice number must render the disclosure popover in the heading, got:\n%s", detailWithoutNumber)
if !strings.Contains(detailWithoutNumber, "<title>Invoice - ") || !strings.Contains(detailWithoutNumber, ">Invoice</h1>") {
t.Errorf("an invoice with no number must be titled \"Invoice\", got:\n%s", detailWithoutNumber)
}
if strings.Contains(detailWithoutNumber, "Assigned when the invoice is issued.") {
t.Errorf("the page header has no help popover for a missing number, got:\n%s", detailWithoutNumber)
}
if strings.Contains(detailWithoutNumber, "Stripe invoice") {
t.Errorf("no Stripe invoice line must render when the mapping carries no number, got:\n%s", detailWithoutNumber)
+1 -1
View File
@@ -102,7 +102,7 @@ func newPeriodPages(t *testing.T, w *world.World, org world.Org, billingQ billin
func (p *periodPages) memberPage(t *testing.T, invoiceID string) *htmltest.Node {
t.Helper()
rec := authtest.Get(t, p.memberCtx, p.member.GetInvoiceDetail, "/partials/member/invoices/"+invoiceID,
rec := authtest.Get(t, p.memberCtx, p.member.GetInvoicePage, "/billing/invoices/"+invoiceID,
authtest.PathValue("invoiceID", invoiceID))
return htmltest.Parse(t, rec.Body.String())
}
@@ -0,0 +1,189 @@
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
package server_test
// The claim page (domains-registry): GET /domains/claims/{claimID} renders one
// claim's DNS records and status under the dashboard, and answers the styled
// error page when the claim is not the workspace's. The handler is called
// directly so the shell it builds is what renders.
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/htmltest"
)
// claimPage requests the claim page for id with the session ctx carries.
func (env *domainsTestEnv) claimPage(ctx context.Context, id string) *httptest.ResponseRecorder {
req := httptest.NewRequest(http.MethodGet, "/domains/claims/"+id, nil).WithContext(ctx)
req.SetPathValue("claimID", id)
rec := httptest.NewRecorder()
env.handler.GetClaimPage(rec, req)
return rec
}
func TestMemberClaimPageRendersAPendingClaim(t *testing.T) {
env := newDomainsTestEnv(t, "connect.example.test", true)
workspace := newDomainsWorkspace(t, env.database, "page")
sctx := env.sessionFor(t, workspace)
root := fmt.Sprintf("page%d.example", time.Now().UnixNano())
claim, err := env.registry.ClaimExternal(context.Background(), workspace, root)
if err != nil {
t.Fatalf("claim: %v", err)
}
rec := env.claimPage(sctx, claim.ClaimID)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d, want 200\n%s", rec.Code, rec.Body.String())
}
body := rec.Body.String()
page := htmltest.Parse(t, body)
if got := page.One(t, "h1").Text(); got != root {
t.Errorf("h1 = %q, want the claim's root %q", got, root)
}
if got := page.One(t, "title").Text(); !strings.HasPrefix(got, root+" - ") {
t.Errorf("title = %q, want it to start %q", got, root+" - ")
}
if got := page.One(t, "nav[aria-label=breadcrumb] ol").Text(); got != "Home "+root {
t.Errorf("trail = %q, want \"Home %s\"", got, root)
}
entry := page.One(t, `#app-rail a.nav-link[href="/"]`)
if !entry.HasClass("active") {
t.Errorf("the rail's Dashboard entry is not marked active: %s", entry.HTML())
}
if got, _ := entry.Attr("aria-current"); got != "true" {
t.Errorf("the rail's Dashboard entry aria-current = %q, want \"true\" (the current section, not the page): %s", got, entry.HTML())
}
if got := page.Count(`[aria-current="page"]`); got != 1 {
t.Errorf("the page has %d current-page markers, want the trail's one", got)
}
text := page.Text()
for _, want := range []string{"Waiting for your DNS records…", "Check now", "Cancel verification", "*." + root, claim.Token} {
if !strings.Contains(text, want) {
t.Errorf("the claim page is missing %q", want)
}
}
page.One(t, "table")
if got := page.Count("#confirmActionModal"); got != 1 {
t.Errorf("the page renders %d confirm modals, want one", got)
}
cancel := page.One(t, `.domain-claim-status button[data-bs-target="#confirmActionModal"]`)
if got, _ := cancel.Attr("data-action-target"); got != "closest .domain-claim-status" {
t.Errorf("the cancel trigger targets %q", got)
}
if got, _ := cancel.Attr("data-action-swap"); got != "outerHTML" {
t.Errorf("the cancel trigger swaps %q, want outerHTML (a nested view otherwise)", got)
}
checkNow := page.One(t, `.domain-claim-status button[hx-post$="/check"]`)
if got, _ := checkNow.Attr("hx-target"); got != "closest .domain-claim-status" {
t.Errorf("Check now targets %q, want the view itself", got)
}
if got, _ := checkNow.Attr("hx-swap"); got != "outerHTML" {
t.Errorf("Check now swaps %q, want outerHTML", got)
}
root5s := page.One(t, ".domain-claim-status")
if got, _ := root5s.Attr("hx-get"); got != "/partials/domains/claims/"+claim.ClaimID {
t.Errorf("the view refreshes from %q", got)
}
if got, _ := root5s.Attr("hx-trigger"); got != "every 5s" {
t.Errorf("the view refreshes on %q, want every 5s", got)
}
page.One(t, `script[defer][src="/static/copy-button.js"]`)
for _, gone := range []string{"Back to", "&larr;", "←"} {
if strings.Contains(body, gone) {
t.Errorf("the claim page renders %q", gone)
}
}
}
func TestMemberClaimPageRendersATerminalClaimWithoutARefresh(t *testing.T) {
env := newDomainsTestEnv(t, "connect.example.test", true)
workspace := newDomainsWorkspace(t, env.database, "terminal")
sctx := env.sessionFor(t, workspace)
root := fmt.Sprintf("terminal%d.example", time.Now().UnixNano())
claim, err := env.registry.ClaimExternal(context.Background(), workspace, root)
if err != nil {
t.Fatalf("claim: %v", err)
}
activateClaim(t, env.database, claim.ClaimID)
rec := env.claimPage(sctx, claim.ClaimID)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d, want 200", rec.Code)
}
page := htmltest.Parse(t, rec.Body.String())
if got := page.One(t, ".app-notice").Text(); !strings.Contains(got, "is verified") {
t.Errorf("the outcome notice reads %q", got)
}
root5s := page.One(t, ".domain-claim-status")
if _, has := root5s.Attr("hx-trigger"); has {
t.Error("a settled claim still refreshes")
}
page.None(t, "table")
}
// TestMemberClaimPageRefusalsAnswerTheStyledErrorPage: another workspace's
// claim, an unknown id, a malformed id and a urn:uuid spelling of an unknown id
// each answer the same styled 404 page, and a failed read answers the styled
// 500.
func TestMemberClaimPageRefusalsAnswerTheStyledErrorPage(t *testing.T) {
env := newDomainsTestEnv(t, "connect.example.test", true)
owner := newDomainsWorkspace(t, env.database, "owner")
stranger := newDomainsWorkspace(t, env.database, "stranger")
root := fmt.Sprintf("owned%d.example", time.Now().UnixNano())
claim, err := env.registry.ClaimExternal(context.Background(), owner, root)
if err != nil {
t.Fatalf("claim: %v", err)
}
sctx := env.sessionFor(t, stranger)
const unknown = "00000000-0000-4000-8000-000000000000"
var first string
for name, id := range map[string]string{
"foreign": claim.ClaimID,
"unknown": unknown,
"malformed": "not-an-id",
"urn": "urn:uuid:" + unknown,
} {
t.Run(name, func(t *testing.T) {
rec := env.claimPage(sctx, id)
if rec.Code != http.StatusNotFound {
t.Fatalf("status = %d, want 404", rec.Code)
}
body := rec.Body.String()
if !strings.HasPrefix(body, "<!DOCTYPE html>") || !strings.Contains(body, "The page you requested does not exist.") {
t.Errorf("not the styled 404 page:\n%s", body)
}
if strings.Contains(body, "404 page not found") || strings.Contains(body, root) {
t.Errorf("the refusal is the plain answer or names the claim:\n%s", body)
}
if first == "" {
first = body
} else if body != first {
t.Error("the refusals differ, so one reveals more than another")
}
})
}
t.Run("a failed read", func(t *testing.T) {
owned := env.sessionFor(t, owner)
canceled, cancel := context.WithCancel(owned)
cancel()
rec := env.claimPage(canceled, claim.ClaimID)
if rec.Code != http.StatusInternalServerError {
t.Fatalf("status = %d, want 500\n%s", rec.Code, rec.Body.String())
}
if body := rec.Body.String(); !strings.HasPrefix(body, "<!DOCTYPE html>") || !strings.Contains(body, "An unexpected error occurred. Try again.") {
t.Errorf("not the styled 500 page:\n%s", body)
}
})
}
+96 -41
View File
@@ -2,10 +2,13 @@
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
// Member domain claims at point of use (dissolve-member-domains, née the
// /domains page per domains-registry design D9): the HTMX partials hosted by
// the sites surface's Domains section and the dashboard's pending-claim
// notice — the workspace's live claims and one claim's DNS instructions with
// its per-record probe state. Claim initiation lives entirely in the
// /domains page per domains-registry design D9): the HTMX partial hosted by
// the sites surface's Domains section, the workspace's live claims, and the
// claim page at /domains/claims/{claimID}, whose body is one claim's DNS
// instructions with its per-record probe state (a view that refreshes and
// answers its buttons by swapping itself, and that has a partial route for
// those swaps). The dashboard's pending-claim notice and the claims list
// link to the claim page. Claim initiation lives entirely in the
// site-creation flow now; this surface offers no add-a-domain form and
// registers no route for one (finding FA-42: the POST this package once
// kept routed for compatibility had no caller left anywhere in the
@@ -35,10 +38,12 @@ import (
"git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/clientholder"
wfdomains "git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/domains"
"git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/queues"
"github.com/google/uuid"
"go.temporal.io/sdk/client"
)
// MemberDomainsHandler serves the /domains page's partials.
// MemberDomainsHandler serves the claims list and claim status partials, and
// the claim page that renders the claim status as its body.
type MemberDomainsHandler struct {
// DomainsQ is the registry store, used for the reads that are plain
// lookups rather than allocation decisions (naming the placements that
@@ -95,11 +100,12 @@ func NewMemberDomainsHandler(cfg MemberDomainsConfig) (*MemberDomainsHandler, er
}, nil
}
// RegisterRoutes registers the member domains partial routes. The claim
// status route is a GET and stays one: reopening DNS instructions is a pure
// read that mints nothing (spec: "reopening them SHALL NOT re-initiate a
// claim or mint new records").
// RegisterRoutes registers the claim page and the member domains partial
// routes. The claim page and the claim status route are GETs and stay so:
// reopening DNS instructions is a pure read that mints nothing (spec:
// "reopening them SHALL NOT re-initiate a claim or mint new records").
func (h *MemberDomainsHandler) RegisterRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /domains/claims/{claimID}", h.GetClaimPage)
mux.HandleFunc("GET /partials/domains/claims", h.GetClaims)
mux.HandleFunc("GET /partials/domains/claims/{claimID}", h.GetClaimStatus)
mux.HandleFunc("POST /partials/domains/claims/{claimID}/check", h.CheckClaimNow)
@@ -113,24 +119,24 @@ func (h *MemberDomainsHandler) RegisterRoutes(mux *http.ServeMux) {
type MemberDomainClaimRow struct {
ClaimID string
Root string
// KindLabel is member-facing wording, not the stored kind: operator
// KindBadge is member-facing wording, not the stored kind: operator
// roots and carved member claims are both "Hosted" (names the deployment
// runs), external claims are "Custom" (a domain the member owns).
KindBadge Badge
StatusBadge Badge
Placements int64
// External marks a claim whose DNS instructions are worth opening.
External bool
// Pending distinguishes a claim still waiting on DNS from a settled one,
// which is what the instructions link is called: records to publish
// versus records to review. Cancel itself lives in the instructions view,
// where the pending-only guard is applied (design D4).
Pending bool
// CanRelease is true for an active member/external claim holding no
// placement — the release guard, mirrored server-side.
CanRelease bool
}
// MemberDomainClaimPageData feeds domain_claim.html: the member shell and the
// claim view, which the page renders as its body.
type MemberDomainClaimPageData struct {
Shell Shell
Claim MemberDomainClaimData
}
// MemberDomainsData feeds member_domains.html.
type MemberDomainsData struct {
Claims []MemberDomainClaimRow
@@ -156,7 +162,8 @@ type MemberDomainRecordView struct {
Optional bool
}
// MemberDomainClaimData feeds member_domains_claim.html.
// MemberDomainClaimData feeds member_domains_claim.html, the body of the
// claim page and the swap target of its own refresh and buttons.
type MemberDomainClaimData struct {
ClaimID string
Domain string
@@ -184,12 +191,14 @@ type MemberDomainClaimData struct {
// and the empty notice while the claim is pending.
func (d MemberDomainClaimData) Outcome() notice.Notice {
switch {
// Released comes before Hosted: a hosted (carved) claim can be released,
// and its page must then say the name is free, not that it is still ours.
case d.Released:
return notice.Information(notice.Strong(d.Domain), " was released. The domain is free again; claim it back at any time.")
case d.Hosted:
return notice.Information(notice.Strong(d.Domain), " is part of our hosting; there's nothing for you to publish in DNS. Any name inside it is yours to use.")
case d.Canceled:
return notice.Information("Verification for ", notice.Strong(d.Domain), " was canceled. The domain is free again; start over when you're ready.")
case d.Released:
return notice.Information(notice.Strong(d.Domain), " was released. The domain is free again; claim it back at any time.")
case d.Expired:
return notice.Warning("Verification for ", notice.Strong(d.Domain), " expired before the DNS record was found. The domain is free again; restart verification at any time.")
case d.Verified && d.Placed:
@@ -312,16 +321,12 @@ func (h *MemberDomainsHandler) surfaceData(ctx context.Context, workspaceID stri
return data
}
for _, row := range rows {
external := row.Kind == domains.KindExternal
data.Claims = append(data.Claims, MemberDomainClaimRow{
ClaimID: row.ClaimID,
Root: row.RootFqdn,
KindBadge: domainKindBadge(row.Kind),
StatusBadge: domainStatusBadge(row.Status),
Placements: row.PlacementCount,
External: external,
Pending: row.Status == domains.StatusPending,
CanRelease: row.Status == domains.StatusActive &&
row.Kind != domains.KindOperatorRoot &&
row.PlacementCount == 0,
@@ -332,8 +337,12 @@ func (h *MemberDomainsHandler) surfaceData(ctx context.Context, workspaceID stri
// claimStatusData renders one claim into the instructions/status view model.
// The probe columns live on the claim row itself, so the verification
// workflow's writes and this read touch the same record.
// workflow's writes and this read touch the same record. A pending claim with
// no status text of its own shows the default waiting sentence.
func (h *MemberDomainsHandler) claimStatusData(ctx context.Context, claim domains.Claim, statusText string) MemberDomainClaimData {
if claim.Status == domains.StatusPending && statusText == "" {
statusText = "Waiting for your DNS records…"
}
data := MemberDomainClaimData{
ClaimID: claim.ClaimID,
Domain: claim.RootFqdn,
@@ -389,30 +398,78 @@ func (h *MemberDomainsHandler) session(w http.ResponseWriter, r *http.Request) (
return session, true
}
// claimFor reads the claim a workspace owns, writing nothing, so each caller
// answers a refusal in its own form. It answers http.StatusOK with the claim,
// http.StatusNotFound for no registry, an id that is not a UUID, a claim that
// does not exist and a claim another workspace owns (the registry collapses
// the last two to ErrNotFound, so an id probe never becomes an existence
// oracle), and http.StatusInternalServerError when the read fails for a
// well-formed id. It reads by the parsed id's canonical form, because
// uuid.Parse accepts spellings (urn:uuid:...) that Postgres refuses.
func (h *MemberDomainsHandler) claimFor(ctx context.Context, workspaceID, claimID string) (domains.Claim, int) {
if h.Registry == nil {
return domains.Claim{}, http.StatusNotFound
}
parsed, err := uuid.Parse(claimID)
if err != nil {
return domains.Claim{}, http.StatusNotFound
}
claim, err := h.Registry.ClaimByID(ctx, workspaceID, parsed.String())
if err != nil {
if errors.Is(err, domains.ErrNotFound) {
return domains.Claim{}, http.StatusNotFound
}
h.Logger.Error("failed to load domain claim", slog.Any("error", err))
return domains.Claim{}, http.StatusInternalServerError
}
return claim, http.StatusOK
}
// ownedClaim loads the claim named in the request path and enforces workspace
// ownership, writing the HTTP error itself when it fails. A claim another
// workspace owns is indistinguishable from one that does not exist (the
// registry collapses both to ErrNotFound).
// ownership, writing the plain 404 itself when it fails, as a partial answers
// (a failed read included, which claimFor logs). A claim another workspace owns is indistinguishable from one that
// does not exist.
func (h *MemberDomainsHandler) ownedClaim(w http.ResponseWriter, r *http.Request) (domains.Claim, bool) {
session, ok := h.session(w, r)
if !ok {
return domains.Claim{}, false
}
if h.Registry == nil {
http.NotFound(w, r)
return domains.Claim{}, false
}
claim, err := h.Registry.ClaimByID(r.Context(), session.WorkspaceID, r.PathValue("claimID"))
if err != nil {
if !errors.Is(err, domains.ErrNotFound) {
h.Logger.Error("failed to load domain claim", slog.Any("error", err))
}
claim, status := h.claimFor(r.Context(), session.WorkspaceID, r.PathValue("claimID"))
if status != http.StatusOK {
http.NotFound(w, r)
return domains.Claim{}, false
}
return claim, true
}
// GetClaimPage handles GET /domains/claims/{claimID}, the claim's DNS
// records and status as a member page under the dashboard. A claim another
// workspace owns, an unknown id and a malformed id each answer the styled 404
// page with the same body; a failed read answers the styled 500 page.
func (h *MemberDomainsHandler) GetClaimPage(w http.ResponseWriter, r *http.Request) {
session, ok := h.session(w, r)
if !ok {
return
}
claim, status := h.claimFor(r.Context(), session.WorkspaceID, r.PathValue("claimID"))
switch status {
case http.StatusOK:
case http.StatusNotFound:
h.Templates.RenderErrorPage(w, r, http.StatusNotFound, "The page you requested does not exist.")
return
default:
h.Templates.RenderErrorPage(w, r, http.StatusInternalServerError, "An unexpected error occurred. Try again.")
return
}
shell := memberShellFor(h.AuthConfig, r, "dashboard")
shell.BelowActive = true
w.Header().Set("Content-Type", "text/html; charset=utf-8")
h.Templates.Render(w, "domain_claim.html", MemberDomainClaimPageData{
Shell: shell,
Claim: h.claimStatusData(r.Context(), claim, ""),
})
}
// GetClaims handles GET /partials/domains/claims — the surface's list view.
func (h *MemberDomainsHandler) GetClaims(w http.ResponseWriter, r *http.Request) {
session, ok := h.session(w, r)
@@ -434,11 +491,9 @@ func (h *MemberDomainsHandler) GetClaimStatus(w http.ResponseWriter, r *http.Req
}
// renderClaimStatus renders the right branch for the claim's current state.
// statusText overrides the default pending copy when non-empty.
// statusText overrides the default pending copy (claimStatusData) when
// non-empty.
func (h *MemberDomainsHandler) renderClaimStatus(w http.ResponseWriter, r *http.Request, claim domains.Claim, statusText string) {
if claim.Status == domains.StatusPending && statusText == "" {
statusText = "Waiting for your DNS records…"
}
h.Templates.Render(w, "member_domains_claim.html", h.claimStatusData(r.Context(), claim, statusText))
}
@@ -33,9 +33,11 @@ func TestMemberShellsHaveNoDomainsNav(t *testing.T) {
}
for name, body := range map[string]string{
"index.html": render("index.html", dashboardData{}),
"products.html": render("products.html", server.ProductsPageData{}),
"billing.html": render("billing.html", server.BillingPageData{}),
"index.html": render("index.html", dashboardData{}),
"products.html": render("products.html", server.ProductsPageData{}),
"billing.html": render("billing.html", server.BillingPageData{}),
"billing_invoice.html": render("billing_invoice.html", server.MemberInvoicePageData{}),
"domain_claim.html": render("domain_claim.html", server.MemberDomainClaimPageData{Claim: server.MemberDomainClaimData{Domain: "wiki.example.org"}}),
} {
if strings.Contains(body, `href="/domains"`) {
t.Errorf("%s still links /domains", name)
@@ -47,8 +49,8 @@ func TestMemberShellsHaveNoDomainsNav(t *testing.T) {
}
// TestDashboardPendingDomainNotice covers the notice's contract: one
// Information notice naming each claim inside the .domains-surface wrapper
// the claim view swaps into, absent without a pending claim (no empty
// Information notice naming each claim with a plain link to the claim's page,
// outside any .domains-surface, absent without a pending claim (no empty
// chrome), opening a claim is a pure GET, and the notice is core content, not
// one of the registry-declared integration cards.
func TestDashboardPendingDomainNotice(t *testing.T) {
@@ -65,15 +67,21 @@ func TestDashboardPendingDomainNotice(t *testing.T) {
st.Render(rec, "index.html", data)
body := rec.Body.String()
page := htmltest.Parse(t, body)
if page.Count(".domains-surface > .app-notice.app-notice-information") != 1 || page.Count(".app-notice") != 1 ||
page.Count(`.domains-surface .app-notice button[hx-target="closest .domains-surface"]`) != 2 {
t.Errorf("the pending claims are not one notice inside the domains surface:\n%s", body)
if page.Count(".app-notice.app-notice-information") != 1 || page.Count(".app-notice") != 1 ||
page.Count(`.app-notice a.btn.btn-link[href^="/domains/claims/"]`) != 2 {
t.Errorf("the pending claims are not one notice with a link to each claim's page:\n%s", body)
}
if page.Count(".domains-surface") != 0 {
t.Errorf("the notice must not sit inside a domains surface:\n%s", body)
}
if strings.Contains(body, "hx-get") && page.Count(".app-notice [hx-get]") != 0 {
t.Errorf("the notice must not swap the claim in place:\n%s", body)
}
for _, want := range []string{
"Domain verification in progress",
"wiki.example.org", "docs.example.net",
`hx-get="/partials/domains/claims/claim-1"`,
`hx-target="closest .domains-surface"`,
`href="/domains/claims/claim-1"`,
`href="/domains/claims/claim-2"`,
"View DNS records",
} {
if !strings.Contains(body, want) {
@@ -95,7 +103,7 @@ func TestDashboardPendingDomainNotice(t *testing.T) {
if strings.Contains(empty.Body.String(), "Domain verification") {
t.Error("no pending claims must mean no notice and no empty chrome")
}
if strings.Contains(empty.Body.String(), "domains-surface") {
t.Error("no pending claims must leave no dangling domains-surface wrapper")
if strings.Contains(empty.Body.String(), `<div class="mt-3"></div>`) {
t.Error("no pending claims must leave no empty wrapper around the notice")
}
}
+14 -2
View File
@@ -158,6 +158,7 @@ func TestMemberDomainsOwnerScoping(t *testing.T) {
req *http.Request
handler http.HandlerFunc
}{
"page": {httptest.NewRequest(http.MethodGet, "/domains/claims/"+claim.ClaimID, nil).WithContext(sctx), env.handler.GetClaimPage},
"status": {httptest.NewRequest(http.MethodGet, base, nil).WithContext(sctx), env.handler.GetClaimStatus},
"check": {postForm(sctx, base+"/check"), env.handler.CheckClaimNow},
"cancel": {postForm(sctx, base+"/cancel"), env.handler.CancelClaim},
@@ -387,6 +388,14 @@ func TestMemberDomainsStatusViewIsAPureRead(t *testing.T) {
}
first, second := open(), open()
// The claim page is a read as well: opening it twice leaves the claim
// as it was.
for range 2 {
if rec := env.claimPage(sctx, claim.ClaimID); rec.Code != http.StatusOK {
t.Fatalf("claim page status = %d, want 200", rec.Code)
}
}
// The wildcard row is part of what a reopen shows, per design D9.
for _, want := range []string{"*." + root, "connect.example.test", "Optional", claim.Token} {
if !strings.Contains(first, want) {
@@ -400,7 +409,10 @@ func TestMemberDomainsStatusViewIsAPureRead(t *testing.T) {
if err != nil {
t.Fatalf("list claims: %v", err)
}
if len(claims) != 1 {
t.Errorf("live claims = %d after two reopens, want 1", len(claims))
if len(claims) != 1 || claims[0].ClaimID != claim.ClaimID {
t.Errorf("live claims = %d after reopening, want the one claim", len(claims))
}
if fresh, err := env.registry.ClaimByID(ctx, workspace, claim.ClaimID); err != nil || fresh.Token != claim.Token {
t.Errorf("reopening changed the claim's token: %v", err)
}
}
+11 -9
View File
@@ -61,7 +61,7 @@ func TestMemberDomainsNoAddForm(t *testing.T) {
}
// TestMemberDomainsClaimsTable covers the list: kind/status badges, the
// placement count, the instructions link for external claims, and the release
// placement count, each claim's root linking to its page, and the release
// control's guard — offered only for an active claim holding no name.
func TestMemberDomainsClaimsTable(t *testing.T) {
body := Render(t, MemberSet(t), "member_domains.html", MemberDomainsData{
@@ -70,7 +70,6 @@ func TestMemberDomainsClaimsTable(t *testing.T) {
ClaimID: "claim-pending", Root: "example.org",
KindBadge: domainKindBadge(domains.KindExternal),
StatusBadge: domainStatusBadge(domains.StatusPending),
External: true, Pending: true,
},
{
ClaimID: "claim-hosted", Root: "site.hosting.test",
@@ -82,14 +81,16 @@ func TestMemberDomainsClaimsTable(t *testing.T) {
ClaimID: "claim-empty", Root: "spare.example",
KindBadge: domainKindBadge(domains.KindExternal),
StatusBadge: domainStatusBadge(domains.StatusActive),
External: true, CanRelease: true,
CanRelease: true,
},
},
})
for _, want := range []string{
"example.org", "Awaiting DNS", "DNS records",
"/partials/domains/claims/claim-pending",
"example.org", "Awaiting DNS",
`href="/domains/claims/claim-pending"`,
`href="/domains/claims/claim-empty"`,
`href="/domains/claims/claim-hosted"`,
`data-action-url="/partials/domains/claims/claim-empty/release"`,
`data-action-target="closest .domains-surface"`, "Release",
} {
@@ -97,10 +98,11 @@ func TestMemberDomainsClaimsTable(t *testing.T) {
t.Errorf("claims table missing %q\n%s", want, body)
}
}
// The hosted claim serves a name, so it gets neither a release control nor
// an instructions link.
if strings.Contains(body, "/partials/domains/claims/claim-hosted") {
t.Error("a hosted claim must not offer the external-claim affordances")
// The claims table links to pages; nothing in it opens the records in place.
for _, gone := range []string{"DNS records", "Details", "hx-get"} {
if strings.Contains(body, gone) {
t.Errorf("claims table still renders %q", gone)
}
}
if strings.Count(body, "/release") != 1 {
t.Errorf("release offered %d times, want exactly the zero-placement claim", strings.Count(body, "/release"))
+27 -23
View File
@@ -29,23 +29,35 @@ import (
// and every answer carries Cache-Control: no-store so that no cache keeps it.
// billingPagePath is where a Pay invoice link lands when the console cannot
// or will not send the member to Stripe: the Billing page, whose detail of an
// or will not send the member to Stripe: the Billing page, whose invoice page for an
// open invoice offers Pay invoice when the key reaches its mapping.
const billingPagePath = "/billing"
// memberInvoice is the ownership gate of an invoice: the invoice must exist
// and its billing account must be one of the organization's. It answers
// http.StatusOK with the invoice, http.StatusNotFound for an unknown invoice
// or another organization's (indistinguishable, so a member cannot probe for
// other organizations' invoices), and http.StatusInternalServerError when the
// organization's billing accounts cannot be read. The invoice detail and the
// by-invoice Pay invoice route both ask it.
// http.StatusOK with the invoice, http.StatusNotFound for an id that is not a
// UUID, an unknown invoice or another organization's (indistinguishable, so a
// member cannot probe for other organizations' invoices), and
// http.StatusInternalServerError, logged, when the invoice or the
// organization's billing accounts cannot be read. It reads by the parsed id's
// canonical form, because uuid.Parse accepts spellings (urn:uuid:...) that
// Postgres refuses. The invoice page and the by-invoice Pay invoice route
// both ask it.
func (h *MemberInvoicesHandler) memberInvoice(ctx context.Context, orgID, invoiceID string) (billing.Invoice, int) {
invoice, err := h.BillingQ.GetInvoiceByID(ctx, invoiceID)
parsed, err := uuid.Parse(invoiceID)
if err != nil {
// Not found (or an unparseable id) — do not distinguish from "not yours".
return billing.Invoice{}, http.StatusNotFound
}
invoice, err := h.BillingQ.GetInvoiceByID(ctx, parsed.String())
if err != nil {
// Not found does not distinguish "unknown" from "not yours".
if errors.Is(err, sql.ErrNoRows) {
return billing.Invoice{}, http.StatusNotFound
}
h.Logger.Error("failed to read invoice",
slog.String("invoice_id", parsed.String()), slog.Any("error", err))
return billing.Invoice{}, http.StatusInternalServerError
}
owned, ok := h.orgOwnsAccount(ctx, orgID, invoice.BillingAccountID)
if !ok {
return billing.Invoice{}, http.StatusInternalServerError
@@ -94,7 +106,7 @@ func hostedPage(inv *stripe.Invoice) string {
}
// GetHostedInvoice handles GET /billing/invoices/{invoiceID}/hosted. After
// the invoice detail's ownership gate (404 for an unknown invoice and for
// the invoice page's ownership gate (404 for an unknown invoice and for
// another organization's) it reads the invoice from Stripe and answers 303 to
// its hosted page, whatever the invoice's status, because the page of a paid
// invoice offers the invoice and its receipt. It answers 303 to /billing,
@@ -109,16 +121,17 @@ func (h *MemberInvoicesHandler) GetHostedInvoice(w http.ResponseWriter, r *http.
return
}
invoiceID := r.PathValue("invoiceID")
if _, status := h.memberInvoice(r.Context(), session.OrgID, invoiceID); status != http.StatusOK {
invoice, status := h.memberInvoice(r.Context(), session.OrgID, invoiceID)
if status != http.StatusOK {
h.pageRefused(w, r, status)
return
}
seeOther(w, h.hostedInvoicePage(r.Context(), session.OrgID, invoiceID))
seeOther(w, h.hostedInvoicePage(r.Context(), session.OrgID, invoice.InvoiceID))
}
// pageRefused answers a Pay invoice route's gate refusal. The routes are
// navigations a member opens in a new tab, so a refusal is the styled error
// page (error-pages); the invoice detail, a partial, answers gateRefused.
// pageRefused answers a gate refusal of a route a member navigates to: Pay
// invoice's routes, which open in a new tab, and the invoice page. A refusal
// is the styled error page (error-pages).
func (h *MemberInvoicesHandler) pageRefused(w http.ResponseWriter, r *http.Request, status int) {
if status == http.StatusNotFound {
h.Templates.RenderErrorPage(w, r, http.StatusNotFound, "The page you requested does not exist.")
@@ -127,15 +140,6 @@ func (h *MemberInvoicesHandler) pageRefused(w http.ResponseWriter, r *http.Reque
h.Templates.RenderErrorPage(w, r, http.StatusInternalServerError, "An unexpected error occurred. Try again.")
}
// gateRefused answers a gate's refusal for the invoice detail.
func (h *MemberInvoicesHandler) gateRefused(w http.ResponseWriter, r *http.Request, status int) {
if status == http.StatusNotFound {
http.NotFound(w, r)
return
}
http.Error(w, "Failed to load invoice", http.StatusInternalServerError)
}
// hostedInvoicePage is where the by-invoice route redirects: the invoice's
// hosted page, or the Billing page.
func (h *MemberInvoicesHandler) hostedInvoicePage(ctx context.Context, orgID, invoiceID string) string {
@@ -370,7 +370,7 @@ func (f *hostedFixture) carriesURL(r capturedRecord) bool {
return false
}
// TestInvoiceDetailOffersPayInvoice: the detail of an open invoice whose
// TestInvoiceDetailOffersPayInvoice: the invoice page of an open invoice whose
// mapping the key reaches links to its hosted route; a paid invoice, an open
// one mapped in the other environment and an unmapped one show none.
func TestInvoiceDetailOffersPayInvoice(t *testing.T) {
@@ -387,7 +387,7 @@ func TestInvoiceDetailOffersPayInvoice(t *testing.T) {
for _, row := range rows {
t.Run(row.invoice, func(t *testing.T) {
id := f.invoices[row.invoice].ID
rec := authtest.Get(t, f.ctx, f.h.GetInvoiceDetail, "/partials/member/invoices/"+id, authtest.PathValue("invoiceID", id))
rec := authtest.Get(t, f.ctx, f.h.GetInvoicePage, "/billing/invoices/"+id, authtest.PathValue("invoiceID", id))
if rec.Code != http.StatusOK {
t.Fatalf("status = %d, want 200", rec.Code)
}
@@ -0,0 +1,268 @@
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
package server
// The member's invoice page (member-invoice-history): GET
// /billing/invoices/{invoiceID} renders one invoice under Billing with the
// location trail, and answers the styled error page when the invoice is not
// the organization's. The handler is called directly through authtest so the
// shell it builds is what renders.
import (
"context"
"io"
"log/slog"
"net/http"
"strings"
"testing"
"time"
"git.coopcloud.tech/wiki-cafe/member-console/internal/auth"
"git.coopcloud.tech/wiki-cafe/member-console/internal/billing"
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/authtest"
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/dbtest"
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/htmltest"
"git.coopcloud.tech/wiki-cafe/member-console/internal/testkit/world"
)
// invoiceAccountsFailingQ fails the read of the organization's billing
// accounts, the one read the ownership gate depends on after the invoice.
type invoiceAccountsFailingQ struct {
billing.Querier
}
func (q invoiceAccountsFailingQ) ListBillingAccountsByOrgID(context.Context, string) ([]billing.Account, error) {
var none []billing.Account
return none, errReadFailed
}
// invoiceReadFailingQ fails the read of the invoice itself, with an error that
// is not sql.ErrNoRows.
type invoiceReadFailingQ struct {
billing.Querier
}
func (q invoiceReadFailingQ) GetInvoiceByID(context.Context, string) (billing.Invoice, error) {
return billing.Invoice{}, errReadFailed
}
// invoicePaymentsFailingQ fails the read of an invoice's payments.
type invoicePaymentsFailingQ struct {
billing.Querier
}
func (q invoicePaymentsFailingQ) GetPaymentsByInvoiceID(context.Context, string) ([]billing.Payment, error) {
var none []billing.Payment
return none, errReadFailed
}
// invoicePageFixture is an organization with a numbered invoice that has a
// line and a payment, an unnumbered draft, and another organization's invoice.
type invoicePageFixture struct {
w *world.World
org world.Org
numbered, foreign world.Invoice
draftID string
pagesFor func(billing.Querier) *invoicePages
defaultBilling billing.Querier
foreignID, unknownID string
}
func newInvoicePageFixture(t *testing.T) *invoicePageFixture {
t.Helper()
database := dbtest.Open(t)
w := world.New(t, database)
org := w.Org("Invoice Cooperative", "personal", w.Person("Owner"))
other := w.Org("Other Cooperative", "personal", w.Person("Stranger"))
account := w.BillingAccount(org, "Primary")
otherAccount := w.BillingAccount(other, "Other")
price := w.OneTimePrice(w.Product("Membership"), 1000)
numbered := w.Invoice(account, world.InvoiceOpts{Number: "0042", Status: "paid", AmountPaid: 1000, PaidAt: time.Now()})
w.LineItem(numbered, price, "Standard plan", 1000,
time.Date(2026, time.May, 1, 12, 0, 0, 0, time.UTC), time.Date(2026, time.May, 31, 12, 0, 0, 0, time.UTC))
w.Payment(numbered, world.PaymentOpts{At: time.Date(2026, time.May, 3, 12, 0, 0, 0, time.UTC)})
foreign := w.Invoice(otherAccount, world.InvoiceOpts{Number: "0099"})
draft, err := billing.New(database).CreateInvoice(t.Context(), billing.CreateInvoiceParams{
BillingAccountID: account.ID, Status: "draft", AmountDue: 500, Currency: "usd",
})
if err != nil {
t.Fatalf("create the draft invoice: %v", err)
}
return &invoicePageFixture{
w: w, org: org, numbered: numbered, foreign: foreign, draftID: draft.InvoiceID,
defaultBilling: billing.New(database),
pagesFor: func(q billing.Querier) *invoicePages { return newInvoicePages(t, org, q) },
foreignID: foreign.ID, unknownID: "00000000-0000-4000-8000-000000000000",
}
}
// invoicePages is the member's invoice handler over one billing querier and
// the session of the organization's owner.
type invoicePages struct {
member *MemberInvoicesHandler
memberCtx context.Context
}
func newInvoicePages(t *testing.T, org world.Org, billingQ billing.Querier) *invoicePages {
t.Helper()
sm := authtest.NewSessionManager()
member, err := NewMemberInvoicesHandler(MemberInvoicesConfig{
BillingQ: billingQ,
AuthConfig: &auth.Config{SessionManager: sm},
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
})
if err != nil {
t.Fatalf("NewMemberInvoicesHandler: %v", err)
}
owner := org.Owner.SignIn()
owner.OrgID = org.ID
return &invoicePages{member: member, memberCtx: authtest.SignIn(t, sm, owner)}
}
// invoicePage requests the invoice page for id through GetInvoicePage.
func (p *invoicePages) invoicePage(t *testing.T, id string) (int, string) {
t.Helper()
rec := authtest.Get(t, p.memberCtx, p.member.GetInvoicePage, "/billing/invoices/"+id, authtest.PathValue("invoiceID", id))
return rec.Code, rec.Body.String()
}
func TestMemberInvoicePageRendersTheInvoiceUnderBilling(t *testing.T) {
f := newInvoicePageFixture(t)
code, body := f.pagesFor(f.defaultBilling).invoicePage(t, f.numbered.ID)
if code != http.StatusOK {
t.Fatalf("status = %d, want 200\n%s", code, body)
}
page := htmltest.Parse(t, body)
if got := page.One(t, "h1").Text(); got != "Invoice 0042" {
t.Errorf("h1 = %q, want \"Invoice 0042\"", got)
}
if got := page.One(t, "title").Text(); !strings.HasPrefix(got, "Invoice 0042 - ") {
t.Errorf("title = %q, want it to start \"Invoice 0042 - \"", got)
}
crumbs := page.One(t, "nav[aria-label=breadcrumb]")
if got := strings.Join(crumbs.Texts("li"), " / "); got != "Home / Billing / Invoice 0042" {
t.Errorf("trail = %q, want \"Home / Billing / Invoice 0042\"", got)
}
billingCrumb := crumbs.One(t, `a[href="/billing"]`)
if billingCrumb.Text() != "Billing" {
t.Errorf("the Billing crumb reads %q", billingCrumb.Text())
}
crumbs.None(t, `.breadcrumb-item.active a`)
rail := page.One(t, "#app-rail")
entry := rail.One(t, `a.nav-link[href="/billing"]`)
if !entry.HasClass("active") {
t.Errorf("the rail's Billing entry is not marked active: %s", entry.HTML())
}
if got, _ := entry.Attr("aria-current"); got != "true" {
t.Errorf("the rail's Billing entry aria-current = %q, want \"true\" (the current section, not the page): %s", got, entry.HTML())
}
if got := page.Count(`[aria-current="page"]`); got != 1 {
t.Errorf("the page has %d current-page markers, want the trail's one", got)
}
text := page.Text()
for _, want := range []string{"Amount due", "Amount paid", "Standard plan", "Line items", "Payments", "May 3, 2026", "May 1, 2026 – May 31, 2026"} {
if !strings.Contains(text, want) {
t.Errorf("the invoice page is missing %q:\n%s", want, text)
}
}
for _, gone := range []string{"Back to", "&larr;", "←"} {
if strings.Contains(body, gone) {
t.Errorf("the invoice page renders %q", gone)
}
}
}
func TestMemberInvoicePageWithoutANumberIsTitledInvoice(t *testing.T) {
f := newInvoicePageFixture(t)
code, body := f.pagesFor(f.defaultBilling).invoicePage(t, f.draftID)
if code != http.StatusOK {
t.Fatalf("status = %d, want 200\n%s", code, body)
}
page := htmltest.Parse(t, body)
if got := page.One(t, "h1").Text(); got != "Invoice" {
t.Errorf("h1 = %q, want \"Invoice\"", got)
}
if got := page.One(t, "title").Text(); !strings.HasPrefix(got, "Invoice - ") {
t.Errorf("title = %q, want it to start \"Invoice - \"", got)
}
if strings.Contains(body, "Assigned when the invoice is issued.") {
t.Error("the page carries a help popover for the missing number")
}
}
func TestMemberInvoicePageRefusalsAnswerTheStyledErrorPage(t *testing.T) {
f := newInvoicePageFixture(t)
pages := f.pagesFor(f.defaultBilling)
var first string
for name, id := range map[string]string{"foreign": f.foreignID, "unknown": f.unknownID, "malformed": "not-an-id"} {
t.Run(name, func(t *testing.T) {
code, body := pages.invoicePage(t, id)
if code != http.StatusNotFound {
t.Fatalf("status = %d, want 404", code)
}
if !strings.HasPrefix(body, "<!DOCTYPE html>") || !strings.Contains(body, "The page you requested does not exist.") {
t.Errorf("not the styled 404 page:\n%s", body)
}
if strings.Contains(body, "0099") {
t.Error("the 404 names the refused invoice")
}
if first == "" {
first = body
} else if body != first {
t.Error("the refusals differ, so one reveals more than another")
}
})
}
t.Run("unreadable invoice", func(t *testing.T) {
code, body := f.pagesFor(invoiceReadFailingQ{Querier: f.defaultBilling}).invoicePage(t, f.numbered.ID)
if code != http.StatusInternalServerError {
t.Fatalf("status = %d, want 500 (a failed read is not a missing invoice)", code)
}
if !strings.HasPrefix(body, "<!DOCTYPE html>") || !strings.Contains(body, "An unexpected error occurred. Try again.") {
t.Errorf("not the styled 500 page:\n%s", body)
}
})
t.Run("unreadable billing accounts", func(t *testing.T) {
code, body := f.pagesFor(invoiceAccountsFailingQ{Querier: f.defaultBilling}).invoicePage(t, f.numbered.ID)
if code != http.StatusInternalServerError {
t.Fatalf("status = %d, want 500", code)
}
if !strings.HasPrefix(body, "<!DOCTYPE html>") || !strings.Contains(body, "An unexpected error occurred. Try again.") {
t.Errorf("not the styled 500 page:\n%s", body)
}
})
}
func TestMemberInvoicePageShowsAProblemWhenAReadFails(t *testing.T) {
f := newInvoicePageFixture(t)
for name, q := range map[string]struct {
querier billing.Querier
message string
}{
"line items": {periodLinesFailingQ{Querier: f.defaultBilling}, "Failed to load invoice line items"},
"payments": {invoicePaymentsFailingQ{Querier: f.defaultBilling}, "Failed to load payments"},
} {
t.Run(name, func(t *testing.T) {
code, body := f.pagesFor(q.querier).invoicePage(t, f.numbered.ID)
if code != http.StatusOK {
t.Fatalf("status = %d, want 200", code)
}
page := htmltest.Parse(t, body)
if page.One(t, "h1").Text() != "Invoice 0042" {
t.Errorf("the page lost its title:\n%s", body)
}
if got := page.One(t, ".alert-danger").Text(); !strings.Contains(got, q.message) {
t.Errorf("the Problem notice reads %q, want %q", got, q.message)
}
})
}
}
+43 -21
View File
@@ -19,11 +19,11 @@ import (
"git.coopcloud.tech/wiki-cafe/member-console/internal/web"
)
// MemberInvoicesHandler handles HTMX partial requests for the member Billing
// page (invoice and payment history). The full /billing page itself is served
// in server.go alongside /products, since it uses the page-level template set;
// this handler owns the data-bearing partials and Pay invoice's two redirects
// (member_hosted_invoice.go).
// MemberInvoicesHandler serves the member Billing page's invoices partial
// (invoice and payment history) and the invoice page. The full /billing page
// itself is served in server.go alongside /products, since it uses the
// page-level template set; this handler owns the invoices partial, the page
// of one invoice, and Pay invoice's two redirects (member_hosted_invoice.go).
type MemberInvoicesHandler struct {
BillingQ billing.Querier
// EntitlementsQ resolves the position behind Pay invoice's by-plan
@@ -68,10 +68,11 @@ func NewMemberInvoicesHandler(cfg MemberInvoicesConfig) (*MemberInvoicesHandler,
}, nil
}
// RegisterRoutes registers member invoice partial routes.
// RegisterRoutes registers the invoices partial and the invoice page, with
// Pay invoice's two redirects.
func (h *MemberInvoicesHandler) RegisterRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /partials/member/invoices", h.GetInvoices)
mux.HandleFunc("GET /partials/member/invoices/{invoiceID}", h.GetInvoiceDetail)
mux.HandleFunc("GET /billing/invoices/{invoiceID}", h.GetInvoicePage)
// Pay invoice (member_hosted_invoice.go): each route reads the URL of
// Stripe's hosted invoice page when the member opens the link and answers
// a redirect. Like GET /billing they sit behind the sign-in requirement.
@@ -119,7 +120,15 @@ type MemberPaymentViewModel struct {
Date string
}
// MemberInvoiceDetailData holds data for the member_invoice_detail.html partial.
// MemberInvoicePageData holds data for billing_invoice.html: the member
// shell and the invoice's detail, which the page renders as its body.
type MemberInvoicePageData struct {
Shell Shell
Detail MemberInvoiceDetailData
}
// MemberInvoiceDetailData holds data for the member_invoice_detail.html
// partial, the body of the invoice page.
type MemberInvoiceDetailData struct {
InvoiceID string
// InvoiceNumber is the platform-assigned reference number
@@ -150,9 +159,9 @@ type MemberInvoiceDetailData struct {
// invoiceBelongsToOrg reports whether billingAccountID is one of the
// organization's billing accounts. It is the ownership gate for the member
// invoice detail view: an invoice whose billing account is not in the member
// invoice page: an invoice whose billing account is not in the member
// org's set must be indistinguishable from a non-existent one (404), so the
// detail handler never reveals another organization's invoices.
// page handler never reveals another organization's invoices.
func invoiceBelongsToOrg(accounts []billing.Account, billingAccountID string) bool {
for _, acc := range accounts {
if acc.BillingAccountID == billingAccountID {
@@ -363,13 +372,15 @@ func (h *MemberInvoicesHandler) invoicesInKeyEnvironment(ctx context.Context, in
return kept
}
// GetInvoiceDetail handles GET /partials/member/invoices/{invoiceID}. It renders
// a single invoice with its line items and payments, but only when the invoice
// belongs to one of the member organization's billing accounts. Invoices that
// do not exist OR belong to another organization both return 404 — the
// indistinguishable response prevents a member from probing the existence of
// other organizations' invoices.
func (h *MemberInvoicesHandler) GetInvoiceDetail(w http.ResponseWriter, r *http.Request) {
// GetInvoicePage handles GET /billing/invoices/{invoiceID}. It renders a
// single invoice with its line items and payments as a member page under
// Billing, but only when the invoice belongs to one of the member
// organization's billing accounts. Invoices that do not exist OR belong to
// another organization both answer the styled 404 page: the
// indistinguishable response does not reveal whether another organization's
// invoice exists. A failed read of the billing accounts answers the styled
// 500 page.
func (h *MemberInvoicesHandler) GetInvoicePage(w http.ResponseWriter, r *http.Request) {
session := h.AuthConfig.GetUserSession(r.Context())
if session == nil {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
@@ -380,9 +391,11 @@ func (h *MemberInvoicesHandler) GetInvoiceDetail(w http.ResponseWriter, r *http.
invoice, status := h.memberInvoice(r.Context(), session.OrgID, invoiceID)
if status != http.StatusOK {
h.gateRefused(w, r, status)
h.pageRefused(w, r, status)
return
}
// The stored id is the canonical spelling every later read and link uses.
invoiceID = invoice.InvoiceID
data := MemberInvoiceDetailData{
InvoiceID: invoice.InvoiceID,
@@ -418,7 +431,7 @@ func (h *MemberInvoicesHandler) GetInvoiceDetail(w http.ResponseWriter, r *http.
slog.String("invoice_id", invoiceID), slog.Any("error", err))
data.Period = formatInvoicePeriod(sql.NullTime{}, sql.NullTime{})
data.Error = notice.Problem("Failed to load invoice line items")
h.Templates.Render(w, "member_invoice_detail.html", data)
h.renderInvoicePage(w, r, data)
return
}
data.Period = formatInvoicePeriod(invoicePeriodFromLines(lineItems))
@@ -435,7 +448,7 @@ func (h *MemberInvoicesHandler) GetInvoiceDetail(w http.ResponseWriter, r *http.
h.Logger.Error("failed to list payments",
slog.String("invoice_id", invoiceID), slog.Any("error", err))
data.Error = notice.Problem("Failed to load payments")
h.Templates.Render(w, "member_invoice_detail.html", data)
h.renderInvoicePage(w, r, data)
return
}
for _, pay := range payments {
@@ -450,5 +463,14 @@ func (h *MemberInvoicesHandler) GetInvoiceDetail(w http.ResponseWriter, r *http.
})
}
h.Templates.Render(w, "member_invoice_detail.html", data)
h.renderInvoicePage(w, r, data)
}
// renderInvoicePage renders the invoice page around the detail, with the
// member shell marking Billing as the entry the page sits below.
func (h *MemberInvoicesHandler) renderInvoicePage(w http.ResponseWriter, r *http.Request, detail MemberInvoiceDetailData) {
shell := memberShellFor(h.AuthConfig, r, "billing")
shell.BelowActive = true
w.Header().Set("Content-Type", "text/html; charset=utf-8")
h.Templates.Render(w, "billing_invoice.html", MemberInvoicePageData{Shell: shell, Detail: detail})
}
+12 -4
View File
@@ -95,7 +95,7 @@ func TestMemberInvoiceTemplatesRender(t *testing.T) {
return buf.String()
}
// Populated list: invoice row links to its detail partial.
// Populated list: invoice row links to the invoice's page.
listOut := render("member_invoices.html", MemberInvoicesData{
Invoices: []InvoiceListItemViewModel{{
InvoiceID: "inv-1",
@@ -107,11 +107,14 @@ func TestMemberInvoiceTemplatesRender(t *testing.T) {
StatusState: "paid", // bare token from getInvoiceStatusBadgeClass; template prefixes text-bg-
}},
})
for _, want := range []string{"inv-1", "/partials/member/invoices/inv-1", "text-bg-success"} {
for _, want := range []string{"inv-1", `href="/billing/invoices/inv-1"`, "text-bg-success"} {
if !strings.Contains(listOut, want) {
t.Errorf("populated list missing %q\n%s", want, listOut)
}
}
if strings.Contains(listOut, "hx-get") {
t.Errorf("populated list still swaps the detail in place:\n%s", listOut)
}
// Empty list shows the projection-aware empty state, not an error, and
// never asserts that no billing history exists (member-invoice-history
@@ -125,7 +128,7 @@ func TestMemberInvoiceTemplatesRender(t *testing.T) {
t.Errorf("empty list still denies billing history:\n%s", emptyOut)
}
// Detail renders line items, payments, and a back affordance.
// Detail renders line items and payments, and no back affordance.
detailOut := render("member_invoice_detail.html", MemberInvoiceDetailData{
InvoiceID: "inv-1",
Status: "paid",
@@ -141,11 +144,16 @@ func TestMemberInvoiceTemplatesRender(t *testing.T) {
{Amount: "$10.00 USD", Status: "succeeded", Date: "May 2, 2026"},
},
})
for _, want := range []string{"Standard plan", "Payments", "Back to invoices", "/partials/member/invoices", "text-bg-success"} {
for _, want := range []string{"Standard plan", "Payments", "text-bg-success"} {
if !strings.Contains(detailOut, want) {
t.Errorf("detail missing %q\n%s", want, detailOut)
}
}
for _, gone := range []string{"Back to", "&larr;", "/partials/member/invoices"} {
if strings.Contains(detailOut, gone) {
t.Errorf("detail still renders %q\n%s", gone, detailOut)
}
}
}
// periodLine is one stored line of an invoice for the period rule: its amount
+13 -3
View File
@@ -5,6 +5,7 @@ package server_test
import (
"net/http/httptest"
"slices"
"strings"
"testing"
@@ -15,7 +16,8 @@ import (
)
// renderMemberShell renders a member page through the root template set
// with the given shell, the way the /, /products, and /billing handlers do.
// with the given shell, the way the /, /products, /billing, invoice page and
// claim page handlers do.
func renderMemberShell(t *testing.T, page string, shell server.Shell) string {
t.Helper()
st := server.NewSafeTemplates(server.MemberSet(t), discardLogger())
@@ -25,6 +27,10 @@ func renderMemberShell(t *testing.T, page string, shell server.Shell) string {
st.Render(rec, page, dashboardData{Shell: shell})
case "products.html":
st.Render(rec, page, server.ProductsPageData{Shell: shell})
case "billing_invoice.html":
st.Render(rec, page, server.MemberInvoicePageData{Shell: shell, Detail: server.MemberInvoiceDetailData{InvoiceID: "inv-1", InvoiceNumber: "0042"}})
case "domain_claim.html":
st.Render(rec, page, server.MemberDomainClaimPageData{Shell: shell, Claim: server.MemberDomainClaimData{ClaimID: "claim-1", Domain: "wiki.example.org"}})
default:
st.Render(rec, page, server.BillingPageData{Shell: shell})
}
@@ -59,7 +65,11 @@ func memberPage(t *testing.T, page string, shell server.Shell) *htmltest.Node {
return htmltest.Parse(t, renderMemberShell(t, page, shell))
}
var memberPages = []string{"index.html", "products.html", "billing.html"}
// entryPages are the three member pages a rail entry names; memberPages adds
// the two pages that sit below an entry.
var entryPages = []string{"index.html", "products.html", "billing.html"}
var memberPages = append(slices.Clone(entryPages), "billing_invoice.html", "domain_claim.html")
// setSupportURL configures the support URL for the rest of the test.
func setSupportURL(t *testing.T, url string) {
@@ -277,7 +287,7 @@ func TestShellRailAccountBlock(t *testing.T) {
}
// TestMemberPagesHaveOneMainLandmark pins page-anatomy "Every page has one
// main landmark" (ACC-40): each of the three member root pages wraps its
// main landmark" (ACC-40): each member page wraps its
// content in exactly one <main>, matching the operator shell's placement.
func TestMemberPagesHaveOneMainLandmark(t *testing.T) {
for _, page := range memberPages {
@@ -51,6 +51,7 @@ func claimOutcomeRows() []shapedRow {
}
return []shapedRow{
outcome("hosted", "alert-info", "is part of our hosting", func(d *MemberDomainClaimData) { d.Hosted = true }),
outcome("hosted and released", "alert-info", "was released", func(d *MemberDomainClaimData) { d.Hosted, d.Released = true, true }),
outcome("canceled", "alert-info", "was canceled", func(d *MemberDomainClaimData) { d.Canceled = true }),
outcome("released", "alert-info", "was released", func(d *MemberDomainClaimData) { d.Released = true }),
outcome("expired", "alert-warning", "expired before the DNS record was found", func(d *MemberDomainClaimData) { d.Expired = true }),
+33 -30
View File
@@ -242,7 +242,7 @@ type DashboardCard struct {
// PendingDomainClaim is one in-flight domain verification surfaced by the
// dashboard's pending notice (dissolve-member-domains): just enough to name
// the root and open its DNS instructions via the core claim-status partial.
// the root and link to the claim's page, where its DNS instructions are.
type PendingDomainClaim struct {
ClaimID string
Root string
@@ -665,7 +665,8 @@ func registerCoreHandlers(httpRequestRouter *http.ServeMux, cfg Config, authConf
}
memberProductsHandler.RegisterRoutes(httpRequestRouter)
// Register Member Invoices partials handler (Billing page)
// Register the member invoices handler: the invoices partial the Billing
// page composes, the invoice page and the Pay invoice routes
memberInvoicesHandler, err := NewMemberInvoicesHandler(MemberInvoicesConfig{
BillingQ: cfg.BillingQ,
EntitlementsQ: cfg.EntitlementsQ,
@@ -680,7 +681,8 @@ func registerCoreHandlers(httpRequestRouter *http.ServeMux, cfg Config, authConf
}
memberInvoicesHandler.RegisterRoutes(httpRequestRouter)
// Register Member Domains partials handler (Domains page). The connect
// Register the member domains handler: the claims partials and the claim
// page at /domains/claims/{claimID}. The connect
// target is the domains-connect-target core key, resolved once by the
// composition root (design D7): an empty value disables external claims
// deployment-wide.
@@ -841,28 +843,28 @@ func readsNoSession(path string, exempt []string) bool {
return strings.HasPrefix(path, "/static/") || path == "/favicon.ico" || slices.Contains(exempt, path)
}
// memberShellFor assembles the shared application shell's data for a member
// page (docs/design-system.md, "Application shell"): the person's identity
// for the account menu, the identity provider's account console, the
// operator role for the rail's surface switch, and the rail entry to mark
// active.
func memberShellFor(authConfig *auth.Config, r *http.Request, active string) Shell {
ctx := r.Context()
return Shell{
Surface: ShellMember,
Name: authConfig.GetUserName(ctx),
Username: authConfig.GetUsername(ctx),
Email: authConfig.GetUserEmail(ctx),
KeycloakAccountURL: config.IdPAccountURL(),
IsOperator: authConfig.HasRole(r, OperatorRole),
Active: active,
}
}
// registerMemberPages registers the member pages: the dashboard at "/", the
// Products and Billing pages, and the redirect from the dissolved Domains
// page. Each composes its regions in-process through include.
func registerMemberPages(httpRequestRouter *http.ServeMux, cfg Config, authConfig *auth.Config, include Include, safeTmpl *SafeTemplates) {
// memberShell assembles the shared application shell's data for a
// member page (docs/design-system.md, "Application shell"): the person's
// identity for the account menu, the identity provider's account console,
// the operator role for the rail's surface switch, and the rail entry to
// mark active.
memberShell := func(r *http.Request, active string) Shell {
ctx := r.Context()
return Shell{
Surface: ShellMember,
Name: authConfig.GetUserName(ctx),
Username: authConfig.GetUsername(ctx),
Email: authConfig.GetUserEmail(ctx),
KeycloakAccountURL: config.IdPAccountURL(),
IsOperator: authConfig.HasRole(r, OperatorRole),
Active: active,
}
}
// Serve index.html via template rendering
httpRequestRouter.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// The "/" pattern matches every otherwise-unrouted path. Only the
@@ -918,7 +920,7 @@ func registerMemberPages(httpRequestRouter *http.ServeMux, cfg Config, authConfi
hasEntitlement = orgHasEntitlement(ctx, cfg.EntitlementsQ, session.OrgID)
}
data := IndexPageData{Shell: memberShell(r, "dashboard"), Name: name, Username: username, Email: email, KeycloakAccountURL: keycloakAccountURL, IsOperator: isOperator, HasMultipleWorkspaces: hasMultipleWorkspaces, CheckoutStatus: checkoutStatus, DashboardCards: cards, Workspaces: workspaces, PendingDomainClaims: pendingDomainClaims, HasEntitlement: hasEntitlement}
data := IndexPageData{Shell: memberShellFor(authConfig, r, "dashboard"), Name: name, Username: username, Email: email, KeycloakAccountURL: keycloakAccountURL, IsOperator: isOperator, HasMultipleWorkspaces: hasMultipleWorkspaces, CheckoutStatus: checkoutStatus, DashboardCards: cards, Workspaces: workspaces, PendingDomainClaims: pendingDomainClaims, HasEntitlement: hasEntitlement}
if checkoutStatus == "success" {
data.BillingFacts = loadBillingFacts(ctx, cfg.Database, cfg.StripeKeyFingerprint, cfg.Logger)
@@ -936,7 +938,7 @@ func registerMemberPages(httpRequestRouter *http.ServeMux, cfg Config, authConfi
// Server-side composition: the three regions render into this
// response; their partial routes stay the swap sources.
data := ProductsPageData{
Shell: memberShell(r, "products"),
Shell: memberShellFor(authConfig, r, "products"),
Entitlements: IncludeOr(include, safeTmpl, cfg.Logger, r, "/partials/member/entitlements", "your entitlements"),
Plans: IncludeOr(include, safeTmpl, cfg.Logger, r, "/partials/member/plans", "plans"),
Addons: IncludeOr(include, safeTmpl, cfg.Logger, r, "/partials/member/addons", "add-ons"),
@@ -950,9 +952,9 @@ func registerMemberPages(httpRequestRouter *http.ServeMux, cfg Config, authConfi
w.Header().Set("Content-Type", "text/html; charset=utf-8")
// Server-side composition: the invoices region renders into this
// response; its partial route stays the swap source.
// response; nothing swaps it afterwards.
data := BillingPageData{
Shell: memberShell(r, "billing"),
Shell: memberShellFor(authConfig, r, "billing"),
Invoices: IncludeOr(include, safeTmpl, cfg.Logger, r, "/partials/member/invoices", "invoices"),
}
@@ -960,9 +962,10 @@ func registerMemberPages(httpRequestRouter *http.ServeMux, cfg Config, authConfi
})
// The standalone member Domains page is dissolved (dissolve-member-domains):
// claims are managed at point of use, in the Domains section nested inside
// the FedWiki sites dashboard card, all via the same /partials/domains/...
// routes registered above. Stale links and bookmarks land on that section's
// claims are listed at point of use, in the Domains section nested inside
// the FedWiki sites dashboard card, via the /partials/domains/... routes
// registered above, and each claim's records and status are its own page
// at /domains/claims/{claimID}. Stale links and bookmarks land on that section's
// fragment anchor (ux-ia-naming D7) rather than a bare dashboard redirect,
// so a member following a domains link lands on domains content, not just
// the dashboard.
@@ -987,8 +990,8 @@ func multipleWorkspaces(ctx context.Context, orgQ organization.Querier, session
// pendingClaims lists the session's workspace's domain claims whose DNS
// verification is still in flight (dissolve-member-domains): with the
// standalone Domains page gone, the dashboard is the durable re-entry point
// for such a claim. Best-effort — a lookup failure only costs the notice,
// standalone Domains page gone, the dashboard is the durable way back to such
// a claim, through its notice's link to the claim's page. Best-effort — a lookup failure only costs the notice,
// never the page.
func pendingClaims(ctx context.Context, domainsQ domains.Querier, logger *slog.Logger, session *auth.UserSession) []PendingDomainClaim {
if session == nil {
+4
View File
@@ -29,6 +29,10 @@ type Shell struct {
// "products", or "billing". The operator rail keeps its own
// ActiveCapability logic in operator.html and ignores this.
Active string
// BelowActive reports that the page sits below the Active entry: the
// rail marks the entry active and gives it aria-current="true" rather
// than "page", because the trail's last crumb is the one current page.
BelowActive bool
// Flash is the load-time success message: a non-empty value is
// pre-rendered into #successToast (partials/shell_toasts.html) and
// shown once on load. The operator's landings set it from
+2 -1
View File
@@ -4,10 +4,12 @@
/static/ 200
/static/fake/ 200
GET /billing 200 h1=Billing
GET /billing/invoices/{invoiceID} 404 h1=404 Not Found
GET /billing/invoices/{invoiceID}/hosted 404 h1=404 Not Found
GET /billing/plans/{ladderID}/unpaid-invoice 404 h1=404 Not Found
GET /domains 302 loc=/#domains first=<a href="/#domains">
GET /domains/ask 400 h1=400 Bad Request
GET /domains/claims/{claimID} 404 h1=404 Not Found
GET /hooks/card 200
GET /operator 200 h1=Operator overview
GET /operator/billing/accounts 200 h1=Billing
@@ -41,7 +43,6 @@ GET /partials/domains/claims/{claimID} 404
GET /partials/member/addons 200
GET /partials/member/entitlements 200 first=<div class="text-center py-4">
GET /partials/member/invoices 200 first=<div class="d-flex align-items-center justify-content-between gap-3 mt-4 mb-2 app-section-header">
GET /partials/member/invoices/{invoiceID} 404
GET /partials/member/plans 200
GET /partials/member/plans/switch/preview 400
GET /partials/operator/organizations/{orgID}/enrollment 200 first=<div class="alert alert-danger app-notice app-notice-problem" role="alert">
+4 -2
View File
@@ -38,6 +38,8 @@ DELETE /partials/operator/plan-ladders/{ladderID}/tiers/{productID} probe=/part
member: 403 type=text/plain text=Forbidden h=nosniff,rid
GET /billing probe=/billing pattern=GET /billing
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /billing/invoices/{invoiceID} probe=/billing/invoices/00000000-0000-0000-0000-000000000000 pattern=GET /billing/invoices/{invoiceID}
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /billing/invoices/{invoiceID}/hosted probe=/billing/invoices/00000000-0000-0000-0000-000000000000/hosted pattern=GET /billing/invoices/{invoiceID}/hosted
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /billing/plans/{ladderID}/unpaid-invoice probe=/billing/plans/00000000-0000-0000-0000-000000000000/unpaid-invoice pattern=GET /billing/plans/{ladderID}/unpaid-invoice
@@ -47,6 +49,8 @@ GET /domains probe=/domains pattern=GET /domains
member: 302 loc=/#domains type=text/html h=nosniff,rid
GET /domains/ask probe=/domains/ask pattern=GET /domains/ask
anon: 400 type=text/html h1=400 Bad Request lead=This link is missing its domain. Ask whoever gave you the link to include a domain, or contact your operator. h=nosniff,rid
GET /domains/claims/{claimID} probe=/domains/claims/00000000-0000-0000-0000-000000000000 pattern=GET /domains/claims/{claimID}
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /hooks/card probe=/hooks/card pattern=GET /hooks/card
anon: 302 loc=/login type=text/html h=nosniff,rid
member: 200 type= h=nosniff,rid
@@ -146,8 +150,6 @@ GET /partials/member/entitlements probe=/partials/member/entitlements pattern=
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/invoices probe=/partials/member/invoices pattern=GET /partials/member/invoices
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/invoices/{invoiceID} probe=/partials/member/invoices/00000000-0000-0000-0000-000000000000 pattern=GET /partials/member/invoices/{invoiceID}
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/plans probe=/partials/member/plans pattern=GET /partials/member/plans
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/plans/switch/preview probe=/partials/member/plans/switch/preview pattern=GET /partials/member/plans/switch/preview
+4 -2
View File
@@ -38,6 +38,8 @@ DELETE /partials/operator/plan-ladders/{ladderID}/tiers/{productID} probe=/part
member: 403 type=text/plain text=Forbidden h=nosniff,rid
GET /billing probe=/billing pattern=GET /billing
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /billing/invoices/{invoiceID} probe=/billing/invoices/00000000-0000-0000-0000-000000000000 pattern=GET /billing/invoices/{invoiceID}
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /billing/invoices/{invoiceID}/hosted probe=/billing/invoices/00000000-0000-0000-0000-000000000000/hosted pattern=GET /billing/invoices/{invoiceID}/hosted
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /billing/plans/{ladderID}/unpaid-invoice probe=/billing/plans/00000000-0000-0000-0000-000000000000/unpaid-invoice pattern=GET /billing/plans/{ladderID}/unpaid-invoice
@@ -47,6 +49,8 @@ GET /domains probe=/domains pattern=GET /domains
member: 302 loc=/#domains type=text/html h=nosniff,rid
GET /domains/ask probe=/domains/ask pattern=GET /domains/ask
anon: 400 type=text/html h1=400 Bad Request lead=This link is missing its domain. Ask whoever gave you the link to include a domain, or contact your operator. h=nosniff,rid
GET /domains/claims/{claimID} probe=/domains/claims/00000000-0000-0000-0000-000000000000 pattern=GET /domains/claims/{claimID}
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /hooks/card probe=/hooks/card pattern=GET /hooks/card
anon: 302 loc=/login type=text/html h=nosniff,rid
member: 200 type= h=nosniff,rid
@@ -146,8 +150,6 @@ GET /partials/member/entitlements probe=/partials/member/entitlements pattern=
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/invoices probe=/partials/member/invoices pattern=GET /partials/member/invoices
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/invoices/{invoiceID} probe=/partials/member/invoices/00000000-0000-0000-0000-000000000000 pattern=GET /partials/member/invoices/{invoiceID}
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/plans probe=/partials/member/plans pattern=GET /partials/member/plans
anon: 302 loc=/login type=text/html h=nosniff,rid
GET /partials/member/plans/switch/preview probe=/partials/member/plans/switch/preview pattern=GET /partials/member/plans/switch/preview
+6
View File
@@ -21,6 +21,12 @@ func TestEveryLayoutRendersTheSharedToasts(t *testing.T) {
{"dashboard", func(t *testing.T) string { return Render(t, MemberSet(t), "index.html", IndexPageData{}) }},
{"products", func(t *testing.T) string { return Render(t, MemberSet(t), "products.html", ProductsPageData{}) }},
{"billing", func(t *testing.T) string { return Render(t, MemberSet(t), "billing.html", BillingPageData{}) }},
{"invoice page", func(t *testing.T) string {
return Render(t, MemberSet(t), "billing_invoice.html", MemberInvoicePageData{})
}},
{"claim page", func(t *testing.T) string {
return Render(t, MemberSet(t), "domain_claim.html", MemberDomainClaimPageData{Claim: MemberDomainClaimData{Domain: "wiki.example.org"}})
}},
{"operator page", func(t *testing.T) string { return Render(t, OperatorSet(t), "operator.html", OperatorPageData{}) }},
} {
t.Run(r.name, func(t *testing.T) {
+18
View File
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
package web
import (
"html/template"
"strings"
)
// BreakAtDots HTML-escapes s and inserts <wbr> after each ".", so a long
// domain name wraps between its labels before the browser breaks inside one.
// Registered in every template set as `breakAtDots`; the page header and the
// DNS records tables render names through it, while data-copy attributes keep
// the plain string.
func BreakAtDots(s string) template.HTML {
return template.HTML(strings.ReplaceAll(template.HTMLEscapeString(s), ".", ".<wbr>"))
}
+20
View File
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
package web
import "testing"
func TestBreakAtDots(t *testing.T) {
for _, c := range []struct{ in, want string }{
{"", ""},
{"example", "example"},
{"a.b.example.org", "a.<wbr>b.<wbr>example.<wbr>org"},
{"*.example.org", "*.<wbr>example.<wbr>org"},
{`<b>&"x'.y`, `&lt;b&gt;&amp;&#34;x&#39;.<wbr>y`},
} {
if got := string(BreakAtDots(c.in)); got != c.want {
t.Errorf("BreakAtDots(%q) = %q, want %q", c.in, got, c.want)
}
}
}
+1
View File
@@ -131,6 +131,7 @@ func surfaceFuncs(root func() SurfaceRoot) template.FuncMap {
"helpIcon": forms.Help,
"surfaceRoot": root,
"shellConfirmForm": shellConfirmForm,
"breakAtDots": BreakAtDots,
}
}
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-05
@@ -0,0 +1,98 @@
## Context
The member surface has three pages: the dashboard at `/`, Products and Billing. Each is registered in `registerMemberPages` (`internal/server/server.go`), which builds the shell through a closure, `memberShell`, and composes its regions server-side through `include`, so each region's partial route stays its swap source.
Two views reach no page of their own:
- **The invoice detail.** `GET /partials/member/invoices/{invoiceID}` (`MemberInvoicesHandler.GetInvoiceDetail`) renders `member_invoice_detail.html`. An invoice number in the list (`member_invoices.html`) is `<a href="#" hx-get=… hx-target="#billing-content">`, so the detail replaces the list inside the Billing page's one region, the URL never changes, and the detail offers "← Back to invoices" to swap the list back. Its title is a section header ("Invoice {number}") under the page's "Billing".
- **A claim's DNS records.** `GET /partials/domains/claims/{claimID}` (`MemberDomainsHandler.GetClaimStatus`) renders `member_domains_claim.html`: the records table, the probe status, "Check now" and "Cancel verification", refreshing itself every 5 seconds while the claim is pending. Two places open it into the nearest `.domains-surface`: the dashboard's pending-claim notice ("View DNS records", inside a `.domains-surface` wrapper made for this swap) and the sites card's claims table (a "DNS records" or "Details" button in the Actions column of each external claim). The view offers "← Back to domains", which loads the claims list into the same element, so on the dashboard the notice becomes the table.
`chrome-conventions` "One location trail" forbids every back affordance; the trail above the title is the way back. `chrome-conventions` "Row navigation is the primary column's link" makes a table's identifier the link to a record's page and forbids navigation drawn as buttons in a table. `domains-registry` dissolved the member Domains page into the sites card and the dashboard notice, and `GET /domains` redirects to the card. `form-conventions` keeps modals for confirmations.
## Goals / Non-Goals
Goals: neither view renders a back control; each is a page whose title and trail say what it is; the lint refuses a back link anywhere.
Non-goals: FedWiki's create dialog, which shows its own DNS instructions; the error pages' way out; any change to what the two views show; what a refused poll swaps in (see Risks).
## Decisions
### 1. Both views become pages
Pick: each view is a member page with its own address, rendered in the member shell with `pageHeader` and its trail: the invoice at `GET /billing/invoices/{invoiceID}`, the claim at `GET /domains/claims/{claimID}`. The controls that opened them become plain links.
Why: the issue offers two ways out, a page or a view that opens without replacing its surroundings. A page gives each view the trail the conventions require and an address that survives a refresh and can be shared, and needs no new shell part. Returning through the trail reloads the page the member came from, so the dashboard's notice and the sites card show the claim's current state after a cancel or a verification, with no event wiring.
Alternatives: a dialog over the page (a new shared view dialog on every member page and its script, a modal that is no confirmation, and a notice and a card left stale when the dialog's buttons change the claim unless a refresh is wired); an in-place expansion under the row or the notice (the 5-second refresh and the buttons swap inside a table row, and the notice grows a table).
### 2. The invoice page
Pick: `GET /billing/invoices/{invoiceID}` is served by `MemberInvoicesHandler`, which already holds the queries and the ownership gate (`memberInvoice`). The handler loads the detail data as `GetInvoiceDetail` does today and renders a new page template, `billing_invoice.html`, whose skeleton is `billing.html`'s: the shell with the Billing rail entry marked, `pageHeader` with `Title` "Invoice {number}" ("Invoice" before the invoice has a number) and `Crumbs` `[{Billing, /billing}]`, then `member_invoice_detail.html` as the body. The body loses its back button and its section header; it keeps the status, Stripe number and period line, the amounts, Pay invoice, line items and payments. A refused gate answers the styled error page with the gate's status, as the hosted-invoice routes do (`pageRefused`): 404 for an unknown, malformed or foreign id, 500 when the organization's billing accounts cannot be read. The partial route, `GetInvoiceDetail` and `gateRefused` go: no swap uses them, and `chrome-conventions` keeps fragments at partial paths only for swaps.
The member shell's construction, today the closure `memberShell` local to `registerMemberPages`, becomes a package function both callers use, so the invoice and claim handlers build the same shell the three pages do. Both handlers' template sets (`web.MemberTemplates(web.CoreTemplates())`) already parse every root page template, the shell parts and `error.html`.
Why: the handler that gates the invoice renders it, so the 404 that hides another organization's invoice is the page's own answer; an `include` of a partial would turn that 404 into a Problem notice inside a 200 page. The trail follows `chrome-conventions`: the surface root, the rail entry, the current page. The operator's invoice page takes the same shape ("Operator / Billing / Invoices / Invoice {number}").
An invoice with no number is titled "Invoice", as the operator's invoice page titles it. The help popover that explained the missing number ("Assigned when the invoice is issued.") sat on the section header, and a page header has no help slot; the list's marker for a missing number keeps its own tooltip.
### 3. The claim page
Pick: `GET /domains/claims/{claimID}` is served by `MemberDomainsHandler`. Its ownership check is a lookup that writes nothing, `claimFor(ctx, workspaceID, claimID) (domains.Claim, int)`, shaped like `memberInvoice`: it answers 404 for a nil registry, an id that is not a UUID, no claim, and another workspace's claim, and 500 only when the read fails for a well-formed id. It reads the claim by the parsed id's canonical form, as `pathUUID` does for operator routes, because the parser accepts spellings (`urn:uuid:…`) Postgres refuses. The page answers a refusal with the styled error page of that status; `ownedClaim`, which the partial routes keep, becomes a wrapper over `claimFor` that writes the plain errors the partials answer today.
The page renders a new template, `domain_claim.html`: the shell with the Dashboard rail entry marked, `pageHeader` with `Title` the claim's root name and no `Crumbs` (the trail reads "Home / {root}", because the claim sits under the surface root itself), then `member_domains_claim.html` as the body, then the toasts and the shared confirm modal as on every member page, and `<script defer src="/static/copy-button.js">`. The body loses its back button and its `h3` domain heading (the page title names the domain); its root element, its 5-second refresh and its buttons are unchanged, and the pending claim's status sentence ("Waiting for your DNS records…"), which the partial's renderer supplies today, moves into the data builder both routes share, so the page shows it before the first refresh; the partial route keeps serving the refresh, "Check now" and the cancel, and the cancel's confirm dialog resolves `closest .domain-claim-status` from the button inside that root.
The openers become links. The dashboard notice's row is `<code>{root}</code> <a class="btn btn-link" href="/domains/claims/{claimID}">View DNS records</a>`, keeping the classes that give a link in a notice row its size and baseline. In the sites card's claims table, each claim's root in the row header becomes the link to its page, and the "DNS records"/"Details" button goes, leaving Release as the Actions column's one verb. Every claim's root links, hosted ones included: the page serves any claim the workspace owns and shows its state (a hosted claim shows its hosted notice), and `chrome-conventions` links a row's identifier whenever the record has a page. The dashboard's `.domains-surface` wrapper around the notice goes with the swap it served; the sites card's stays, because Release swaps the claims list into it.
Why: the claim's page sits under the dashboard, the surface root, so its trail has no rail entry. The path sits under `/domains`, beside the redirect that sends the old Domains page's links to the sites card, and away from `/domains/ask`, the proxy's certificate endpoint, by its `claims` segment. `domains-registry` keeps its rule that there is no member domains page: the claim's page is one claim's instructions and status, reached only from the claim, never a list and never in the navigation. A button that navigates is what the row-navigation rule forbids, and once the records are a page the button only navigates. `ownedClaim` writes its own refusal, so a page handler that called it and then rendered the styled page would send two bodies; the lookup that writes nothing lets each caller answer in its own form, and parsing the id first keeps a malformed id a 404 rather than a database error.
### 4. The rail marks the entry a page sits under, without calling it the current page
Pick: `Shell` gains `BelowActive bool`. The member rail marks the `Active` entry `active` either way, and gives it `aria-current="page"` when `BelowActive` is false and `aria-current="true"` when it is true. The invoice page sets it under Billing, and the claim page under Dashboard.
Why: until now `Active` was set only on the entry's own page, so the rail's `aria-current="page"` was true. On a page below the entry it would announce a second current page beside the trail's last crumb; `aria-current="true"` still tells a screen reader which entry the page belongs to, as the `active` class tells a sighted reader. The operator rail marks `active` with no `aria-current`, so it needs no change.
### 5. The page title wraps a long name
Pick: `.app-page-header-text` in `app.css` gains `overflow-wrap: anywhere`, which the title and every crumb inherit.
Why: the claim's root is the claim page's title, and a long root with no break opportunity (`mycooperativecommunitywiki.example.org`) runs past a 390px viewport. The `h3` the claim view drops wrapped its `code` with `text-break`; the title keeps that behaviour. A rule on the header's text block changes no markup, so the tests and goldens that pin the header's classes stay as they are, and a title that fits renders as before.
### 5a. Domain names break at their dots
Pick: a template function inserts `<wbr>` after each dot of a string it renders, and the page title, the current crumb and the records table's names and values go through it. In the records table, the status badges may wrap.
Why: no CSS rule can choose where a word breaks, but `<wbr>` marks a preferred break, so a long domain wraps between its labels ("mycooperativecommunitywiki." then "example.org") before `overflow-wrap: anywhere` breaks inside a label, which it still does for a label longer than the line. A badge does not wrap, so "Not checked yet" set the Status column's width at 390px and left the names a narrow column; letting the table's badges wrap gives that width back. The rule is scoped to the records table because a badge elsewhere sits in a column sized for it.
### 6. The copy script
Pick: the claim page loads `static/copy-button.js`, which handles `.js-copy` buttons by delegation on the document and reads `data-copy`, so it survives the view's refresh. Its header comment says it is loaded by the claim page.
Why: the records' copy buttons had no handler on the dashboard unless the FedWiki card's script, which carries its own copy of the behaviour, happened to load. The page is now the one place the records render.
### 7. The lint rule
Pick: `back-link` reads every template the anatomy lint reads, partials and integration templates included, after blanking its comments, so a comment is not read even when it quotes markup. In text nodes and attribute values, read with character references decoded (`html.UnescapeString` on text; attribute values arrive decoded), it matches the words "Back" and "to" or "To" separated by any whitespace, a non-breaking space or a line break included, at a word boundary, and any of the left-pointing marks "←", "⟵", "⇐", "‹" and "«", so `&larr;`, `&laquo;` and their kin count. A text node or attribute value is reported once, at the line its text node or tag starts on, however many checks it matches. Its message names `chrome-conventions` "One location trail" and says the trail is the way back.
Why: the token rules already read text with template actions stripped and attribute values, which is where a back link's words live, and the error pages' "Back to the dashboard" and "Back to the console" come from Go strings through a template action, so the rule leaves the one sanctioned way out alone. A capital-B match at a word boundary keeps ordinary copy such as "Feedback to the team" from firing, while a capital T, a non-breaking space or a line break between the words does not let a back link through. No template uses any of the five marks for anything but going back. The arrow is the back link's other half, and a link reading "← Things" is a back link without the words. Decoding the text, rather than searching the source for the entity, keeps one report per node and puts it on the node's line.
### 8. The trail's first crumb in `page-anatomy`
Pick: "One title size and one header layout" stops describing the trail itself and defers to `chrome-conventions` "One location trail", whose wording the code follows: the first crumb is the surface's root, then the rail entry, then real intermediate pages, then the current page; the surface roots and error pages render none. Its scenario's subject becomes "a person" (the member surface now has detail pages too) and its breadcrumb "{surface root} / {rail entry} / … / {instance}" (the operator's invoice page has an intermediate crumb).
Why: this change adds the member surface's first trails below a root page, and the two requirements disagreed on what those trails read.
## Risks / Trade-offs
- [A member leaves the dashboard to read a claim's records] → the trail's "Home" returns them, and the dashboard they return to is current.
- [Links and bookmarks to `/partials/member/invoices/{id}`] → the route was a fragment never shown in the address bar; nothing outside the console links to it.
- [The demo database holds no domain claim] → nothing links to a claim's page in the demo data, so the claim page is a Skip entry in the screens manifest and is captured by hand, as the sites card is, until the demo data holds a claim.
- [A refresh answered 404, after the claim left the session's workspace] → htmx swaps the partial's plain-text 404 over the view and the error toast shows. The claim page inherits this from the view; what a refused poll should show is #325.
- [A refresh lands while the cancel's confirm dialog is open] → it replaces `.domain-claim-status`, including the target id the dialog stamped on it, so the cancel's answer finds no target; the claim is canceled, and the next refresh shows it within five seconds. Also inherited from the view.
## Migration Plan
None: no schema change.
## Open Questions
None.
@@ -0,0 +1,68 @@
## Why
Two member views open in place of a region and offer "← Back to …" to return, which `chrome-conventions` "One location trail" forbids (#321). The invoice detail swaps into the Billing page's only region under the "Billing" title, so the title names a page the content no longer is. A domain claim's DNS records swap into the region that opened them; on the dashboard that region is the pending-claim notice, and "← Back to domains" puts the whole claims table where the notice was, a second copy of the table the sites card already shows. Below the lg breakpoint the rail is a drawer, so the trail is the one statement of where a view sits, and these two views carry the wrong one. No lint rule refuses a back link, so nothing stopped either.
## What Changes
- **The invoice detail is a page.** `GET /billing/invoices/{invoiceID}` renders the member shell with the Billing rail entry marked, titled "Invoice {number}" ("Invoice" before the invoice has a number) under the trail "Home / Billing / Invoice {number}", and the detail below it with no back control. Each invoice number in the Billing page's list is a plain link to it. An invoice the member's organization does not own, or no invoice, answers the 404 page. The partial route `GET /partials/member/invoices/{invoiceID}` goes; nothing swaps the detail in any more.
- **A domain claim's DNS records are a page.** `GET /domains/claims/{claimID}` renders the member shell with the Dashboard rail entry marked, titled with the claim's root name under the trail "Home / {root}", and the claim's records and status below it: the 5-second refresh, "Check now" and "Cancel verification" work as before, and the page has no back control. The dashboard notice's "View DNS records" is a plain link to it, and in the sites card's claims table each claim's root name is the link to its page, in place of the "DNS records" and "Details" buttons. A claim the workspace does not own, or no claim, answers the 404 page. The partial route `GET /partials/domains/claims/{claimID}` stays: the page's refresh and its two buttons swap it.
- **The lint refuses a back link.** A new rule, `back-link`, fails on "Back to" or a left arrow ("←" or `&larr;`) in any template's text or attribute values, partials included, so a third cannot appear.
## Ride-alongs
- **The claim view's copy buttons.** On the dashboard the claim view's copy buttons worked only when the FedWiki card's script happened to be loaded, because the core copy script (`static/copy-button.js`) is referenced by no template. The claim page loads it.
- **The rail's current-page claim.** The member rail gives its marked entry `aria-current="page"`. On the two new pages that entry is the page's parent, not the page, so there the rail marks the entry with `aria-current="true"`, the section the page belongs to; the trail's last crumb is the one current page.
- **The records table at narrow widths.** The records table's first cell, the record type and its purpose, did not wrap, so "Optional; lets any subdomain work without new DNS records" alone was wider than a 390px screen and squeezed the name and value columns until they broke one character per line, out of view. The cell now wraps, in the claim view and in FedWiki's DNS dialog, which carries the same table.
- **Long names break at their dots, and the records' status badges wrap.** A domain name in the page title, the trail and the records table breaks between its labels before it breaks inside one, and a status badge in the records table wraps, so the names get the width at 390px.
- **A long page title wraps.** The page header's title and its crumbs break a long word, so a long domain name stays inside a 390px viewport. A title that fits renders as before.
- **The operator invoice page's requirement.** `operator-billing-views` "Operator invoice detail is addressable" still requires a back affordance to the invoices view, which the page no longer renders and the new rule refuses. It now requires the trail whose Invoices crumb leads there.
- **The trail's first crumb in `page-anatomy`.** "One title size and one header layout" says the trail's first crumb is the page's rail entry and that rail-entry pages render none; `chrome-conventions` and the code put the surface's root first and give a rail-entry page "Operator / Products". The requirement is corrected to defer to `chrome-conventions`.
- **Stale comments** that describe a back affordance or a swap the change removes, in the handlers, the templates and `PageHeader`'s doc comment; and the docs that list the lint rules or describe a member Domains page.
## Strings
No new words. The pages reuse the titles their views carry today ("Invoice {number}", "Invoice", the claim's root name) and the crumb "Billing". The browser tab reads "Invoice {number} - {deployment}" ("Invoice - {deployment}" before the invoice has a number) and "{root} - {deployment}", in the form the Billing page's "Billing - {deployment}" uses. A refused request on either page shows the error page's existing sentences, "The page you requested does not exist." or "An unexpected error occurred. Try again."
Removed: "← Back to invoices", "← Back to domains", the sites card's "DNS records" and "Details" buttons, and the help popover "Assigned when the invoice is issued." on an unnumbered invoice's detail (the list's marker for a missing number keeps its own).
### Visible changes for the screens review
- **Billing:** the invoice numbers are plain links; opening one loads a new page.
- **The invoice page:** the trail "Home / Billing / Invoice {number}" above the title "Invoice {number}"; the status, Stripe number and period line under the title; no back link.
- **The claim page:** the trail "Home / {root}" above the title; the records table, status and buttons as before; no back link and no small domain heading.
- **The dashboard:** the pending-claim notice unchanged; "View DNS records" opens the claim page.
- **The sites card's claims table:** each root name is a link; the "DNS records" and "Details" buttons are gone, and Release stays.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `member-invoice-history`: the invoice detail is a member page at its own address with the trail, linked from the list.
- `member-dashboard`: the pending-claim notice links to each claim's page.
- `domains-registry`: each claim's DNS instructions and status are a member page of their own; there is still no member domains list page and no navigation entry.
- `fedwiki-sites`: the sites card's claims list links each claim's root to its page instead of opening the records inline.
- `page-anatomy`: the trail's first crumb is the surface's root, as `chrome-conventions` says.
- `operator-billing-views`: the operator invoice page carries the trail to the invoices view instead of a back affordance.
- `ui-quality-gate`: the lint refuses a back link.
## Impact
- **Code:** `internal/server/server.go` (`registerMemberPages`, the member shell, `PendingDomainClaim`'s comment), `internal/server/shell.go`, `internal/server/member_invoices.go`, `internal/server/member_hosted_invoice.go`, `internal/server/member_domains.go`, `internal/server/anatomy.go`; templates `billing.html`, `index.html`, `partials/member_invoices.html`, `partials/member_invoice_detail.html`, `partials/member_domains.html`, `partials/member_domains_claim.html`, `partials/shell_rail_member.html`, `internal/integrations/fedwiki/templates/fedwiki_sites.html` (a comment), and two new page templates; `internal/embeds/static/app.css`; `internal/embeds/static/copy-button.js` (its comment); `internal/lint/anatomy.go`.
- **Tests:** the invoice and claim pages (title, trail, rail, no back link, the confirm dialog, 404 and 500), the list's, the notice's and the sites card's links, the claim page's refresh and buttons, the layout tests that enumerate every member page, the lint rule and its verdicts golden, the route goldens, and the tests that pinned "Back to invoices", the in-place swaps and the dashboard's `.domains-surface` wrapper.
- **Docs:** `docs/testing.md` and `docs/design-system.md` (the anatomy rule lists), `docs/fedwiki-setup.md` (a Domains page that no longer exists).
- **Screens:** the manifest lists the invoice page as a screen and the claim page as a Skip entry, because the demo data holds no claim to reach it by; the claim page is captured by hand. `member-billing` changes by the links' markup only.
- **Schema:** none.
## Out of scope
- **FedWiki's own DNS instructions** inside its create dialog, which open and close with the create flow and carry no back link.
- **The error page's "Back to the dashboard"** and the sign-in failure page's "Back to the console": an error page has no trail and links out in its copy (`error-pages` "The error page offers exactly one way out"). Both are Go strings the page renders through a template action, so the new rule does not read them.
- **What a refused refresh shows** on the claim view (a plain-text 404 swapped over it), which the page inherits from the view (#325).
## Related issues
- **#321** closes with this change.
@@ -0,0 +1,103 @@
## MODIFIED Requirements
### Requirement: Members manage their domains at point of use
The console SHALL present member domain management at point of use rather than on a
standalone destination: the workspace's live claims — root name, kind, status, and
placement count — SHALL be listed within the member sites surface, and a
pending-claim notice SHALL appear on the member dashboard while any of the
workspace's claims is `pending`. There SHALL be no member navigation entry for
domains and no member page that lists domains; `GET /domains` SHALL redirect to the
dashboard. Each claim's DNS instructions and status SHALL be a member page of its own
at `/domains/claims/{claimID}`, rendered in the member shell with the Dashboard rail
entry active, titled with the claim's root name under the location trail
"Home / {root}" and carrying no back link (chrome-conventions "One location trail").
The sites surface's claims list and the dashboard notice SHALL link to it, and a
claim the workspace does not own, or no claim, SHALL answer the 404 page without
revealing whether the claim exists. The claim affordances SHALL be: viewing a pending claim's DNS
instructions and per-record probe status (from the sites surface and from the
dashboard notice), triggering an immediate re-check (signal the workflow,
coalescing, backoff reset), canceling a pending claim (frees the name immediately
and stops the workflow), and releasing a claim that has no placements. Adding an
external domain SHALL be offered only through the site-creation flow's
external-domain entry (entitlement-gated per the external-claim requirements). DNS
instructions SHALL render as a records table with one row per record — the TXT
challenge, the connect record pointing at the configured connect target, and an
**optional** wildcard row (`*.<root>` → target) explained as letting any subdomain
work without further DNS changes — each name and value copyable in one click, with
per-record status, observed values on mismatch, last-checked time, and the window
end. The status view SHALL update in place using the established HTMX polling
pattern (no full page reload, no inline scripts).
Instructions SHALL remain reachable while a claim is pending, and reopening them
SHALL NOT re-initiate a claim or mint new records. Cancellation SHALL apply only to
`pending` claims — a claim that already became `active`, `expired`, or `canceled`
SHALL be left unchanged and its current state shown. Cancel and re-check SHALL be
permitted only for the owning workspace.
#### Scenario: Claims list shows verification state at its new home
- **WHEN** a member with an active carved claim and a pending external claim opens
the member sites surface
- **THEN** both claims SHALL be listed with kind and status
- **AND** the pending claim SHALL link to its DNS instructions view
#### Scenario: No member navigation entry for domains
- **WHEN** any member shell renders its navigation
- **THEN** no Domains entry SHALL appear
- **AND** a request to `GET /domains` SHALL redirect to the dashboard
#### Scenario: Pending claim stays reachable without the standalone page
- **WHEN** a member starts an external claim from site creation and navigates away
- **THEN** the dashboard SHALL show a pending-domain notice while the claim is
pending
- **AND** the notice SHALL link to the claim's page, which shows its DNS
instructions without re-initiating the claim or minting new records
#### Scenario: A claim's instructions are a page under Home
- **WHEN** a member follows "View DNS records" for the pending claim on `example.org`
- **THEN** `/domains/claims/{claimID}` renders titled "example.org" under the trail
"Home / example.org", with the Dashboard rail entry active, the records table,
"Check now" and "Cancel verification"
- **AND** no back link renders on the page
- **AND** the page's status refreshes in place every 5 seconds while the claim is
pending
#### Scenario: Another workspace's claim is not found
- **WHEN** a member requests the page of a claim another workspace owns, or of an
id that names no claim
- **THEN** the 404 page renders, the same for both
#### Scenario: Wildcard row is optional guidance
- **WHEN** the DNS instructions render for an external claim
- **THEN** the wildcard row SHALL be labeled optional
- **AND** verification SHALL succeed from the TXT record alone
#### Scenario: Release is guarded by placements
- **WHEN** a member attempts to release a claim that still has a placement
- **THEN** the release SHALL be refused, telling the member to remove the site(s)
first
#### Scenario: Cancel frees the name immediately
- **WHEN** the owning member cancels a pending external claim
- **THEN** the claim SHALL become `canceled`, the workflow SHALL stop, and the name
SHALL be immediately claimable again
#### Scenario: Cancel loses the race to verification
- **WHEN** a cancel request arrives after the workflow has already marked the claim
`active`
- **THEN** the claim SHALL remain `active` and the member SHALL see its verified
state
#### Scenario: Status updates in place
- **WHEN** a probe records new per-record state while the member has the status view
open
- **THEN** the view SHALL reflect it via the polling swap without a full page reload
@@ -0,0 +1,33 @@
## MODIFIED Requirements
### Requirement: Member sites surface embeds workspace domain management
The member sites surface SHALL embed the workspace's domain-claims section (the
core claims list and its management affordances) so that domains are managed where
sites live: each claim renders with kind, status, and placement count, and its root
name links to the claim's page (domains-registry "Members manage their domains at
point of use"), where its DNS instructions and status show; active claims with no placements offer the
existing one-click site create alongside a release affordance. The section SHALL
reuse the core claims list partial and its release route unchanged (same CSRF pattern)
— the fedwiki surface hosts core partials, never reimplements them. The create
form's external-domain path SHALL manage its claim inline and SHALL NOT link to a
standalone domains page.
#### Scenario: Sites view lists the workspace's claims
- **WHEN** a member with at least one claim opens the member sites surface
- **THEN** the domain-claims section SHALL render each claim with kind, status,
and placement count
#### Scenario: Verified unplaced claim offers create and release together
- **WHEN** a member's external claim becomes `active` with no placements
- **THEN** the sites surface SHALL offer a one-click site create for it
- **AND** SHALL offer releasing the claim as the alternative
#### Scenario: No links to a standalone domains page
- **WHEN** the member sites surface or the site-creation form renders
- **THEN** no link to the `/domains` redirect SHALL be present; the claims list and
its release render inline, and each claim's records open on its own page under
`/domains/claims/`
@@ -0,0 +1,32 @@
## MODIFIED Requirements
### Requirement: Dashboard surfaces pending domain claims
The member dashboard SHALL render a pending-domain notice while at least one of the
workspace's domain claims is `pending`, and SHALL render nothing domain-related
otherwise (no empty chrome). The notice SHALL name the pending root(s), each with a
"View DNS records" link to that claim's page (domains-registry "Members manage their
domains at point of use"), and following it SHALL NOT re-initiate the claim or mint
new records. The notice is
core-rendered content — domains is core substrate, not an integration — and SHALL
NOT be implemented as an integration-declared dashboard card, preserving the
card registry's integration-genericity requirement.
#### Scenario: Pending claim shows a notice
- **WHEN** the workspace has a claim in `pending`
- **THEN** the dashboard SHALL show the pending-domain notice naming the claim root
- **AND** its "View DNS records" link SHALL open the claim's page, which renders the
claim's DNS instructions and per-record status
#### Scenario: No pending claims, no notice
- **WHEN** the workspace has no `pending` claims
- **THEN** the dashboard SHALL render no domain notice and no empty placeholder
#### Scenario: Notice is core content, not a card
- **WHEN** the dashboard's integration card section is inspected
- **THEN** the pending-domain notice SHALL NOT be among the registry-declared cards
- **AND** core dashboard templates SHALL still contain no integration-specific
references
@@ -0,0 +1,31 @@
## MODIFIED Requirements
### Requirement: Member views invoice detail with line items and payments
The system SHALL provide a per-invoice detail page at `/billing/invoices/{invoiceID}`, rendered in the member shell with the Billing rail entry active, titled "Invoice {number}" ("Invoice" before the invoice has a number) under the location trail "Home / Billing / Invoice {number}" and carrying no back link (chrome-conventions "One location trail"), with Stripe's number as a secondary "Stripe invoice ..." line under the title when the mapping carries one. Each invoice number in the Billing page's invoice list, and the marker that stands in for a missing one, SHALL be a plain link to that page. The page shows the period the invoice's lines pay for (Requirement: An invoice shows the period its lines pay for), the invoice's line items (description, quantity, amount) and the payments recorded against it (amount, status, date), each dated when it succeeded or failed (stripe-invoice-payment-projection, Requirement: A payment is dated when it succeeded or failed) and listed most recent first. The detail page SHALL only be accessible to a member of the organization that owns the invoice.
#### Scenario: Member opens an invoice they own
- **WHEN** an authenticated member selects an invoice belonging to their organization
- **THEN** the system displays the invoice's status, amounts, and the period its lines pay for, its line items with description, quantity, and amount, and any associated payments with amount, status, and date
#### Scenario: The invoice detail is a page under Billing
- **WHEN** a member follows invoice 0042's number in the Billing page's list
- **THEN** the browser loads `/billing/invoices/{invoiceID}`, whose trail reads "Home / Billing / Invoice 0042" above the title "Invoice 0042", with the Billing rail entry active
- **AND** no back link renders on the page
#### Scenario: A payment's date is when it settled
- **WHEN** a member opens an invoice whose payment the console recorded a day after Stripe reported it paid
- **THEN** the payment's date is the day Stripe reports it paid
#### Scenario: Member requests an invoice that is not theirs
- **WHEN** an authenticated member requests an invoice whose billing account does not belong to their organization
- **THEN** the system responds with the 404 page and does not reveal whether the invoice exists
#### Scenario: Member requests a non-existent invoice
- **WHEN** an authenticated member requests an invoice ID that does not exist
- **THEN** the system responds with the 404 page
@@ -0,0 +1,32 @@
## MODIFIED Requirements
### Requirement: Operator invoice detail is addressable
The system SHALL provide a per-invoice detail view at `/operator/billing/invoices/{invoiceID}` headed "Invoice {number}" (the UUID muted beneath; Stripe's number, when the mapping carries one, shown as "Stripe invoice {stripe_invoice_number}", an external reference and never the heading), showing the invoice's period as "Period: {period}", the period its lines pay for (member-invoice-history, Requirement: An invoice shows the period its lines pay for), the invoice's line items (description, quantity, amount, period), amounts due and paid with correct minor-unit formatting, status including the derived Overdue presentation, due and paid dates, the linked organization (linked to its composite), and its Stripe sync state with the deep link when synced — reusing the member invoice-detail projection queries rather than a parallel read path. The page SHALL carry the location trail "Operator / Billing / Invoices / Invoice {number}" (chrome-conventions "One location trail"), whose Invoices crumb leads to the invoices view, and no back link; it SHALL mark the Billing sidebar entry active and answer an unknown invoice ID with the panel's ordinary 404 handling.
#### Scenario: Invoice detail renders the full projection
- **WHEN** an operator loads `/operator/billing/invoices/{invoiceID}` for a projected invoice
- **THEN** line items, amounts, status (with Overdue derived when applicable), dates, the linked organization, and Stripe sync state render
- **AND** the trail's Invoices crumb leads to the invoices view, and no back link renders
#### Scenario: The invoice's period comes from its lines
- **WHEN** an operator opens the invoice of an upgrade made on Nov 10, 2026 from a monthly price to a yearly one, whose lines are a credit from Nov 10, 2026 to Nov 29, 2026 and a charge from Nov 10, 2026 to Nov 10, 2027, while Stripe's invoice-level period runs from Oct 29, 2026 to Nov 10, 2026
- **THEN** the page reads "Period: Nov 10, 2026 – Nov 10, 2027"
- **AND** each line's row shows that line's own period
#### Scenario: A credit of zero does not stretch the period
- **WHEN** an operator opens the invoice of an upgrade made on Nov 10, 2026 from a yearly price of $0 to a monthly one, whose lines are a line of zero from Nov 10, 2026 to Mar 1, 2027 and a charge from Nov 10, 2026 to Dec 10, 2026
- **THEN** the page reads "Period: Nov 10, 2026 – Dec 10, 2026"
#### Scenario: An invoice whose lines are all zero shows their period
- **WHEN** an operator opens the invoice of a price of $0, whose only line is of zero from Oct 29, 2026 to Nov 29, 2026
- **THEN** the page reads "Period: Oct 29, 2026 – Nov 29, 2026"
#### Scenario: Unknown invoice IDs 404 in the shell
- **WHEN** an operator loads the detail route with an ID no invoice has
- **THEN** the panel's ordinary 404 handling answers inside the operator shell
@@ -0,0 +1,21 @@
## MODIFIED Requirements
### Requirement: One title size and one header layout
The `pageHeader` part SHALL render the page title as `<h1 class="h2">`, preceded by an optional location trail (chrome-conventions "One location trail"), followed by an optional one-sentence lead in the muted body colour, with one right-hand slot that holds either a muted count or one action control, never both and never more than one control. The trail is the one chrome-conventions "One location trail" defines: a Bootstrap breadcrumb whose first crumb is the surface's root, followed by the page's rail entry when the page sits below one, then real intermediate pages only, then the current page, unlinked with `aria-current="page"`; the surface roots and error pages render none. Pages SHALL NOT size the title otherwise (no unsized `h1`, no `h4`), SHALL NOT add a second header row, SHALL NOT put a paragraph longer than one sentence in the lead, and SHALL NOT render a back link. Every page body (a template a handler names as the page's `BodyTemplate`, and every member page) SHALL render `pageHeader`; a detail or edit page's title is the instance's name, never a card title. The trail is the header's: it renders above the title and outside any box, and nothing else on the page renders a trail or a back link (maintainer, 2026-08-30, replacing the back affordance).
#### Scenario: Title size is uniform
- **WHEN** any page rendered through `pageHeader` is compared with any other
- **THEN** both titles are `h1.h2` and both headers place the lead, the count, and the action in the same positions
#### Scenario: A detail page is titled and its trail sits above the title
- **WHEN** a person opens a detail or edit page below a rail entry
- **THEN** the page renders `pageHeader` with the instance's name as the `h1.h2` title and a breadcrumb "{surface root} / {rail entry} / … / {instance}" above it, outside any card, the current page unlinked
- **AND** no back link renders on the page
#### Scenario: The right-hand slot holds one thing
- **WHEN** a page supplies both a count and an action to `pageHeader`
- **THEN** rendering fails at template execution with a message naming the page, rather than rendering both
@@ -0,0 +1,30 @@
## ADDED Requirements
### Requirement: Lint refuses a back link
`member-console lint` SHALL fail with `back-link` when any template it reads for the page anatomy, partials and integration templates included, carries a back affordance: the words "Back" and "to" or "To" separated by whitespace (a capital B, at a word boundary), or a left-pointing mark ("←", "⟵", "⇐", "‹", "«"), in a text node or an attribute value, read with character references decoded, so `&larr;` and `&laquo;` count. Template comments and HTML comments SHALL NOT be read, even when they quote markup. A text node or attribute value that matches more than once SHALL be reported once. The message SHALL name chrome-conventions "One location trail" and say that the location trail above the title is the way back. The error pages' way out ("Back to the dashboard", "Back to the console") is a Go string rendered through a template action, so the rule does not read it; `error-pages` "The error page offers exactly one way out" governs it.
#### Scenario: A back button in a fragment fails
- **WHEN** a partial renders `<button type="button" class="btn btn-link" hx-get="/partials/x">&larr; Back to things</button>`
- **THEN** `member-console lint` reports `back-link` once, with the file and line, and exits non-zero
#### Scenario: An arrow alone fails
- **WHEN** a template renders `<a href="/x">&larr; Things</a>`, `<span>← Things</span>` or `<a href="/x" aria-label="← Things">x</a>`
- **THEN** `member-console lint` reports `back-link` for each
#### Scenario: A comment that mentions going back passes
- **WHEN** a template's only occurrences are inside `{{/* Back to the list */}}` and `<!-- &larr; Back to top -->`
- **THEN** `member-console lint` reports no `back-link`
#### Scenario: Ordinary words containing the phrase pass
- **WHEN** a template's text reads "Feedback to the team" or "back to back"
- **THEN** `member-console lint` reports no `back-link`
#### Scenario: The error page's way out passes
- **WHEN** the lint reads `error.html`, which renders its way out as `{{ .Action.Label }}`
- **THEN** it reports no `back-link`, though the page shows "Back to the dashboard"
@@ -0,0 +1,76 @@
## 1. The member shell
- [x] 1.1 `internal/server/server.go`: the closure `memberShell` in `registerMemberPages` becomes a package function, `memberShellFor(authConfig *auth.Config, r *http.Request, active string) Shell`, with the closure's doc comment; the dashboard, Products and Billing call it. The member invoices and member domains handlers call it with the `AuthConfig` they already hold.
- [x] 1.2 `internal/server/shell.go`: `Shell` gains `BelowActive bool`, documented as "the page sits below the Active entry: the rail marks the entry but does not call it the current page" (design decision 4). `internal/embeds/templates/partials/shell_rail_member.html`: each entry keeps its `active` class when `.Active` names it and renders `aria-current="page"` only when `.Active` names it and `.BelowActive` is false.
- [x] 1.3 `internal/embeds/static/app.css`: `.app-page-header-text` gains `overflow-wrap: anywhere` with a comment saying a long name, such as a domain, wraps inside the viewport (design decision 5); no template markup changes, so the tests and goldens that pin `<h1 class="h2 mb-0">` and the active crumb stay as they are. `PageHeader`'s doc comment in `internal/server/anatomy.go` drops "an optional back affordance above it" and names the trail instead; the comment near "Products and Billing are rail-entry pages" (`anatomy.go`, the member headers) names the two pages below an entry.
## 2. The invoice page
- [x] 2.1 `internal/server/member_invoices.go`: `GetInvoiceDetail` becomes `GetInvoicePage`, registered as `GET /billing/invoices/{invoiceID}` in `RegisterRoutes` in place of `GET /partials/member/invoices/{invoiceID}`. It keeps the session check, the gate (`memberInvoice`) and the data loading; a refused gate answers `pageRefused` (the styled error page: 404 for an unknown, malformed or foreign id, 500 when the billing accounts cannot be read), and `gateRefused` is deleted. It renders `billing_invoice.html` with a new `MemberInvoicePageData{Shell Shell; Detail MemberInvoiceDetailData}`, `Shell` from `memberShellFor(h.AuthConfig, r, "billing")` with `BelowActive: true`. The two early renders on a failed line-item or payment read render the same page with the detail's `Error` set. Doc comments: `GetInvoicePage` states the route, the gate, and that the 404 does not reveal whether another organization's invoice exists; `MemberInvoicesHandler`'s says it serves the invoices partial and the invoice page; `RegisterRoutes`' names both. In `member_hosted_invoice.go`, `pageRefused`'s comment names the invoice page among its callers in place of "the invoice detail, a partial, answers gateRefused", and `billingPagePath`'s comment names the invoice page as where Pay invoice is offered.
- [x] 2.2 `internal/server/anatomy.go`: `MemberInvoiceDetailData.Title()` returns "Invoice " + number, or "Invoice" when the number is empty. `MemberInvoicePageData.Header()` returns `PageHeader{Title: d.Detail.Title(), Crumbs: []Link{{Label: "Billing", URL: "/billing"}}}`, with a comment naming the trail it produces. `MemberInvoiceDetailData.Header()` (the section header with its help popover) is deleted. The comment above the member invoices region's methods drops "the title survives the list/detail swaps".
- [x] 2.3 New `internal/embeds/templates/billing_invoice.html`: `billing.html`'s skeleton (head, scripts, shell, toasts, the shared confirm modal), `<title>{{ .Detail.Title }} - {{ deploymentName }}</title>`, `{{ template "pageHeader" .Header }}`, then `{{ template "member_invoice_detail.html" .Detail }}`. Add `billing_invoice.html` to `memberRootPages` in `internal/lint/anatomy.go`, so `page-without-header` reads it.
- [x] 2.4 `internal/embeds/templates/partials/member_invoice_detail.html`: delete the back button and the `sectionHeader` call; the status badge, Stripe number and period line opens the body. Its header comment says it is the invoice page's body and names `billing_invoice.html`.
- [x] 2.5 `internal/embeds/templates/partials/member_invoices.html`: each invoice number, and the marker for a missing one, is `<a href="{{ routeURL "/billing/invoices/{invoiceID}" .InvoiceID }}">…</a>` with no `hx-*` attributes; the help icon beside the marker stays. Its header comment drops "the region titles itself so the heading follows the list/detail swaps". `billing.html`'s comment on `#billing-content` drops the swap and the self-titling region: the region holds the invoices list, composed server-side.
- [x] 2.6 `test/e2e/screens/manifest.go`: add `{Name: "member-billing-invoice-detail", Route: "/billing/invoices/{invoiceID}", Surface: "member", Role: "member", Instance: &Instance{ListPath: "/billing", LinkPrefix: "/billing/invoices/"}}` after `member-billing`. The hosted route keeps its Skip entry; the list renders no hosted link, so the first match is an invoice.
## 3. The claim page
- [x] 3.1 `internal/server/member_domains.go`: a lookup that writes nothing, `claimFor(ctx context.Context, workspaceID, claimID string) (domains.Claim, int)` (use the claim type `ownedClaim` returns today), shaped like `memberInvoice`: 404 for a nil `Registry`, an id that does not parse as a UUID (`uuid.Parse`), `domains.ErrNotFound`, and another workspace's claim; 500 for any other read error; 200 with the claim otherwise. It reads the claim by the parsed id's canonical form (`parsed.String()`, as `pathUUID` in `operator_ids.go` does), because `uuid.Parse` accepts `urn:uuid:…`, which Postgres refuses. `ownedClaim` keeps its signature and behaviour for the partial routes and becomes a wrapper that calls `claimFor` and writes the plain errors it writes today. `GetClaimPage`, registered in `RegisterRoutes` as `GET /domains/claims/{claimID}`, checks the session as `ownedClaim` does, calls `claimFor`, and on a refusal answers `RenderErrorPage` with "The page you requested does not exist." (404) or "An unexpected error occurred. Try again." (500), writing nothing else. Otherwise it builds the claim data as `GetClaimStatus` does (`claimStatusData`) and renders `domain_claim.html` with a new `MemberDomainClaimPageData{Shell Shell; Claim MemberDomainClaimData}`, `Shell` from `memberShellFor(h.AuthConfig, r, "dashboard")` with `BelowActive: true`. Doc comments: the package comment and `MemberDomainsHandler`'s name the claim page beside the partials (in place of "the dashboard's pending-claim notice" hosting them and "serves the /domains page's partials"); `RegisterRoutes`' names the page route.
- [x] 3.1a `internal/server/member_domains.go`: the pending claim's default status sentence, "Waiting for your DNS records…", moves from `renderClaimStatus` into `claimStatusData` (applied when the claim is pending and no other status text is given), so the page, the partial and the cancel and check answers all carry it; `renderClaimStatus`'s comment changes to match.
- [x] 3.2 `internal/server/anatomy.go`: `MemberDomainClaimPageData.Header()` returns `PageHeader{Title: d.Claim.Domain}` (no `Crumbs`; the trail reads "Home / {root}").
- [x] 3.3 New `internal/embeds/templates/domain_claim.html`: the same skeleton as 2.3, toasts and `{{ template "shell_confirm_modal.html" . }}` included, with `<title>{{ .Claim.Domain }} - {{ deploymentName }}</title>`, `<script defer src="/static/copy-button.js"></script>` among the scripts, `{{ template "pageHeader" .Header }}`, then `{{ template "member_domains_claim.html" .Claim }}`. Add `domain_claim.html` to `memberRootPages`.
- [x] 3.4 `internal/embeds/templates/partials/member_domains_claim.html`: delete the back button and the `h3` domain heading with its comment, and the `mb-3` wrapper they shared if it holds nothing else. The root element, its polling attributes, the records table, the status lines and the two buttons are unchanged. Its header comment says the view is the claim page's body and the swap target of its own refresh and buttons.
- [x] 3.4a `member_domains_claim.html` and `internal/integrations/fedwiki/templates/fedwiki_custom_domain_pending.html`: the records table's first cell (the record type badge and its purpose) drops `text-nowrap`, so the purpose wraps and the name and value columns keep a readable width at 390px. A browser layout test on the pattern of `test/e2e/notices/layout_test.go` renders the claim view at 390 with a long root and asserts the records table fits the viewport and no row is taller than a few lines.
- [x] 3.4b Long names break at their dots, and the records table's status badges wrap. A template function in the member and operator sets, `breakAtDots`, HTML-escapes a string and inserts `<wbr>` after each `.`, returning `template.HTML`; the `pageHeader` part renders the title and the current crumb through it, and `member_domains_claim.html` and FedWiki's `fedwiki_custom_domain_pending.html` render each record's name and value through it (the `data-copy` attributes stay the plain strings). In `app.css`, a badge inside the records table wraps (`white-space: normal`, `text-align: start`), scoped to that table so no other badge changes. Tests: the function escapes `<`, `&` and quotes and inserts `<wbr>` after every dot; the claim page renders the root with `<wbr>`; `data-copy` holds no `<wbr>`; the records layout test's row-height limit drops to what the new layout measures plus a margin, and a break (the badge rule removed) fails it.
- [x] 3.5 `internal/embeds/templates/partials/member_domains.html`: each row's header is `<th scope="row"><a href="{{ routeURL "/domains/claims/{claimID}" .ClaimID }}"><code class="text-break">{{ .Root }}</code></a></th>`, for every claim; the "DNS records"/"Details" button is deleted, and Release stays the Actions column's one control. The comment at the top names one `.domains-surface` host, the sites card, which Release swaps into, and says each claim's root links to its page. `MemberDomainClaimRow`'s `Pending` and `External` fields, and the comments that explain the two labels, are removed if nothing else reads them after this task (`grep` the templates and Go), or their comments updated if something does. `internal/integrations/fedwiki/templates/fedwiki_sites.html`'s comment above `id="domains"` drops "DNS-instruction links … all work inline here" and says each claim's root links to its page while the claims list and Release stay in the card.
Build note: `Pending` and `External` on `MemberDomainClaimRow` were read by no template and no Go code after this task, so both fields and the assignments in `surfaceData` are removed, and `member_domains_test.go` no longer sets them.
- [x] 3.6 `internal/embeds/templates/index.html`: in `pendingClaimsWords`, each row's control is `<a class="btn btn-link" href="{{ routeURL "/domains/claims/{claimID}" .ClaimID }}">View DNS records</a>`. The wrapper around the notice drops the `domains-surface` class and keeps `mt-3`; the comment above it says the notice links to each claim's page. `PendingDomainClaim`'s comment in `server.go` says the notice links to the claim's page; the other comments in `server.go` that call the domains handler the Domains page's or describe the dashboard as re-entering the claim through the partial (`grep -n "Domains page\|claim-status\|re-entry" internal/server/server.go`) are corrected.
- [x] 3.7 `internal/embeds/static/copy-button.js`: the header comment says the claim page loads it.
- [x] 3.8 `test/e2e/screens/manifest.go`: the claim page's route is a Skip entry, `{Route: "/domains/claims/{claimID}", Skip: "a domain claim's page; the demo data holds no domain claim, so the capture cannot reach one"}`, under its own comment: the demo database holds no domain claim, so nothing links to a claim's page, and the page is captured by hand until the demo data holds one. The `Skip` field's doc comment names a page the demo data cannot reach beside the routes that are not screens.
## 4. The lint rule
- [x] 4.1 `internal/lint/anatomy.go`: `back-link`, beside the token rules that read text nodes and attribute values, over every template `ruleAnatomy` reads. It reads each text node through `html.UnescapeString` (attribute values arrive decoded), and fires on one that matches `\bBack[\s\x{00A0}]+[Tt]o\b` or contains one of "←", "⟵", "⇐", "‹", "«", so `&larr;` and `&laquo;` count; the source is tokenized after `blankComments`, so no comment is read, even one that quotes markup. Each matching text node or attribute value is reported once, at the line its text node or tag starts on. Message: `renders a back link; the location trail above the title is the way back (chrome-conventions "One location trail"): make the view a page with its own trail, or open it without replacing the page`. Add it to the rule list in the comment that documents the anatomy rules.
- [x] 4.2 `internal/lint`: cases in the style the file's neighbours use (`anatomy_test.go` or `verdicts_test.go`). The cases go in `verdicts_test.go`'s fixtures, so the verdicts golden pins the rule's message. Reported: `<button type="button" class="btn btn-link" hx-get="/partials/x">&larr; Back to things</button>` in a partial (once), `<a href="/x">&larr; Things</a>` (the entity alone), `<span>← Things</span>` (the arrow alone), `<a href="/x" aria-label="← Things">x</a>` (the arrow in an attribute), `<span title="Back to list">x</span>` (the words in an attribute). Not reported: `{{/* Back to the list */}}` and `<!-- &larr; Back to top -->` (capital B, so reading comments would fire), "Feedback to the team", "back to back", and a template rendering `{{ .Action.Label }}`. `go test ./internal/lint -run TestLintVerdicts -update` regenerates the golden; read the diff: it holds only these fixtures' lines.
- [x] 4.3 After sections 2 and 3, `make lint` passes on the real templates.
## 5. Tests
- [x] 5.1 The invoice page (`internal/server`), requested through `GetInvoicePage` so the handler's `Shell` (with `BelowActive`) is what renders: a member's own invoice renders `h1` "Invoice 0042", the trail "Home / Billing / Invoice 0042" with "Billing" linking to `/billing` and the current crumb unlinked, the rail's Billing entry `active` with no `aria-current` inside `#app-rail`, exactly one `aria-current="page"` on the page, the status, period, amounts, line items and payments, and no "Back to" and no `&larr;`; an unnumbered invoice is titled "Invoice" with no help popover; another organization's invoice, an unknown id and a malformed id each answer the styled 404 page with the same body, starting `<!DOCTYPE html>`; unreadable billing accounts answer the styled 500; a failed line-item read and a failed payments read each render the page with its Problem notice. The tests that called `/partials/member/invoices/{invoiceID}` move to the page route or the page template: `member_invoices_test.go` (`:110` expects the page link in the list; `:144`'s requirement of "Back to invoices" and `/partials/member/invoices` becomes their absence), `invoice_number_render_test.go` (`:233-240` expects the plain link; `:254-255` finds the number in the page title; `:270-271` expects the title "Invoice" and no help popover), `member_hosted_invoice_db_test.go`, `invoice_period_db_test.go`, `billing_times_db_test.go`, `member_notices_render_test.go`.
Build note: `member_notices_render_test.go` keeps rendering `member_invoice_detail.html` for its Problem row instead of `billing_invoice.html`: the page carries the shell, whose dialog close buttons fail that test's "no close button" check on a notice; the page's own Problem notice is covered by `TestMemberInvoicePageShowsAProblemWhenAReadFails`.
- [x] 5.2 The Billing list: each invoice number and the missing-number marker is an `href` to `/billing/invoices/{id}` carrying no `hx-get`.
- [x] 5.3 The claim page, requested through `GetClaimPage`: a pending claim renders `h1` with the root, the status sentence "Waiting for your DNS records…", the trail "Home / {root}", the rail's Dashboard entry `active` with no `aria-current` inside `#app-rail`, exactly one `aria-current="page"` on the page, the records table, "Check now", "Cancel verification", exactly one `#confirmActionModal`, the Cancel trigger inside `.domain-claim-status`, the root element's every-5s refresh against `/partials/domains/claims/{claimID}`, the copy script, and no "Back to"; a terminal claim renders its outcome notice and no refresh; another workspace's claim, an unknown UUID, a malformed id and a `urn:uuid:` spelling of an unknown id each answer the styled 404 page with the same body, starting `<!DOCTYPE html>` and not containing "404 page not found". `member_domains_scope_test.go`'s foreign-claim test (every route) and its reopening-mints-nothing test add the page route.
- [x] 5.4 The openers: the dashboard notice's rows (`member_domains_dissolve_render_test.go` `TestDashboardPendingDomainNotice`) link to `/domains/claims/{claimID}` with no `hx-get`, and the notice is no longer inside a `.domains-surface`; the sites card's claims table (`member_domains_test.go`) links every claim's root, hosted included, to its page and renders no "DNS records" or "Details" control (the hosted-claim check at `:91-104` asserts the hosted root's link to `/domains/claims/claim-hosted`).
- [x] 5.5 The member layout enumerations add `billing_invoice.html` and `domain_claim.html`: `toasts_render_test.go` (one error toast and one success toast), `member_domains_dissolve_render_test.go` (no Domains navigation entry), `member_nav_test.go` (the rail's shape; its `active` plus `aria-current` assertion holds for the three entry pages only; `renderMemberShell` gains the data types for the two new templates instead of falling through to `BillingPageData`).
- [x] 5.6 The route goldens (`internal/server/testdata/routes.golden`, `routes-not-ready.golden`, `route_pages.golden`): regenerate with the test that owns them and read the diff: it holds the two page routes added and the invoice partial route removed, nothing else.
- [x] 5.7 Breaks, one per behaviour, each reverted after its test fails, recorded in this task as CAUGHT by <TestName> or MISSED (a MISSED break strengthens its test): the invoice page's crumb removed; the invoice page answering the plain `http.NotFound` instead of the styled page; the list's link restored to `href="#"`; the claim page's ownership check removed; the claim page calling `ownedClaim` before rendering the styled 404; the claim page without the copy script; the claim page without the confirm modal; the claim page without the pending status sentence (default left in `renderClaimStatus`); `claimFor` reading the raw id instead of its canonical form (a `urn:uuid:` id answers 500); the notice's link restored to the `hx-get` swap; the sites card's "DNS records" button restored; the rail's `aria-current` restored on a page below its entry; the back button restored in either view (the lint fails); the lint's arrow check dropped; the lint reading text without decoding it (`&larr;` no longer counts); the lint reading comments, and, added by the review's fixes: the released case after the hosted one; the lint's comment blanking dropped; the lint's whitespace class narrowed to a plain space; one of the five marks dropped; `aria-current="page"` on a page below its entry (the rail break above); `memberInvoice` answering 404 for a failed read; Check now's `hx-target` removed; Cancel's `data-action-swap` removed. Results:
- the invoice page's crumb removed: CAUGHT by TestMemberInvoicePageRendersTheInvoiceUnderBilling
- the invoice page answering the plain `http.NotFound`: CAUGHT by TestMemberInvoicePageRefusalsAnswerTheStyledErrorPage
- the list's link restored to `href="#"`: CAUGHT by TestMemberInvoiceTemplatesRenderNumber
- the claim page's ownership check removed (the registry's workspace comparison): CAUGHT by TestMemberClaimPageRefusalsAnswerTheStyledErrorPage and TestMemberDomainsOwnerScoping
- the claim page calling `ownedClaim` before rendering the styled 404: CAUGHT by TestMemberClaimPageRefusalsAnswerTheStyledErrorPage
- the claim page without the copy script: CAUGHT by TestMemberClaimPageRendersAPendingClaim
- the claim page without the confirm modal: CAUGHT by TestMemberClaimPageRendersAPendingClaim and TestShellCarriesConfirmModal
- the pending status sentence only in `renderClaimStatus`: CAUGHT by TestMemberClaimPageRendersAPendingClaim
- `claimFor` reading the raw id: CAUGHT by TestMemberClaimPageRefusalsAnswerTheStyledErrorPage (the `urn` row)
- the notice's link restored to the `hx-get` swap: CAUGHT by TestDashboardPendingDomainNotice
- the sites card's "DNS records" button restored: CAUGHT by TestMemberDomainsClaimsTable
- `aria-current="page"` on a page below its entry: CAUGHT by TestMemberInvoicePageRendersTheInvoiceUnderBilling and TestMemberClaimPageRendersAPendingClaim
- the back button restored in the invoice view: CAUGHT by `member-console lint` (back-link, file and line) and TestMemberInvoicePageRendersTheInvoiceUnderBilling
- the back button restored in the claim view: CAUGHT by `member-console lint` (back-link, file and line) and TestMemberClaimPageRendersAPendingClaim
- the lint's arrow check dropped: CAUGHT by TestLintVerdicts
- the lint reading text without decoding it: CAUGHT by TestLintVerdicts
- the lint reading comments (comment blanking dropped): CAUGHT by TestLintVerdicts
- the lint's whitespace class narrowed to a plain space: CAUGHT by TestLintVerdicts
- one of the five marks dropped: CAUGHT by TestLintVerdicts
- the released case after the hosted one: CAUGHT by TestMemberNoticesRender (row "hosted and released")
- `memberInvoice` answering 404 for a failed read: CAUGHT by TestMemberInvoicePageRefusalsAnswerTheStyledErrorPage ("unreadable invoice")
- Check now's `hx-target` removed: CAUGHT by TestMemberClaimPageRendersAPendingClaim
- Cancel's `data-action-swap` removed: CAUGHT by TestMemberClaimPageRendersAPendingClaim
## 6. Docs and checks
- [x] 6.1 Docs: `docs/testing.md`'s list of anatomy rule ids and `docs/design-system.md`'s "What holds it" gain `back-link`; `docs/fedwiki-setup.md`'s description of a Domains page at `/domains` names the sites card's claims list and each claim's page instead; and where `docs/design-system.md` describes the location trail or member pages, one sentence names a page with its own trail as the form for a view that would otherwise replace a region (read the page first; none if it already says so).
- [x] 6.2 `openspec validate member-detail-views-are-pages --strict` passes; `make lint` passes; with the test stack up, the full suite passes on reset databases.
- [x] 6.3 `make screens` is expected to add `member-billing-invoice-detail` (the claim page is a Skip entry, task 3.8); `member-billing` may change by the links' markup only. Every other change is read and named.
- [x] 6.4 Hand captures at 1280 and 390 into `test/screens/member-detail-views-are-pages/` with a sheet: the Billing list; an invoice page (paid, and open with Pay invoice); the dashboard with a pending-claim notice; a pending claim's page with a long root such as `mycooperativecommunitywiki.example.org` at 390; a verified claim's page; the sites card's claims table where FedWiki is configured, or the reason it was not reachable.
+26 -4
View File
@@ -605,8 +605,14 @@ standalone destination: the workspace's live claims — root name, kind, status,
placement count — SHALL be listed within the member sites surface, and a
pending-claim notice SHALL appear on the member dashboard while any of the
workspace's claims is `pending`. There SHALL be no member navigation entry for
domains and no standalone member domains page; `GET /domains` SHALL redirect to the
dashboard. The claim affordances SHALL be: viewing a pending claim's DNS
domains and no member page that lists domains; `GET /domains` SHALL redirect to the
dashboard. Each claim's DNS instructions and status SHALL be a member page of its own
at `/domains/claims/{claimID}`, rendered in the member shell with the Dashboard rail
entry active, titled with the claim's root name under the location trail
"Home / {root}" and carrying no back link (chrome-conventions "One location trail").
The sites surface's claims list and the dashboard notice SHALL link to it, and a
claim the workspace does not own, or no claim, SHALL answer the 404 page without
revealing whether the claim exists. The claim affordances SHALL be: viewing a pending claim's DNS
instructions and per-record probe status (from the sites surface and from the
dashboard notice), triggering an immediate re-check (signal the workflow,
coalescing, backoff reset), canceling a pending claim (frees the name immediately
@@ -644,8 +650,24 @@ permitted only for the owning workspace.
- **WHEN** a member starts an external claim from site creation and navigates away
- **THEN** the dashboard SHALL show a pending-domain notice while the claim is
pending
- **AND** the notice SHALL open the claim's DNS instructions without re-initiating
the claim or minting new records
- **AND** the notice SHALL link to the claim's page, which shows its DNS
instructions without re-initiating the claim or minting new records
#### Scenario: A claim's instructions are a page under Home
- **WHEN** a member follows "View DNS records" for the pending claim on `example.org`
- **THEN** `/domains/claims/{claimID}` renders titled "example.org" under the trail
"Home / example.org", with the Dashboard rail entry active, the records table,
"Check now" and "Cancel verification"
- **AND** no back link renders on the page
- **AND** the page's status refreshes in place every 5 seconds while the claim is
pending
#### Scenario: Another workspace's claim is not found
- **WHEN** a member requests the page of a claim another workspace owns, or of an
id that names no claim
- **THEN** the 404 page renders, the same for both
#### Scenario: Wildcard row is optional guidance
+7 -5
View File
@@ -755,10 +755,11 @@ compensation orphans.
The member sites surface SHALL embed the workspace's domain-claims section (the
core claims list and its management affordances) so that domains are managed where
sites live: each claim renders with kind, status, and placement count; pending
claims link to their DNS instructions; active claims with no placements offer the
sites live: each claim renders with kind, status, and placement count, and its root
name links to the claim's page (domains-registry "Members manage their domains at
point of use"), where its DNS instructions and status show; active claims with no placements offer the
existing one-click site create alongside a release affordance. The section SHALL
reuse the core domains partial routes unchanged (same CSRF and polling patterns)
reuse the core claims list partial and its release route unchanged (same CSRF pattern)
— the fedwiki surface hosts core partials, never reimplements them. The create
form's external-domain path SHALL manage its claim inline and SHALL NOT link to a
standalone domains page.
@@ -778,8 +779,9 @@ standalone domains page.
#### Scenario: No links to a standalone domains page
- **WHEN** the member sites surface or the site-creation form renders
- **THEN** no link to `/domains` SHALL be present; claim status and management
render inline
- **THEN** no link to the `/domains` redirect SHALL be present; the claims list and
its release render inline, and each claim's records open on its own page under
`/domains/claims/`
### Requirement: Site creation with no configured domains fails honestly before the form
+7 -5
View File
@@ -3,7 +3,6 @@
## Purpose
Defines the member dashboard (`index.html`): it renders one card per dashboard-card declaration from the registered integrations without naming any integration in core templates, loads card scripts as deferred external scripts, shows a pending-domain notice while a domain claim is pending, and shows one empty state when there is nothing to display.
## Requirements
### Requirement: Dashboard cards are registry-driven
@@ -55,9 +54,10 @@ Scripts declared by a dashboard card SHALL be rendered by core as `<script defer
The member dashboard SHALL render a pending-domain notice while at least one of the
workspace's domain claims is `pending`, and SHALL render nothing domain-related
otherwise (no empty chrome). The notice SHALL name the pending root(s) and open the
claim's DNS-instructions/status view (the core domains partial, established polling
pattern) without re-initiating the claim or minting new records. The notice is
otherwise (no empty chrome). The notice SHALL name the pending root(s), each with a
"View DNS records" link to that claim's page (domains-registry "Members manage their
domains at point of use"), and following it SHALL NOT re-initiate the claim or mint
new records. The notice is
core-rendered content — domains is core substrate, not an integration — and SHALL
NOT be implemented as an integration-declared dashboard card, preserving the
card registry's integration-genericity requirement.
@@ -66,7 +66,8 @@ card registry's integration-genericity requirement.
- **WHEN** the workspace has a claim in `pending`
- **THEN** the dashboard SHALL show the pending-domain notice naming the claim root
- **AND** opening it SHALL render the claim's DNS instructions and per-record status
- **AND** its "View DNS records" link SHALL open the claim's page, which renders the
claim's DNS instructions and per-record status
#### Scenario: No pending claims, no notice
@@ -93,3 +94,4 @@ When no integration declares a card and the person's organization holds no entit
- **WHEN** a member's organization holds one plan, which grants only an on/off capability, and its subscription is `past_due`, so the capability is not granted
- **THEN** the dashboard does not render the empty state
@@ -30,13 +30,19 @@ The system SHALL provide a member-facing Billing page that lists the invoices be
### Requirement: Member views invoice detail with line items and payments
The system SHALL provide a per-invoice detail view, addressable by invoice ID, headed "Invoice {number}" (the marker and tooltip when absent; Stripe's number as a secondary "Stripe invoice ..." line when the mapping carries one), that shows the period the invoice's lines pay for (Requirement: An invoice shows the period its lines pay for), the invoice's line items (description, quantity, amount) and the payments recorded against it (amount, status, date), each dated when it succeeded or failed (stripe-invoice-payment-projection, Requirement: A payment is dated when it succeeded or failed) and listed most recent first. The detail view SHALL only be accessible to a member of the organization that owns the invoice.
The system SHALL provide a per-invoice detail page at `/billing/invoices/{invoiceID}`, rendered in the member shell with the Billing rail entry active, titled "Invoice {number}" ("Invoice" before the invoice has a number) under the location trail "Home / Billing / Invoice {number}" and carrying no back link (chrome-conventions "One location trail"), with Stripe's number as a secondary "Stripe invoice ..." line under the title when the mapping carries one. Each invoice number in the Billing page's invoice list, and the marker that stands in for a missing one, SHALL be a plain link to that page. The page shows the period the invoice's lines pay for (Requirement: An invoice shows the period its lines pay for), the invoice's line items (description, quantity, amount) and the payments recorded against it (amount, status, date), each dated when it succeeded or failed (stripe-invoice-payment-projection, Requirement: A payment is dated when it succeeded or failed) and listed most recent first. The detail page SHALL only be accessible to a member of the organization that owns the invoice.
#### Scenario: Member opens an invoice they own
- **WHEN** an authenticated member selects an invoice belonging to their organization
- **THEN** the system displays the invoice's status, amounts, and the period its lines pay for, its line items with description, quantity, and amount, and any associated payments with amount, status, and date
#### Scenario: The invoice detail is a page under Billing
- **WHEN** a member follows invoice 0042's number in the Billing page's list
- **THEN** the browser loads `/billing/invoices/{invoiceID}`, whose trail reads "Home / Billing / Invoice 0042" above the title "Invoice 0042", with the Billing rail entry active
- **AND** no back link renders on the page
#### Scenario: A payment's date is when it settled
- **WHEN** a member opens an invoice whose payment the console recorded a day after Stripe reported it paid
@@ -45,12 +51,12 @@ The system SHALL provide a per-invoice detail view, addressable by invoice ID, h
#### Scenario: Member requests an invoice that is not theirs
- **WHEN** an authenticated member requests an invoice whose billing account does not belong to their organization
- **THEN** the system responds with 404 Not Found and does not reveal whether the invoice exists
- **THEN** the system responds with the 404 page and does not reveal whether the invoice exists
#### Scenario: Member requests a non-existent invoice
- **WHEN** an authenticated member requests an invoice ID that does not exist
- **THEN** the system responds with 404 Not Found
- **THEN** the system responds with the 404 page
### Requirement: Billing history requires authentication
@@ -221,13 +221,13 @@ Each of the four billing views SHALL lead with human-meaningful columns (the lin
### Requirement: Operator invoice detail is addressable
The system SHALL provide a per-invoice detail view at `/operator/billing/invoices/{invoiceID}` headed "Invoice {number}" (the UUID muted beneath; Stripe's number, when the mapping carries one, shown as "Stripe invoice {stripe_invoice_number}", an external reference and never the heading), showing the invoice's period as "Period: {period}", the period its lines pay for (member-invoice-history, Requirement: An invoice shows the period its lines pay for), the invoice's line items (description, quantity, amount, period), amounts due and paid with correct minor-unit formatting, status including the derived Overdue presentation, due and paid dates, the linked organization (linked to its composite), and its Stripe sync state with the deep link when synced — reusing the member invoice-detail projection queries rather than a parallel read path. The page SHALL carry the standard back affordance to the invoices view (`chrome-conventions`), mark the Billing sidebar entry active, and answer an unknown invoice ID with the panel's ordinary 404 handling.
The system SHALL provide a per-invoice detail view at `/operator/billing/invoices/{invoiceID}` headed "Invoice {number}" (the UUID muted beneath; Stripe's number, when the mapping carries one, shown as "Stripe invoice {stripe_invoice_number}", an external reference and never the heading), showing the invoice's period as "Period: {period}", the period its lines pay for (member-invoice-history, Requirement: An invoice shows the period its lines pay for), the invoice's line items (description, quantity, amount, period), amounts due and paid with correct minor-unit formatting, status including the derived Overdue presentation, due and paid dates, the linked organization (linked to its composite), and its Stripe sync state with the deep link when synced — reusing the member invoice-detail projection queries rather than a parallel read path. The page SHALL carry the location trail "Operator / Billing / Invoices / Invoice {number}" (chrome-conventions "One location trail"), whose Invoices crumb leads to the invoices view, and no back link; it SHALL mark the Billing sidebar entry active and answer an unknown invoice ID with the panel's ordinary 404 handling.
#### Scenario: Invoice detail renders the full projection
- **WHEN** an operator loads `/operator/billing/invoices/{invoiceID}` for a projected invoice
- **THEN** line items, amounts, status (with Overdue derived when applicable), dates, the linked organization, and Stripe sync state render
- **AND** a back affordance leads to the invoices view
- **AND** the trail's Invoices crumb leads to the invoices view, and no back link renders
#### Scenario: The invoice's period comes from its lines
+3 -3
View File
@@ -31,7 +31,7 @@ Every page on the member and operator surfaces SHALL render its title through th
### Requirement: One title size and one header layout
The `pageHeader` part SHALL render the page title as `<h1 class="h2">`, preceded by an optional location trail (chrome-conventions "One location trail"), followed by an optional one-sentence lead in the muted body colour, with one right-hand slot that holds either a muted count or one action control, never both and never more than one control. The trail is a Bootstrap breadcrumb whose first crumb is the page's rail entry, whose intermediate crumbs are real intermediate pages only, and whose last crumb is the current page, unlinked with `aria-current="page"`; rail-entry pages and error pages render none. Pages SHALL NOT size the title otherwise (no unsized `h1`, no `h4`), SHALL NOT add a second header row, SHALL NOT put a paragraph longer than one sentence in the lead, and SHALL NOT render a back link. Every page body (a template a handler names as the page's `BodyTemplate`, and every member page) SHALL render `pageHeader`; a detail or edit page's title is the instance's name, never a card title. The trail is the header's: it renders above the title and outside any box, and nothing else on the page renders a trail or a back link (maintainer, 2026-08-30, replacing the back affordance).
The `pageHeader` part SHALL render the page title as `<h1 class="h2">`, preceded by an optional location trail (chrome-conventions "One location trail"), followed by an optional one-sentence lead in the muted body colour, with one right-hand slot that holds either a muted count or one action control, never both and never more than one control. The trail is the one chrome-conventions "One location trail" defines: a Bootstrap breadcrumb whose first crumb is the surface's root, followed by the page's rail entry when the page sits below one, then real intermediate pages only, then the current page, unlinked with `aria-current="page"`; the surface roots and error pages render none. Pages SHALL NOT size the title otherwise (no unsized `h1`, no `h4`), SHALL NOT add a second header row, SHALL NOT put a paragraph longer than one sentence in the lead, and SHALL NOT render a back link. Every page body (a template a handler names as the page's `BodyTemplate`, and every member page) SHALL render `pageHeader`; a detail or edit page's title is the instance's name, never a card title. The trail is the header's: it renders above the title and outside any box, and nothing else on the page renders a trail or a back link (maintainer, 2026-08-30, replacing the back affordance).
#### Scenario: Title size is uniform
@@ -40,8 +40,8 @@ The `pageHeader` part SHALL render the page title as `<h1 class="h2">`, preceded
#### Scenario: A detail page is titled and its trail sits above the title
- **WHEN** an operator opens a detail or edit page below a rail entry
- **THEN** the page renders `pageHeader` with the instance's name as the `h1.h2` title and a breadcrumb "{rail entry} / {instance}" above it, outside any card, the current page unlinked
- **WHEN** a person opens a detail or edit page below a rail entry
- **THEN** the page renders `pageHeader` with the instance's name as the `h1.h2` title and a breadcrumb "{surface root} / {rail entry} / … / {instance}" above it, outside any card, the current page unlinked
- **AND** no back link renders on the page
#### Scenario: The right-hand slot holds one thing
+29
View File
@@ -301,3 +301,32 @@ The anatomy lint SHALL refuse, under the rule `actions-column`, a template that
- **WHEN** `ui_notice.html` renders `alert-danger`, `shell_toasts.html` renders `role="alert"` on the error toast, a table cell carries `class="text-danger"`, an element carries `class="app-alerting"` or `role="alertdialog"`, and a template comment names `class="alert"`
- **THEN** `raw-notice` reports none of them
### Requirement: Lint refuses a back link
`member-console lint` SHALL fail with `back-link` when any template it reads for the page anatomy, partials and integration templates included, carries a back affordance: the words "Back" and "to" or "To" separated by whitespace (a capital B, at a word boundary), or a left-pointing mark ("←", "⟵", "⇐", "‹", "«"), in a text node or an attribute value, read with character references decoded, so `&larr;` and `&laquo;` count. Template comments and HTML comments SHALL NOT be read, even when they quote markup. A text node or attribute value that matches more than once SHALL be reported once. The message SHALL name chrome-conventions "One location trail" and say that the location trail above the title is the way back. The error pages' way out ("Back to the dashboard", "Back to the console") is a Go string rendered through a template action, so the rule does not read it; `error-pages` "The error page offers exactly one way out" governs it.
#### Scenario: A back button in a fragment fails
- **WHEN** a partial renders `<button type="button" class="btn btn-link" hx-get="/partials/x">&larr; Back to things</button>`
- **THEN** `member-console lint` reports `back-link` once, with the file and line, and exits non-zero
#### Scenario: An arrow alone fails
- **WHEN** a template renders `<a href="/x">&larr; Things</a>`, `<span>← Things</span>` or `<a href="/x" aria-label="← Things">x</a>`
- **THEN** `member-console lint` reports `back-link` for each
#### Scenario: A comment that mentions going back passes
- **WHEN** a template's only occurrences are inside `{{/* Back to the list */}}` and `<!-- &larr; Back to top -->`
- **THEN** `member-console lint` reports no `back-link`
#### Scenario: Ordinary words containing the phrase pass
- **WHEN** a template's text reads "Feedback to the team" or "back to back"
- **THEN** `member-console lint` reports no `back-link`
#### Scenario: The error page's way out passes
- **WHEN** the lint reads `error.html`, which renders its way out as `{{ .Action.Label }}`
- **THEN** it reports no `back-link`, though the page shows "Back to the dashboard"
+152
View File
@@ -0,0 +1,152 @@
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
// Package records_test measures the DNS records table of the claim view in a
// browser at 390px: the table stays inside its container and no row grows
// tall, which is what breaks when a cell refuses to wrap and squeezes the
// name and value columns until their code breaks one character per line.
// The view is rendered from the console's own member template set with
// server.MemberDomainClaimData (exported, so the data is built directly) and
// styled with the embedded bootstrap.css and app.css, so no stack is needed;
// the test skips where Chromium cannot launch.
package records_test
import (
"bytes"
"encoding/json"
"fmt"
"strings"
"testing"
"git.coopcloud.tech/wiki-cafe/member-console/internal/embeds"
"git.coopcloud.tech/wiki-cafe/member-console/internal/server"
"git.coopcloud.tech/wiki-cafe/member-console/internal/web"
wfdomains "git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/domains"
"git.coopcloud.tech/wiki-cafe/member-console/test/e2e/browsertest"
)
const (
root = "mycooperativecommunitywiki.example.org"
connectTarget = "connect.localtest.me"
maxRowHeight = 375
)
// claimView renders the pending claim's records view the way the handler
// builds it: the TXT challenge, the connect record and the optional wildcard.
func claimView(t *testing.T) string {
t.Helper()
set, err := web.MemberTemplates(web.CoreTemplates())
if err != nil {
t.Fatalf("MemberTemplates: %v", err)
}
data := server.MemberDomainClaimData{
ClaimID: "claim-1",
Domain: root,
StatusText: "Waiting for your DNS records…",
ExpiresAt: "Nov 6, 2026 15:04 UTC",
Polling: true,
Records: []server.MemberDomainRecordView{
{
Kind: "TXT", Purpose: "Proves you control the domain",
Name: wfdomains.ChallengeRecordName(root),
Value: wfdomains.ChallengeRecordValue("0123456789abcdef0123456789abcdef"),
State: "unchecked",
},
{
Kind: "CNAME", Purpose: "Points the domain at your site",
Name: root, Value: connectTarget, State: "unchecked",
},
{
Kind: "CNAME", Purpose: "Optional; lets any subdomain work without new DNS records",
Name: "*." + root, Value: connectTarget, State: "unchecked", Optional: true,
},
},
}
var buf bytes.Buffer
if err := set.ExecuteTemplate(&buf, "member_domains_claim.html", data); err != nil {
t.Fatalf("member_domains_claim.html: %v", err)
}
return buf.String()
}
func document(t *testing.T) string {
t.Helper()
bootstrap, err := embeds.Static.ReadFile("static/bootstrap.css")
if err != nil {
t.Fatal(err)
}
app, err := embeds.Static.ReadFile("static/app.css")
if err != nil {
t.Fatal(err)
}
return fmt.Sprintf(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>%s
%s</style></head><body><div id="box" style="width:390px;padding:0 16px;box-sizing:border-box">%s</div></body></html>`,
bootstrap, app, claimView(t))
}
func TestRecordsTableFitsAt390(t *testing.T) {
browser := browsertest.NewBrowser(t)
page := browser.MustPage("about:blank")
page.MustSetViewport(390, 844, 1, false)
if err := page.SetDocumentContent(document(t)); err != nil {
t.Fatalf("SetDocumentContent: %v", err)
}
res, err := page.Eval(`() => JSON.stringify((() => {
const wrap = document.querySelector("#box .table-responsive");
const table = wrap && wrap.querySelector("table");
if (!table) return null;
return {
box: document.getElementById("box").clientWidth,
wrapScroll: wrap.scrollWidth, wrapClient: wrap.clientWidth,
table: table.getBoundingClientRect().width,
rows: [...table.querySelectorAll("tbody tr")].map(r => r.getBoundingClientRect().height),
docScroll: document.documentElement.scrollWidth,
cols: [...table.querySelectorAll("tbody tr:first-child td")].map(c => c.getBoundingClientRect().width),
};
})())`)
if err != nil {
t.Fatalf("eval: %v", err)
}
var m *struct {
Box, WrapScroll, WrapClient, Table float64
Rows []float64
DocScroll float64
Cols []float64
}
if err := json.Unmarshal([]byte(res.Value.Str()), &m); err != nil || m == nil {
t.Fatalf("no records table in the view (%v): %s", err, res.Value.Str())
}
if m.WrapScroll != m.WrapClient {
t.Errorf("records table scrolls sideways: scrollWidth %v, clientWidth %v", m.WrapScroll, m.WrapClient)
}
if m.Table > m.Box {
t.Errorf("records table is %vpx wide in a %vpx container", m.Table, m.Box)
}
if len(m.Rows) != 3 {
t.Fatalf("rows = %d, want the TXT, connect and wildcard rows", len(m.Rows))
}
for i, h := range m.Rows {
if h > maxRowHeight {
t.Errorf("row %d is %vpx tall, limit %d", i, h, maxRowHeight)
}
}
t.Logf("table %vpx in %vpx, rows %v, first-row columns %v", m.Table, m.Box, m.Rows, m.Cols)
}
// TestRecordNamesBreakAtDots checks the rendered view marks a break after
// each dot of a record's name and keeps the copy buttons' data on the plain
// string.
func TestRecordNamesBreakAtDots(t *testing.T) {
view := claimView(t)
if want := "mycooperativecommunitywiki.<wbr>example.<wbr>org"; !strings.Contains(view, want) {
t.Errorf("the view lacks the root with a break after each dot (%q)", want)
}
if !strings.Contains(view, `data-copy="`+root+`"`) {
t.Errorf("data-copy must hold the plain root %q", root)
}
for _, part := range strings.Split(view, `data-copy="`)[1:] {
if value, _, _ := strings.Cut(part, `"`); strings.Contains(value, "<wbr>") {
t.Errorf("data-copy holds a <wbr>: %q", value)
}
}
}
+13 -5
View File
@@ -27,8 +27,9 @@ type Screen struct {
// link whose href starts with LinkPrefix on ListPath. When no such link
// exists the screen is reported as "no instance", not failed.
Instance *Instance
// Skip names why this route is not a screen (a redirect, an API-shaped
// page); a Skip entry satisfies screen-coverage and captures nothing.
// Skip names why this route is not captured: it is not a screen (a
// redirect, an API-shaped page), or it is a page the demo data cannot
// reach. A Skip entry satisfies screen-coverage and captures nothing.
Skip string
}
@@ -96,9 +97,11 @@ var Manifest = []Screen{
{Name: "member-dashboard", Route: "/", Path: "/", Surface: "member", Role: "member"},
{Name: "member-products", Route: "/products", Path: "/products", Surface: "member", Role: "member"},
{Name: "member-billing", Route: "/billing", Path: "/billing", Surface: "member", Role: "member"},
// Workspaces, plan switching, and member domains carry no screen of
{Name: "member-billing-invoice-detail", Route: "/billing/invoices/{invoiceID}", Surface: "member", Role: "member",
Instance: &Instance{ListPath: "/billing", LinkPrefix: "/billing/invoices/"}},
// Workspaces, plan switching, and the claims list carry no screen of
// their own (finding FA-46): all three are HTMX partials embedded in
// the two member screens above, not routes of their own, so there is
// the member screens above, not routes of their own, so there is
// no separate Route to add here even after their forms library
// migration (forms-library lane D). What each is missing instead:
// - Workspaces (workspace_list.html/workspace_create.html, swapped
@@ -107,7 +110,7 @@ var Manifest = []Screen{
// reset demo database never satisfies (index.html:96), so neither
// the list nor member.workspace.create's create form ever appears
// in a base capture regardless of manifest entries.
// - Member domains (member_domains.html) and FedWiki sites
// - The claims list (member_domains.html) and FedWiki sites
// (fedwiki_sites.html, the card that embeds it): FA-46's own
// evidence is that no baseline capture shows either, because the
// demo deployment the captures run against does not mount FedWiki.
@@ -122,6 +125,11 @@ var Manifest = []Screen{
// database or a new member walkthrough, both beyond a template
// migration and left for the maintainer to schedule.
// A page the demo data cannot reach. The demo database holds no domain
// claim, so nothing links to a claim's page and a capture would find no
// instance; the page is captured by hand until the demo data holds one.
{Route: "/domains/claims/{claimID}", Skip: "a domain claim's page; the demo data holds no domain claim, so the capture cannot reach one"},
// Routes that are not screens.
{Route: "/domains", Skip: "redirects to the dashboard's domains section (dissolve-member-domains)"},
{Route: "/domains/ask", Skip: "the reverse proxy's on-demand TLS authorization endpoint (domain-authorization); answers 200/4xx to a ?domain= query, not a page"},