From a570a3a0360f6c065c16f16270996a0cb6fe625b Mon Sep 17 00:00:00 2001
From: Matthew Boedicker <24275+mmb@users.noreply.github.com>
Date: Sat, 9 May 2026 09:23:32 -0700
Subject: [PATCH] Pagination test
---
tests/integration/pagination_test.go | 66 ++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 tests/integration/pagination_test.go
diff --git a/tests/integration/pagination_test.go b/tests/integration/pagination_test.go
new file mode 100644
index 0000000..30b5481
--- /dev/null
+++ b/tests/integration/pagination_test.go
@@ -0,0 +1,66 @@
+package integration_test
+
+import (
+ "context"
+ "fmt"
+ "net/url"
+ "time"
+
+ "github.com/chromedp/chromedp"
+ . "github.com/onsi/ginkgo/v2"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("pagination", func() {
+ var (
+ mainTab context.Context
+ checkTab context.Context
+ testRootURL string
+ )
+
+ BeforeEach(func() {
+ var cancel context.CancelFunc
+
+ mainTab, cancel = chromedp.NewContext(browser)
+ DeferCleanup(cancel)
+ checkTab, cancel = chromedp.NewContext(browser)
+ DeferCleanup(cancel)
+
+ testID := fmt.Sprintf("%d", time.Now().UnixNano())
+ post(mainTab, tmpbbsURL, testID, "", "")
+ Eventually(func() string {
+ return get(checkTab, tmpbbsURL)
+ }, "5s").Should(ContainSubstring(testID))
+ testRootURL = mostRecentReplyURL(checkTab, tmpbbsURL)
+ })
+
+ It("shows page navigation", func() {
+ for i := range 100 {
+ title := fmt.Sprintf("pagination test post %d", i)
+ post(mainTab, testRootURL, title, "", "")
+ Eventually(func() string {
+ return get(checkTab, testRootURL)
+ }, "5s").Should(ContainSubstring(title))
+ }
+
+ testRootURLParsed, err := url.Parse(testRootURL)
+ Expect(err).NotTo(HaveOccurred())
+ path := testRootURLParsed.Path
+
+ Expect(get(checkTab, testRootURL)).To(ContainSubstring(fmt.Sprintf(
+ `>page 1 / page 2 / page 10`,
+ path, path)))
+ Expect(get(checkTab, testRootURL+"?p=2")).To(ContainSubstring(fmt.Sprintf(
+ `>page 1 / page 2 / page 3 / page 10`,
+ path, path, path)))
+ Expect(get(checkTab, testRootURL+"?p=3")).To(ContainSubstring(fmt.Sprintf(
+ `>page 1 / page 2 / page 3 / page 4 / page 10`,
+ path, path, path, path)))
+ Expect(get(checkTab, testRootURL+"?p=9")).To(ContainSubstring(fmt.Sprintf(
+ `>page 1 / page 8 / page 9 / page 10`,
+ path, path, path)))
+ Expect(get(checkTab, testRootURL+"?p=10")).To(ContainSubstring(fmt.Sprintf(
+ `>page 1 / page 9 / page 10`,
+ path, path)))
+ })
+})