diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 14:31:48 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 14:31:48 +0200 |
| commit | c769f80475e99b1f810fbb6c29eade3cc43a3786 (patch) | |
| tree | 3d1b4fe2a540b6ccbb11256ad26305b15a3c074e /internal/web/server_test.go | |
| parent | a87f2fafbda90cc9eeb32ea856356c34e1d880b0 (diff) | |
| download | lectio-c769f80475e99b1f810fbb6c29eade3cc43a3786.tar.gz lectio-c769f80475e99b1f810fbb6c29eade3cc43a3786.zip | |
web: empty pane when no version selected (hidden vset marker); config default checked on fresh load; v0.13.0
Diffstat (limited to 'internal/web/server_test.go')
| -rw-r--r-- | internal/web/server_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 638eb2b..925ea18 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -407,6 +407,36 @@ func TestChooseListener(t *testing.T) { }) } +// TestVsetEmptyShowsNothing guards the "uncheck all -> show nothing" behavior: +// a form submit (vset present) with no v param yields an empty pane, while a +// fresh visit (no vset) checks the config default and renders it. +func TestVsetEmptyShowsNothing(t *testing.T) { + srv := NewServer(config.Default()) + + // Form submit, every box unchecked: empty pane, nothing checked. + empty := httptest.NewRecorder() + srv.ServeHTTP(empty, httptest.NewRequest("GET", "/readings?vset=1&lectionary=traditional", nil)) + if b := strings.TrimSpace(empty.Body.String()); b != "" { + t.Errorf("readings with vset and no v should be empty, got %q", b) + } + + // Fresh visit (no vset): config default (bt for modern) box is checked. + fresh := httptest.NewRecorder() + srv.ServeHTTP(fresh, httptest.NewRequest("GET", "/", nil)) + if !strings.Contains(fresh.Body.String(), `value="bt" checked`) { + t.Errorf("fresh visit should check the config default (bt) version box") + } + + // Full page with vset and no v: no VERSION box checked (mono may be). + idx := httptest.NewRecorder() + srv.ServeHTTP(idx, httptest.NewRequest("GET", "/?vset=1", nil)) + for _, v := range bibleVersions { + if strings.Contains(idx.Body.String(), `value="`+v+`" checked`) { + t.Errorf("index with vset and no v: %q box should not be checked", v) + } + } +} + // TestReaderPaneOutsideForm guards the mono fix: #pane must render AFTER the // controls </form> so its reading text inherits body's --font-reading (which // the mono toggle flips) instead of the form's --font-ui. |
