From 52fe274c5a525de52aeba23e7f22d6489999389a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 26 Jul 2021 17:28:15 +0200 Subject: [PATCH] Allow to pass file uploads to AbsintheHelpers.graphql_query/2 Signed-off-by: Thomas Citharel --- test/support/absinthe_helpers.ex | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/support/absinthe_helpers.ex b/test/support/absinthe_helpers.ex index 4070dd808..8610d5b9d 100644 --- a/test/support/absinthe_helpers.ex +++ b/test/support/absinthe_helpers.ex @@ -28,14 +28,24 @@ defmodule Mobilizon.GraphQL.AbsintheHelpers do @spec graphql_query(Conn.t(), Keyword.t()) :: map | no_return def graphql_query(conn, options) do conn - |> post("/api", build_query(options[:query], Keyword.get(options, :variables, %{}))) + |> post( + "/api", + build_query( + options[:query], + Keyword.get(options, :variables, %{}), + Keyword.get(options, :uploads, %{}) + ) + ) |> json_response(200) end - defp build_query(query, variables) do - %{ - "query" => query, - "variables" => variables - } + defp build_query(query, variables, uploads) do + Map.merge( + %{ + "query" => query, + "variables" => variables + }, + uploads + ) end end