Harden PRD live site rendering checks

This commit is contained in:
2026-05-09 01:03:19 -04:00
parent 96732c8932
commit 89a8e05eeb
8 changed files with 208 additions and 149 deletions
@@ -201,6 +201,7 @@ impl SidecarSnapshotRequest {
pub struct SidecarSnapshot {
loaded_url: Option<String>,
title: Option<String>,
render_state: String,
width: u32,
height: u32,
#[cfg(test)]
@@ -250,6 +251,7 @@ impl SidecarSnapshot {
Ok(Self {
loaded_url: report.loaded_url,
title: report.title,
render_state: report.state,
width: report.width,
height: report.height,
#[cfg(test)]
@@ -272,6 +274,11 @@ impl SidecarSnapshot {
self.title.as_deref()
}
#[must_use]
pub fn render_state(&self) -> &str {
self.render_state.as_str()
}
#[must_use]
pub fn width(&self) -> u32 {
self.width
@@ -28,6 +28,7 @@ fn accepts_loading_report_with_visible_content() -> Result<(), ServoSidecarError
assert_eq!(snapshot.loaded_url(), Some("https://example.com/"));
assert_eq!(snapshot.title(), Some("Example Domain"));
assert_eq!(snapshot.render_state(), "loading");
assert_eq!(snapshot.width(), 2);
assert_eq!(snapshot.height(), 1);
assert_eq!(snapshot.non_white_pixel_count, 1);
@@ -156,6 +157,7 @@ fn assert_live_sites_render(cases: &[LiveSiteCase]) -> Result<(), Box<dyn Error>
assert_eq!(snapshot.width(), LIVE_SITE_WIDTH, "{}", case.url);
assert_eq!(snapshot.height(), LIVE_SITE_HEIGHT, "{}", case.url);
assert_render_state_is_open(snapshot.render_state(), case.url);
assert_loaded_url_contains(&snapshot, case.url)?;
assert_title_contains(&snapshot, case.title_fragment)?;
assert!(snapshot.non_white_pixel_count > 0, "{}", case.url);
@@ -173,6 +175,11 @@ fn assert_live_sites_render(cases: &[LiveSiteCase]) -> Result<(), Box<dyn Error>
Ok(())
}
#[cfg(feature = "live-site-smoke")]
fn assert_render_state_is_open(state: &str, url: &str) {
assert!(matches!(state, "complete" | "loading"), "{url} state: {state}");
}
#[cfg(feature = "live-site-smoke")]
fn assert_loaded_url_contains(
snapshot: &SidecarSnapshot,