summaryrefslogtreecommitdiff
path: root/internal/web/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/server_test.go')
-rw-r--r--internal/web/server_test.go34
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")
+ }
+}