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 <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-04-21 15:15:02 +02:00
parent 7b3ce8d812
commit f23f438763
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -808,6 +808,53 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
end end
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:
"<p>it will be fine, what do you think? <br>#Detected <br>#ThisIsAVeryLongHashTagThatWillNotBeDetectedByTheParser</p>",
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 """ @update_event_mutation """
mutation updateEvent( mutation updateEvent(
$eventId: ID! $eventId: ID!