1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00

add pinned comment test case for comment container

This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-08-13 13:23:34 +07:00
parent 39b13efdd5
commit e3f91413cf
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2

View File

@ -42,19 +42,21 @@ namespace osu.Game.Tests.Visual.Online
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().IsLoading);
}
[Test]
public void TestSingleCommentsPage()
[TestCase(false)]
[TestCase(true)]
public void TestSingleCommentsPage(bool withPinned)
{
setUpCommentsResponse(exampleComments);
setUpCommentsResponse(getExampleComments(withPinned));
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
AddUntilStep("show more button hidden",
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 0);
}
[Test]
public void TestMultipleCommentPages()
[TestCase(false)]
[TestCase(true)]
public void TestMultipleCommentPages(bool withPinned)
{
var comments = exampleComments;
var comments = getExampleComments(withPinned);
comments.HasMore = true;
comments.TopLevelCount = 10;
@ -64,11 +66,12 @@ namespace osu.Game.Tests.Visual.Online
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 1);
}
[Test]
public void TestMultipleLoads()
[TestCase(false)]
[TestCase(true)]
public void TestMultipleLoads(bool withPinned)
{
var comments = exampleComments;
int topLevelCommentCount = exampleComments.Comments.Count;
var comments = getExampleComments(withPinned);
int topLevelCommentCount = comments.Comments.Count;
AddStep("hide container", () => commentsContainer.Hide());
setUpCommentsResponse(comments);
@ -92,7 +95,9 @@ namespace osu.Game.Tests.Visual.Online
};
});
private CommentBundle exampleComments => new CommentBundle
private CommentBundle getExampleComments(bool withPinned = false)
{
var bundle = new CommentBundle
{
Comments = new List<Comment>
{
@ -124,6 +129,37 @@ namespace osu.Game.Tests.Visual.Online
},
},
IncludedComments = new List<Comment>(),
PinnedComments = new List<Comment>(),
};
if (withPinned)
{
var pinnedComment = new Comment
{
Id = 15,
Message = "This is pinned comment",
LegacyName = "PinnedUser",
CreatedAt = DateTimeOffset.Now,
VotesCount = 999,
Pinned = true,
RepliesCount = 1,
};
bundle.Comments.Add(pinnedComment);
bundle.PinnedComments.Add(pinnedComment);
bundle.Comments.Add(new Comment
{
Id = 20,
Message = "Reply to pinned comment",
LegacyName = "AbandonedUser",
CreatedAt = DateTimeOffset.Now,
VotesCount = 0,
ParentId = 15,
});
}
return bundle;
}
}
}