diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 13:16:57 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 13:16:57 +0200 |
| commit | 4c23ae5107690a77a4253eaecbb7dfa822bdffc3 (patch) | |
| tree | 2935b0a534df0e189c49c9fad533bb79d096a636 /internal/web/server_test.go | |
| parent | a675a983424f1f8d103fc12d55ef4f7129a92d62 (diff) | |
| download | lectio-4c23ae5107690a77a4253eaecbb7dfa822bdffc3.tar.gz lectio-4c23ae5107690a77a4253eaecbb7dfa822bdffc3.zip | |
web reader: fix chapter arrows (drive chap select) + mono (move #pane out of controls form)
Diffstat (limited to 'internal/web/server_test.go')
| -rw-r--r-- | internal/web/server_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 77dfe74..638eb2b 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -406,3 +406,37 @@ func TestChooseListener(t *testing.T) { } }) } + +// 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. +func TestReaderPaneOutsideForm(t *testing.T) { + srv := NewServer(config.Default()) + rec := httptest.NewRecorder() + srv.ServeHTTP(rec, httptest.NewRequest("GET", "/reader", nil)) + b := rec.Body.String() + f := strings.Index(b, "</form>") + p := strings.Index(b, `id="pane"`) + if f < 0 || p < 0 || p < f { + t.Errorf("#pane must render after </form> (form@%d pane@%d)", f, p) + } +} + +// TestReaderArrowsDriveChapSelect guards the chapter-nav fix: the arrows drive +// the chap <select> (single source of truth) rather than a competing hx-vals +// "chap" param, and the server renders the requested book+chapter. +func TestReaderArrowsDriveChapSelect(t *testing.T) { + srv := NewServer(config.Default()) + rec := httptest.NewRecorder() + srv.ServeHTTP(rec, httptest.NewRequest("GET", "/reader?book=Luke&chap=12", nil)) + b := rec.Body.String() + if !strings.Contains(b, "select[name=chap]") { + t.Errorf("chapter arrows should drive the chap <select>") + } + if strings.Contains(b, `hx-vals='{"chap"`) { + t.Errorf("chapter arrows must not use a competing hx-vals chap param") + } + if !strings.Contains(b, "Luke 12") { + t.Errorf("server did not render the requested Luke 12") + } +} |
