Side B adds a substantial, functional integration test exercising real pool-scoped voting flows end-to-end, providing lasting regression coverage. Side A merely deletes a small entrypoint file with no compensating functionality added elsewhere in the diff, offering minimal lasting value.
constitution · epochs · watch · epoch 3
c_7752a1605bf0 (tommy-mor) vs c_7ca21f5e83a8 (tommy-mor)
download prompt · raw event · cmp_4b7331ab9577ac
council reasoning
B adds a full browser integration test (seed pool items, enter via /vote?pool=, assert pair scoping and edge-history morph across the vote/next-pair loop), which is lasting product coverage. A only deletes an obsolete 24-line test runner entrypoint—useful cleanup but no new behavior or protection.
Side B adds a substantial end-to-end browser test that seeds a pool, exercises the vote→next-pair workflow, and verifies key invariants such as votes appearing in edge history and all presented pairs belonging to the requested pool. Side A only deletes the JVM test runner entrypoint (`test/runner.clj`), removing functionality without introducing a replacement in the shown patch.
sides
A — c_7752a1605bf0 (tommy-mor)
message
[71f27882] Delete test/runner.clj
diff preview
diff --git a/test/runner.clj b/test/runner.clj deleted file mode 100644 index e8d3d3d05e84110545d68350b7db2c9d1cfbf979..0000000000000000000000000000000000000000 --- a/test/runner.clj +++ /dev/null @@ -1,24 +0,0 @@ -(ns test.runner - "JVM entrypoint: run the same flows as Kaocha (for scripts / quick runs)." - (:require [test.integration :as integration] - [test.auth :as auth] - [test.grants :as grants] - [test.invites :as invites] - [test.room-list :as room-list] - [test.browser-sse :as browser-sse] - [test.browser-post-redact :as browser-post-redact] - [test.browser-ui-morph :as browser-ui-morph])) - -(defn run-core! [] - (integration/integration-flow!) - (auth/auth-flow!) - (grants/grants-flow!) - (invites/invites-flow!) - (room-list/room-list-flow!)) - -(defn -main [& args] - (case (vec args) - ["browser-sse"] (browser-sse/sse-browser-flow!) - ["browser-post-redact"] (browser-post-redact/post-redact-flow!) - ["browser-ui-morph"] (browser-ui-morph/ui-morph-flow!) - (run-core!)))
B — c_7ca21f5e83a8 (tommy-mor)
message
[7287df45] Add browser test for pool-scoped vote sequence. Seeds ~/pool/a-j (10 letters), enters /vote?pool=~/pool, then follows the vote → next-pair loop up to 15 iterations. Asserts each vote lands in edge history and each pair shown belongs to the pool. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
diff preview
diff --git a/test/browser_vote_pool.clj b/test/browser_vote_pool.clj
new file mode 100644
index 0000000000000000000000000000000000000000..d51f05db47dc3cb013e56e65f3a1edfbbcbd96ab
--- /dev/null
+++ b/test/browser_vote_pool.clj
@@ -0,0 +1,137 @@
+(ns test.browser-vote-pool
+ "Pool-scoped voting: seed ~/pool/a-j, enter via /vote?pool=~/pool, follow
+ the vote → next-pair → vote sequence until no next pair or 15 iterations."
+ (:require [babashka.fs :as fs]
+ [cheshire.core :as json]
+ [clojure.string :as str]
+ [clojure.test :refer [deftest is]]
+ [com.blockether.spel.core :as core]
+ [com.blockether.spel.locator :as locator]
+ [com.blockether.spel.page :as page]
+ [test.common :as common]
+ [test.oauth :as oauth]))
+
+(defn- wait-for-text [pg selector expected timeout-ms]
+ (let [deadline (+ (System/currentTimeMillis) timeout-ms)]
+ (loop []
+ (let [text (locator/text-content (page/locator pg selector))]
+ (if (and (string? text) (str/includes? text expected))
+ true
+ (if (< (System/currentTimeMillis) deadline)
+ (do (Thread/sleep 200) (recur))
+ false))))))
+
+(defn- element-text [pg selector]
+ (try (locator/text-content (page/locator pg selector)) (catch Exception _ nil)))
+
+(defn- enc [^String s]
+ (java.net.URLEncoder/encode s "UTF-8"))
+
+(def letters ["a" "b" "c" "d" "e" "f" "g" "h" "i" "j"])
+
+(defn vote-pool-flow! []
+ (println "\n━━━ browser vote pool (/vote?pool= seeds + follow next-pair sequence) ━━━\n")
+
+ (common/letlocals
+ (bind build (common/run-cargo-build-release! ["slugsocial-server"]))
+ (is (zero? (:exit build)) "cargo build succeeds")
+ (bind server-bin "target/release/slugsocial-server")
+
+ (bind tmp-dir (str (fs/create-temp-dir {:prefix "slug-browser-vote-pool-"})))
+ (bind slug-port (common/pick-port))
+ (bind google-port (common/pick-port))
+ (bind base-url (str "http://127.0.0.1:" slug-port))
+ (bind google-url (str "http://127.0.0.1:" google-port))
+
+ (bind !server (atom nil))
+ (bind !google (atom nil))
+ (bind server-env (common/slug-server-env tmp-dir base-url google-url slug-port))
+ (try
+ (reset! !google (oauth/start-mock-google google-port
+ :google-users ["google-user-alice"]))
+ (reset! !server (common/start-server server-bin server-env))
+ (is (common/wait-for-server base-url 10000) "server responds to /healthz")
+
+ (let [alice-token (oauth/fetch-bearer-token! base-url :username "alice")
+ thread-tag "browser-vote-pool"
+ ;; seed ~/pool/a through ~/pool/j as items with bodies
+ item-lines (str/join "\n"
+ (map (fn [l] (str "~/pool/" l " {" l "}")) letters))
+ raw (str "# " thread-tag "\n\n~/pool {root}\n" item-lines "\n")
+ post-resp (oauth/http-post-json
+ (str base-url "/api/v0/rpc")
+ [{"Post" {"room" "public"
+ "thread_tag" thread-tag
+ "text" raw
+ "return_rank_diff" false}}]
+ :headers {"Authorization" (str "Bearer " alice-token)})
+ post-json (json/parse-string (:body post-resp) false)
+ _ (is (true? (get-in post-json ["results" 0 "ok"]))
+ "seed ~/pool/a-j items via rpc")
+ pool-url (str base-url "/vote?pool=" (enc "~/pool"))]
+
+ (core/with-playwright [pw]
+ (core/with-browser [browser (core/launch-chromium pw {:headless true :channel "chrome"})]
+ (core/with-context [ctx (core/new-context browser)]
+ (core/with-page [pg (core/new-page-from-context ctx)]
+ (page/navigate pg (str base-url "/login"))
+ (is (wait-for-text pg "body" "@alice" 15000) "alice session after login")
+
+ ;; Enter via pool URL — page picks first pair automatically.
+ (page/navigate pg pool-url)
+ (is (wait-for-text pg "body.view-vote-compare" "compare" 15000)
+ "pool entry: vote compare page loads")
+
+ ;; Verify the initial pair is within the pool.
+ (let [pair-text (element-text pg ".vote-compare-pair")]
+ (is (and (string? pair-text) (str/includes? pair-text "~/pool/"))
+ (str "initial pair is within ~/pool: " pair-text)))
+
+ ;; Follow vote → next-pair sequence up to 15 iterations.
+ (let [votes-cast
+ (loop [i 0]
+ (if (>= i 15)
+ i
+ (let [explanation (str "pool vote " i " reason")]
+ (locator/fill (page/locator pg "#vote-explain") explanation)
+ (locator/click (page/locator pg "#vote-compare-form button[type=submit]"))
+ ;; Wait for edge history morph confirming the vote landed.
+ (if-not (wait-for-text pg "ul.vote-edge-history" explanation 20000)
+ (do (println " vote" i "history morph timed out — stopping")
+ i)
+ (let [has-next (wait-for-text pg "[data-testid=\"vote-next-pair\"]"
+ "next pair" 8000)]
+ (if-not has-next
+ ;; "no next pair" — pool exhausted.
+ (do (println " no next pair after vote" i " — pool exhausted")
+ (inc i))
+ (do
+ ;; Verify the pair on this page is within the pool before advancing.
+ (let [pt (element-text pg ".vote-compare-pair")]
+ (is (and (string? pt) (str/includes? pt "~/pool/"))
+ (str "pair at vote " i " is within ~/pool: " pt)))
+ (locator/click (page/locator pg "[data-testid=\"vote-next-pair\"]"))
+ ;; Wait for next pair to load.
+ (wait-for-text pg "body.view-vote-compare" "compare" 10000)
+ (recur (inc i)))))))))]
+
+ (is (>= votes-cast 1) (str "cast at least 1 vote, got: " votes-cast))
+ (println (str " pool voting sequence complete: " votes-cast " vote(s) cast")))
+
+ ;; After the sequence, the current page is still a pool-scoped vote page.
+ (let [url (page/url pg)]
+ (is (str/includes? (or url "") "/vote")
+ (str "still on /vote after sequence: " url))))))))
+
+ (finally
+ (when-some [s @!server] (common/kill-server s))
+ (when-some [g @!google] ((:stop-fn g)))
+ (fs/delete-tree tmp-dir)))
+
+ nil))
+
+(defn vote-pool-browser-test [& _args]
+ (vote-pool-flow!))
+
+(deftest browser-vote-pool-sequence
+ (vote-pool-flow!))
Hardlinks — judgments / attempts / prompt
judgments
attempts
Prompt text is loaded only by the download route.