[WIP] Test transmogrifier

Introduce MobilizonWeb.API namespace

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Format

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

WIP

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

remove unneeded code

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Fix tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Fix warnings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-12-14 17:41:55 +01:00
parent e3a8343112
commit c1e6612405
41 changed files with 2961 additions and 246 deletions

View File

@@ -0,0 +1,41 @@
defmodule MobilizonWeb.Resolvers.CommentResolverTest do
use MobilizonWeb.ConnCase
alias Mobilizon.{Events, Actors}
alias Mobilizon.Actors.{Actor, User}
alias MobilizonWeb.AbsintheHelpers
import Mobilizon.Factory
@comment %{text: "some body"}
setup %{conn: conn} do
{:ok, %User{default_actor: %Actor{} = actor} = user} =
Actors.register(%{email: "test@test.tld", password: "testest", username: "test"})
{:ok, conn: conn, actor: actor, user: user}
end
describe "Comment Resolver" do
test "create_comment/3 creates a comment", %{conn: conn, actor: actor, user: user} do
category = insert(:category)
mutation = """
mutation {
createComment(
text: "I love this event",
actor_username: "#{actor.preferred_username}"
) {
text,
uuid
}
}
"""
res =
conn
|> auth_conn(user)
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
assert json_response(res, 200)["data"]["createComment"]["text"] == "I love this event"
end
end
end

View File

@@ -116,10 +116,10 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
createEvent(
title: "come to my event",
description: "it will be fine",
beginsOn: "#{DateTime.utc_now() |> DateTime.to_iso8601()}",
organizer_actor_id: #{actor.id},
category_id: #{category.id},
addressType: #{"OTHER"}
begins_on: "#{DateTime.utc_now() |> DateTime.to_iso8601()}",
organizer_actor_username: "#{actor.preferred_username}",
category: "#{category.title}",
address_type: #{"OTHER"}
) {
title,
uuid

View File

@@ -22,7 +22,7 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
mutation {
createGroup(
preferred_username: "#{@new_group_params.groupname}",
creator_username: "#{actor.preferred_username}"
admin_actor_username: "#{actor.preferred_username}"
) {
preferred_username,
type
@@ -44,7 +44,7 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
mutation {
createGroup(
preferred_username: "#{@new_group_params.groupname}",
creator_username: "#{actor.preferred_username}",
admin_actor_username: "#{actor.preferred_username}",
) {
preferred_username,
type
@@ -57,7 +57,7 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|> auth_conn(user)
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
assert hd(json_response(res, 200)["errors"])["message"] == "group_name_not_available"
assert hd(json_response(res, 200)["errors"])["message"] == "existing_group_name"
end
test "list_groups/3 returns all groups", context do