diff --git a/big_tests/tests/graphql_sse_SUITE.erl b/big_tests/tests/graphql_sse_SUITE.erl index 8a7a097c3ea..6937e45f0cf 100644 --- a/big_tests/tests/graphql_sse_SUITE.erl +++ b/big_tests/tests/graphql_sse_SUITE.erl @@ -21,7 +21,7 @@ all() -> groups() -> [{admin, [parallel], admin_tests()}, {user, [parallel], user_tests()}, - {timeout, [], [sse_should_not_get_timeout]}]. + {timeout, [parallel], [sse_should_not_get_timeout, sse_works_with_long_messages]}]. init_per_suite(Config) -> Config1 = escalus:init_per_suite(Config), @@ -148,6 +148,17 @@ sse_should_not_get_timeout(Config) -> sse_helper:stop_sse(Stream) end). +sse_works_with_long_messages(Config) -> + escalus:fresh_story(Config, [{alice, 1}, {bob, 1}], fun (Alice, Bob) -> + From = escalus_client:full_jid(Bob), + To = escalus_client:short_jid(Alice), + {200, Stream} = graphql_helper:execute_user_command_sse(<<"stanza">>, <<"subscribeForMessages">>, Alice, #{}, Config), + Message = binary:copy(<<"0">>, 2000), + escalus:send(Bob, escalus_stanza:chat(From, To, Message)), + sse_helper:wait_for_event(Stream), + sse_helper:stop_sse(Stream) + end). + %% Helpers get_graphql_user_listener() -> diff --git a/src/graphql/mongoose_graphql_response.erl b/src/graphql/mongoose_graphql_response.erl index f8a44fec83b..64d5602393b 100644 --- a/src/graphql/mongoose_graphql_response.erl +++ b/src/graphql/mongoose_graphql_response.erl @@ -3,10 +3,10 @@ -export([term_to_json/1, term_to_pretty_json/1]). term_to_json(Term) -> - jiffy:encode(fixup(Term)). + iolist_to_binary(jiffy:encode(fixup(Term))). term_to_pretty_json(Term) -> - jiffy:encode(fixup(Term), [pretty]). + iolist_to_binary(jiffy:encode(fixup(Term), [pretty])). %% Ground types fixup(Term) when is_number(Term) -> Term;