diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs index f47322b9e0..56b161db2a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs @@ -253,6 +253,11 @@ namespace osu.Game.Tests.Visual.Online InputManager.MoveMouseTo(btn); InputManager.Click(MouseButton.Left); }); + AddStep("Set reason to other", () => + { + var reason = this.ChildrenOfType>().Single(); + reason.Current.Value = CommentReportReason.Other; + }); AddStep("Try to report", () => { var btn = this.ChildrenOfType().Single().ChildrenOfType().Single(); @@ -261,12 +266,10 @@ namespace osu.Game.Tests.Visual.Online }); AddWaitStep("Wait", 3); AddAssert("Nothing happened", () => this.ChildrenOfType().Any()); - AddStep("Set report data", () => + AddStep("Add comment", () => { var field = this.ChildrenOfType().Single().ChildrenOfType().First(); field.Current.Value = report_text; - var reason = this.ChildrenOfType>().Single(); - reason.Current.Value = CommentReportReason.Other; }); AddStep("Try to report", () => { diff --git a/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs b/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs new file mode 100644 index 0000000000..e2e90535d0 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneReportPopover.cs @@ -0,0 +1,118 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using System.Net.Http; +using NUnit.Framework; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Testing; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Overlays.Chat; + +namespace osu.Game.Tests.Visual.Online +{ + public partial class TestSceneReportPopover : OsuTestScene + { + private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; + + private ReportPopoverContainer popover = null!; + + [SetUpSteps] + public void SetUp() + { + AddStep("create popover", () => + { + Child = new PopoverContainer + { + RelativeSizeAxes = Axes.Both, + Child = popover = new ReportPopoverContainer(), + }; + }); + } + + [Test] + public void TestSuccess() + { + ChatReportRequest pendingRequest = null!; + + AddStep("setup request handling", () => + { + dummyAPI.HandleRequest += request => + { + if (request is ChatReportRequest chatReportRequest) + { + pendingRequest = chatReportRequest; + return true; + } + + return false; + }; + }); + AddStep("show popover", () => popover.ShowPopover()); + AddStep("input reason", () => this.ChildrenOfType().First().Text = "reason"); + AddStep("send report", () => this.ChildrenOfType