From 4b2f3efcbd9c203ce5f3c1aefe3664ca0976e73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 30 Sep 2025 15:16:58 +0200 Subject: [PATCH] Add tests covering desired UX --- .../TestSceneBeatmapCarouselArtistGrouping.cs | 34 +++++++++++++++++++ ...tSceneBeatmapCarouselDifficultyGrouping.cs | 26 ++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselArtistGrouping.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselArtistGrouping.cs index c34077889d..1178f89da6 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselArtistGrouping.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselArtistGrouping.cs @@ -249,5 +249,39 @@ namespace osu.Game.Tests.Visual.SongSelectV2 CheckDisplayedBeatmapSetsCount(10); CheckDisplayedBeatmapsCount(30); } + + [Test] + public void TestGroupDoesNotExpandAgainOnRefilterIfManuallyCollapsed() + { + ApplyToFilterAndWaitForFilter("filter", c => c.SearchText = BeatmapSets[2].Metadata.Title); + + CheckDisplayedGroupsCount(1); + CheckDisplayedBeatmapSetsCount(1); + CheckDisplayedBeatmapsCount(3); + + CheckHasSelection(); + + ApplyToFilterAndWaitForFilter("remove filter", c => c.SearchText = string.Empty); + + CheckDisplayedGroupsCount(5); + CheckDisplayedBeatmapSetsCount(10); + CheckDisplayedBeatmapsCount(30); + + ToggleGroupCollapse(); + + ApplyToFilterAndWaitForFilter("apply no-op filter", c => c.AllowConvertedBeatmaps = !c.AllowConvertedBeatmaps); + AddAssert("group didn't re-expand", () => Carousel.ExpandedGroup, () => Is.Null); + + ToggleGroupCollapse(); + AddAssert("beatmap set re-expanded correctly", () => Carousel.ExpandedBeatmapSet?.BeatmapSet, () => Is.EqualTo(BeatmapSets[2])); + + ApplyToFilterAndWaitForFilter("filter", c => c.SearchText = BeatmapSets[1].Metadata.Title); + + CheckDisplayedGroupsCount(1); + CheckDisplayedBeatmapSetsCount(1); + CheckDisplayedBeatmapsCount(3); + + CheckHasSelection(); + } } } diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselDifficultyGrouping.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselDifficultyGrouping.cs index 58ecfcbf3b..2cffe60ec1 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselDifficultyGrouping.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselDifficultyGrouping.cs @@ -337,5 +337,31 @@ namespace osu.Game.Tests.Visual.SongSelectV2 AddAssert("expanded group is still first", () => (Carousel.ExpandedGroup as StarDifficultyGroupDefinition)?.Difficulty.Stars, () => Is.EqualTo(0)); } + + [Test] + public void TestExpandedGroupDoesNotExpandAgainOnRefilterIfManuallyCollapsed() + { + SelectPrevSet(); + + WaitForBeatmapSelection(2, 9); + AddAssert("expanded group is last", () => (Carousel.ExpandedGroup as StarDifficultyGroupDefinition)?.Difficulty.Stars, () => Is.EqualTo(6)); + + SelectNextPanel(); + Select(); + + WaitForBeatmapSelection(2, 9); + AddAssert("expanded group is first", () => (Carousel.ExpandedGroup as StarDifficultyGroupDefinition)?.Difficulty.Stars, () => Is.EqualTo(0)); + + ToggleGroupCollapse(); + + // doesn't actually filter anything away, but triggers a filter. + ApplyToFilterAndWaitForFilter("filter", c => c.SearchText = "Some"); + AddAssert("group didn't re-expand", () => (Carousel.ExpandedGroup as StarDifficultyGroupDefinition)?.Difficulty.Stars, () => Is.Null); + + ToggleGroupCollapse(); + + ApplyToFilterAndWaitForFilter("filter", c => c.SearchText = "Som"); + AddAssert("expanded group is first", () => (Carousel.ExpandedGroup as StarDifficultyGroupDefinition)?.Difficulty.Stars, () => Is.EqualTo(0)); + } } }