tui: measure panel dashboard readiness
This commit is contained in:
@@ -298,6 +298,104 @@ impl ExpectedPanelTicketRow {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ExpectedDashboardContent {
|
||||
pub tickets: Vec<ExpectedPanelTicketRow>,
|
||||
pub pod_names: Vec<String>,
|
||||
}
|
||||
|
||||
impl ExpectedDashboardContent {
|
||||
fn description(&self) -> String {
|
||||
let tickets = self
|
||||
.tickets
|
||||
.iter()
|
||||
.map(ExpectedPanelTicketRow::description)
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
let pods = self.pod_names.join(", ");
|
||||
format!("tickets=[{tickets}] pods=[{pods}]")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct DashboardContentSnapshot {
|
||||
pub tickets: Vec<ExpectedPanelTicketRow>,
|
||||
pub pod_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DashboardContentReady {
|
||||
pub ticket_configured: bool,
|
||||
pub selected: Option<PanelRowKey>,
|
||||
pub categories: DashboardContentCategories,
|
||||
#[serde(default)]
|
||||
pub diagnostics: Vec<String>,
|
||||
pub rows: Vec<RenderedPanelRow>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DashboardContentCategories {
|
||||
pub ticket_rows: usize,
|
||||
pub ready_ticket_rows: usize,
|
||||
pub planning_ticket_rows: usize,
|
||||
pub pod_rows: usize,
|
||||
pub actionable_rows: usize,
|
||||
}
|
||||
|
||||
impl DashboardContentReady {
|
||||
pub fn rows_rendered(&self) -> RowsRendered {
|
||||
RowsRendered {
|
||||
selected: self.selected.clone(),
|
||||
rows: self.rows.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn snapshot_for_expected(
|
||||
&self,
|
||||
expected: &ExpectedDashboardContent,
|
||||
) -> DashboardContentSnapshot {
|
||||
DashboardContentSnapshot {
|
||||
tickets: expected
|
||||
.tickets
|
||||
.iter()
|
||||
.filter(|ticket| self.rows.iter().any(|row| ticket.matches(row)))
|
||||
.cloned()
|
||||
.collect(),
|
||||
pod_names: expected
|
||||
.pod_names
|
||||
.iter()
|
||||
.filter(|pod_name| {
|
||||
self.rows
|
||||
.iter()
|
||||
.any(|row| row.key.kind == "pod" && row.key.id == pod_name.as_str())
|
||||
})
|
||||
.cloned()
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DashboardSourceBreakdown {
|
||||
pub total_elapsed_ms: u128,
|
||||
pub sources: Vec<DashboardSourceTiming>,
|
||||
pub ticket_rows: usize,
|
||||
pub pod_rows: usize,
|
||||
pub diagnostics: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DashboardSourceTiming {
|
||||
pub source: String,
|
||||
pub elapsed_ms: u128,
|
||||
}
|
||||
|
||||
impl DashboardSourceBreakdown {
|
||||
pub fn has_source(&self, source: &str) -> bool {
|
||||
self.sources.iter().any(|timing| timing.source == source)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct RowsRendered {
|
||||
pub selected: Option<PanelRowKey>,
|
||||
@@ -542,6 +640,52 @@ impl PanelHarness {
|
||||
serde_json::from_value(event.data).map_err(HarnessError::from)
|
||||
}
|
||||
|
||||
/// Waits for the dashboard-content-ready observer event. Unlike first-frame
|
||||
/// or row-count readiness, this requires representative user-visible content:
|
||||
/// ready + planning Ticket rows and a Pod row, then checks the fixture-specific
|
||||
/// rows as a small snapshot of the expected dashboard content.
|
||||
pub fn wait_for_dashboard_content_ready(
|
||||
&mut self,
|
||||
expected: &ExpectedDashboardContent,
|
||||
timeout: Duration,
|
||||
) -> Result<DashboardContentReady> {
|
||||
let expected_snapshot = DashboardContentSnapshot {
|
||||
tickets: expected.tickets.clone(),
|
||||
pod_names: expected.pod_names.clone(),
|
||||
};
|
||||
let description = expected.description();
|
||||
let event = self.wait_for(
|
||||
format!("dashboard content ready ({description})"),
|
||||
timeout,
|
||||
|event| {
|
||||
if event.event != "dashboard_content_ready" {
|
||||
return false;
|
||||
}
|
||||
serde_json::from_value::<DashboardContentReady>(event.data.clone())
|
||||
.map(|ready| ready.snapshot_for_expected(expected) == expected_snapshot)
|
||||
.unwrap_or(false)
|
||||
},
|
||||
)?;
|
||||
serde_json::from_value(event.data).map_err(HarnessError::from)
|
||||
}
|
||||
|
||||
pub fn latest_dashboard_source_breakdown(
|
||||
&mut self,
|
||||
) -> Result<Option<DashboardSourceBreakdown>> {
|
||||
Ok(self
|
||||
.events()?
|
||||
.into_iter()
|
||||
.rev()
|
||||
.filter(|event| event.event == "dashboard_source_breakdown")
|
||||
.find_map(|event| serde_json::from_value(event.data).ok()))
|
||||
}
|
||||
|
||||
pub fn expect_dashboard_source_breakdown(&mut self) -> Result<DashboardSourceBreakdown> {
|
||||
self.latest_dashboard_source_breakdown()?.ok_or_else(|| {
|
||||
HarnessError::Protocol("missing dashboard_source_breakdown observer event".to_string())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn assert_fixture_ticket_row_not_rendered(
|
||||
&mut self,
|
||||
expected: &ExpectedPanelTicketRow,
|
||||
@@ -1041,6 +1185,24 @@ impl FixtureWorkspace {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn planning_fixture_ticket_row(&self) -> ExpectedPanelTicketRow {
|
||||
ExpectedPanelTicketRow::new(
|
||||
self.planning_ticket_id.clone(),
|
||||
PLANNING_FIXTURE_TICKET_TITLE,
|
||||
"planning",
|
||||
)
|
||||
}
|
||||
|
||||
pub fn expected_dashboard_content(&self) -> ExpectedDashboardContent {
|
||||
ExpectedDashboardContent {
|
||||
tickets: vec![
|
||||
self.ready_fixture_ticket_row(),
|
||||
self.planning_fixture_ticket_row(),
|
||||
],
|
||||
pod_names: vec!["workspace".to_string()],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn panel_config(&self, binary: PathBuf) -> PanelHarnessConfig {
|
||||
PanelHarnessConfig {
|
||||
binary,
|
||||
|
||||
+35
-11
@@ -1,7 +1,7 @@
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const FIRST_VISIBLE_RENDER_BUDGET: Duration = Duration::from_millis(1500);
|
||||
const ROWS_READY_BUDGET: Duration = Duration::from_secs(5);
|
||||
const DASHBOARD_CONTENT_READY_BUDGET: Duration = Duration::from_secs(5);
|
||||
|
||||
use yoi_e2e::{
|
||||
ExpectedPanelTicketRow, FixtureCleanupReport, FixtureWorkspace, KeyPress, PanelHarness,
|
||||
@@ -114,11 +114,11 @@ fn panel_first_visible_render_arrives_before_background_reload() -> yoi_e2e::Res
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn panel_fixture_ticket_row_ready_has_startup_budget() -> yoi_e2e::Result<()> {
|
||||
fn panel_dashboard_content_ready_has_startup_budget() -> yoi_e2e::Result<()> {
|
||||
let binary = yoi_binary()?;
|
||||
let fixture = FixtureWorkspace::new(&binary)?;
|
||||
assert_fixture_paths_are_isolated(&fixture);
|
||||
let ready_ticket = fixture.ready_fixture_ticket_row();
|
||||
let expected_content = fixture.expected_dashboard_content();
|
||||
|
||||
let started = Instant::now();
|
||||
let mut panel = PanelHarness::spawn(fixture.panel_config(binary))?;
|
||||
@@ -137,23 +137,47 @@ fn panel_fixture_ticket_row_ready_has_startup_budget() -> yoi_e2e::Result<()> {
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
|
||||
let rows_ready_remaining = ROWS_READY_BUDGET
|
||||
let content_ready_remaining = DASHBOARD_CONTENT_READY_BUDGET
|
||||
.checked_sub(started.elapsed())
|
||||
.unwrap_or_else(|| Duration::from_millis(0));
|
||||
let rows = panel.wait_for_fixture_ticket_rows_ready(&ready_ticket, rows_ready_remaining)?;
|
||||
let content_ready =
|
||||
panel.wait_for_dashboard_content_ready(&expected_content, content_ready_remaining)?;
|
||||
assert!(
|
||||
rows.has_fixture_ticket_row(&ready_ticket),
|
||||
"rows-ready event must contain concrete ready fixture Ticket row; artifacts at {}",
|
||||
content_ready.ticket_configured,
|
||||
"dashboard content ready must include usable Ticket configuration; artifacts at {}",
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
let rows_ready_elapsed = started.elapsed();
|
||||
assert!(
|
||||
content_ready.categories.ready_ticket_rows > 0
|
||||
&& content_ready.categories.planning_ticket_rows > 0
|
||||
&& content_ready.categories.pod_rows > 0,
|
||||
"dashboard content ready must include ready Ticket, planning Ticket, and Pod categories; got {:?}; artifacts at {}",
|
||||
content_ready.categories,
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
let content_ready_elapsed = started.elapsed();
|
||||
eprintln!(
|
||||
"panel fixture rows ready: {rows_ready_elapsed:?} (budget {ROWS_READY_BUDGET:?}); artifacts at {}",
|
||||
"panel dashboard content ready: {content_ready_elapsed:?} (budget {DASHBOARD_CONTENT_READY_BUDGET:?}; first frame {first_visible_elapsed:?}); artifacts at {}",
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
assert!(
|
||||
rows_ready_elapsed <= ROWS_READY_BUDGET,
|
||||
"fixture rows ready took {rows_ready_elapsed:?}, budget {ROWS_READY_BUDGET:?}; artifacts at {}",
|
||||
content_ready_elapsed <= DASHBOARD_CONTENT_READY_BUDGET,
|
||||
"dashboard content ready took {content_ready_elapsed:?}, budget {DASHBOARD_CONTENT_READY_BUDGET:?}; artifacts at {}",
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
|
||||
let source_breakdown = panel.expect_dashboard_source_breakdown()?;
|
||||
assert!(
|
||||
source_breakdown.has_source("pod_list.initial")
|
||||
&& source_breakdown.has_source("ticket_config")
|
||||
&& source_breakdown.has_source("workspace_panel.build"),
|
||||
"dashboard source breakdown should include pod, ticket, and panel-build sources; got {:?}; artifacts at {}",
|
||||
source_breakdown,
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
eprintln!(
|
||||
"panel dashboard source breakdown: {:?}; artifacts at {}",
|
||||
source_breakdown,
|
||||
panel.artifacts().dir.display()
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user