Skip to main content

max / makenotwork

Assert rendered row counts in directory pagination test directory_pagination_shows_limited_communities checked only the pagination chrome, so a handler that returned all 30 communities on page 1 would still pass. Count the per-row directory-name marker: 25 on page 1, 5 on page 2.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-08-23 20:52 UTC
Signed with PGP, not checked
Commit: aa62c05bfe52209aafcf747b8167e21927ce8620
Parent: 7df1af2
1 file changed, +12 insertions, -0 deletions
@@ -48,6 +48,13 @@
48 48
49 49 let resp = h.client.get("/").await;
50 50 assert!(resp.status.is_success());
51 + // One `directory-name` div per rendered community row, so counting them
52 + // counts the rows the handler actually paginated down to.
53 + assert_eq!(
54 + resp.text.matches("directory-name").count(),
55 + 25,
56 + "page 1 should render 25 of the 30 communities"
57 + );
51 58 assert!(
52 59 resp.text.contains("Page 1 of 2"),
53 60 "Should show pagination info: {}",
@@ -64,6 +71,11 @@
64 71
65 72 let resp = h.client.get("/?page=2").await;
66 73 assert!(resp.status.is_success());
74 + assert_eq!(
75 + resp.text.matches("directory-name").count(),
76 + 5,
77 + "page 2 should render the remaining 5 communities"
78 + );
67 79 assert!(
68 80 resp.text.contains("Previous"),
69 81 "Should show Previous link on page 2"