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