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,
|
||||
is_future \\ true
|
||||
) do
|
||||
query = from(e in Event, distinct: true, preload: [:organizer_actor, :participants])
|
||||
|
||||
query
|
||||
Event
|
||||
|> distinct([e], [{^direction, ^sort}, asc: e.id])
|
||||
|> preload([:organizer_actor, :participants])
|
||||
|> sort(sort, direction)
|
||||
|> filter_future_events(is_future)
|
||||
|> filter_public_visibility()
|
||||
|> filter_draft()
|
||||
|> filter_local_or_from_followed_instances_events()
|
||||
|> Page.build_page(page, limit, sort)
|
||||
|> Page.build_page(page, limit)
|
||||
end
|
||||
|
||||
@spec stream_events_for_sitemap :: Enum.t()
|
||||
|
|
|
@ -1166,42 +1166,38 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
|||
event.uuid
|
||||
]
|
||||
|
||||
Enum.each(0..15, fn _ ->
|
||||
insert(:event)
|
||||
end)
|
||||
|
||||
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
|
||||
insert(:event)
|
||||
# Process.sleep(1000)
|
||||
insert(:event)
|
||||
|
||||
res =
|
||||
conn
|
||||
|> AbsintheHelpers.graphql_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
|
||||
|
||||
res =
|
||||
conn
|
||||
|> AbsintheHelpers.graphql_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
|
||||
end
|
||||
|
||||
|
|
|
@ -436,10 +436,28 @@ defmodule Mobilizon.Web.ActivityPubControllerTest do
|
|||
|> get(Actor.build_url(group.preferred_username, :members))
|
||||
|> 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 member["role"] == "member"
|
||||
assert result["totalItems"] == 2
|
||||
|
||||
assert member["role"] == "member" ||
|
||||
assert(result["totalItems"] == 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue