This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork20
test(blog): missing published test#394
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 0 additions & 1 deletiontest/groupher_server/cms/comments/repo_comment_test.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletionstest/groupher_server_web/mutation/cms/comments/blog_comment_test.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletionstest/groupher_server_web/mutation/cms/comments/job_comment_test.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletionstest/groupher_server_web/mutation/cms/comments/post_comment_test.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletionstest/groupher_server_web/mutation/cms/comments/repo_comment_test.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletionstest/groupher_server_web/query/accounts/published/published_blogs_test.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
defmodule GroupherServer.Test.Query.Accounts.Published.Blogs do | ||
use GroupherServer.TestTools | ||
alias GroupherServer.CMS | ||
@publish_count 10 | ||
setup do | ||
{:ok, user} = db_insert(:user) | ||
{:ok, blog} = db_insert(:blog) | ||
{:ok, community} = db_insert(:community) | ||
guest_conn = simu_conn(:guest) | ||
user_conn = simu_conn(:user, user) | ||
{:ok, ~m(guest_conn user_conn community blog user)a} | ||
end | ||
describe "[published blogs]" do | ||
@query """ | ||
query($login: String!, $filter: PagedFilter!) { | ||
pagedPublishedBlogs(login: $login, filter: $filter) { | ||
entries { | ||
id | ||
title | ||
author { | ||
id | ||
} | ||
} | ||
totalPages | ||
totalCount | ||
pageSize | ||
pageNumber | ||
} | ||
} | ||
""" | ||
test "can get published blogs", ~m(guest_conn community user)a do | ||
blog_attrs = mock_attrs(:blog, %{community_id: community.id}) | ||
{:ok, blog} = CMS.create_article(community, :blog, blog_attrs, user) | ||
{:ok, blog2} = CMS.create_article(community, :blog, blog_attrs, user) | ||
variables = %{login: user.login, filter: %{page: 1, size: 20}} | ||
results = guest_conn |> query_result(@query, variables, "pagedPublishedBlogs") | ||
assert results["entries"] |> Enum.any?(&(&1["id"] == to_string(blog.id))) | ||
assert results["entries"] |> Enum.any?(&(&1["id"] == to_string(blog2.id))) | ||
end | ||
end | ||
describe "[account published comments on blog]" do | ||
@query """ | ||
query($login: String!, $thread: Thread, $filter: PagedFilter!) { | ||
pagedPublishedArticleComments(login: $login, thread: $thread, filter: $filter) { | ||
entries { | ||
id | ||
bodyHtml | ||
author { | ||
id | ||
} | ||
article { | ||
id | ||
title | ||
author { | ||
nickname | ||
login | ||
} | ||
} | ||
} | ||
totalPages | ||
totalCount | ||
pageSize | ||
pageNumber | ||
} | ||
} | ||
""" | ||
test "user can get paged published comments on blog", ~m(guest_conn user blog)a do | ||
pub_comments = | ||
Enum.reduce(1..@publish_count, [], fn _, acc -> | ||
{:ok, comment} = CMS.create_article_comment(:blog, blog.id, "comment", user) | ||
acc ++ [comment] | ||
end) | ||
random_comment_id = pub_comments |> Enum.random() |> Map.get(:id) |> to_string | ||
variables = %{login: user.login, thread: "BLOG", filter: %{page: 1, size: 20}} | ||
results = guest_conn |> query_result(@query, variables, "pagedPublishedArticleComments") | ||
entries = results["entries"] | ||
assert results |> is_valid_pagination? | ||
assert results["totalCount"] == @publish_count | ||
assert entries |> Enum.all?(&(not is_nil(&1["article"]["author"]))) | ||
assert entries |> Enum.all?(&(&1["article"]["id"] == to_string(blog.id))) | ||
assert entries |> Enum.all?(&(&1["author"]["id"] == to_string(user.id))) | ||
assert entries |> Enum.any?(&(&1["id"] == random_comment_id)) | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.