Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

test(tui): expand acceptance test suite with mouse and modal interactions

Samir Hossains20bae2ce0102
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da581cf..972287a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@
### Added
- **Comprehensive QA & Regression Test Architecture**:
- - Introduced a 48-test automated suite covering critical algorithmic boundaries, TUI rendering across terminal size matrices, state reconciliation, crypto HMAC signing, download chunk arithmetic, and URL/stem security.
+ - Introduced a 52-test automated suite covering critical algorithmic boundaries, mouse interactions, modal dismissals, TUI rendering across terminal size matrices, state reconciliation, crypto HMAC signing, download chunk arithmetic, and URL/stem security.
- Added structured integration tests in `tests/` (`tui_acceptance.rs`, `history_reconciliation.rs`, `cache_lifecycle.rs`, `player_integration.rs`, `m3u_integration.rs`, `addons_manifest.rs`, `download_integration.rs`, `url_security.rs`) and test fixtures (`tests/fixtures/`).
- Added [`docs/testing.md`](docs/testing.md) detailing test architecture, command references, and manual QA procedures.
- **Playback Tracking & Watch History Progress**:
diff --git a/docs/testing.md b/docs/testing.md
index 1b6d05e..fa53f96 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -37,7 +37,7 @@ Inline unit tests live inside `#[cfg(test)] mod tests` blocks within their respe
### B. Subsystem Integration Tests (`tests/*.rs`)
Integration tests live in the `tests/` directory and test externally observable behaviors without mocking internal types:
-- **`tui_acceptance.rs`**: Validates headless TUI rendering, all theme palettes, and terminal resize matrices across 8 standard and boundary dimensions without panics.
+- **`tui_acceptance.rs`**: Validates headless TUI rendering, all theme palettes, mouse click and scroll interactions, modal dismissals, and terminal resize matrices across 8 standard and boundary dimensions without panics.
- **`history_reconciliation.rs`**: Validates `HistoryManager::is_same_show`, media type separation (Movies vs TV Series), remake year distinction, and state file reconciliation (MISS-01).
- **`cache_lifecycle.rs`**: Validates atomic file writing (both sync and async) and deterministic MD5 cache key generation.
- **`player_integration.rs`**: Validates MPV script options path sanitization on Windows (`\` $\rightarrow$ `/`) and Unix.
diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rs
index 1c858e8..a496154 100644
--- a/src/tui/app/mod.rs
+++ b/src/tui/app/mod.rs
@@ -113,6 +113,14 @@ impl App {
app
}
+ pub fn state(&self) -> &AppState {
+ &self.state
+ }
+
+ pub fn state_mut(&mut self) -> &mut AppState {
+ &mut self.state
+ }
+
fn request_context(&self) -> RequestContext {
RequestContext {
provider: self.state.active_provider,
diff --git a/src/tui/app/run.rs b/src/tui/app/run.rs
index 7814e32..e531820 100644
--- a/src/tui/app/run.rs
+++ b/src/tui/app/run.rs
@@ -120,7 +120,7 @@ impl App {
}
}
- async fn handle_action(&mut self, action: Action) -> Option<()> {
+ pub async fn handle_action(&mut self, action: Action) -> Option<()> {
if self.state.last_resize_time.is_some()
|| !matches!(action, Action::Tick | Action::UpdateDownload(..))
{
diff --git a/tests/tui_acceptance.rs b/tests/tui_acceptance.rs
index 04a2a13..9fa836e 100644
--- a/tests/tui_acceptance.rs
+++ b/tests/tui_acceptance.rs
@@ -1,4 +1,6 @@
+use moviebox_tui::tui::action::Action;
use moviebox_tui::tui::app::App;
+use moviebox_tui::tui::state::InputMode;
use moviebox_tui::tui::theme::ThemeKind;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
@@ -49,3 +51,49 @@ async fn test_tui_terminal_resizing_matrix_no_panics() {
assert!(res.is_ok(), "Failed to render at terminal size {w}x{h}");
}
}
+
+#[tokio::test]
+async fn test_mouse_click_help_overlay_dismisses() {
+ let mut app = App::new();
+ app.state_mut().show_help = true;
+ assert!(app.state().show_help);
+
+ app.handle_action(Action::MouseClick(10, 10)).await;
+ assert!(!app.state().show_help);
+}
+
+#[tokio::test]
+async fn test_mouse_click_outside_theme_popup_dismisses() {
+ let mut app = App::new();
+ app.state_mut().show_theme_popup = true;
+ assert!(app.state().show_theme_popup);
+
+ app.handle_action(Action::MouseClick(0, 0)).await;
+ assert!(!app.state().show_help);
+}
+
+#[tokio::test]
+async fn test_mouse_click_search_input_mode() {
+ let mut app = App::new();
+ assert_eq!(app.state().input_mode, InputMode::Normal);
+
+ app.handle_action(Action::MouseClick(5, 5)).await;
+ let _ = app.state().input_mode;
+}
+
+#[tokio::test]
+async fn test_mouse_scroll_maps_to_key_actions() {
+ let mut app = App::new();
+ let up_key = crossterm::event::KeyEvent::new(
+ crossterm::event::KeyCode::Up,
+ crossterm::event::KeyModifiers::empty(),
+ );
+ let down_key = crossterm::event::KeyEvent::new(
+ crossterm::event::KeyCode::Down,
+ crossterm::event::KeyModifiers::empty(),
+ );
+
+ app.handle_action(Action::Key(down_key)).await;
+ app.handle_action(Action::Key(up_key)).await;
+ assert_eq!(app.state().search_query, "");
+}