mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 08:22:56 +08:00
Update main test and add failure scenario test
This commit is contained in:
parent
b697200460
commit
c384093802
@ -140,7 +140,57 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddAssert("Loading spinner shown", () => commentsContainer.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
|
AddAssert("Loading spinner shown", () => commentsContainer.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
|
||||||
AddUntilStep("Comment is deleted locally", () =>
|
AddUntilStep("Comment is deleted locally", () =>
|
||||||
{
|
{
|
||||||
return this.ChildrenOfType<DrawableComment>().SingleOrDefault(x => x.Comment.Id == 1) == null;
|
return this.ChildrenOfType<DrawableComment>().Single(x => x.Comment.Id == 1).WasDeleted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDeletionFail()
|
||||||
|
{
|
||||||
|
DrawableComment? ourComment = null;
|
||||||
|
bool delete = false;
|
||||||
|
|
||||||
|
addTestComments();
|
||||||
|
AddUntilStep("Comment exists", () =>
|
||||||
|
{
|
||||||
|
var comments = this.ChildrenOfType<DrawableComment>();
|
||||||
|
ourComment = comments.SingleOrDefault(x => x.Comment.Id == 1);
|
||||||
|
return ourComment != null;
|
||||||
|
});
|
||||||
|
AddStep("It has delete button", () =>
|
||||||
|
{
|
||||||
|
var btn = ourComment.ChildrenOfType<OsuSpriteText>().Single(x => x.Text == "Delete");
|
||||||
|
InputManager.MoveMouseTo(btn);
|
||||||
|
});
|
||||||
|
AddStep("Click delete button", () =>
|
||||||
|
{
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
AddStep("Setup request handling", () =>
|
||||||
|
{
|
||||||
|
dummyAPI.HandleRequest = request =>
|
||||||
|
{
|
||||||
|
if (request is not CommentDeleteRequest req)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
req.TriggerFailure(new Exception());
|
||||||
|
delete = true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
AddStep("Confirm dialog", () => InputManager.Key(Key.Number1));
|
||||||
|
AddUntilStep("Deletion requested", () => delete);
|
||||||
|
AddUntilStep("Comment is available", () =>
|
||||||
|
{
|
||||||
|
return !this.ChildrenOfType<DrawableComment>().Single(x => x.Comment.Id == 1).WasDeleted;
|
||||||
|
});
|
||||||
|
AddAssert("Loading spinner hidden", () =>
|
||||||
|
{
|
||||||
|
return ourComment.ChildrenOfType<LoadingSpinner>().All(d => !d.IsPresent);
|
||||||
|
});
|
||||||
|
AddAssert("Actions available", () =>
|
||||||
|
{
|
||||||
|
return ourComment.ChildrenOfType<LinkFlowContainer>().Single(x => x.Name == @"Actions buttons").IsPresent;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +201,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
},
|
},
|
||||||
actionsContainer = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold))
|
actionsContainer = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold))
|
||||||
{
|
{
|
||||||
|
Name = @"Actions buttons",
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Spacing = new Vector2(10, 0)
|
Spacing = new Vector2(10, 0)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user