Fix tests with events listing
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
69355b4d2e
commit
ad0086032b
|
@ -357,15 +357,15 @@ defmodule Mobilizon.Events do
|
||||||
direction \\ :asc,
|
direction \\ :asc,
|
||||||
is_future \\ true
|
is_future \\ true
|
||||||
) do
|
) do
|
||||||
query = from(e in Event, distinct: true, preload: [:organizer_actor, :participants])
|
Event
|
||||||
|
|> distinct([e], [{^direction, ^sort}, asc: e.id])
|
||||||
query
|
|> preload([:organizer_actor, :participants])
|
||||||
|> sort(sort, direction)
|
|> sort(sort, direction)
|
||||||
|> filter_future_events(is_future)
|
|> filter_future_events(is_future)
|
||||||
|> filter_public_visibility()
|
|> filter_public_visibility()
|
||||||
|> filter_draft()
|
|> filter_draft()
|
||||||
|> filter_local_or_from_followed_instances_events()
|
|> filter_local_or_from_followed_instances_events()
|
||||||
|> Page.build_page(page, limit, sort)
|
|> Page.build_page(page, limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec stream_events_for_sitemap :: Enum.t()
|
@spec stream_events_for_sitemap :: Enum.t()
|
||||||
|
|
|
@ -1166,42 +1166,38 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||||
event.uuid
|
event.uuid
|
||||||
]
|
]
|
||||||
|
|
||||||
Enum.each(0..15, fn _ ->
|
|
||||||
insert(:event)
|
insert(:event)
|
||||||
end)
|
# Process.sleep(1000)
|
||||||
|
insert(:event)
|
||||||
res =
|
|
||||||
conn
|
|
||||||
|> AbsintheHelpers.graphql_query(query: @fetch_events_query)
|
|
||||||
|
|
||||||
assert res["data"]["events"]["total"] == 17
|
|
||||||
assert res["data"]["events"]["elements"] |> length == 10
|
|
||||||
|
|
||||||
res =
|
|
||||||
conn
|
|
||||||
|> AbsintheHelpers.graphql_query(query: @fetch_events_query, variables: %{page: 2})
|
|
||||||
|
|
||||||
assert res["data"]["events"]["total"] == 17
|
|
||||||
assert res["data"]["events"]["elements"] |> length == 7
|
|
||||||
|
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
|> AbsintheHelpers.graphql_query(
|
|> AbsintheHelpers.graphql_query(
|
||||||
query: @fetch_events_query,
|
query: @fetch_events_query,
|
||||||
variables: %{page: 2, limit: 15}
|
variables: %{page: 1, limit: 2}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert res["data"]["events"]["total"] == 17
|
assert res["data"]["events"]["total"] == 3
|
||||||
assert res["data"]["events"]["elements"] |> length == 2
|
assert res["data"]["events"]["elements"] |> length == 2
|
||||||
|
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
|> AbsintheHelpers.graphql_query(
|
|> AbsintheHelpers.graphql_query(
|
||||||
query: @fetch_events_query,
|
query: @fetch_events_query,
|
||||||
variables: %{page: 3, limit: 15}
|
variables: %{page: 2, limit: 2}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert res["data"]["events"]["total"] == 17
|
assert res["data"]["events"]["total"] == 3
|
||||||
|
assert res["data"]["events"]["elements"] |> length == 1
|
||||||
|
|
||||||
|
res =
|
||||||
|
conn
|
||||||
|
|> AbsintheHelpers.graphql_query(
|
||||||
|
query: @fetch_events_query,
|
||||||
|
variables: %{page: 3, limit: 2}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert res["data"]["events"]["total"] == 3
|
||||||
assert res["data"]["events"]["elements"] |> length == 0
|
assert res["data"]["events"]["elements"] |> length == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -436,10 +436,28 @@ defmodule Mobilizon.Web.ActivityPubControllerTest do
|
||||||
|> get(Actor.build_url(group.preferred_username, :members))
|
|> get(Actor.build_url(group.preferred_username, :members))
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|
||||||
assert [admin_member | [member]] = result["first"]["orderedItems"]
|
assert members = result["first"]["orderedItems"]
|
||||||
|
|
||||||
|
admin_member =
|
||||||
|
Enum.find(
|
||||||
|
members,
|
||||||
|
fn member ->
|
||||||
|
member["actor"] == actor_group_admin.url
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
member =
|
||||||
|
Enum.find(
|
||||||
|
members,
|
||||||
|
fn member ->
|
||||||
|
member["actor"] == actor_applicant.url
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
assert admin_member["role"] == "administrator"
|
assert admin_member["role"] == "administrator"
|
||||||
assert member["role"] == "member"
|
|
||||||
assert result["totalItems"] == 2
|
assert member["role"] == "member" ||
|
||||||
|
assert(result["totalItems"] == 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue