summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Wach <pwach@bloomberg.net>2024-01-20 12:07:23 +0000
committerPiotr Wach <pwach@bloomberg.net>2024-01-20 12:07:23 +0000
commitdcff2eebed4422f3103d99eac6bd91e56df327c6 (patch)
tree62cf0ecbbc382e10a16cd95a800601b640170b8c
parent65f6735b7a0761b1371bcede86e9b46b9920bb5c (diff)
Tests for refresh & selection
-rw-r--r--src/interactive/app/terminal.rs6
-rw-r--r--src/interactive/app/tests/journeys_readonly.rs45
2 files changed, 47 insertions, 4 deletions
diff --git a/src/interactive/app/terminal.rs b/src/interactive/app/terminal.rs
index 3cb98a6..2a8deb5 100644
--- a/src/interactive/app/terminal.rs
+++ b/src/interactive/app/terminal.rs
@@ -101,15 +101,13 @@ mod tests {
B: Backend,
{
while self.state.scan.is_some() {
- if let Some(res) = self.state.process_event(
+ self.state.process_event(
&mut self.window,
&mut self.traversal,
&mut self.display,
terminal,
&events,
- )? {
- return Ok(res);
- }
+ )?;
}
Ok(WalkResult {
num_errors: self.stats.io_errors,
diff --git a/src/interactive/app/tests/journeys_readonly.rs b/src/interactive/app/tests/journeys_readonly.rs
index 09ac31a..04a16e7 100644
--- a/src/interactive/app/tests/journeys_readonly.rs
+++ b/src/interactive/app/tests/journeys_readonly.rs
@@ -173,6 +173,51 @@ fn simple_user_journey_read_only() -> Result<()> {
assert!(app.window.glob_pane.is_none());
}
+ // Refresh finishes eventually
+ {
+ assert!(app.state.scan.is_none());
+
+ // 'R' refreshes all entries in the view
+ app.process_events(&mut terminal, into_events([
+ Event::Key(KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE)),
+ ]))?;
+ assert!(app.state.scan.is_some());
+
+ // refresh should finish eventually
+ app.run_until_traversed(&mut terminal, into_events([]))?;
+ assert!(app.state.scan.is_none());
+ }
+
+ // Refresh finishes eventually
+ {
+ // Refresh is not running
+ assert!(app.state.scan.is_none());
+
+ app.process_events(&mut terminal, into_codes("j"))?;
+ assert_eq!(
+ node_by_name(&app, fixture_str(long_root)),
+ node_by_index(&app, *app.state.navigation().selected.as_ref().unwrap()),
+ "it moves the cursor down and selects the next item based on the current sort mode"
+ );
+
+ // 'R' refreshes all entries in the view
+ app.process_events(&mut terminal, into_events([
+ Event::Key(KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE)),
+ ]))?;
+ assert!(app.state.scan.is_some());
+
+ // Refresh should finish
+ app.run_until_traversed(&mut terminal, into_events([]))?;
+ assert!(app.state.scan.is_none());
+
+ // Previous selection is preserved
+ assert_eq!(
+ node_by_name(&app, fixture_str(long_root)),
+ node_by_index(&app, *app.state.navigation().selected.as_ref().unwrap()),
+ "previous selection is preserved after refresh"
+ );
+ }
+
// Entry-Navigation
{
// when hitting the j key