From 35f98e0a8a0573d51a4412ec7f60c7de068acfe6 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Fri, 24 Jul 2026 14:38:12 +0200 Subject: web: drop phantom hidden bt for traditional on explicit submit, so 'no version -> nothing' works in trad too; v0.13.1 --- internal/web/server_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'internal/web/server_test.go') diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 925ea18..5f15796 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -437,6 +437,35 @@ func TestVsetEmptyShowsNothing(t *testing.T) { } } +// TestTraditionalDropsPhantomBT guards the traditional case of "no version -> +// nothing": a phantom checked-but-hidden bt (carried over from modern) must not +// substitute to wuj on an explicit form submit, but a fresh visit keeps the +// bt->wuj default. +func TestTraditionalDropsPhantomBT(t *testing.T) { + srv := NewServer(config.Default()) + + // Explicit submit, only the phantom bt "checked": empty pane. + phantom := httptest.NewRecorder() + srv.ServeHTTP(phantom, httptest.NewRequest("GET", "/readings?vset=1&lectionary=traditional&v=bt", nil)) + if b := strings.TrimSpace(phantom.Body.String()); b != "" { + t.Errorf("traditional vset+v=bt should be empty, got %d bytes", len(b)) + } + + // Explicit submit, bt phantom + a real corpus version: still renders it. + withWuj := httptest.NewRecorder() + srv.ServeHTTP(withWuj, httptest.NewRequest("GET", "/readings?vset=1&lectionary=traditional&v=bt&v=wuj", nil)) + if !strings.Contains(withWuj.Body.String(), "block") { + t.Errorf("traditional vset+v=bt+v=wuj should still render wuj") + } + + // Fresh visit (no vset): the bt->wuj default is kept and wuj is checked. + fresh := httptest.NewRecorder() + srv.ServeHTTP(fresh, httptest.NewRequest("GET", "/?lectionary=traditional", nil)) + if !strings.Contains(fresh.Body.String(), `value="wuj" checked`) { + t.Errorf("fresh traditional visit should default to wuj (checked)") + } +} + // TestReaderPaneOutsideForm guards the mono fix: #pane must render AFTER the // controls so its reading text inherits body's --font-reading (which // the mono toggle flips) instead of the form's --font-ui. -- cgit v1.3