summaryrefslogtreecommitdiffstats
path: root/tests/live.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
commite757979f1a2afdbe7146066345bb9acd19d3b151 (patch)
tree30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /tests/live.rs
parent94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff)
downloadaur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz
aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
Diffstat (limited to 'tests/live.rs')
-rw-r--r--tests/live.rs31
1 files changed, 11 insertions, 20 deletions
diff --git a/tests/live.rs b/tests/live.rs
index 16b68c5..da0f7ec 100644
--- a/tests/live.rs
+++ b/tests/live.rs
@@ -1,7 +1,3 @@
-//! The live surfaces: the SSE log tail and the htmx-refreshed builds table
-//! (§13). The budget matters here — the whole point of "htmx and thirty lines of
-//! glue" is that a reviewer can audit everything the browser runs.
-
mod common;
use std::io::Read;
@@ -51,9 +47,8 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() {
std::fs::create_dir_all(log.parent().unwrap()).unwrap();
std::fs::write(&log, "==> step materialize\n").unwrap();
- // A producer appends while the stream is open, then finishes the build. If
- // the endpoint buffered its response, everything would arrive only after the
- // build ended and the "live" claim would be false.
+ // A producer appends while the stream is open, then finishes the build. If the
+ // endpoint buffered its response the "live" claim would be false.
let db = web.env.db.clone();
let id2 = id.clone();
let log2 = log.clone();
@@ -101,20 +96,17 @@ fn the_builds_table_refreshes_via_htmx_and_still_works_without_js() {
let web = Web::attach(env, fx);
let base = web.url("/builds");
- // One queued build so the table has a row: the empty state is a paragraph,
- // and asserting on it would prove nothing about server rendering.
+ // One queued build so the table has a row.
queued(&web.env, "plain-make");
let page = ureq::get(&base).call().unwrap().into_string().unwrap();
// The refresh is an attribute on the table, not a script we wrote.
assert!(page.contains("hx-trigger=\"every 3s\""), "no htmx refresh: {}", &page[..400.min(page.len())]);
assert!(page.contains("hx-get=\"/builds?fragment=1\""), "the refresh has no target");
assert!(page.contains("<script src=\"/static/htmx.min.js\""), "htmx is not loaded");
- // And with JavaScript switched off the same HTML already contains the table:
- // the refresh is an enhancement, not a requirement.
+ // And with JavaScript off the same HTML already contains the table.
assert!(page.contains("<table>"), "no server-rendered table");
- // The fragment endpoint returns the table on its own, so htmx can swap it in
- // without dragging the whole document along.
+ // The fragment endpoint returns the table on its own, so htmx can swap it in.
let frag = ureq::get(&format!("{base}?fragment=1")).call().unwrap().into_string().unwrap();
assert!(frag.starts_with("<div id=\"builds\""), "fragment is not the table: {}", &frag[..120.min(frag.len())]);
assert!(!frag.contains("<!doctype"), "the fragment is a whole page");
@@ -126,9 +118,8 @@ fn htmx_is_the_only_javascript_and_what_is_shipped_fits_the_budget() {
let (env, fx) = env_with_fixture("plain-make");
let web = Web::attach(env, fx);
// Served bytes are what a browser actually downloads, and that is the budget
- // with any meaning: the file on disk is 48 KB, the wire copy is not.
- // Read the wire bytes directly: an HTTP client would transparently
- // decompress, which is exactly the thing this budget is about.
+ // with any meaning. An HTTP client would transparently decompress, which is
+ // exactly what this budget is about, so read the wire directly.
let (headers, served) = raw_get(&web, "/static/htmx.min.js", true);
assert!(headers.to_lowercase().contains("content-encoding: gzip"), "the vendored js is not compressed: {headers}");
assert!(
@@ -159,13 +150,13 @@ fn the_stylesheet_is_served_and_the_review_surface_needs_no_javascript() {
assert!(css.contains("body"), "app.css is a placeholder");
let page = web.get("/reviews").body;
assert!(page.contains("<link rel=\"stylesheet\" href=\"/static/app.css\">"), "the page does not load it");
- // The review flow is the one that must work with scripting disabled, so it
- // deliberately does not load htmx at all.
+ // The review flow is the one that must work with scripting disabled, so it does
+ // not load htmx at all.
assert!(!page.contains("<script"), "the review surface ships JavaScript");
}
-/// Ask for a path over a bare socket so the response is seen as it goes over the
-/// wire, before any client-side content negotiation undoes it.
+/// Ask for a path over a bare socket so the response is seen before any client-side
+/// content negotiation undoes it.
fn raw_get(web: &Web, path: &str, gzip: bool) -> (String, Vec<u8>) {
use std::io::{BufRead, BufReader, Write};
let addr = web.server.addr.clone();