dns-record-collapse: a published record is drawn folded
test / test (push) Waiting to run

The dns_record partial draws a record whose tag is "published" and that
has no "In DNS now" (Record.Folded) as a <details> whose summary is the
head - name, tag, "Show values" - with the host, type and value behind
it, as the mockup of fffee9c. Every other record stays a <div>, open.
One partial, so the outbound domain's page, the inbound domain's and
Settings › Notification mail change together; panel.css takes the
mockup's rules, help.go the help's sentence word for word.

Re-check DNS posts and redirects to the page, which is drawn from the
fresh check: a record that has just turned right comes back folded. No
page that draws records polls them, so nothing has to keep a fold open.

Tests: the dns_record partial folds only a published record and closes
the block it opened (TestDNSRecordFoldsOnlyWhenPublished); the mismatch
test reads the folded head. go vet + go test (26 packages) and make e2e
on the test server for this tree.

CHANGELOG [Unreleased]; roadmap row done, its section says what was
decided.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mix
2026-10-16 12:34:28 +03:00
co-authored by Claude Opus 5.5
parent fffee9cb5d
commit 51f303c466
7 changed files with 74 additions and 9 deletions
+23 -1
View File
@@ -265,7 +265,7 @@ func TestDNSRecordShowsInDNSNowOnlyOnAMismatch(t *testing.T) {
Host: "sp2026._domainkey.example.org", Type: "TXT", Value: "v=DKIM1; p=AAA", ValueRows: 3,
}))
mustContain(t, ok,
`<div class="sp-record"><div class="sp-record-head"><h3>DKIM</h3><span class="tag is-success is-light">published</span><small>selector</small></div>`,
`<details class="sp-record"><summary class="sp-record-head"><h3>DKIM</h3><span class="tag is-success is-light">published</span><small>selector</small><span class="sp-record-toggle"><i class="ti ti-eye"></i><span>Show values</span><span>Hide values</span></span></summary>`,
`<div class="sp-row">`, `<input class="input" readonly value="sp2026._domainkey.example.org">`,
`<label class="label">Type</label><div class="control"><input class="input" readonly value="TXT">`,
`<textarea class="textarea" rows="3" readonly>v=DKIM1; p=AAA</textarea>`)
@@ -281,6 +281,28 @@ func TestDNSRecordShowsInDNSNowOnlyOnAMismatch(t *testing.T) {
`<input class="input" readonly value="v=spf1 ip4:203.0.113.25 ~all">`)
}
// Only a record DNS holds as shown is folded; one that needs work stays open
// with its values in view, and the fold closes where it opened.
func TestDNSRecordFoldsOnlyWhenPublished(t *testing.T) {
for _, status := range []string{"mismatch", "fail", "warn", "unknown"} {
out := squash(partial(t, "dns_record", Record{Name: "SPF", Status: Tag{Status: status},
Host: "example.org", Type: "TXT", Value: "v=spf1 a -all"}))
mustContain(t, out, `<div class="sp-record"><div class="sp-record-head"><h3>SPF</h3>`, `value="v=spf1 a -all"`)
mustNotContain(t, out, "<details", "<summary", "sp-record-toggle")
}
ok := squash(partial(t, "dns_record", Record{Name: "MX", Status: Tag{Status: "published"},
Host: "example.org", Type: "MX", Value: "10 mail.example.org."}))
if !strings.HasPrefix(ok, `<details class="sp-record">`) || !strings.HasSuffix(ok, `</details>`) {
t.Errorf("a published record is not one <details> block:\n%s", ok)
}
if strings.Contains(ok, "<details open") {
t.Errorf("a published record is drawn open:\n%s", ok)
}
if (Record{Status: Tag{Status: "published"}, InDNS: "x"}).Folded() {
t.Error("a record with an In DNS now value is folded")
}
}
func TestCopyFieldSingleLineAndMultiLine(t *testing.T) {
one := squash(partial(t, "copy_field", CopyField{Label: "Login", Value: "prod-server", Help: Plain("Keep it.")}))
mustContain(t, one,