Harden PRD live site rendering checks
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -16,6 +16,7 @@ pub(super) struct WebSurfaceFrame {
|
||||
pub(super) requested_url: String,
|
||||
loaded_url: Option<String>,
|
||||
title: Option<String>,
|
||||
render_state: String,
|
||||
width: u32,
|
||||
height: u32,
|
||||
scroll_offset: WebSurfaceScrollOffset,
|
||||
@@ -36,6 +37,7 @@ impl WebSurfaceFrame {
|
||||
let height = snapshot.height();
|
||||
let loaded_url = snapshot.loaded_url().map(str::to_string);
|
||||
let title = snapshot.title().map(str::to_string);
|
||||
let render_state = snapshot.render_state().to_string();
|
||||
let rgba_bytes = snapshot.into_rgba_bytes();
|
||||
|
||||
let Some(buffer) = ImageBuffer::<Rgba<u8>, _>::from_raw(width, height, rgba_bytes) else {
|
||||
@@ -48,6 +50,7 @@ impl WebSurfaceFrame {
|
||||
requested_url,
|
||||
loaded_url,
|
||||
title,
|
||||
render_state,
|
||||
width,
|
||||
height,
|
||||
scroll_offset,
|
||||
@@ -66,7 +69,8 @@ impl WebSurfaceFrame {
|
||||
}
|
||||
|
||||
pub(super) fn detail_label(&self) -> String {
|
||||
let mut detail = self.scroll_offset.detail_label(self.size());
|
||||
let mut detail =
|
||||
format!("{} {}", self.render_state(), self.scroll_offset.detail_label(self.size()));
|
||||
if let Some(click_point) = self.click_point {
|
||||
detail = format!("{detail} {}", click_point.detail_label());
|
||||
}
|
||||
@@ -80,6 +84,10 @@ impl WebSurfaceFrame {
|
||||
WebSurfaceSize { width: self.width, height: self.height }
|
||||
}
|
||||
|
||||
pub(super) fn render_state(&self) -> &str {
|
||||
self.render_state.as_str()
|
||||
}
|
||||
|
||||
pub(super) fn scroll_offset(&self) -> WebSurfaceScrollOffset {
|
||||
self.scroll_offset
|
||||
}
|
||||
|
||||
@@ -74,9 +74,14 @@ fn assert_prd_frame_is_ready(frame: &WebSurfaceFrame, case: &LiveSiteCase) {
|
||||
case.url
|
||||
);
|
||||
assert_eq!(frame.scroll_offset(), WebSurfaceScrollOffset::default(), "{}", case.url);
|
||||
assert_render_state_is_open(frame.render_state(), case.url);
|
||||
assert!(frame.url_label().contains(normalized_url(case.url)), "{}", frame.url_label());
|
||||
assert!(frame.title_label().contains(case.title_fragment), "{}", frame.title_label());
|
||||
assert_eq!(frame.detail_label(), "934x657", "{}", case.url);
|
||||
assert_eq!(frame.detail_label(), format!("{} 934x657", frame.render_state()), "{}", case.url);
|
||||
}
|
||||
|
||||
fn assert_render_state_is_open(state: &str, url: &str) {
|
||||
assert!(matches!(state, "complete" | "loading"), "{url} state: {state}");
|
||||
}
|
||||
|
||||
fn live_surface_bounds() -> Bounds<gpui::Pixels> {
|
||||
|
||||
Reference in New Issue
Block a user