From 4c480f1c43b75de98ced4c48a7f79e34d62f1825 Mon Sep 17 00:00:00 2001 From: Aleksey Sabilin Date: Wed, 29 Jul 2026 15:58:41 +0300 Subject: [PATCH] fix(test): lookup banned words via q after batch Bare GET /banned-words is paginated (limit 50); on dirty IFT the batch words fall off page 1 and admin_test_banned_words flakes. Assert via ?q= like the single-add case; same for delete check. --- test/api/admins/admin_banned_words_tests.erl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/api/admins/admin_banned_words_tests.erl b/test/api/admins/admin_banned_words_tests.erl index c2453b1..91cb704 100644 --- a/test/api/admins/admin_banned_words_tests.erl +++ b/test/api/admins/admin_banned_words_tests.erl @@ -122,8 +122,14 @@ test_batch_add_words(Token) -> Result = jsx:decode(list_to_binary(RespBody), [return_maps]), ?assertEqual(3, maps:get(<<"added">>, Result)), ?assertEqual(0, maps:get(<<"skipped">>, Result)), - AllWords = api_test_runner:admin_get(<<"/v1/admin/banned-words">>, Token), - [?assert(lists:any(fun(W) -> maps:get(<<"word">>, W) =:= Word end, AllWords)) || Word <- Words], + %% Lookup via ?q= — bare GET is paginated and flakes on dirty IFT stands. + lists:foreach( + fun(Word) -> + Found = api_test_runner:admin_get(<<"/v1/admin/banned-words?q=", Word/binary>>, Token), + ?assertEqual(1, length(Found)), + ?assertEqual(Word, maps:get(<<"word">>, hd(Found))) + end, + Words), ct:pal(" OK"). %% @doc DELETE /v1/admin/banned-words/:word – удаление слова. @@ -132,8 +138,8 @@ test_delete_word(Token, Word) -> Path = <<"/v1/admin/banned-words/", Word/binary>>, Result = api_test_runner:admin_delete(Path, Token), ?assertEqual(<<"deleted">>, maps:get(<<"status">>, Result)), - Words = api_test_runner:admin_get(<<"/v1/admin/banned-words">>, Token), - ?assertNot(lists:any(fun(W) -> maps:get(<<"word">>, W) =:= Word end, Words)), + Left = api_test_runner:admin_get(<<"/v1/admin/banned-words?q=", Word/binary>>, Token), + ?assert(lists:all(fun(W) -> maps:get(<<"word">>, W) =/= Word end, Left)), ct:pal(" OK"). %% @doc PUT /v1/admin/banned-words/:word – попытка переименовать в уже существующее слово (409).