mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Add test case with no existing comments
This commit is contained in:
parent
fbb674d8e9
commit
88c3eef8e1
@ -32,13 +32,18 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
private CommentsContainer commentsContainer;
|
private CommentsContainer commentsContainer;
|
||||||
|
|
||||||
|
private TextBox editorTextBox;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
|
{
|
||||||
Child = new BasicScrollContainer
|
Child = new BasicScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = commentsContainer = new CommentsContainer()
|
Child = commentsContainer = new CommentsContainer()
|
||||||
});
|
};
|
||||||
|
editorTextBox = commentsContainer.ChildrenOfType<TextBox>().First();
|
||||||
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestIdleState()
|
public void TestIdleState()
|
||||||
@ -129,21 +134,41 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
commentsContainer.ChildrenOfType<DrawableComment>().Count(d => d.Comment.Pinned == withPinned) == 1);
|
commentsContainer.ChildrenOfType<DrawableComment>().Count(d => d.Comment.Pinned == withPinned) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase]
|
[Test]
|
||||||
public void TestPost()
|
public void TestPost()
|
||||||
|
{
|
||||||
|
setUpCommentsResponse(new CommentBundle { Comments = new List<Comment>() });
|
||||||
|
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||||
|
AddAssert("no comments placeholder shown", () => commentsContainer.ChildrenOfType<CommentsContainer.NoCommentsPlaceholder>().Any());
|
||||||
|
|
||||||
|
setUpPostResponse();
|
||||||
|
AddStep("enter text", () => editorTextBox.Current.Value = "comm");
|
||||||
|
AddStep("submit", () => commentsContainer.ChildrenOfType<RoundedButton>().First().TriggerClick());
|
||||||
|
|
||||||
|
AddUntilStep("comment sent", () =>
|
||||||
|
{
|
||||||
|
string writtenText = editorTextBox.Current.Value;
|
||||||
|
var comment = commentsContainer.ChildrenOfType<DrawableComment>().Last();
|
||||||
|
return comment.ChildrenOfType<SpriteText>().Any(y => y.Text == writtenText);
|
||||||
|
});
|
||||||
|
AddAssert("no comments placeholder removed", () => !commentsContainer.ChildrenOfType<CommentsContainer.NoCommentsPlaceholder>().Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPostWithExistingComments()
|
||||||
{
|
{
|
||||||
setUpCommentsResponse(getExampleComments());
|
setUpCommentsResponse(getExampleComments());
|
||||||
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||||
|
|
||||||
setUpPostResponse();
|
setUpPostResponse();
|
||||||
AddStep("Enter text", () => this.ChildrenOfType<CommentEditor>().Single().ChildrenOfType<TextBox>().Single().Current.Value = "comm");
|
AddStep("enter text", () => editorTextBox.Current.Value = "comm");
|
||||||
AddStep("Submit", () => this.ChildrenOfType<CommentEditor>().Single().ChildrenOfType<RoundedButton>().First().TriggerClick());
|
AddStep("submit", () => commentsContainer.ChildrenOfType<CommentEditor>().Single().ChildrenOfType<RoundedButton>().First().TriggerClick());
|
||||||
AddUntilStep("Comment sent", () =>
|
|
||||||
|
AddUntilStep("comment sent", () =>
|
||||||
{
|
{
|
||||||
string text = this.ChildrenOfType<CommentEditor>().Single().ChildrenOfType<TextBox>().Single().Current.Value;
|
string writtenText = editorTextBox.Current.Value;
|
||||||
return this.ChildrenOfType<DrawableComment>().Any(x =>
|
var comment = commentsContainer.ChildrenOfType<DrawableComment>().Last();
|
||||||
{
|
return comment.ChildrenOfType<SpriteText>().Any(y => y.Text == writtenText);
|
||||||
return x.ChildrenOfType<SpriteText>().Any(y => y.Text == text);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class NoCommentsPlaceholder : CompositeDrawable
|
internal partial class NoCommentsPlaceholder : CompositeDrawable
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user