Show a missing-statistics notice once during a champ select (#75)

With the statistics missing, the Anvil area no longer repeats « Aucune Saison
en cours » when the header already says it, and « Autres champions » is not
offered since there is nothing to browse.

Test tidy-ups: the saved-portraits assertion message says what is checked,
main.rs tests use card_images' TestDir instead of their own TempDir, and the
test-only accessors of Page move after the last method so choose_sort reads
with its doc comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-21 02:26:14 +01:00
1 parent 28d86d48b7
commit 485d7b9065
4 files changed
+77 -47

No files matched your search

+47 -11
View File
@@ -921,16 +921,6 @@ impl Page {
self.order.iter().filter_map(move |&ix| rows.get(ix))
}
#[cfg(test)]
pub(crate) fn champion_sort(&self) -> Option<ChampionSort> {
self.champion_sort
}
#[cfg(test)]
pub(crate) fn home_filter(&self) -> StateFilter {
self.home_filter
}
/// The player chose a sort: the cards of every section follow it, and it is saved.
pub(crate) fn choose_sort(&mut self, sort: ChampionSort, cx: &mut Context<Self>) {
if self.champion_sort == Some(sort) {
@@ -970,7 +960,7 @@ impl Page {
self.champ_select_notice = match (&self.stats_error, self.stats.is_some()) {
(Some(error), _) => error.clone().into(),
(None, true) => SharedString::default(),
(None, false) if self.current_season.is_none() => "Aucune Saison en cours".into(),
(None, false) if self.current_season.is_none() => home::NO_SEASON.into(),
(None, false) if self.status.updating.is_none() => "Compte indisponible".into(),
(None, false) => "Chargement des statistiques…".into(),
};
@@ -1192,6 +1182,16 @@ impl Page {
.map(|alert| alert.small().into_any_element())
.collect()
}
#[cfg(test)]
pub(crate) fn champion_sort(&self) -> Option<ChampionSort> {
self.champion_sort
}
#[cfg(test)]
pub(crate) fn home_filter(&self) -> StateFilter {
self.home_filter
}
}
impl Render for Page {
@@ -2833,6 +2833,42 @@ mod tests {
}
}
#[gpui::test]
async fn missing_statistics_are_said_once_and_leave_nothing_to_browse(cx: &mut TestAppContext) {
cx.executor().allow_parking();
// No current Season: the header says so, and the Anvil area does not say it again.
let (page, mut window) = open_page(cx);
send(&page, &mut window, &frames()[0]);
draw(&mut window);
page.read_with(&window, |p, _| {
assert_eq!(p.champ_select_notice, "Aucune Saison en cours");
});
assert!(window.debug_bounds("no-season").is_some());
assert!(window.debug_bounds("anvil-notice").is_none());
assert!(window.debug_bounds("anvil-row").is_none());
assert!(window.debug_bounds("others-toggle").is_none());
// The statistics are on their way: the area says so, and there is nothing to browse yet.
let (page, mut window) = open_page_with_tracker(cx, joueur_tracker_with(true));
send(&page, &mut window, &frames()[0]);
draw(&mut window);
page.read_with(&window, |p, _| {
assert_eq!(
p.anvil_line().as_deref(),
Some("Chargement des statistiques…")
);
});
assert!(window.debug_bounds("no-season").is_none());
assert!(window.debug_bounds("anvil-notice").is_some());
assert!(window.debug_bounds("others-toggle").is_none());
// Once they are there, the section is offered.
cx.condition(&page, |p, _| p.stats.is_some()).await;
draw(&mut window);
assert!(window.debug_bounds("anvil-notice").is_none());
assert!(window.debug_bounds("others-toggle").is_some());
}
/// What the non-anvil champions of the capture are, in the home's order (A to Z by name).
const OTHERS_A_TO_Z: [u32; 4] = [103, 12, 25, 50];