feat(test): diagnose failed effect assertions

This commit is contained in:
slhx agent
2026-07-13 10:02:11 +02:00
parent d32f3cb893
commit e70c863da7
5 changed files with 50 additions and 5 deletions
+19 -1
View File
@@ -492,10 +492,28 @@ impl EffectInspector {
})
}
/// Assert that a generated target receives an HTML update containing text.
/// Check that a generated target receives an HTML update containing text.
/// req: test/001 req: dx/006
pub fn updates_html_containing(&self, target: impl GeneratedTarget, needle: &str) -> bool {
self.has_html_update_containing(target.__hemx_resource_id(), needle)
}
/// Assert that a generated target receives an HTML update containing text.
///
/// Unlike wrapping [`Self::updates_html_containing`] in `assert!`, failures include the
/// expected resource and payload fragment together with every actual effect operation.
/// req: test/001 req: test/018 req: dx/006
#[track_caller]
pub fn assert_updates_html_containing(&self, target: impl GeneratedTarget, needle: &str) {
let resource = target.__hemx_resource_id();
assert!(
self.has_html_update_containing(resource, needle),
"expected an HTML update for {resource:?} containing {needle:?}; actual effects: {:#?}",
self.batch.ops
);
}
fn has_html_update_containing(&self, resource: ResourceId, needle: &str) -> bool {
self.batch.ops.iter().any(|op| {
matches!(
op,