From e1ea994da4ce7b8724fca0d183d9883431ab1c87 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 27 Nov 2026 01:55:43 +0300 Subject: [PATCH] =?UTF-8?q?opening=20session:=20test=20that=20a=20first-mo?= =?UTF-8?q?ve=20mistake=20returns=20once=20and=20keeps=20the=20count=20(10?= =?UTF-8?q?=20=E2=86=92=2020=20is=20the=20next=20session:=2010=20learned?= =?UTF-8?q?=20moves=20due=20today=20+=2010=20new)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop/src/opening_session_tests.rs | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/apps/desktop/src/opening_session_tests.rs b/apps/desktop/src/opening_session_tests.rs index 7515ab2..13f8d31 100644 --- a/apps/desktop/src/opening_session_tests.rs +++ b/apps/desktop/src/opening_session_tests.rs @@ -2167,3 +2167,42 @@ fn async_failed_commit_preserves_event_for_retry_without_double_counting() { assert_eq!(f.attempts().len(), 1); assert_eq!(f.attempts()[0].client_attempt_id, "async-retry"); } + +#[test] +fn a_mistake_on_the_first_move_returns_it_once_and_keeps_the_count() { + // The next daily session after learning new moves: the learned e4 is due again + // today, Nf3 and Bb5 are still new. The count is due + new, and a mistake on the + // first move does not grow it. + let pgn = "1. e4 e5 2. Nf3 Nc6 3. Bb5 *"; + let mut f = Fixture::with( + pgn, + LearningSide::White, + &["e2e4"], + &["g1f3", "f1b5"], + "first-move-wrong", + SessionKind::Daily, + ); + let at = Instant::now(); + assert_eq!(f.ui.session.remaining(), 3); + tick_with_prime(&mut f.ui, at, Duration::ZERO, NOW); + assert_eq!(f.ui.session.current_expected_uci(), Some("e2e4")); + assert!(f.ui.play_uci_with_id_at("d2d4", "e4-wrong".into(), at, NOW)); + tick_with_prime(&mut f.ui, at + WRONG_SHOWN, Duration::ZERO, NOW); + assert_eq!(f.ui.state(), Some(State::Wrong)); + assert_eq!(f.ui.session.remaining(), 3); + answer_current(&mut f, at + WRONG_SHOWN, NOW, "e4-replay"); + assert_eq!(f.ui.session.remaining(), 3); + let mut asked = Vec::new(); + for _ in 0..4 { + f.ui.debug_settle(); + let Some(uci) = f.ui.session.current_expected_uci().map(str::to_owned) else { + break; + }; + answer_current(&mut f, at, NOW, &format!("again-{uci}-{}", asked.len())); + asked.push(uci); + } + f.ui.debug_settle(); + assert!(f.ui.is_finished()); + assert_eq!(asked, ["g1f3", "f1b5", "e2e4"]); + assert_eq!(f.ui.session.remaining(), 0); +}