122 lines
4.0 KiB
Rust
122 lines
4.0 KiB
Rust
|
|
// Contracts for launcher diagnostics report completeness.
|
||
|
|
//
|
||
|
|
// Scope: inspect diagnostics report schema and text rendering.
|
||
|
|
// Targets: `client/src/launcher/diagnostics/*`.
|
||
|
|
// Why: when a remote call looks wrong, Copy Report should preserve enough
|
||
|
|
// routing, media, calibration, timing, and recommendation context to debug
|
||
|
|
// without spelunking live logs first.
|
||
|
|
|
||
|
|
const DIAGNOSTICS_MODELS: &str = include_str!(concat!(
|
||
|
|
env!("CARGO_MANIFEST_DIR"),
|
||
|
|
"/client/src/launcher/diagnostics/diagnostics_models.rs"
|
||
|
|
));
|
||
|
|
const SNAPSHOT_REPORT: &str = include_str!(concat!(
|
||
|
|
env!("CARGO_MANIFEST_DIR"),
|
||
|
|
"/client/src/launcher/diagnostics/snapshot_report.rs"
|
||
|
|
));
|
||
|
|
const SNAPSHOT_REPORT_TEXT: &str = include_str!(concat!(
|
||
|
|
env!("CARGO_MANIFEST_DIR"),
|
||
|
|
"/client/src/launcher/diagnostics/snapshot_report_text.rs"
|
||
|
|
));
|
||
|
|
const RECOMMENDATIONS: &str = include_str!(concat!(
|
||
|
|
env!("CARGO_MANIFEST_DIR"),
|
||
|
|
"/client/src/launcher/diagnostics/recommendations.rs"
|
||
|
|
));
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn snapshot_report_schema_captures_runtime_media_and_calibration_context() {
|
||
|
|
for field in [
|
||
|
|
"client_version",
|
||
|
|
"server_version",
|
||
|
|
"server_available",
|
||
|
|
"routing",
|
||
|
|
"view_mode",
|
||
|
|
"remote_active",
|
||
|
|
"power_state",
|
||
|
|
"left_capture_transport",
|
||
|
|
"right_capture_transport",
|
||
|
|
"upstream_camera_transport",
|
||
|
|
"selected_camera",
|
||
|
|
"selected_microphone",
|
||
|
|
"selected_speaker",
|
||
|
|
"upstream_camera",
|
||
|
|
"upstream_microphone",
|
||
|
|
"upstream_mode",
|
||
|
|
"av_delivery_skew_ms",
|
||
|
|
"av_enqueue_skew_ms",
|
||
|
|
"planner_live_lag_ms",
|
||
|
|
"planner_skew_ms",
|
||
|
|
"planner_stale_audio_drops",
|
||
|
|
"planner_stale_video_drops",
|
||
|
|
"planner_freshness_reanchors",
|
||
|
|
"planner_video_freezes",
|
||
|
|
"calibration_profile",
|
||
|
|
"calibration_source",
|
||
|
|
"active_audio_offset_us",
|
||
|
|
"active_video_offset_us",
|
||
|
|
"recent_samples",
|
||
|
|
"recommendations",
|
||
|
|
"probe_command",
|
||
|
|
] {
|
||
|
|
assert!(
|
||
|
|
DIAGNOSTICS_MODELS.contains(field),
|
||
|
|
"SnapshotReport should expose diagnostic field {field}"
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn report_builder_populates_schema_from_live_state_and_recent_samples() {
|
||
|
|
for marker in [
|
||
|
|
"crate::VERSION.to_string()",
|
||
|
|
"state.server_version.clone()",
|
||
|
|
"state.webcam_transport.label().to_string()",
|
||
|
|
"state.upstream_sync.live_lag_ms",
|
||
|
|
"state.upstream_sync.planner_skew_ms",
|
||
|
|
"state.upstream_sync.stale_audio_drops",
|
||
|
|
"state.upstream_sync.stale_video_drops",
|
||
|
|
"state.upstream_sync.freshness_reanchors",
|
||
|
|
"state.upstream_sync.video_freezes",
|
||
|
|
"state.calibration.profile.clone()",
|
||
|
|
"state.calibration.source.clone()",
|
||
|
|
"state.calibration.active_audio_offset_us",
|
||
|
|
"state.calibration.active_video_offset_us",
|
||
|
|
"recent_samples: log.iter().cloned().collect()",
|
||
|
|
"recommendations_for(state, log)",
|
||
|
|
] {
|
||
|
|
assert!(
|
||
|
|
SNAPSHOT_REPORT.contains(marker),
|
||
|
|
"SnapshotReport::from_state should populate {marker}"
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn text_report_names_failure_stage_and_next_actions() {
|
||
|
|
for marker in [
|
||
|
|
"Lesavka Diagnostics",
|
||
|
|
"media staging",
|
||
|
|
"av sync guardrails",
|
||
|
|
"server upstream planner",
|
||
|
|
"drops/heals",
|
||
|
|
"calibration",
|
||
|
|
"recent samples",
|
||
|
|
"uplink:",
|
||
|
|
"recommendations",
|
||
|
|
"quality probe",
|
||
|
|
] {
|
||
|
|
assert!(
|
||
|
|
SNAPSHOT_REPORT_TEXT.contains(marker),
|
||
|
|
"diagnostic text should include operator section {marker}"
|
||
|
|
);
|
||
|
|
}
|
||
|
|
assert!(
|
||
|
|
RECOMMENDATIONS.contains("recommendations_for")
|
||
|
|
&& RECOMMENDATIONS.contains("server_available")
|
||
|
|
&& RECOMMENDATIONS.contains("webcam uplink queue")
|
||
|
|
&& RECOMMENDATIONS.contains("microphone uplink queue")
|
||
|
|
&& RECOMMENDATIONS.contains("Device H.264 pass-through"),
|
||
|
|
"diagnostics should include actionable recommendations for likely failure layers"
|
||
|
|
);
|
||
|
|
}
|