From 7407efeea5e2fda55f4ea03eb6bd21a7737b1b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Jul 2025 10:59:30 +0200 Subject: [PATCH 1/2] Add failing test coverage --- .../TestSceneBeatmapTitleWedge.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapTitleWedge.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapTitleWedge.cs index 2ff677becd..efd9f6a5cd 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapTitleWedge.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapTitleWedge.cs @@ -18,6 +18,7 @@ using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; @@ -246,6 +247,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2 { var (working, onlineSet) = createTestBeatmap(); onlineSet.FavouriteCount = 9999; + onlineSet.HasFavourited = true; working.BeatmapSetInfo.OnlineID = onlineSet.OnlineID = 99999; currentOnlineSet = onlineSet; @@ -253,6 +255,42 @@ namespace osu.Game.Tests.Visual.SongSelectV2 }); AddStep("allow request to complete", () => resetEvent.Set()); AddAssert("favourites count = 9999", () => this.ChildrenOfType().Single().Text.ToString() == "9,999"); + + AddStep("set up request handler to fail", () => + { + ((DummyAPIAccess)API).HandleRequest = request => + { + switch (request) + { + case GetBeatmapSetRequest set: + if (set.ID == currentOnlineSet?.OnlineID) + { + set.TriggerSuccess(currentOnlineSet); + return true; + } + + return false; + + case PostBeatmapFavouriteRequest favourite: + Task.Run(() => + { + resetEvent.Wait(10000); + favourite.TriggerFailure(new APIException("You have too many favourited beatmaps! Please unfavourite some before trying again.", null)); + }); + return true; + + default: + return false; + } + }; + }); + AddStep("reset event", () => resetEvent.Reset()); + AddStep("click favourite button", () => this.ChildrenOfType().Single().TriggerClick()); + AddAssert("spinner visible", () => this.ChildrenOfType().Single() + .ChildrenOfType().Single().State.Value, () => Is.EqualTo(Visibility.Visible)); + AddStep("allow request to complete", () => resetEvent.Set()); + AddAssert("spinner hidden", () => this.ChildrenOfType().Single() + .ChildrenOfType().Single().State.Value, () => Is.EqualTo(Visibility.Hidden)); } [TestCase(120, 125, null, "120-125 (mostly 120)")] From 2ff01abffa56f02c705a0bbfaa8d6429b3a242ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Jul 2025 11:04:54 +0200 Subject: [PATCH 2/2] Fix song select favourite button getting stuck spinning if operation failed Closes https://github.com/ppy/osu/issues/34376 Compare handling with https://github.com/ppy/osu/blob/0b453772da964dddd2ee73f677367293b26dbf2a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs#L81-L85 --- .../SelectV2/BeatmapTitleWedge_FavouriteButton.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/osu.Game/Screens/SelectV2/BeatmapTitleWedge_FavouriteButton.cs b/osu.Game/Screens/SelectV2/BeatmapTitleWedge_FavouriteButton.cs index ae44442876..a3087d3c30 100644 --- a/osu.Game/Screens/SelectV2/BeatmapTitleWedge_FavouriteButton.cs +++ b/osu.Game/Screens/SelectV2/BeatmapTitleWedge_FavouriteButton.cs @@ -21,6 +21,7 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; +using osu.Game.Overlays.Notifications; using osuTK; using osuTK.Graphics; @@ -50,6 +51,9 @@ namespace osu.Game.Screens.SelectV2 [Resolved] private IAPIProvider api { get; set; } = null!; + [Resolved] + private INotificationOverlay? notifications { get; set; } + internal LocalisableString Text => valueText.Text; public FavouriteButton() @@ -224,6 +228,15 @@ namespace osu.Game.Screens.SelectV2 beatmapSet.FavouriteCount += hasFavourited ? 1 : -1; setBeatmapSet(beatmapSet, withHeartAnimation: hasFavourited); }; + favouriteRequest.Failure += e => + { + notifications?.Post(new SimpleNotification + { + Text = e.Message, + Icon = FontAwesome.Solid.Times, + }); + setBeatmapSet(beatmapSet, withHeartAnimation: false); + }; api.Queue(favouriteRequest); setLoading(); }