diff --git a/host/tests/it/chat.rs b/host/tests/it/chat.rs index f1047fd..0818ea3 100644 --- a/host/tests/it/chat.rs +++ b/host/tests/it/chat.rs @@ -31,6 +31,35 @@ async fn request(port: u16, path: &str, body: Option<&str>) -> anyhow::Result<(u let status = header.split_whitespace().nth(1).unwrap().parse()?; Ok((status, bytes[end..].to_vec())) } +#[test] +fn page_rendering() -> anyhow::Result<()> { + let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("../userland/chat"); + let page = std::fs::read_to_string(source.join("index.html"))?; + let script = page + .split_once("") + .unwrap() + .0; + let dir = tempfile::tempdir()?; + let extracted = dir.path().join("chat.js"); + std::fs::write(&extracted, script)?; + let fixture = source.join("render.test.cjs"); + for args in [ + [Path::new("--check"), extracted.as_path()], + [fixture.as_path(), extracted.as_path()], + ] { + let output = std::process::Command::new("node").args(args).output()?; + anyhow::ensure!( + output.status.success(), + "Page script: {}", + String::from_utf8_lossy(&output.stderr) + ); + } + Ok(()) +} + #[tokio::test(flavor = "current_thread")] async fn seeded_chat() -> anyhow::Result<()> { seeded_chat_case(false).await diff --git a/userland/chat/index.html b/userland/chat/index.html index 4bc94e6..22d0632 100644 --- a/userland/chat/index.html +++ b/userland/chat/index.html @@ -3,13 +3,49 @@ Sausage chat
Sausage chat
-

Conversation

+

Conversation

'); +for (const expected of ['

', '