Добавить авто-регистрацию тикетов (hash/dedupe/500/WS). Refs EventHub/EventHubBack#35
This commit is contained in:
@@ -36,6 +36,8 @@ test() ->
|
||||
#{error_message => <<"Something broke">>, stacktrace => <<"line 42">>}),
|
||||
|
||||
test_create_ticket(Token),
|
||||
test_create_ticket_dedupe(Token),
|
||||
test_create_ticket_manual(Token),
|
||||
test_create_ticket_missing_fields(Token),
|
||||
test_create_ticket_unauthorized(),
|
||||
test_list_tickets(Token, TicketId),
|
||||
@@ -47,7 +49,6 @@ test() ->
|
||||
|
||||
ct:pal("=== All user tickets tests passed ==="),
|
||||
ok.
|
||||
|
||||
%%%===================================================================
|
||||
%%% Тестовые функции
|
||||
%%%===================================================================
|
||||
@@ -57,13 +58,57 @@ test() ->
|
||||
test_create_ticket(Token) ->
|
||||
ct:pal(" TEST: Create a ticket"),
|
||||
Resp = api_test_runner:client_request(post, <<"/v1/tickets">>, Token,
|
||||
jsx:encode(#{error_message => <<"Test bug">>, stacktrace => <<"trace">>})),
|
||||
jsx:encode(#{
|
||||
error_message => <<"Test bug">>,
|
||||
stacktrace => <<"trace">>,
|
||||
source => <<"frontend">>,
|
||||
context => #{route => <<"/test">>, build => <<"dev">>}
|
||||
})),
|
||||
{ok, 201, _, Body} = Resp,
|
||||
#{<<"id">> := Id, <<"status">> := Status} = jsx:decode(list_to_binary(Body), [return_maps]),
|
||||
Decoded = jsx:decode(list_to_binary(Body), [return_maps]),
|
||||
#{<<"id">> := Id, <<"status">> := Status, <<"source">> := Source, <<"error_hash">> := Hash} = Decoded,
|
||||
?assert(is_binary(Id)),
|
||||
?assertEqual(<<"open">>, Status),
|
||||
?assertEqual(<<"frontend">>, Source),
|
||||
?assert(is_binary(Hash)),
|
||||
?assert(byte_size(Hash) > 0),
|
||||
ct:pal(" OK: ticket ~s created", [Id]).
|
||||
|
||||
%% @doc Повторный POST с тем же сообщением увеличивает count.
|
||||
-spec test_create_ticket_dedupe(binary()) -> ok.
|
||||
test_create_ticket_dedupe(Token) ->
|
||||
ct:pal(" TEST: Dedupe ticket by hash"),
|
||||
Payload = jsx:encode(#{
|
||||
error_message => <<"Dedupe me">>,
|
||||
stacktrace => <<"same stack">>,
|
||||
source => <<"frontend">>
|
||||
}),
|
||||
{ok, 201, _, Body1} = api_test_runner:client_request(post, <<"/v1/tickets">>, Token, Payload),
|
||||
#{<<"id">> := Id1, <<"count">> := Count1} = jsx:decode(list_to_binary(Body1), [return_maps]),
|
||||
{ok, 201, _, Body2} = api_test_runner:client_request(post, <<"/v1/tickets">>, Token, Payload),
|
||||
#{<<"id">> := Id2, <<"count">> := Count2} = jsx:decode(list_to_binary(Body2), [return_maps]),
|
||||
?assertEqual(Id1, Id2),
|
||||
?assertEqual(Count1 + 1, Count2),
|
||||
ct:pal(" OK: count bumped to ~p", [Count2]).
|
||||
|
||||
%% @doc Ручной клиентский репорт: source=manual без stacktrace.
|
||||
-spec test_create_ticket_manual(binary()) -> ok.
|
||||
test_create_ticket_manual(Token) ->
|
||||
ct:pal(" TEST: Create manual ticket"),
|
||||
Resp = api_test_runner:client_request(post, <<"/v1/tickets">>, Token,
|
||||
jsx:encode(#{
|
||||
error_message => <<"Button does nothing">>,
|
||||
source => <<"manual">>,
|
||||
context => #{steps => <<"1. Open calendar\n2. Click share">>}
|
||||
})),
|
||||
{ok, 201, _, Body} = Resp,
|
||||
#{<<"source">> := Source, <<"error_hash">> := Hash} =
|
||||
jsx:decode(list_to_binary(Body), [return_maps]),
|
||||
?assertEqual(<<"manual">>, Source),
|
||||
?assert(is_binary(Hash)),
|
||||
?assert(byte_size(Hash) > 0),
|
||||
ct:pal(" OK: manual ticket created").
|
||||
|
||||
%% @doc Отсутствие обязательного поля error_message: 400 Bad Request.
|
||||
-spec test_create_ticket_missing_fields(binary()) -> ok.
|
||||
test_create_ticket_missing_fields(Token) ->
|
||||
|
||||
Reference in New Issue
Block a user