Add ability to check chatlog for test assertions. (#27727)

This commit is contained in:
warriorstar-orion
2025-01-08 20:53:51 +00:00
committed by GitHub
parent 1fd7e36deb
commit db5be68723
4 changed files with 15 additions and 2 deletions
+5
View File
@@ -71,6 +71,11 @@ SUBSYSTEM_DEF(chat)
/datum/controller/subsystem/chat/proc/send_immediate(send_target, list/message_data)
var/list/targets = islist(send_target) ? send_target : list(send_target)
for(var/target in targets)
#ifdef GAME_TESTS
var/mob/M = target
if(istype(M) && M?:mind?:key == "interaction_test_[M.UID()]")
LAZYADD(GLOB.game_test_chats[M.mind.key], message_to_html(message_data))
#endif
var/client/client = CLIENT_FROM_VAR(target)
if(isnull(client))
continue
+2
View File
@@ -1,3 +1,5 @@
GLOBAL_LIST_EMPTY(game_test_chats)
/// For advanced cases, fail unconditionally but don't return (so a test can return multiple results)
#define TEST_FAIL(reason) (Fail(reason || "No reason", __FILE__, __LINE__))
+7
View File
@@ -66,3 +66,10 @@
/datum/test_puppeteer/proc/rejuvenate()
puppet.rejuvenate()
/datum/test_puppeteer/proc/last_chatlog_has_text(snippet)
if(!(puppet.mind.key in GLOB.game_test_chats))
return FALSE
var/list/puppet_chat_list = GLOB.game_test_chats[puppet.mind.key]
var/last_chat_html = puppet_chat_list[length(puppet_chat_list)]
return findtextEx(last_chat_html, snippet)
@@ -6,10 +6,9 @@
player.click_on(janicart)
TEST_ASSERT_EQUAL(janicart.inserted_key, janicart_key, "did not find janicart key in vehicle")
var/move_delay = janicart.vehicle_move_delay
player.spawn_obj_in_hand(/obj/item/borg/upgrade/vtec)
player.click_on(janicart)
TEST_ASSERT(janicart.vehicle_move_delay < move_delay, "VTEC upgrade not applied properly")
TEST_ASSERT(player.last_chatlog_has_text("You upgrade the janicart"), "VTEC upgrade not applied properly")
TEST_ASSERT_NULL(janicart.mybag, "unexpected trash bag on janicart")
var/obj/item/storage/bag/trash/bag = player.spawn_obj_in_hand(/obj/item/storage/bag/trash)