From 1ce1e959d60ee0427e20313af1edf4620f80ce62 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Mon, 29 Nov 2021 17:44:47 +0100 Subject: [PATCH] Rewrite domain_removal_SUITE:last_removal to avoid two stories --- big_tests/tests/domain_removal_SUITE.erl | 59 ++++++++++++------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/big_tests/tests/domain_removal_SUITE.erl b/big_tests/tests/domain_removal_SUITE.erl index 7b7e1fe4d74..88bb775ff02 100644 --- a/big_tests/tests/domain_removal_SUITE.erl +++ b/big_tests/tests/domain_removal_SUITE.erl @@ -353,35 +353,36 @@ vcard_removal(Config) -> end). last_removal(Config0) -> - Config1 = escalus_fresh:create_users(Config0, [{alice, 1}, {bob, 1}]), - Config2 = escalus:make_everyone_friends(Config1), - escalus:story(Config2, [{alice, 1}], - fun(Alice) -> - %% Bob logs in - {ok, Bob} = escalus_client:start_for(Config2, bob, <<"bob">>), - - %% Bob logs out with a status - Status = escalus_stanza:tags([{<<"status">>, <<"I am a banana!">>}]), - Presence = escalus_stanza:presence(<<"unavailable">>, Status), - escalus_client:send(Bob, Presence), - escalus_client:stop(Config2, Bob), - timer:sleep(1024), % more than a second - - %% Alice asks for Bob's last availability - BobShortJID = escalus_client:short_jid(Bob), - escalus_client:send(Alice, escalus_stanza:last_activity(BobShortJID)), - - %% Alice receives Bob's status and last online time > 0 - Stanza = escalus_client:wait_for_stanza(Alice), - escalus:assert(is_last_result, Stanza), - true = (1 =< get_last_activity(Stanza)), - <<"I am a banana!">> = get_last_status(Stanza), - - run_remove_domain(), - escalus_client:send(Alice, escalus_stanza:last_activity(BobShortJID)), - Error = escalus_client:wait_for_stanza(Alice), - escalus:assert(is_error, [<<"auth">>, <<"forbidden">>], Error) - end). + F = fun(Config2, Alice, Bob) -> + escalus_story:make_all_clients_friends([Alice, Bob]), + + %% Bob logs out with a status + Status = escalus_stanza:tags([{<<"status">>, <<"I am a banana!">>}]), + Presence = escalus_stanza:presence(<<"unavailable">>, Status), + escalus_client:send(Bob, Presence), + + escalus_client:stop(Config2, Bob), + timer:sleep(1024), % more than a second + + PresUn = escalus_client:wait_for_stanza(Alice), + escalus:assert(is_presence_with_type, [<<"unavailable">>], PresUn), + + %% Alice asks for Bob's last availability + BobShortJID = escalus_client:short_jid(Bob), + GetLast = escalus_stanza:last_activity(BobShortJID), + Stanza = escalus_client:send_iq_and_wait_for_result(Alice, GetLast), + + %% Alice receives Bob's status and last online time > 0 + escalus:assert(is_last_result, Stanza), + true = (1 =< get_last_activity(Stanza)), + <<"I am a banana!">> = get_last_status(Stanza), + + run_remove_domain(), + escalus_client:send(Alice, GetLast), + Error = escalus_client:wait_for_stanza(Alice), + escalus:assert(is_error, [<<"auth">>, <<"forbidden">>], Error) + end, + escalus:fresh_story_with_config(Config0, [{alice, 1}, {bob, 1}], F). %% Helpers