From f23f43876363651cc9c54468f7522ad1adfcb737 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 21 Apr 2022 15:15:02 +0200 Subject: [PATCH] Add test for the hashtag special cases - Test that same hashtags with different casing are taken only once into account - Test that too long hashtags are not extracted from description Signed-off-by: Thomas Citharel --- test/graphql/resolvers/event_test.exs | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/graphql/resolvers/event_test.exs b/test/graphql/resolvers/event_test.exs index aeba6c2aa..7db786bca 100644 --- a/test/graphql/resolvers/event_test.exs +++ b/test/graphql/resolvers/event_test.exs @@ -808,6 +808,53 @@ defmodule Mobilizon.Web.Resolvers.EventTest do end end + describe "create_event/3 with special tags" do + test "same tags with different casing", %{conn: conn, actor: actor, user: user} do + begins_on = DateTime.utc_now() + + res = + conn + |> auth_conn(user) + |> AbsintheHelpers.graphql_query( + query: @create_event_mutation, + variables: %{ + title: "come to my event", + description: "it will be fine", + begins_on: "#{DateTime.add(begins_on, 3600 * 24)}", + organizer_actor_id: "#{actor.id}", + tags: ["Hello", "hello"] + } + ) + + assert res["error"] == nil + assert res["data"]["createEvent"]["tags"] == [%{"slug" => "hello", "title" => "Hello"}] + end + + test "too long tags", %{conn: conn, actor: actor, user: user} do + begins_on = DateTime.utc_now() + + res = + conn + |> auth_conn(user) + |> AbsintheHelpers.graphql_query( + query: @create_event_mutation, + variables: %{ + title: "come to my event", + description: + "

it will be fine, what do you think?
#Detected
#ThisIsAVeryLongHashTagThatWillNotBeDetectedByTheParser

", + begins_on: "#{DateTime.add(begins_on, 3600 * 24)}", + organizer_actor_id: "#{actor.id}" + } + ) + + assert res["error"] == nil + + assert res["data"]["createEvent"]["tags"] == [ + %{"slug" => "detected", "title" => "detected"} + ] + end + end + @update_event_mutation """ mutation updateEvent( $eventId: ID!