mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 20:16:55 +01:00
Add ability to check chatlog for test assertions. (#27727)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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__))
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user