diff --git a/crates/fastled-cli/src/server.rs b/crates/fastled-cli/src/server.rs index 6b1b89a2..eb991a8c 100644 --- a/crates/fastled-cli/src/server.rs +++ b/crates/fastled-cli/src/server.rs @@ -49,24 +49,80 @@ const LOADING_PAGE: &str = r#" .spinner { width: 40px; height: 40px; border: 4px solid #333; border-top: 4px solid #4fc3f7; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; } + .spinner.error { border-top-color: #ef5350; animation: none; } @keyframes spin { to { transform: rotate(360deg); } } - #status { font-size: 1.2em; } + #header { font-size: 1.2em; display: flex; align-items: baseline; gap: 12px; } + #status { } + #elapsed { color: #888; font-size: 0.9em; } + #header.error #status { color: #ef5350; } #log { margin-top: 20px; width: 80%; max-height: 50vh; overflow-y: auto; font-size: 0.85em; color: #aaa; white-space: pre-wrap; text-align: left; line-height: 1.4; padding: 8px; background: #1a1a1a; border-radius: 4px; } -
-
Compiling...
+
+
"#; @@ -413,6 +470,36 @@ mod tests { ); } + /// Instant-launch failure UX (#148 acceptance criterion 5): + /// when a compile has failed and `index.html` is absent, `/` must still + /// return the in-browser loading page (which surfaces the error log) — + /// it must NOT 404 or navigate to a stale page. + #[tokio::test] + async fn test_loading_page_stays_when_build_failed_and_no_index_html() { + let (addr, dir) = setup_server().await; + fs::write( + dir.path().join("build-status.json"), + r#"{"status":"error","message":"Compilation failed"}"#, + ) + .unwrap(); + let resp = reqwest::get(format!("http://{addr}/")).await.unwrap(); + assert_eq!( + resp.status(), + 200, + "viewer should land on the loading page, not 404/redirect, when compile failed" + ); + let body = resp.text().await.unwrap(); + assert!( + body.contains("Compiling..."), + "expected loading page, got: {body}" + ); + // Sanity check: the embedded JS knows how to render the error state. + assert!( + body.contains("setError"), + "loading page must include error-handling branch" + ); + } + #[tokio::test] async fn test_serves_index_html_when_present() { let (addr, dir) = setup_server().await;