forge
Explore
Log in

Don't you dare go Hollow

flyout tests no longer 500 CI: the GET / path needs a topcoat bundle, so the marks HTML is pinned without a router.

Browse files at this commit

3bc2d0088ac9b51f3050af900bb937a37bc0486dAhmet Kaan GümüşParent: 6557831
cargo test --workspace on GitHub has no asset bundle; the two new landing GETs panicked in topcoat-asset and rolled the dots commit back off the box. Guard those GETs like the other admin HTML tests, and keep a pure trio_marks assertion that runs either way.
crates/im-web/src/admin.rsmodified+80 -29
@@ -1970,6 +1970,7 @@ mod tests {
1970 };1970 };
1971 1971
1972 use crate::config::Config;1972 use crate::config::Config;
1973+ use crate::health::Probe;
1973 use crate::server::{self, SESSION_COOKIE};1974 use crate::server::{self, SESSION_COOKIE};
1974 1975
1975 struct Setup {1976 struct Setup {
@@ -2590,7 +2591,7 @@ mod tests {
2590 let http = reqwest::Client::new();2591 let http = reqwest::Client::new();
2591 2592
2592 // A stand-in service answering the deploy body.2593 // A stand-in service answering the deploy body.
2593- use crate::health::{Probe, probe_healthz};2594+ use crate::health::probe_healthz;
2594 let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();2595 let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
2595 2596
2596 let addr = listener.local_addr().unwrap();2597 let addr = listener.local_addr().unwrap();
@@ -2661,7 +2662,9 @@ mod tests {
2661 /// The signed-in flyout marks each sibling with the same health the2662 /// The signed-in flyout marks each sibling with the same health the
2662 /// admin table reads: a sibling answering `ok` renders `health-on`,2663 /// admin table reads: a sibling answering `ok` renders `health-on`,
2663 /// a dark port `health-off`, dots only — no body, no latency — and2664 /// a dark port `health-off`, dots only — no body, no latency — and
2664- /// im's own row stays out of the flyout.2665+ /// im's own row stays out of the flyout. The render needs the asset
2666+ /// bundle; the markup itself is pinned router-free in
2667+ /// `family_flyout_marks_pure_html` below.
2665 #[tokio::test]2668 #[tokio::test]
2666 async fn family_flyout_marks_siblings_with_health_dots() {2669 async fn family_flyout_marks_siblings_with_health_dots() {
2667 use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};2670 use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};
@@ -2671,14 +2674,6 @@ mod tests {
2671 // A live sibling answering the deploy body, and a dark one.2674 // A live sibling answering the deploy body, and a dark one.
2672 let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();2675 let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
2673 let live_url = format!("http://{}", listener.local_addr().unwrap());2676 let live_url = format!("http://{}", listener.local_addr().unwrap());
2674- let talker = tokio::spawn(async move {
2675- let (mut sock, _) = listener.accept().await.unwrap();
2676- let mut buf = [0u8; 1024];
2677- let _ = sock.read(&mut buf).await;
2678- sock.write_all(b"HTTP/1.1 200 OK\r\ncontent-length: 6\r\n\r\nok dev")
2679- .await
2680- .unwrap();
2681- });
2682 let dark = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();2677 let dark = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
2683 let dark_url = format!("http://{}", dark.local_addr().unwrap());2678 let dark_url = format!("http://{}", dark.local_addr().unwrap());
2684 drop(dark);2679 drop(dark);
@@ -2698,21 +2693,34 @@ mod tests {
2698 .await2693 .await
2699 .unwrap();2694 .unwrap();
2700 }2695 }
2696+ // The render needs the asset bundle; without one `GET /` has no
2697+ // asset config to draw from. The markup itself is pinned
2698+ // router-free in `family_flyout_marks_pure_html` below.
2699+ if setup.assets {
2700+ let talker = tokio::spawn(async move {
2701+ let (mut sock, _) = listener.accept().await.unwrap();
2702+ let mut buf = [0u8; 1024];
2703+ let _ = sock.read(&mut buf).await;
2704+ sock.write_all(b"HTTP/1.1 200 OK\r\ncontent-length: 6\r\n\r\nok dev")
2705+ .await
2706+ .unwrap();
2707+ });
2708+ let (_, _, body) = get_full(&setup.router, "/", Some(&setup.plain_cookie)).await;
2709+ talker.await.unwrap();
2710+ assert!(body.contains("service-trio"), "{body}");
2711+ assert!(
2712+ body.contains(r#"<a class="trio-mark" href="http://127.0.0.1:"#),
2713+ "the marks stay links: {body}"
2714+ );
2715+ assert!(body.contains("health-dot health-on"), "the ok sibling reads on: {body}");
2716+ assert!(body.contains(">iz</a>"), "the live sibling renders: {body}");
2717+ assert!(body.contains("health-dot health-off"), "the dark sibling reads off: {body}");
2718+ assert!(body.contains(">in</a>"), "the dark sibling renders: {body}");
2719+ assert!(!body.contains(">im</a>"), "im's own row stays out: {body}");
2720+ assert!(!body.contains("ok dev"), "the flyout carries dots only: {body}");
2721+ assert!(!body.contains(" ms</span>"), "the flyout carries no latency: {body}");
2722+ }
2701 2723
2702- let (_, _, body) = get_full(&setup.router, "/", Some(&setup.plain_cookie)).await;
2703- talker.await.unwrap();
2704- assert!(body.contains("service-trio"), "{body}");
2705- assert!(
2706- body.contains(r#"<a class="trio-mark" href="http://127.0.0.1:"#),
2707- "the marks stay links: {body}"
2708- );
2709- assert!(body.contains("health-dot health-on"), "the ok sibling reads on: {body}");
2710- assert!(body.contains(">iz</a>"), "the live sibling renders: {body}");
2711- assert!(body.contains("health-dot health-off"), "the dark sibling reads off: {body}");
2712- assert!(body.contains(">in</a>"), "the dark sibling renders: {body}");
2713- assert!(!body.contains(">im</a>"), "im's own row stays out: {body}");
2714- assert!(!body.contains("ok dev"), "the flyout carries dots only: {body}");
2715- assert!(!body.contains(" ms</span>"), "the flyout carries no latency: {body}");
2716 }2724 }
2717 2725
2718 /// A family with no siblings is the bare mark: no flyout in the DOM2726 /// A family with no siblings is the bare mark: no flyout in the DOM
@@ -2720,10 +2728,53 @@ mod tests {
2720 #[tokio::test]2728 #[tokio::test]
2721 async fn family_flyout_without_siblings_is_the_bare_mark() {2729 async fn family_flyout_without_siblings_is_the_bare_mark() {
2722 let setup = setup().await;2730 let setup = setup().await;
2723- let (_, _, body) = get_full(&setup.router, "/", Some(&setup.plain_cookie)).await;2731+ if setup.assets {
2724- assert!(!body.contains("service-trio"), "{body}");2732+ let (_, _, body) = get_full(&setup.router, "/", Some(&setup.plain_cookie)).await;
2725- assert!(!body.contains("wordmark-family"), "{body}");2733+ assert!(!body.contains("service-trio"), "{body}");
2726- assert!(!body.contains("health-dot"), "{body}");2734+ assert!(!body.contains("wordmark-family"), "{body}");
2727- assert!(body.contains("wordmark-text"), "the bare mark stays: {body}");2735+ assert!(!body.contains("health-dot"), "{body}");
2736+ assert!(body.contains("wordmark-text"), "the bare mark stays: {body}");
2737+ } else {
2738+ // No bundle, no render. The empty family stays pinned
2739+ // router-free: only im's own row exists, so there is
2740+ // nothing to reveal and nothing to probe — no marks at all.
2741+ let marks = crate::layout::trio_marks([(
2742+ "im",
2743+ "http://127.0.0.1:7650",
2744+ Probe::Up { body: "ok dev".into(), ms: 1 },
2745+ )]);
2746+ assert!(marks.is_empty(), "an im-only family has no flyout: {marks}");
2747+ }
2748+ }
2749+
2750+ /// The CI gate for the flyout markup: `trio_marks` is the exact
2751+ /// HTML the flyout renders, so the probe-to-dot mapping and im's
2752+ /// omission are pinned without a router or an asset bundle — which
2753+ /// is where the renders above get skipped. Up reads `health-on`,
2754+ /// Down `health-off`, the keys stay links, and the probe's body and
2755+ /// latency never leave the admin table.
2756+ #[test]
2757+ fn family_flyout_marks_pure_html() {
2758+ let marks = crate::layout::trio_marks([
2759+ ("iz", "http://127.0.0.1:9001", Probe::Up { body: "ok dev".into(), ms: 12 }),
2760+ ("in", "http://127.0.0.1:9002", Probe::Down),
2761+ // im's own row goes in; it must not come back out.
2762+ ("im", "http://127.0.0.1:7650", Probe::Up { body: "ok dev".into(), ms: 1 }),
2763+ ]);
2764+ assert!(
2765+ marks.contains(r#"<a class="trio-mark" href="http://127.0.0.1:9001">"#),
2766+ "the marks stay links: {marks}"
2767+ );
2768+ assert!(marks.contains("health-dot health-on"), "the ok sibling reads on: {marks}");
2769+ assert!(marks.contains(">iz</a>"), "the live sibling renders: {marks}");
2770+ assert!(marks.contains("health-dot health-off"), "the dark sibling reads off: {marks}");
2771+ assert!(marks.contains(">in</a>"), "the dark sibling renders: {marks}");
2772+ assert!(!marks.contains(">im</a>"), "im's own row stays out: {marks}");
2773+ assert!(!marks.contains("ok dev"), "the flyout carries dots only: {marks}");
2774+ assert!(!marks.contains(" ms</span>"), "the flyout carries no latency: {marks}");
2775+ assert!(
2776+ marks.contains(r#"<span class="trio-sep">·</span>"#),
2777+ "the marks join on middots: {marks}"
2778+ );
2728 }2779 }
2729 }2780 }
crates/im-web/src/layout.rsmodified+31 -11
@@ -53,19 +53,12 @@ pub async fn family_wordmark(cx: &Cx) -> Result<BoxView<'_>> {
53 let url = format!("{}/healthz", service.url.trim_end_matches('/'));53 let url = format!("{}/healthz", service.url.trim_end_matches('/'));
54 probes.push(tokio::spawn(async move { probe_healthz(&http, &url).await }));54 probes.push(tokio::spawn(async move { probe_healthz(&http, &url).await }));
55 }55 }
56- let mut marks = Vec::new();56+ let mut rows = Vec::new();
57 for (service, probe) in siblings.iter().zip(probes) {57 for (service, probe) in siblings.iter().zip(probes) {
58- let key = crate::pages::escape(&service.key);58+ let probe = probe.await.unwrap_or(Probe::Down);
59- let url = crate::pages::escape(&service.url);59+ rows.push((service.key.as_str(), service.url.as_str(), probe));
60- let dot = match probe.await.unwrap_or(Probe::Down) {
61- Probe::Up { .. } => "health-on",
62- Probe::Down => "health-off",
63- };
64- marks.push(format!(
65- r#"<a class="trio-mark" href="{url}"><span class="health-dot {dot}"></span>{key}</a>"#
66- ));
67 }60 }
68- let marks = marks.join(r#"<span class="trio-sep">·</span>"#);61+ let marks = trio_marks(rows);
69 Ok(view! {62 Ok(view! {
70 cx =>63 cx =>
71 <div class="wordmark-family">64 <div class="wordmark-family">
@@ -78,6 +71,33 @@ pub async fn family_wordmark(cx: &Cx) -> Result<BoxView<'_>> {
78 .boxed())71 .boxed())
79 }72 }
80 73
74+/// The flyout's marks as final HTML, pure over resolved probes: im's own
75+/// row filtered out, every sibling a plain link carrying its probe's dot
76+/// — `health-on` while it answers `ok`, `health-off` while it does not —
77+/// middots between. Dots only: the probe's body and latency belong to
78+/// the admin table, never to the chrome. Extracted from
79+/// `family_wordmark` so the tests pin this exact markup without a
80+/// router or an asset bundle.
81+pub(crate) fn trio_marks<'a>(
82+ rows: impl IntoIterator<Item = (&'a str, &'a str, Probe)>,
83+) -> String {
84+ rows.into_iter()
85+ .filter(|(key, _, _)| *key != "im")
86+ .map(|(key, url, probe)| {
87+ let key = crate::pages::escape(key);
88+ let url = crate::pages::escape(url);
89+ let dot = match probe {
90+ Probe::Up { .. } => "health-on",
91+ Probe::Down => "health-off",
92+ };
93+ format!(
94+ r#"<a class="trio-mark" href="{url}"><span class="health-dot {dot}"></span>{key}</a>"#
95+ )
96+ })
97+ .collect::<Vec<_>>()
98+ .join(r#"<span class="trio-sep">·</span>"#)
99+}
100+
81 /// The profile card's face: the photo when the account has one, the name's101 /// The profile card's face: the photo when the account has one, the name's
82 /// first letter on a quiet tile when it does not. The URL's `?v=` is the102 /// first letter on a quiet tile when it does not. The URL's `?v=` is the
83 /// row's `photo_version` — the same number `/directory` answers with — so103 /// row's `photo_version` — the same number `/directory` answers with — so