test(engine): add InfoToastEvent test for locked challenge X-key press

Verifies that pressing X when the player's level is below
CHALLENGE_UNLOCK_LEVEL emits an InfoToastEvent containing the unlock
level, rather than silently doing nothing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-04-27 04:48:55 +00:00
parent be4cefe79a
commit 60e853f52b
+19
View File
@@ -198,4 +198,23 @@ mod tests {
assert_eq!(challenge_progress_label(0), format!("1 / {total}"));
assert_eq!(challenge_progress_label(2), format!("3 / {total}"));
}
#[test]
fn pressing_x_below_unlock_level_fires_info_toast() {
let mut app = headless_app();
// Level 0 is below CHALLENGE_UNLOCK_LEVEL.
app.world_mut()
.resource_mut::<ButtonInput<KeyCode>>()
.press(KeyCode::KeyX);
app.update();
let events = app.world().resource::<Events<InfoToastEvent>>();
let mut cursor = events.get_cursor();
let fired: Vec<_> = cursor.read(events).collect();
assert_eq!(fired.len(), 1, "must show a toast explaining the lock");
assert!(
fired[0].0.contains(&CHALLENGE_UNLOCK_LEVEL.to_string()),
"toast must mention the unlock level"
);
}
}