panel-redesign: the queue in the new shell; the old design is removed
Stage 2, steps 7 and 8 in one commit: the static guard fails as soon as
the ratchet holds no page while legacy.css still exists, and the tests
of the old layout need it while that layout exists - the two steps do
not split into states that pass on their own. Written by Sonnet,
reviewed by Opus.
The queue
- out-queue, named after its mockup: today's content - the listing of
postqueue -p in a log pane, polled as before (GET
/outbound/queue/fragment) - and the "How retries work" facts. The
mockup's table of messages is the roadmap's queue-as-a-table; the
outline guard exempts this page for exactly that reason. Routes and
the global-only check are unchanged; the page has no actions and
never had.
- Inbound has no Queue entry and no route serves one.
The old design is gone
- Deleted: layout_legacy.html, legacy.css, logo-compact.svg,
mail_queue.html, mail_queue_body.html.
- view.go has one path: every page is layout.html + components.html +
its own files; kitPages, kitFragments, the map-data branch of Render,
the dict and back template functions and metaOf's map branch are
removed. handlers: pageBase removed.
- legacy_pages.txt holds its header and no entry.
- panel.js: the old copy handler (button.copy in .code-row) is
removed. A show-when rule now applies to every element it matches,
and hiding adds Bulma's is-hidden beside the hidden attribute - a
.box or a grid row has a display of its own and stayed visible.
- The user form hides both domain lists again when the role is Global
(Box.DomainPick, an attribute; data-global-role on the select).
- Tests of the old layout are deleted; what they asserted about the
shell (version only signed in, the menu follows the user's reach,
Inbound only with the feature, Help present, the current entry
marked) is asserted on the kit pages, two tests added for it.
For the owner: is-hidden is a Bulma class outside the subset of
check.py. No template writes it - the script sets it at run time to
hide a block - so no guard sees it; say if it should be on the list.
Evidence
- docs/assets/panel-redesign/evidence/out-queue.png: 1440 px wide,
headless Edge, the real template served locally with its fixture -
NOT from the container (no Docker on this machine).
- panel/audit.js on out-queue, user and backup at 1440 and 1280:
366 texts checked, problems: [].
- In a browser against the local fixture server: the encryption
fields of Backup, the manual / auto limit fields and the custom
report address of Domain settings show and hide with their control;
all 28 fixture pages answer 200 with panel.css, /static/legacy.css
answers 404.
- Not exercised: polling against a real postqueue (none on Windows).
- go test -count=1 ./internal/web/... ./cmd/panel
ok internal/web
ok internal/web/auth
ok internal/web/handlers
ok internal/web/validate
ok internal/web/view
ok cmd/panel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,15 +4,14 @@ import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Tests of the component kit's own code: the template functions, each partial
|
||||
// in each of its states, the shell's visibility rules and the agreement between
|
||||
// kitPages and legacy_pages.txt. The design contract itself (vocabulary, outlines,
|
||||
// the stylesheet) is held by the guard tests, which this file does not repeat.
|
||||
// in each of its states and the shell's visibility rules. The design contract
|
||||
// itself (vocabulary, outlines, the stylesheet) is held by the guard tests,
|
||||
// which this file does not repeat.
|
||||
|
||||
func kitEngine(t *testing.T) *Engine {
|
||||
t.Helper()
|
||||
@@ -503,8 +502,29 @@ func TestMenuOfADomainAdministratorLeavesNoGap(t *testing.T) {
|
||||
mustNotContain(t, out, "/outbound/dmarc")
|
||||
}
|
||||
|
||||
// Signing out is a POST, as it is in the old layout and as the handler demands;
|
||||
// it has to work without scripts.
|
||||
// A domain administrator who was given inbound domains only is offered Inbound
|
||||
// and none of the sending pages, and the wordmark takes them to what they have.
|
||||
func TestMenuOfAnInboundOnlyAdministratorLeavesNoGap(t *testing.T) {
|
||||
out := renderShell(t, kitEngine(t), Meta{Title: "t", User: "ops", HasInbound: true, Section: "inbound", Page: "domains"})
|
||||
mustContain(t, out, `href="/inbound/domains"`, `href="/account"`, `href="/help"`,
|
||||
`<a class="navbar-item" href="/inbound/domains"><img src="/static/wordmark.svg"`)
|
||||
// (The kit page's own examples link to /outbound/domains, so the menu's group
|
||||
// is looked for by its link.)
|
||||
mustNotContain(t, out, `href="/overview"`, `href="/server/`, `navbar-link" href="/outbound/domains"`, `href="/outbound/log"`, `href="/outbound/dmarc"`)
|
||||
}
|
||||
|
||||
// The Inbound entry needs the feature as well as something to reach in it.
|
||||
func TestInboundEntryNeedsTheFeature(t *testing.T) {
|
||||
off, err := New("t")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mustNotContain(t, renderShell(t, off, Meta{Title: "t", User: "admin", IsGlobal: true}), "/inbound/domains")
|
||||
mustContain(t, renderShell(t, kitEngine(t), Meta{Title: "t", User: "admin", IsGlobal: true}), `href="/inbound/domains"`)
|
||||
}
|
||||
|
||||
// Signing out is a POST, as the handler demands; it has to work without
|
||||
// scripts.
|
||||
func TestSignOutStaysAPostForm(t *testing.T) {
|
||||
out := renderShell(t, kitEngine(t), Meta{Title: "t", User: "admin", IsGlobal: true})
|
||||
mustContain(t, out, `<form method="post" action="/logout"><button type="submit" class="navbar-item"><i class="ti ti-logout"></i>Sign out</button></form>`)
|
||||
@@ -531,59 +551,22 @@ func TestKitLayoutLoadsOnlyTheKit(t *testing.T) {
|
||||
`<link rel="stylesheet" href="/static/bulma.min.css">`+"\n"+`<link rel="stylesheet" href="/static/tabler-icons.css">`+"\n"+`<link rel="stylesheet" href="/static/panel.css">`,
|
||||
`<script src="/static/htmx.min.js" defer></script>`, `<script src="/static/panel.js" defer></script>`,
|
||||
`<meta name="htmx-config" content='{"includeIndicatorStyles":false}'>`)
|
||||
mustNotContain(t, out, "legacy.css", "http://", "https://cdn")
|
||||
mustNotContain(t, out, "http://", "https://cdn")
|
||||
}
|
||||
}
|
||||
|
||||
// Meta can come from a struct that embeds it or from the map a handler builds.
|
||||
func TestMetaOfReadsAStructAndAMap(t *testing.T) {
|
||||
// Meta comes from a struct that embeds it; any other data has none, which is
|
||||
// the signed-out screen.
|
||||
func TestMetaOfReadsAStruct(t *testing.T) {
|
||||
want := Meta{Title: "t", User: "u", IsGlobal: true, HasOutbound: true, HasInbound: true, Section: "server", Page: "users"}
|
||||
if got := metaOf(&Kit{Meta: want}); got != want {
|
||||
t.Errorf("metaOf(struct) = %+v", got)
|
||||
}
|
||||
got := metaOf(map[string]any{"Title": "t", "User": "u", "IsGlobal": true, "HasOutbound": true, "HasInbound": true, "Section": "server", "Page": "users", "Other": 1})
|
||||
if got != want {
|
||||
t.Errorf("metaOf(map) = %+v", got)
|
||||
}
|
||||
if got := metaOf(42); got != (Meta{}) {
|
||||
t.Errorf("metaOf(other) = %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
// A page is on the new layout exactly when legacy_pages.txt does not list it.
|
||||
func TestKitPagesAreTheOnesOffTheRatchet(t *testing.T) {
|
||||
b, err := os.ReadFile("legacy_pages.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacy := map[string]bool{}
|
||||
for _, line := range strings.Split(string(b), "\n") {
|
||||
if line = strings.TrimSpace(line); line != "" && !strings.HasPrefix(line, "#") && !strings.HasPrefix(line, "@") {
|
||||
legacy[line] = true
|
||||
}
|
||||
}
|
||||
for name := range pageFiles {
|
||||
if kitPages[name] == legacy[name] {
|
||||
t.Errorf("page %q: kitPages=%v and legacy_pages.txt lists it=%v; it must be in exactly one", name, kitPages[name], legacy[name])
|
||||
}
|
||||
}
|
||||
for name := range kitPages {
|
||||
if _, ok := pageFiles[name]; !ok {
|
||||
t.Errorf("kitPages names %q, which is not a page", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The old pages keep rendering through the old layout and stylesheet.
|
||||
func TestLegacyPagesStayOnTheOldLayout(t *testing.T) {
|
||||
e := kitEngine(t)
|
||||
rec := httptest.NewRecorder()
|
||||
e.Render(rec, http.StatusOK, "mail_queue", map[string]any{"Title": "t", "User": "admin", "IsGlobal": true})
|
||||
out := rec.Body.String()
|
||||
mustContain(t, out, `href="/static/legacy.css"`, `class="shell"`)
|
||||
mustNotContain(t, out, "bulma.min.css", "tabler-icons.css", "/static/panel.css", "navbar")
|
||||
}
|
||||
|
||||
// Poll, ID and OOB are optional attributes: empty, box_open and page_head write
|
||||
// exactly the markup they wrote before they existed.
|
||||
func TestPollAndOOBAttributesAreAbsentWhenEmpty(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user