Skip to content

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

test(tui): add end-to-end user journeys for movie navigation and mode switching

Samir Hossains190c91af5356
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dfcf84c..a9eb0fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@
### Added
- **Comprehensive QA & Regression Test Architecture**:
- - Introduced a 59-test automated suite covering critical algorithmic boundaries, error handling, addon manifest validation, mouse interactions, modal dismissals, TUI rendering across terminal size matrices, state reconciliation, crypto HMAC signing, download chunk arithmetic, and URL/stem security.
+ - Introduced a 61-test automated suite covering critical algorithmic boundaries, end-to-end user journeys, error handling, addon manifest validation, 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/` (`error_handling.rs`, `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 cd4b9f3..b93efc4 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -39,7 +39,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:
- **`error_handling.rs`**: Validates search failure cleanup, addon manifest error toasts, stream and download resolution failure notifications, malformed M3U recovery, and URL scheme rejection.
-- **`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.
+- **`tui_acceptance.rs`**: Validates headless TUI rendering, all theme palettes, end-to-end user journeys (search, details, navigation, mode switching), 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/tests/tui_acceptance.rs b/tests/tui_acceptance.rs
index 9fa836e..49be4cd 100644
--- a/tests/tui_acceptance.rs
+++ b/tests/tui_acceptance.rs
@@ -1,6 +1,8 @@
+use moviebox_tui::models::SearchResult;
+use moviebox_tui::providers::models::ProviderKind;
use moviebox_tui::tui::action::Action;
use moviebox_tui::tui::app::App;
-use moviebox_tui::tui::state::InputMode;
+use moviebox_tui::tui::state::{InputMode, Screen};
use moviebox_tui::tui::theme::ThemeKind;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
@@ -97,3 +99,51 @@ async fn test_mouse_scroll_maps_to_key_actions() {
app.handle_action(Action::Key(up_key)).await;
assert_eq!(app.state().search_query, "");
}
+
+#[tokio::test]
+async fn test_full_user_journey_movie_search_details_and_back_navigation() {
+ let mut app = App::new();
+ app.state_mut().is_tv_mode = false;
+ app.state_mut().is_addon_mode = false;
+ app.state_mut().active_screen = Screen::Home;
+ app.state_mut().last_search_edit =
+ std::time::Instant::now() - std::time::Duration::from_millis(600);
+
+ let sample_item = SearchResult {
+ id: "12345".to_string(),
+ title: "Inception".to_string(),
+ stype: 1,
+ release_year: "2010".to_string(),
+ cover_url: None,
+ season: 0,
+ episode: 0,
+ provider: ProviderKind::MovieBox,
+ };
+
+ app.state_mut().search_results.push(sample_item);
+ app.state_mut().search_list_state.select(Some(0));
+
+ app.handle_action(Action::Submit).await;
+ assert_eq!(app.state().active_screen, Screen::Details);
+ assert_eq!(app.state().active_subject_id.as_deref(), Some("12345"));
+
+ app.handle_action(Action::GoBack).await;
+ assert_eq!(app.state().active_screen, Screen::Home);
+}
+
+#[tokio::test]
+async fn test_full_user_journey_mode_switching_and_theme_selection() {
+ let mut app = App::new();
+ app.state_mut().is_addon_mode = false;
+ app.state_mut().is_tv_mode = false;
+
+ app.handle_action(Action::ToggleAddonMode).await;
+ assert!(app.state().is_addon_mode);
+
+ app.handle_action(Action::SwitchToStreamingMode).await;
+ assert!(!app.state().is_addon_mode);
+
+ app.handle_action(Action::SelectTheme("TokyoNight".to_string()))
+ .await;
+ assert_eq!(app.state().active_theme_kind, "TokyoNight");
+}