Skip to main content

max / makenotwork

Delete test comments that restate the line under them Judged pass over the seven workflow suites the comment audit flagged, one site at a time rather than by pattern. 57 label comments in, 12 out. Most of what went was a comment duplicating the assert message three lines below it, which is the one place a reader is guaranteed to look when the test fails. What stayed is anything the code cannot say: the reason a setup uses direct SQL instead of the HTTP path, why a discarded GET exists at all (CSRF), the cross-community attack geography in the endorsement and quote suites, the two hash-vs-text discriminators that tell the fabricated and altered quote tests apart, and the data-table slicing note that stops someone matching the header nav link instead of the row. Comments documenting an absent call are kept for the same reason. That a test never calls add_membership, or deliberately runs without login, is invisible in the code and load-bearing to what the test proves. Two comments were false rather than filler. mod removal claimed to verify a 403 it never checks, and the directory pagination suite labelled two blocks "should show 25" and "should show the remaining 5" where neither count is ever asserted. Both labels are gone; the coverage gap they imply is filed separately. The suspended-settings check claimed the community name was unchanged when only the tag table is read, so it now says what it verifies. Four copies of the mention setup carried a bare "via direct SQL" label that restated the query while dropping the reason the first copy gives. They are normalized to carry the reason rather than deleted, so that simplifying one back to the HTTP path stays visibly wrong. crud.rs kept six section labels as bare comments while nineteen banners in sibling suites use the ASCII form; they now match.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-08-05 17:50 UTC
Signed with PGP, not checked
Commit: 9652f8ed76b4e39eaa875b83f60bed6db8d9175e
Parent: f4b2f47
7 files changed, +12 insertions, -69 deletions
@@ -25,7 +25,6 @@
25 25 .await
26 26 .unwrap();
27 27
28 - // Re-establish session with correct user_id
29 28 h.client.get("/").await;
30 29 let body = serde_json::json!({
31 30 "user_id": admin_id.to_string(),
@@ -43,7 +42,6 @@
43 42 let admin_id = Uuid::new_v4();
44 43 let mut h = TestHarness::new_with_admin(admin_id).await;
45 44
46 - // Set up admin session
47 45 sqlx::query(
48 46 "INSERT INTO users (mnw_account_id, username, display_name)
49 47 VALUES ($1, 'admin', 'Admin') ON CONFLICT DO NOTHING",
@@ -67,8 +65,6 @@
67 65 .await;
68 66 assert!(resp.status.is_redirection() || resp.status == axum::http::StatusCode::OK);
69 67
70 - // Verify community is now suspended (returns 403)
71 - // Verify the suspension stuck in the DB
72 68 let suspended: bool =
73 69 sqlx::query_scalar("SELECT suspended_at IS NOT NULL FROM communities WHERE id = $1")
74 70 .bind(community_id)
@@ -97,7 +93,6 @@
97 93
98 94 let community_id = h.create_community("Test", "test").await;
99 95
100 - // Suspend it
101 96 sqlx::query(
102 97 "UPDATE communities SET suspended_at = now(), suspension_reason = 'test' WHERE id = $1",
103 98 )
@@ -138,7 +133,6 @@
138 133 let body = serde_json::json!({ "user_id": admin_id.to_string(), "username": "admin" });
139 134 h.client.post_json("/_test/login", &body.to_string()).await;
140 135
141 - // Create a user to suspend
142 136 let target_id = Uuid::new_v4();
143 137 sqlx::query(
144 138 "INSERT INTO users (mnw_account_id, username, display_name) VALUES ($1, 'baduser', 'Bad User')",
@@ -225,7 +219,6 @@
225 219 let body = serde_json::json!({ "user_id": admin_id.to_string(), "username": "admin" });
226 220 h.client.post_json("/_test/login", &body.to_string()).await;
227 221
228 - // Create a searchable user
229 222 let target_id = Uuid::new_v4();
230 223 sqlx::query(
231 224 "INSERT INTO users (mnw_account_id, username, display_name)
@@ -295,7 +288,6 @@
295 288 )
296 289 .await;
297 290
298 - // Verify mod_log entry exists
299 291 let count: i64 = sqlx::query_scalar(
300 292 "SELECT COUNT(*) FROM mod_log WHERE action = 'suspend_community' AND actor_id = $1",
301 293 )
@@ -16,7 +16,6 @@
16 16 .post_form("/p/test/general/new", "title=My+Thread&body=Hello+world")
17 17 .await;
18 18
19 - // Should redirect to the new thread
20 19 assert!(
21 20 resp.status.is_redirection() || resp.status.is_success(),
22 21 "Expected redirect, got {}",
@@ -38,7 +37,6 @@
38 37 .post_form("/p/test/general/new", "title=Nope&body=Should+fail")
39 38 .await;
40 39
41 - // Should redirect to login
42 40 assert!(
43 41 resp.status.is_redirection(),
44 42 "Expected redirect to login, got {}",
@@ -84,7 +82,6 @@
84 82 .create_thread_with_post(cat_id, user_id, "Locked Thread", "OP")
85 83 .await;
86 84
87 - // Lock the thread
88 85 mt_db::mutations::set_thread_locked(&h.db, thread_id, true)
89 86 .await
90 87 .unwrap();
@@ -98,7 +95,7 @@
98 95 assert_eq!(resp.status.as_u16(), 403);
99 96 }
100 97
101 - // Immutable posts, old edit/delete routes return 404
98 + // --- immutable posts: the old edit/delete routes 404
102 99
103 100 #[tokio::test]
104 101 async fn user_cannot_edit_post() {
@@ -122,7 +119,6 @@
122 119 let resp = h.client.get(&edit_url).await;
123 120 assert_eq!(resp.status.as_u16(), 404, "Edit GET should be 404");
124 121
125 - // POST edit should also 404
126 122 let resp = h.client.post_form(&edit_url, "body=Updated+body").await;
127 123 assert_eq!(resp.status.as_u16(), 404, "Edit POST should be 404");
128 124 }
@@ -152,7 +148,7 @@
152 148 assert_eq!(resp.status.as_u16(), 404, "Delete POST should be 404");
153 149 }
154 150
155 - // Mod removal
151 + // --- mod removal
156 152
157 153 #[tokio::test]
158 154 async fn mod_can_remove_post() {
@@ -185,8 +181,8 @@
185 181 resp.status
186 182 );
187 183
188 - // Verify removed_at is set but content preserved. Direct loader use is fine
189 - // in a test assertion (no community-scope invariant to uphold here).
184 + // Direct loader use is fine in a test assertion (no community-scope
185 + // invariant to uphold here).
190 186 #[allow(clippy::disallowed_methods)]
191 187 let post_data = mt_db::queries::get_post_for_edit(&h.db, post_id)
192 188 .await
@@ -198,7 +194,6 @@
198 194 "Content should be preserved"
199 195 );
200 196
201 - // Verify removed_at via direct query
202 197 let removed_at: Option<chrono::DateTime<chrono::Utc>> =
203 198 sqlx::query_scalar("SELECT removed_at FROM posts WHERE id = $1")
204 199 .bind(post_id)
@@ -208,7 +203,7 @@
208 203 assert!(removed_at.is_some(), "removed_at should be set");
209 204 }
210 205
211 - // Thread edit/delete restricted to mod/owner
206 + // --- thread edit/delete restricted to mod and owner
212 207
213 208 #[tokio::test]
214 209 async fn mod_can_edit_thread_title() {
@@ -306,7 +301,7 @@
306 301 assert_eq!(resp.status.as_u16(), 403, "Regular user should get 403");
307 302 }
308 303
309 - // Footnotes
304 + // --- footnotes
310 305
311 306 #[tokio::test]
312 307 async fn add_footnote_by_author() {
@@ -340,14 +335,12 @@
340 335 resp.status
341 336 );
342 337
343 - // Verify footnote in DB
344 338 let footnotes = mt_db::queries::list_footnotes_for_posts(&h.db, &[post_id])
345 339 .await
346 340 .unwrap();
347 341 assert_eq!(footnotes.len(), 1);
348 342 assert_eq!(footnotes[0].author_id, user_id);
349 343
350 - // Verify footnote renders on page
351 344 let resp = h.client.get(&thread_url).await;
352 345 assert!(
353 346 resp.text.contains("Correction:"),
@@ -372,7 +365,6 @@
372 365 .unwrap();
373 366 let post_id = posts[0].id;
374 367
375 - // Log in as a different user
376 368 let other_id = h.login_as("fnother").await;
377 369 h.add_membership(other_id, comm_id, "member").await;
378 370
@@ -405,7 +397,6 @@
405 397 .unwrap();
406 398 let post_id = posts[0].id;
407 399
408 - // Insert two footnotes
409 400 mt_db::mutations::insert_footnote(
410 401 &h.db,
411 402 post_id,
@@ -475,7 +466,7 @@
475 466 );
476 467 }
477 468
478 - // Verified quoting
469 + // --- verified quoting
479 470
480 471 fn compute_quote_hash(text: &str) -> String {
481 472 use sha2::{Digest, Sha256};
@@ -693,7 +684,6 @@
693 684 .await;
694 685 assert!(resp.status.is_redirection(), "Quote reply should succeed");
695 686
696 - // Load the thread page and check for attribution
697 687 let resp = h.client.get(&thread_url).await;
698 688 assert!(
699 689 resp.text.contains("quote-attribution"),
@@ -701,7 +691,7 @@
701 691 );
702 692 }
703 693
704 - // Inline field-error contract, 422 + X-Form-Field so mt.js can render the
694 + // --- inline field-error contract: 422 + X-Form-Field so mt.js can render the
705 695 // message next to the offending input instead of as a transient toast.
706 696
707 697 #[tokio::test]
@@ -56,7 +56,6 @@
56 56 .unwrap();
57 57 let post_id = posts[0].id;
58 58
59 - // Login as a different user
60 59 let endorser_id = h.login_as("endorser").await;
61 60 h.add_membership(endorser_id, comm_id, "member").await;
62 61
@@ -73,7 +72,6 @@
73 72 resp.status
74 73 );
75 74
76 - // Verify DB row exists
77 75 let endorsements = mt_db::queries::list_endorsements_for_posts(&h.db, &[post_id])
78 76 .await
79 77 .unwrap();
@@ -116,7 +114,6 @@
116 114 "mismatched-slug endorse must 404"
117 115 );
118 116
119 - // And no endorsement was recorded.
120 117 let endorsements = mt_db::queries::list_endorsements_for_posts(&h.db, &[post_id])
121 118 .await
122 119 .unwrap();
@@ -250,7 +247,6 @@
250 247 .unwrap();
251 248 let post_id = posts[0].id;
252 249
253 - // Mod-remove the post
254 250 mt_db::mutations::mod_remove_post(&h.db, post_id, author_id)
255 251 .await
256 252 .unwrap();
@@ -327,14 +323,12 @@
327 323 .unwrap();
328 324 let post_id = posts[0].id;
329 325
330 - // Have someone endorse via DB
331 326 let endorser_id = h.login_as("modcountendorser").await;
332 327 h.add_membership(endorser_id, comm_id, "member").await;
333 328 mt_db::mutations::toggle_endorsement(&h.db, post_id, endorser_id)
334 329 .await
335 330 .unwrap();
336 331
337 - // Login as moderator and view thread
338 332 let mod_id = h.login_as("modviewer").await;
339 333 h.add_membership(mod_id, comm_id, "moderator").await;
340 334
@@ -364,7 +358,6 @@
364 358 .unwrap();
365 359 let post_id = posts[0].id;
366 360
367 - // Have someone endorse via DB
368 361 let endorser_id = h.login_as("hiddenendorser").await;
369 362 h.add_membership(endorser_id, comm_id, "member").await;
370 363 mt_db::mutations::toggle_endorsement(&h.db, post_id, endorser_id)
@@ -35,7 +35,6 @@
35 35 resp.status
36 36 );
37 37
38 - // Find the thread and view it
39 38 let threads =
40 39 mt_db::queries::list_threads_in_category_paginated(&h.db, "test", "general", 10, 0)
41 40 .await
@@ -64,7 +63,7 @@
64 63 let _cat_id = h.create_category(comm_id, "General", "general").await;
65 64 h.add_membership(author_id, comm_id, "member").await;
66 65
67 - // Create mentioned user via direct SQL
66 + // Create the mentioned user via direct SQL (so author stays logged in)
68 67 let mentioned_id = uuid::Uuid::new_v4();
69 68 sqlx::query("INSERT INTO users (mnw_account_id, username, display_name) VALUES ($1, $2, $2)")
70 69 .bind(mentioned_id)
@@ -82,7 +81,6 @@
82 81 )
83 82 .await;
84 83
85 - // Check DB for mention row
86 84 let threads =
87 85 mt_db::queries::list_threads_in_category_paginated(&h.db, "test", "general", 10, 0)
88 86 .await
@@ -165,7 +163,6 @@
165 163 let thread_url = format!("/p/test/general/{thread_id}");
166 164 let resp = h.client.get(&thread_url).await;
167 165
168 - // Should contain @nonexistent as plain text, not as a link
169 166 assert!(
170 167 resp.text.contains("@nonexistent"),
171 168 "Unknown mention should appear as plain text"
@@ -175,7 +172,6 @@
175 172 "Unknown mention should NOT be a link"
176 173 );
177 174
178 - // No DB rows
179 175 let posts = mt_db::queries::list_posts_in_thread(&h.db, thread_id)
180 176 .await
181 177 .unwrap();
@@ -196,7 +192,7 @@
196 192 let _cat_id = h.create_category(comm_id, "General", "general").await;
197 193 h.add_membership(author_id, comm_id, "member").await;
198 194
199 - // Create the mentioned user via direct SQL
195 + // Create the mentioned user via direct SQL (so author stays logged in)
200 196 let mentioned_id = uuid::Uuid::new_v4();
201 197 sqlx::query("INSERT INTO users (mnw_account_id, username, display_name) VALUES ($1, $2, $2)")
202 198 .bind(mentioned_id)
@@ -206,7 +202,6 @@
206 202 .unwrap();
207 203 h.add_membership(mentioned_id, comm_id, "member").await;
208 204
209 - // Author creates thread mentioning the other user
210 205 h.client.get("/p/test/general/new").await;
211 206 let resp = h
212 207 .client
@@ -252,7 +247,7 @@
252 247 let _cat_id = h.create_category(comm_id, "General", "general").await;
253 248 h.add_membership(author_id, comm_id, "member").await;
254 249
255 - // Create the mentioned user
250 + // Create the mentioned user via direct SQL (so author stays logged in)
256 251 let mentioned_id = uuid::Uuid::new_v4();
257 252 sqlx::query("INSERT INTO users (mnw_account_id, username, display_name) VALUES ($1, $2, $2)")
258 253 .bind(mentioned_id)
@@ -262,7 +257,6 @@
262 257 .unwrap();
263 258 h.add_membership(mentioned_id, comm_id, "member").await;
264 259
265 - // Author creates thread mentioning user B
266 260 h.client.get("/p/test/general/new").await;
267 261 let resp = h
268 262 .client
@@ -277,14 +271,12 @@
277 271 resp.status
278 272 );
279 273
280 - // Find thread ID
281 274 let threads =
282 275 mt_db::queries::list_threads_in_category_paginated(&h.db, "test", "general", 10, 0)
283 276 .await
284 277 .unwrap();
285 278 let thread_id = threads[0].id;
286 279
287 - // User B tracks the thread
288 280 mt_db::mutations::track_thread(&h.db, mentioned_id, thread_id)
289 281 .await
290 282 .unwrap();
@@ -296,7 +288,6 @@
296 288 });
297 289 h.client.post_json("/_test/login", &body.to_string()).await;
298 290
299 - // View tracked page
300 291 let resp = h.client.get("/tracked").await;
301 292 assert!(
302 293 resp.text.contains("badge-mention"),
@@ -46,7 +46,6 @@
46 46 .await;
47 47 }
48 48
49 - // Page 1 should show 25
50 49 let resp = h.client.get("/").await;
51 50 assert!(resp.status.is_success());
52 51 assert!(
@@ -63,7 +62,6 @@
63 62 "Should not show Previous link on page 1"
64 63 );
65 64
66 - // Page 2 should show the remaining 5
67 65 let resp = h.client.get("/?page=2").await;
68 66 assert!(resp.status.is_success());
69 67 assert!(
@@ -85,7 +83,6 @@
85 83 resp.text.contains("No threads yet"),
86 84 "expected empty state message"
87 85 );
88 - // Should not render pagination
89 86 assert!(
90 87 !resp.text.contains("pagination"),
91 88 "pagination should not appear with 0 threads"
@@ -103,11 +100,9 @@
103 100 h.create_thread_with_post(cat_id, user_id, "Thread One", "body")
104 101 .await;
105 102
106 - // Request page=999
107 103 let resp = h.client.get("/p/test/general?page=999").await;
108 104
109 105 assert!(resp.status.is_success());
110 - // Should still show the thread (clamped to page 1)
111 106 assert!(
112 107 resp.text.contains("Thread One"),
113 108 "thread should be visible on clamped page"
@@ -142,7 +137,6 @@
142 137 let cat_id = h.create_category(comm_id, "General", "general").await;
143 138 h.add_membership(user_id, comm_id, "member").await;
144 139
145 - // Create two threads
146 140 let _t1 = h
147 141 .create_thread_with_post(cat_id, user_id, "Few Replies", "body")
148 142 .await;
@@ -150,7 +144,6 @@
150 144 .create_thread_with_post(cat_id, user_id, "Many Replies", "body")
151 145 .await;
152 146
153 - // Add extra replies to t2
154 147 for i in 0..3 {
155 148 mt_db::mutations::create_post(
156 149 &h.db,
@@ -163,7 +156,6 @@
163 156 .unwrap();
164 157 }
165 158
166 - // Sort by replies desc, "Many Replies" should come first
167 159 let resp = h
168 160 .client
169 161 .get("/p/test/general?sort=replies&order=desc")
@@ -23,12 +23,10 @@
23 23 let cat_id = h.create_category(comm_id, "General", "general").await;
24 24 h.add_membership(user_id, comm_id, "member").await;
25 25
26 - // Create a thread (user is thread author)
27 26 let thread_id = h
28 27 .create_thread_with_post(cat_id, user_id, "My Thread", "Hello world")
29 28 .await;
30 29
31 - // Create a reply in another thread
32 30 let thread_id_2 = h
33 31 .create_thread_with_post(cat_id, user_id, "Another Thread", "Second post")
34 32 .await;
@@ -47,7 +45,6 @@
47 45 "should list reply activity"
48 46 );
49 47
50 - // Verify thread_id link is present
51 48 assert!(
52 49 resp.text.contains(&thread_id.to_string()),
53 50 "should link to thread"
@@ -82,7 +79,6 @@
82 79 let comm_id = h.create_community("SuspendedComm", "suspended-comm").await;
83 80 h.add_membership(user_id, comm_id, "member").await;
84 81
85 - // Suspend the community
86 82 sqlx::query("UPDATE communities SET suspended_at = now() WHERE id = $1")
87 83 .bind(comm_id)
88 84 .execute(&h.db)
@@ -131,7 +127,6 @@
131 127 let mut h = TestHarness::new().await;
132 128 let _user_id = h.login_as("snoop").await;
133 129
134 - // Try to access another user's summary
135 130 let other_id = uuid::Uuid::new_v4();
136 131 let resp = h.client.get(&format!("/api/user/{other_id}/summary")).await;
137 132 assert_eq!(
@@ -149,25 +144,21 @@
149 144 let cat_id = h.create_category(comm_id, "General", "general").await;
150 145 h.add_membership(author_id, comm_id, "member").await;
151 146
152 - // Author creates a thread with a post
153 147 let thread_id = h
154 148 .create_thread_with_post(cat_id, author_id, "Great Thread", "Great content")
155 149 .await;
156 150
157 - // Get the first post ID
158 151 let posts = mt_db::queries::list_posts_in_thread(&h.db, thread_id)
159 152 .await
160 153 .unwrap();
161 154 let post_id = posts[0].id;
162 155
163 - // Another user endorses the post
164 156 let endorser_id = h.login_as("endorser1").await;
165 157 h.add_membership(endorser_id, comm_id, "member").await;
166 158 mt_db::mutations::toggle_endorsement(&h.db, post_id, endorser_id)
167 159 .await
168 160 .unwrap();
169 161
170 - // Check the author's profile shows endorsement count
171 162 let resp = h.client.get("/p/endorse-comm/u/endorsedauthor").await;
172 163 assert_eq!(resp.status.as_u16(), 200);
173 164 assert!(
@@ -86,7 +86,7 @@
86 86 );
87 87 }
88 88
89 - // Nothing leaked through: no tag was created, name unchanged.
89 + // The 403s were real and not just status codes: nothing reached the database.
90 90 let tags = mt_db::queries::list_tags_for_community(&h.db, comm_id)
91 91 .await
92 92 .unwrap();
@@ -108,7 +108,6 @@
108 108 .await
109 109 .unwrap();
110 110
111 - // Create thread with tag via form
112 111 h.client.get("/p/test/general/new").await;
113 112 let body = format!("title=Tagged+Thread&body=Content&tags={tag_id}");
114 113 let resp = h.client.post_form("/p/test/general/new", &body).await;
@@ -118,7 +117,6 @@
118 117 resp.status
119 118 );
120 119
121 - // Check thread_tags
122 120 let threads = mt_db::queries::list_threads_in_category_sorted(
123 121 &h.db,
124 122 "test",
@@ -164,12 +162,10 @@
164 162 .create_thread_with_post(cat_id, owner_id, "Untagged Thread", "no tag")
165 163 .await;
166 164
167 - // Filter by tag
168 165 let resp = h.client.get("/p/test/general?tag=bug").await;
169 166 assert!(resp.text.contains("Tagged Thread"));
170 167 assert!(!resp.text.contains("Untagged Thread"));
171 168
172 - // Without filter, both visible
173 169 let resp = h.client.get("/p/test/general").await;
174 170 assert!(resp.text.contains("Tagged Thread"));
175 171 assert!(resp.text.contains("Untagged Thread"));
@@ -193,7 +189,6 @@
193 189 .await
194 190 .unwrap();
195 191
196 - // Delete the tag
197 192 h.client.get("/p/test/settings").await;
198 193 let body = format!("tag_id={tag_id}");
199 194 let resp = h
@@ -206,7 +201,6 @@
206 201 resp.status
207 202 );
208 203
209 - // Tag gone
210 204 let tags = mt_db::queries::list_tags_for_community(&h.db, comm_id)
211 205 .await
212 206 .unwrap();