Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

test(blog): missing published test#394

Merged
mydearxym merged 2 commits intodevfrompublished-test-for-blog
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -404,7 +404,6 @@ defmodule GroupherServer.Test.CMS.Comments.RepoComment do
assert results.total_count == total_count + 1
end

@tag :wip
test "paged article comments folded flag should be false", ~m(user repo)a do
total_count = 30
page_number = 1
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,7 +116,7 @@ defmodule GroupherServer.Test.Mutation.Comments.BlogComment do
}
}
"""
@tag :wip

test "login user can upvote a exsit blog comment", ~m(blog user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:blog, blog.id, "blog comment", user)
variables = %{id: comment.id}
Expand All@@ -141,7 +141,7 @@ defmodule GroupherServer.Test.Mutation.Comments.BlogComment do
}
}
"""
@tag :wip

test "login user can undo upvote a exsit blog comment", ~m(blog user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:blog, blog.id, "blog comment", user)
variables = %{id: comment.id}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,7 +116,7 @@ defmodule GroupherServer.Test.Mutation.Comments.JobComment do
}
}
"""
@tag :wip

test "login user can upvote a exsit job comment", ~m(job user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:job, job.id, "job comment", user)
variables = %{id: comment.id}
Expand All@@ -141,7 +141,7 @@ defmodule GroupherServer.Test.Mutation.Comments.JobComment do
}
}
"""
@tag :wip

test "login user can undo upvote a exsit job comment", ~m(job user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:job, job.id, "job comment", user)
variables = %{id: comment.id}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,7 +116,7 @@ defmodule GroupherServer.Test.Mutation.Comments.PostComment do
}
}
"""
@tag :wip

test "login user can upvote a exsit post comment", ~m(post user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:post, post.id, "post comment", user)
variables = %{id: comment.id}
Expand All@@ -141,7 +141,7 @@ defmodule GroupherServer.Test.Mutation.Comments.PostComment do
}
}
"""
@tag :wip

test "login user can undo upvote a exsit post comment", ~m(post user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:post, post.id, "post comment", user)
variables = %{id: comment.id}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,7 +116,7 @@ defmodule GroupherServer.Test.Mutation.Comments.RepoComment do
}
}
"""
@tag :wip

test "login user can upvote a exsit repo comment", ~m(repo user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:repo, repo.id, "repo comment", user)
variables = %{id: comment.id}
Expand All@@ -141,7 +141,7 @@ defmodule GroupherServer.Test.Mutation.Comments.RepoComment do
}
}
"""
@tag :wip

test "login user can undo upvote a exsit repo comment", ~m(repo user guest_conn user_conn)a do
{:ok, comment} = CMS.create_article_comment(:repo, repo.id, "repo comment", user)
variables = %{id: comment.id}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp