Fix flaky update beatmap set test

It is generally not possible to click a button that's not yet there,
and it turns out that when the test in question is ran headless, it may
not necessarily be there immediately.
This commit is contained in:
Bartłomiej Dach 2022-10-13 21:03:52 +02:00
parent 47d7d6fad9
commit df66a0c2e9
No known key found for this signature in database

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -150,6 +151,7 @@ namespace osu.Game.Tests.Visual.SongSelect
public void TestUpdateLocalBeatmap() public void TestUpdateLocalBeatmap()
{ {
DialogOverlay dialogOverlay = null!; DialogOverlay dialogOverlay = null!;
UpdateBeatmapSetButton? updateButton = null;
AddStep("create carousel with dialog overlay", () => AddStep("create carousel with dialog overlay", () =>
{ {
@ -176,7 +178,8 @@ namespace osu.Game.Tests.Visual.SongSelect
carousel.UpdateBeatmapSet(testBeatmapSetInfo); carousel.UpdateBeatmapSet(testBeatmapSetInfo);
}); });
AddStep("click button", () => getUpdateButton()?.TriggerClick()); AddUntilStep("wait for update button", () => (updateButton = getUpdateButton()) != null);
AddStep("click button", () => updateButton.AsNonNull().TriggerClick());
AddAssert("dialog displayed", () => dialogOverlay.CurrentDialog is UpdateLocalConfirmationDialog); AddAssert("dialog displayed", () => dialogOverlay.CurrentDialog is UpdateLocalConfirmationDialog);
AddStep("click confirmation", () => AddStep("click confirmation", () =>