wip: repertoire_ui test fixes in progress
This commit is contained in:
parent
98f0e4749f
commit
0493965a71
2 changed files with 9 additions and 3 deletions
|
|
@ -270,6 +270,8 @@ pub struct RepertoireUi {
|
|||
index_job: u64,
|
||||
stats: HashMap<RepertoireId, Result<RowStats, String>>,
|
||||
stats_key: Option<StatsKey>,
|
||||
/// The key of the counts shown (older than `stats_key` while counting).
|
||||
stats_shown: Option<StatsKey>,
|
||||
screen: Screen,
|
||||
/// The «Lines» screen a branch session was started from.
|
||||
lines_return: Option<Box<OpeningLinesUi>>,
|
||||
|
|
@ -320,6 +322,7 @@ impl RepertoireUi {
|
|||
index_job: 0,
|
||||
stats: HashMap::new(),
|
||||
stats_key: None,
|
||||
stats_shown: None,
|
||||
screen: Screen::Repertoires,
|
||||
lines_return: None,
|
||||
preparing: None,
|
||||
|
|
@ -905,6 +908,7 @@ impl RepertoireUi {
|
|||
Event::Stats(key, stats) => {
|
||||
if self.stats_key.as_ref() == Some(&key) {
|
||||
self.stats = stats;
|
||||
self.stats_shown = Some(key);
|
||||
}
|
||||
}
|
||||
Event::Imported(job, result) => {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ fn settle(ui: &mut RepertoireUi, ctx: &egui::Context, settings: &mut Settings, s
|
|||
&& ui.stats_key.as_ref().is_some_and(|key| {
|
||||
key.library_revision == ui.library.revision
|
||||
&& key.learning_revision == ui.learning.revision
|
||||
});
|
||||
})
|
||||
&& ui.stats_shown == ui.stats_key;
|
||||
if ready || Instant::now() > deadline {
|
||||
frame(ui, ctx, settings, size, Vec::new());
|
||||
return;
|
||||
|
|
@ -519,7 +520,8 @@ fn a_session_needs_no_question_to_go_back_and_counts_refresh_after_it() {
|
|||
frame(&mut ui, &ctx, &mut settings, size, vec![key(Key::Enter)]);
|
||||
settle(&mut ui, &ctx, &mut settings, size);
|
||||
assert!(matches!(ui.screen, Screen::Repertoires));
|
||||
// One new move was shown and played: it is due again today, two are left new.
|
||||
// e4 was shown and played, Nf3 shown when the session stopped: both are due
|
||||
// again today (a shown move comes back a minute later), d4 is still new.
|
||||
let stats = ui.stats.get(&id).unwrap().as_ref().unwrap();
|
||||
assert_eq!((stats.unseen, stats.due), (2, 1));
|
||||
assert_eq!((stats.unseen, stats.due), (1, 2));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue