2026-10-29 22:31:17 +02:00
extends RefCounted
## Exercise the same rendered buttons as a player. Wall-clock jumps only
## replace waiting; no direct invocation of task completion or ending selection.
var game : Node
var errors : Array [ String ] = [ ]
var results : Array = [ ]
var checks := 0
func check ( ok : bool , message : String ) - > void :
checks + = 1
if not ok :
errors . append ( message )
push_error ( " PHONE QA: " + message )
2026-10-30 01:49:04 +02:00
func check_clocks ( expected : String , context : String ) - > void :
check ( game . clock_label . text == expected , " Katya call duration " + context )
check ( game . stage . mother_clock . text == expected , " Mother call duration " + context )
2026-10-29 22:31:17 +02:00
func click ( id : String ) - > void :
2026-10-30 12:49:18 +02:00
var gameplay := id == " question "
2026-10-30 01:03:42 +02:00
for action in game . story . actions :
if action . id == id : gameplay = true
if gameplay : wait_for_speech ( )
2026-10-29 22:31:17 +02:00
var control : Button = game . action_button ( id )
check ( control != null , " Visible button: " + id )
if control != null :
check ( not control . disabled , " Enabled button: " + id )
control . pressed . emit ( )
func at ( second : float ) - > void :
2026-10-30 01:03:42 +02:00
if second > = game . speech_until : game . voice . stop ( )
2026-10-29 22:31:17 +02:00
game . start_tick = Time . get_ticks_msec ( ) - int ( second * 1000.0 )
game . _process ( 0 )
2026-10-30 01:03:42 +02:00
if second > = game . speech_until : game . voice . stop ( )
game . refresh_live ( )
func wait_for_speech ( ) - > void :
for step in range ( 12 ) :
if game . speech_finished ( ) and game . events . is_empty ( ) : return
var next : float = maxf ( game . elapsed , game . speech_until ) + 0.01
if not game . events . is_empty ( ) : next = maxf ( next , float ( game . events [ 0 ] . at ) + 0.01 )
at ( next )
check ( false , " Dialogue must finish before choosing " )
2026-10-29 22:31:17 +02:00
func perform ( id : String ) - > void :
click ( id )
check ( not game . busy . is_empty ( ) , " Command accepted: " + id )
if not game . busy . is_empty ( ) :
at ( game . reply_at + 0.02 )
at ( game . busy_end + 0.03 )
func start ( number : int , knowledge : int = 0 ) - > void :
game . show_test_menu ( )
var selection : OptionButton = null
var memories : OptionButton = null
for node in game . overlay . find_children ( " * " , " OptionButton " , true , false ) :
if node . has_meta ( " test_chapter " ) : selection = node
if node . has_meta ( " test_knowledge " ) : memories = node
check ( selection != null and memories != null , " Test menu selectors " )
selection . select ( number - 1 )
memories . select ( knowledge )
click ( " test_start " )
func render ( ) - > void :
await game . get_tree ( ) . process_frame
await game . get_tree ( ) . process_frame
if DisplayServer . get_name ( ) != " headless " :
await RenderingServer . frame_post_draw
2026-10-30 12:31:52 +02:00
func escape ( ) - > void :
var key := InputEventKey . new ( )
key . keycode = KEY_ESCAPE
key . physical_keycode = KEY_ESCAPE
key . pressed = true
game . get_viewport ( ) . push_input ( key , true )
var release := key . duplicate ( )
release . pressed = false
game . get_viewport ( ) . push_input ( release , true )
await render ( )
2026-10-29 22:31:17 +02:00
func capture ( name : String ) - > void :
2026-10-30 01:38:31 +02:00
if DisplayServer . get_name ( ) != " headless " :
await game . get_tree ( ) . create_timer ( 0.42 ) . timeout
2026-10-29 22:31:17 +02:00
await render ( )
if DisplayServer . get_name ( ) != " headless " :
game . get_viewport ( ) . get_texture ( ) . get_image ( ) . save_png ( directory ( ) . path_join ( name + " .png " ) )
func directory ( ) - > String :
return OS . get_executable_path ( ) . get_base_dir ( ) . path_join ( " captures " ) if OS . has_feature ( " template " ) else ProjectSettings . globalize_path ( " res://../qa " )
func finish ( expected : String ) - > void :
at ( 90.1 )
check ( game . impacted and not game . running , " Strike finishes " )
check ( game . busy . is_empty ( ) and game . events . is_empty ( ) , " Strike clears pending work " )
check ( not game . voice . playing , " Strike cuts dialogue " )
check ( game . outcome == expected , " Expected " + expected + " , got " + game . outcome )
results . append ( { " chapter " : game . chapter , " outcome " : game . outcome , " facts " : game . facts . keys ( ) } )
game . show_ending ( )
func realtime_check ( ) - > void :
# Opt-in, genuinely wait for the complete prologue and production transition.
start ( 1 )
game . qa_mode = false
2026-10-30 01:49:04 +02:00
var warning_finished : Array [ float ] = [ ]
var record_warning := func ( ) :
if game . running and not game . heard . is_empty ( ) and game . heard [ - 1 ] == " hum " :
warning_finished . append ( game . elapsed )
game . voice . finished . connect ( record_warning )
2026-10-29 22:31:17 +02:00
var began := Time . get_ticks_msec ( )
for step in range ( 3 ) :
await game . get_tree ( ) . create_timer ( 30.0 ) . timeout
print ( " PHONE_REALTIME elapsed= " , ( Time . get_ticks_msec ( ) - began ) / 1000.0 )
await game . get_tree ( ) . create_timer ( 9.0 ) . timeout
2026-10-30 01:49:04 +02:00
game . voice . finished . disconnect ( record_warning )
2026-10-29 22:31:17 +02:00
check ( game . impacted and not game . running , " Real 90-second strike " )
2026-10-30 01:49:04 +02:00
check_clocks ( " 01:30 " , " real disconnected call " )
check ( warning_finished . size ( ) == 1 , " Real warning plays to its natural end " )
if warning_finished . size ( ) == 1 :
var warning_gap := float ( game . story . timeline . impact ) - warning_finished [ 0 ]
check ( warning_gap > = 5 , " Real warning leaves five seconds before impact " )
print ( " PHONE_REALTIME warning_gap= " , warning_gap )
2026-10-29 22:31:17 +02:00
for beat in game . story . intro :
check ( beat . line in game . heard , " Real prologue " + str ( beat . line ) )
check ( " after_call " in game . heard , " Production post-impact reply " )
check ( game . action_button ( " next " ) != null , " Production ending overlay " )
await capture ( " phone-real-ending " )
click ( " next " )
2026-10-30 01:38:31 +02:00
while game . dialing : await game . get_tree ( ) . create_timer ( 0.1 ) . timeout
2026-10-29 22:31:17 +02:00
await game . get_tree ( ) . create_timer ( 5.0 ) . timeout
check ( game . chapter == 2 and game . running , " Production redial " )
check ( " greeting " in game . heard and " call_02_k " in game . heard , " Production second opening " )
2026-10-30 01:03:42 +02:00
check ( game . action_button ( " keys_search " ) . disabled , " Real audio keeps early answers disabled " )
for frame in range ( 100 ) :
if game . can_respond ( ) : break
await game . get_tree ( ) . create_timer ( 0.2 ) . timeout
check ( game . can_respond ( ) and not game . action_button ( " keys_search " ) . disabled , " Real audio completion unlocks answers " )
2026-10-29 22:31:17 +02:00
game . qa_mode = true
start ( 10 , 2 )
for id in [ " keys_fast " , " lamp_fast " , " safe " , " front " , " side_open " , " phone_shelf " ] : perform ( id )
game . qa_mode = false
at ( 90.1 )
await game . get_tree ( ) . create_timer ( 8.0 ) . timeout
check ( game . outcome == " connected " and " after_alive " in game . heard , " Production mother reply after impact " )
check ( game . action_button ( " next " ) != null , " Production connected ending overlay " )
game . qa_mode = true
print ( " PHONE_REALTIME complete " )
2026-10-30 12:49:18 +02:00
func realtime_final_check ( ) - > void :
start ( 2 )
wait_for_speech ( )
at ( float ( game . story . timeline . hum ) - 0.5 )
click ( " keys_search " )
var finished_at : Array [ float ] = [ ]
var record_final := func ( ) :
if game . running and game . heard [ - 1 ] == " hum " : finished_at . append ( game . elapsed )
game . voice . finished . connect ( record_final )
await game . get_tree ( ) . create_timer ( 10.0 ) . timeout
game . voice . finished . disconnect ( record_final )
check ( game . impacted and game . heard [ - 1 ] == " hum " , " Real late Katya request ends with mother's final line " )
check ( finished_at . size ( ) == 1 , " Real final mother recording finishes without interruption " )
if finished_at . size ( ) == 1 :
var gap := float ( game . story . timeline . impact ) - finished_at [ 0 ]
check ( gap > = 5.0 , " Real final line still leaves five seconds before explosion " )
print ( " PHONE_FINAL_REALTIME gap= " , gap )
check ( " keys_search_m " not in game . heard and not game . items . has ( " keys " ) , " Real deferred reply cannot replace final mother line " )
2026-10-29 22:31:17 +02:00
func run ( target : Node ) - > void :
game = target
DirAccess . make_dir_recursive_absolute ( directory ( ) )
check ( game . story . chapters . size ( ) == 10 , " Ten chapters " )
2026-10-30 01:03:42 +02:00
check ( game . story . lines . size ( ) == 110 , " All 110 spoken lines " )
2026-10-29 22:31:17 +02:00
for id in game . story . lines :
check ( game . voice_stream ( id ) != null and game . voice_length ( id ) > 0.1 , " Playable audio " + id )
2026-10-30 00:23:30 +02:00
var voices : Dictionary = JSON . parse_string ( FileAccess . get_file_as_string ( " res://data/voice_manifest.json " ) )
var jessica_count := 0
2026-10-30 00:43:57 +02:00
var carol_count := 0
2026-10-30 00:23:30 +02:00
for id in game . story . lines :
if game . story . lines [ id ] . speaker == " Катя " :
check ( voices [ id ] . provider == " ElevenLabs " and voices [ id ] . voice_id == " cgSgspJ2msm6clMCkdW9 " , " Jessica assigned: " + id )
jessica_count + = 1
else :
2026-10-30 00:43:57 +02:00
check ( voices [ id ] . provider == " ElevenLabs " and voices [ id ] . voice_id == " 5u41aNhyCU6hXOcjPPv0 " , " Carol assigned: " + id )
carol_count + = 1
2026-10-30 01:03:42 +02:00
check ( jessica_count == 52 , " All 52 Katya lines use Jessica " )
check ( carol_count == 58 , " All 58 mother lines use Carol " )
2026-10-30 00:43:57 +02:00
check ( game . voice_length ( " greeting " ) < = game . story . intro [ 0 ] . at , " Greeting fits before prologue " )
check ( 45 + game . voice_length ( " power " ) < = 51 , " Blackout reaction fits before conversation resumes " )
2026-10-30 01:49:04 +02:00
var warning_at : float = game . story . timeline . hum
check ( 90 - warning_at - game . voice_length ( " hum " ) > = 5 , " At least five seconds after full warning before strike " )
check ( game . hum . stream . get_length ( ) > = 90 - warning_at , " Background hum covers the longer wait until impact " )
2026-10-30 00:23:30 +02:00
for index in range ( game . story . intro . size ( ) ) :
var beat : Dictionary = game . story . intro [ index ]
2026-10-30 01:49:04 +02:00
var next_at : float = game . story . intro [ index + 1 ] . at if index + 1 < game . story . intro . size ( ) else warning_at
2026-10-30 00:43:57 +02:00
if float ( beat . at ) < 45 : next_at = minf ( next_at , 45 )
2026-10-30 00:23:30 +02:00
check ( float ( beat . at ) + game . voice_length ( beat . line ) < = next_at , " Intro line fits before next cue: " + str ( beat . line ) )
2026-10-29 22:31:17 +02:00
await capture ( " phone-menu " )
2026-10-30 12:31:52 +02:00
check ( game . menu_screen == " main " and not game . stage . smartphone . is_visible_in_tree ( ) and not game . stage . mother_phone . is_visible_in_tree ( ) , " Main menu hides the call interface " )
check ( game . menu_content . get_global_rect ( ) . get_center ( ) . distance_to ( game . ui . get_global_rect ( ) . get_center ( ) ) < 2 , " Main menu is centered in the viewport " )
check ( game . stage . menu_mode and game . stage . glow . get_shader_parameter ( " menu_bokeh " ) == 1.0 , " Main menu uses the bokeh background " )
check ( game . action_button ( " start " ) != null and game . action_button ( " quit " ) != null , " Main menu offers start and exit " )
2026-10-30 00:43:57 +02:00
click ( " settings " )
2026-10-30 12:31:52 +02:00
check ( game . menu_screen == " settings " and not game . stage . call_layout . visible , " Settings stay on the menu background " )
2026-10-30 00:43:57 +02:00
await capture ( " phone-credits " )
click ( " back_menu " )
2026-10-30 12:31:52 +02:00
click ( " testing " )
check ( game . menu_screen == " testing " , " Scene selection opens from main menu " )
await capture ( " phone-scene-menu " )
await escape ( )
check ( game . menu_screen == " main " , " Escape returns from scene selection to main menu " )
2026-10-30 01:38:31 +02:00
game . dial_call ( 1 , true , 0 , true )
check ( game . dialing and not game . running , " Dial animation precedes the 90-second clock " )
2026-10-30 01:49:04 +02:00
check_clocks ( " " , " hidden before connection " )
2026-10-30 01:38:31 +02:00
check ( game . stage . mother_status . text == " Входящий звонок " , " Mother sees incoming daughter call " )
await game . get_tree ( ) . create_timer ( 0.55 ) . timeout
await capture ( " phone-dialing " )
await game . get_tree ( ) . create_timer ( 1.9 if DisplayServer . get_name ( ) == " headless " else 1.5 ) . timeout
check ( game . running and not game . dialing and game . elapsed < 1.0 , " Connection starts a fresh full attempt " )
2026-10-30 01:49:04 +02:00
check_clocks ( " 00:00 " , " first connection " )
2026-10-30 01:38:31 +02:00
check ( " greeting " in game . heard , " Mother answers after connection " )
2026-10-30 12:31:52 +02:00
check ( game . menu_screen . is_empty ( ) and game . stage . call_layout . visible and not game . stage . menu_mode , " Call restores the gameplay background " )
2026-10-30 01:38:31 +02:00
game . stage . update ( 1.0 )
check ( game . stage . purple_level > game . stage . pink_level , " Mother lights the violet background " )
await capture ( " phone-mother-voice " )
at ( 4.0 )
game . stage . update ( 1.0 )
check ( game . stage . pink_level > game . stage . purple_level , " Katya lights the pink background " )
await capture ( " phone-katya-voice " )
2026-10-30 01:03:42 +02:00
start ( 2 )
var blocked : Button = game . action_button ( " keys_search " )
check ( blocked != null and blocked . disabled , " Choices visible but disabled during greeting " )
await capture ( " phone-locked-answers " )
blocked . pressed . emit ( )
game . choose_action ( " keys_search " )
check ( game . busy . is_empty ( ) and game . heard == [ " greeting " ] , " Early clicks cannot cut off a speaker " )
at ( game . speech_until - 0.02 )
check ( game . action_button ( " keys_search " ) . disabled , " Still blocked before audio end " )
wait_for_speech ( )
check ( not game . action_button ( " keys_search " ) . disabled , " Choices enabled after complete opening exchange " )
2026-10-30 01:38:31 +02:00
await capture ( " phone-answer-cloud " )
for answer in game . command_list . get_children ( ) :
if answer is Button : check ( not answer . text . ends_with ( " с " ) , " Answer has no duration: " + answer . text )
if DisplayServer . get_name ( ) != " headless " :
var tag : Button = game . action_button ( " keys_search " )
# Keep the user's physical cursor from cancelling the timed synthetic hover.
# Click dispatch is still checked through the real viewport just below.
game . command_list . mouse_filter = Control . MOUSE_FILTER_IGNORE
await render ( )
game . command_list . hovered = null
game . command_list . pointer_inside = false
var previous : Vector2 = tag . position
await game . get_tree ( ) . create_timer ( 0.65 ) . timeout
check ( tag . position . distance_to ( previous ) > 0.1 , " Answer tags drift gently " )
var pointer := InputEventMouseMotion . new ( )
pointer . position = tag . position + tag . size / 2
game . command_list . _gui_input ( pointer )
await game . get_tree ( ) . create_timer ( 0.45 ) . timeout
check ( tag . scale . x > 1.08 , " Hovered answer grows " )
var held : Vector2 = tag . position
await game . get_tree ( ) . create_timer ( 0.25 ) . timeout
check ( tag . position . distance_to ( held ) < 0.1 , " Hovered answer holds still for clicking " )
await capture ( " phone-answer-hover " )
pointer = InputEventMouseMotion . new ( )
pointer . position = Vector2 ( - 20 , - 20 )
game . command_list . _gui_input ( pointer )
await game . get_tree ( ) . create_timer ( 0.5 ) . timeout
check ( tag . scale . x < 1.08 , " Answer returns to its depth after hover " )
game . command_list . mouse_filter = Control . MOUSE_FILTER_STOP
await render ( )
var press := InputEventMouseButton . new ( )
press . button_index = MOUSE_BUTTON_LEFT
press . position = tag . get_global_rect ( ) . get_center ( )
press . pressed = true
game . get_viewport ( ) . push_input ( press , true )
var release := InputEventMouseButton . new ( )
release . button_index = MOUSE_BUTTON_LEFT
release . position = press . position
release . pressed = false
game . get_viewport ( ) . push_input ( release , true )
check ( game . busy . get ( " id " , " " ) == " keys_search " , " Mouse selects the visible floating answer " )
start ( 2 )
wait_for_speech ( )
await render ( )
2026-10-30 12:31:52 +02:00
check ( game . stage . memory_button . size . x > = 100 and game . action_button ( " menu " ) == null , " Call screen keeps memory without a menu button " )
2026-10-30 01:38:31 +02:00
if DisplayServer . get_name ( ) != " headless " :
var original_size := DisplayServer . window_get_size ( )
DisplayServer . window_set_size ( Vector2i ( 1366 , 768 ) )
await capture ( " phone-wide-layout " )
check ( game . ui . get_global_rect ( ) . encloses ( game . stage . mother_phone . get_global_rect ( ) ) , " Mother phone fits wide viewport " )
check ( game . ui . get_global_rect ( ) . encloses ( game . stage . smartphone . get_global_rect ( ) ) , " Katya phone fits wide viewport " )
DisplayServer . window_set_size ( original_size )
await render ( )
2026-10-30 12:31:52 +02:00
var chapter_before_menu : int = game . chapter
var elapsed_before_menu : float = game . elapsed
await escape ( )
check ( game . menu_screen == " main " and game . action_button ( " resume " ) != null , " Escape opens menu during a call " )
check ( not game . stage . call_layout . visible and game . action_button ( " keys_search " ) == null , " Menu hides gameplay choices " )
await capture ( " phone-menu-during-call " )
at ( elapsed_before_menu + 1.0 )
check ( game . elapsed > = elapsed_before_menu + 1.0 and game . running , " Call clock continues in menu " )
click ( " resume " )
check ( game . menu_screen . is_empty ( ) and game . stage . call_layout . visible and game . chapter == chapter_before_menu , " Resume restores the same call " )
await escape ( )
await escape ( )
check ( game . menu_screen . is_empty ( ) and game . running , " Escape also returns directly to the call " )
2026-10-30 01:38:31 +02:00
var cloud_rect : Rect2 = game . stage . choice_scroll . get_global_rect ( )
check ( cloud_rect . position . y > game . transcript_scroll . get_global_rect ( ) . position . y , " Answers below central dialogue " )
for child in game . command_list . get_children ( ) :
if child is Button :
check ( child . get_global_rect ( ) . position . x > = cloud_rect . position . x and child . get_global_rect ( ) . end . x < = cloud_rect . end . x + 1 , " Answer fits cloud width: " + child . text )
click ( " memory " )
check ( game . action_button ( " close_memory " ) != null , " Notebook opens from call screen " )
click ( " close_memory " )
2026-10-30 01:03:42 +02:00
click ( " keys_search " )
2026-10-30 12:49:18 +02:00
check ( game . action_button ( " cancel " ) == null , " No change-answer control " )
game . choose_action ( " lamp_search " )
check ( game . busy . get ( " id " ) == " keys_search " , " Chosen request cannot be replaced while speaking " )
at ( game . speech_until + 0.1 )
game . choose_action ( " lamp_search " )
check ( game . busy . get ( " id " ) == " keys_search " and not game . can_respond ( ) , " Chosen request stays locked during the search " )
2026-10-30 01:03:42 +02:00
at ( game . reply_at + 0.01 )
2026-10-30 12:49:18 +02:00
check ( not game . can_respond ( ) , " Mother's answer cannot be interrupted by a choice " )
2026-10-30 01:03:42 +02:00
at ( game . busy_end + 0.12 )
check ( game . can_respond ( ) , " Next choices enabled after response and task completion " )
start ( 1 )
check ( game . soundscape . streams . size ( ) == 16 , " All ambience and foley assets loaded " )
check ( game . soundscape . beds . fridge . playing and game . soundscape . beds . tv . playing , " Powered room starts alive " )
check ( game . soundscape . duck_db < = - 11.9 , " Background ducks under spoken greeting " )
game . soundscape . update_mix ( 0.5 , false )
check ( game . soundscape . duck_db > - 11 and game . soundscape . duck_db < 0 , " Background recovers gently after speech " )
game . soundscape . dialogue_started ( - 40 )
check ( game . soundscape . duck_db < = - 23.9 , " Very quiet voices receive extra background attenuation " )
game . soundscape . set_volume ( 0 )
check ( AudioServer . get_bus_volume_db ( game . soundscape . scene_bus ) < = - 79 , " Independent background mute " )
game . soundscape . set_volume ( 0.75 )
at ( 36.1 )
check ( game . soundscape . history . any ( func ( cue ) : return cue . id == " kettle " ) , " Kettle follows the shared call clock " )
at ( 45.01 )
check ( not game . soundscape . beds . fridge . playing and not game . soundscape . beds . tv . playing , " Power cut silences appliances " )
check ( game . soundscape . beds . room . playing and game . soundscape . beds . line . playing , " Room and telephone survive power cut " )
finish ( " flat " )
check ( not game . soundscape . active and game . soundscape . queue . is_empty ( ) , " Strike stops room and all pending sounds " )
start ( 2 )
perform ( " keys_search " )
check ( game . soundscape . history . any ( func ( cue ) : return cue . id == " keys " ) , " Key sound follows actual search " )
click ( " lamp_search " )
2026-10-30 12:49:18 +02:00
at ( float ( game . story . timeline . hum ) + 0.01 )
check ( not game . soundscape . queue . any ( func ( cue ) : return cue . task ) , " Final reaction discards pending action sounds " )
2026-10-30 00:43:57 +02:00
# Every redial repeats the same external world, including the first call.
for number in range ( 1 , 11 ) :
start ( number )
2026-10-30 01:49:04 +02:00
check_clocks ( " 00:00 " , " reset in call " + str ( number ) )
at ( 0.95 )
check_clocks ( " 00:00 " , " before first full second " )
at ( 1.05 )
check_clocks ( " 00:01 " , " one elapsed second " )
2026-10-30 00:43:57 +02:00
at ( 23.99 )
check ( not game . fired . has ( " alarm " ) , " No early siren: " + str ( number ) )
at ( 24.01 )
check ( game . fired . get ( " alarm " ) == 24.0 , " Same siren time: " + str ( number ) )
2026-10-30 01:38:31 +02:00
check ( game . siren . playing and game . siren . volume_db < - 60 , " Siren starts softly: " + str ( number ) )
at ( 27 )
2026-10-30 12:26:10 +02:00
check ( game . siren . volume_db > - 20 and game . siren . volume_db < - 10 , " Siren rises gradually: " + str ( number ) )
2026-10-30 01:38:31 +02:00
at ( 30 )
2026-10-30 12:26:10 +02:00
check ( absf ( game . siren . volume_db + 8 ) < 0.1 , " Siren reaches audible background level: " + str ( number ) )
2026-10-30 00:43:57 +02:00
at ( 44.99 )
2026-10-30 12:26:10 +02:00
check ( not game . fired . has ( " power " ) and game . soundscape . powered , " Lights stay on until 45: " + str ( number ) )
2026-10-30 00:43:57 +02:00
at ( 45.01 )
2026-10-30 12:26:10 +02:00
check ( game . fired . get ( " power " ) == 45.0 and game . archive . any ( func ( line ) : return line . text . begins_with ( " Свет в квартире погас. " ) ) , " Same visible blackout: " + str ( number ) )
2026-10-30 00:43:57 +02:00
check ( " power " in game . heard , " Mother acknowledges blackout: " + str ( number ) )
2026-10-30 01:49:04 +02:00
at ( 59.95 )
check_clocks ( " 00:59 " , " before minute rollover " )
at ( 60.05 )
check_clocks ( " 01:00 " , " minute rollover " )
at ( warning_at - 0.01 )
2026-10-30 00:43:57 +02:00
check ( not game . fired . has ( " hum " ) , " No early hum: " + str ( number ) )
2026-10-30 01:49:04 +02:00
at ( warning_at + 0.01 )
check ( game . fired . get ( " hum " ) == warning_at , " Same hum time: " + str ( number ) )
at ( warning_at + game . voice_length ( " hum " ) + 0.01 )
check ( not game . impacted and game . heard [ - 1 ] == " hum " , " Full warning leaves time before impact: " + str ( number ) )
2026-10-30 00:43:57 +02:00
at ( 89.99 )
2026-10-30 01:49:04 +02:00
check_clocks ( " 01:29 " , " last second of call " )
2026-10-30 00:43:57 +02:00
check ( not game . impacted , " No early strike: " + str ( number ) )
finish ( " flat " )
2026-10-30 01:49:04 +02:00
check_clocks ( " 01:30 " , " duration held after disconnect " )
at ( 95 )
check_clocks ( " 01:30 " , " post-call notifications do not advance duration " )
2026-10-30 00:43:57 +02:00
check ( game . fired . get ( " impact " ) == 90.0 , " Same strike time: " + str ( number ) )
start ( 1 )
at ( 45.01 )
await capture ( " phone-first-blackout " )
start ( 2 )
at ( 45.01 )
await capture ( " phone-second-blackout " )
start ( 2 )
at ( 38 )
click ( " keys_search " )
at ( 45.01 )
check ( not game . busy . is_empty ( ) and " power " not in game . heard , " Blackout does not interrupt an unrelated spoken task " )
2026-10-30 12:26:10 +02:00
check ( game . fired . get ( " power " ) == 45.0 and not game . soundscape . powered , " Busy task cannot postpone blackout " )
2026-10-29 22:31:17 +02:00
for number in range ( 1 , 11 ) :
start ( number )
check ( game . chapter == number and game . place == " flat " and game . items . is_empty ( ) , " Fresh chapter " + str ( number ) )
check ( game . heard == [ " greeting " ] , " Identical opening " + str ( number ) )
if number == 1 :
check ( game . action_button ( " keys_search " ) == null , " Prologue has no commands " )
2026-10-30 01:49:04 +02:00
check_clocks ( " 00:00 " , " prologue shows duration " )
2026-10-29 22:31:17 +02:00
for beat in game . story . intro : at ( beat . at + 0.01 )
2026-10-30 01:03:42 +02:00
check ( game . heard . size ( ) == 19 and " power " in game . heard , " Ordinary conversation and blackout acknowledgement " )
2026-10-29 22:31:17 +02:00
else :
var entry : Dictionary = game . story . chapters [ number - 1 ]
var opening_at : float = game . events [ 0 ] . at
var reply_time : float = game . events [ 1 ] . at
check ( opening_at > = game . voice_length ( " greeting " ) , " Greeting is not truncated " )
at ( opening_at + 0.01 )
at ( reply_time + 0.01 )
check ( entry . opening in game . heard and entry . reply in game . heard , " Unique opening " + str ( number ) )
perform ( " question " )
check ( entry . question in game . heard and entry . answer in game . heard , " Unique exchange " + str ( number ) )
2026-10-30 01:49:04 +02:00
at ( warning_at + 0.01 )
2026-10-29 22:31:17 +02:00
check ( game . heard [ - 1 ] == " hum " , " Hum before strike " )
finish ( " flat " )
await capture ( " phone-ending " )
# Learn through real commands. Precise instructions require discoveries,
# rather than the chapter index or a hidden action.
start ( 2 )
check ( game . action_button ( " safe " ) == null , " Safe requires remembered code " )
game . choose_action ( " safe " )
check ( game . busy . is_empty ( ) , " Hidden action rejected " )
perform ( " keys_search " )
check ( game . facts . has ( " keys " ) and game . items . has ( " keys " ) , " Key discovery " )
perform ( " lamp_search " )
check ( game . facts . has ( " lamp " ) and game . items . has ( " lamp " ) , " Lamp discovery " )
finish ( " flat " )
click ( " next " )
check ( game . chapter == 3 and game . facts . has ( " keys " ) and game . items . is_empty ( ) , " Redial remembers knowledge only " )
check ( game . action_button ( " keys_fast " ) != null and game . action_button ( " keys_search " ) == null , " Shortcut replaces slow search " )
start ( 4 )
perform ( " mail_hint " )
perform ( " read_mail " )
check ( game . facts . has ( " code " ) , " Code obtainable before blackout " )
at ( 45.01 )
check ( game . action_button ( " read_mail " ) == null , " No laptop after blackout " )
finish ( " flat " )
click ( " next " )
perform ( " safe " )
check ( game . items . has ( " spare " ) and game . facts . has ( " route " ) , " Code opens safe on next call " )
start ( 4 )
perform ( " mail_hint " )
at ( 40 )
click ( " read_mail " )
at ( 46 )
check ( game . busy . is_empty ( ) and not game . facts . has ( " code " ) , " Power cancels unfinished mail " )
check ( " late_mail " in game . heard , " Power failure dialogue " )
start ( 4 , 2 )
game . facts . erase ( " code " )
at ( 28 )
click ( " read_mail " )
check ( game . busy_end < 45 , " Mail scheduled before blackout " )
at ( 46 )
check ( game . facts . has ( " code " ) , " Late frame preserves pre-blackout completion " )
start ( 5 , 2 )
perform ( " keys_fast " )
click ( " front " )
at ( 92 )
check ( game . outcome == " landing " , " Late frame resolves movement before impact " )
2026-10-30 12:49:18 +02:00
# The final mother line always wins, including a request spoken by Katya
# at the boundary and a queued answer that would overlap the ending.
for number in range ( 2 , 11 ) :
start ( number )
wait_for_speech ( )
at ( warning_at - 0.5 )
click ( " keys_search " )
check ( game . stage . speaker == " Катя " and game . speech_until > warning_at , " Late Katya request crosses final cue: " + str ( number ) )
at ( warning_at + 0.01 )
check ( game . heard [ - 1 ] == " hum " and game . stage . speaker == " Мама " , " Mother interrupts Katya at final cue: " + str ( number ) )
check ( game . busy . is_empty ( ) and game . events . is_empty ( ) and game . command_list . get_child_count ( ) == 0 , " Final sequence clears pending choices: " + str ( number ) )
game . choose_action ( " speak_love " )
game . say ( " here " )
at ( 89.99 )
check ( game . heard [ - 1 ] == " hum " and game . heard . count ( " hum " ) == 1 and not game . can_respond ( ) , " Nothing replaces the final line: " + str ( number ) )
finish ( " flat " )
check ( not game . items . has ( " keys " ) and not game . facts . has ( " keys " ) , " Interrupted request grants nothing: " + str ( number ) )
2026-10-29 22:31:17 +02:00
start ( 2 )
2026-10-30 12:49:18 +02:00
wait_for_speech ( )
var search : Dictionary = game . story . actions . filter ( func ( action ) : return action . id == " keys_search " ) [ 0 ]
at ( warning_at - game . action_duration ( search ) + game . voice_length ( search . response ) * 0.5 )
2026-10-29 22:31:17 +02:00
click ( " keys_search " )
2026-10-30 12:49:18 +02:00
check ( game . reply_at < warning_at and game . busy_end > warning_at , " Mother reply would overlap the final cue " )
at ( game . reply_at + 0.01 )
check ( search . response not in game . heard , " Do not start a mother reply that cannot finish before the final phrase " )
at ( 89.99 )
check ( game . heard [ - 1 ] == " hum " and not game . items . has ( " keys " ) , " Skipped reply cannot overtake final phrase or grant an item " )
2026-10-29 22:31:17 +02:00
finish ( " flat " )
start ( 3 )
perform ( " inner " )
finish ( " inner " )
start ( 5 )
perform ( " keys_search " )
perform ( " front " )
perform ( " stairs " )
2026-10-30 01:03:42 +02:00
check ( game . facts . has ( " stairs " ) , " Unlit intact stairs discovered " )
check ( " целая " in game . story . facts . stairs and " завален " not in game . story . facts . stairs , " Stairwell is intact " )
await capture ( " phone-dark-stairwell " )
2026-10-29 22:31:17 +02:00
finish ( " landing " )
# Full route with learned facts is feasible at normal production durations,
# including both speakers' complete audio lengths.
start ( 7 , 2 )
game . facts . erase ( " latch " )
for id in [ " keys_fast " , " lamp_fast " , " safe " , " front " , " side_try " ] : perform ( id )
check ( game . facts . has ( " latch " ) , " Latch discovered from physical attempt " )
finish ( " landing " )
click ( " next " )
for id in [ " keys_fast " , " lamp_fast " , " safe " , " front " , " side_open " ] : perform ( id )
check ( game . place == " alcove " and game . elapsed < 75 , " Reach alcove in time " )
finish ( " alcove " )
start ( 8 , 2 )
game . facts . erase ( " signal " )
for id in [ " keys_fast " , " lamp_fast " , " safe " , " front " , " side_open " , " phone_test " ] : perform ( id )
check ( game . facts . has ( " signal " ) , " Signal location found " )
perform ( " phone_shelf " )
check ( game . items . has ( " connected " ) and game . elapsed < 90 , " Reach responsive ending through discovery " )
var route_time : float = game . elapsed
await capture ( " phone-gameplay " )
finish ( " connected " )
await capture ( " phone-connected " )
# A late frame cannot complete a task after the impact. Old callbacks and
# popup buttons cannot apply a task twice.
start ( 10 , 2 )
2026-10-30 12:49:18 +02:00
at ( 80 )
2026-10-29 22:31:17 +02:00
click ( " safe " )
at ( 92 )
check ( game . outcome == " flat " and not game . items . has ( " spare " ) , " Low-FPS deadline wins over pending safe " )
game . choose_action ( " keys_fast " )
check ( game . busy . is_empty ( ) , " Post-impact commands ignored " )
var save_file := directory ( ) . path_join ( " phone-profile-test.cfg " )
check ( game . Profile . write_profile ( save_file , { " code " : true } , { " connected " : true } , 10 ) == OK , " Profile writes " )
var saved : Dictionary = game . Profile . read_profile ( save_file , game . story . facts , game . story . endings )
check ( saved . facts == { " code " : true } and saved . endings == { " connected " : true } and saved . loops == 10 , " Profile disk roundtrip " )
var cfg := ConfigFile . new ( )
cfg . set_value ( " save " , " facts " , { " code " : 1 , " unknown " : true , " lamp " : true } )
cfg . set_value ( " save " , " loops " , - 3 )
cfg . save ( save_file )
saved = game . Profile . read_profile ( save_file , game . story . facts , game . story . endings )
check ( saved . facts == { " lamp " : true } and saved . loops == 0 , " Invalid save data filtered " )
2026-10-29 22:36:22 +02:00
# Notifications are an independent clock: four during the call, the fifth
# two seconds after the strike. Reading never pauses or cancels mom's task.
start ( 2 )
at ( 16.9 )
check ( game . notifications . is_empty ( ) , " No early push " )
at ( 17 )
check ( game . notifications . size ( ) == 1 and game . unread == 1 , " First push at 17 seconds " )
check ( game . notification_card . visible , " Push is visible " )
2026-10-30 01:38:31 +02:00
await render ( )
if DisplayServer . get_name ( ) != " headless " :
check ( game . stage . smartphone . display . get_global_rect ( ) . encloses ( game . notification_card . get_global_rect ( ) ) , " Push stays on Katya's smartphone " )
2026-10-29 22:36:22 +02:00
click ( " dismiss_push " )
check ( not game . notification_card . visible and game . unread == 1 , " Dismiss keeps message unread " )
click ( " keys_search " )
at ( 34 )
check ( game . notifications . size ( ) == 2 and not game . busy . is_empty ( ) , " Second push during mom task " )
click ( " open_push " )
check ( game . viewing_messages and game . unread == 0 , " Open push reads inbox " )
at ( 40 )
check ( game . items . has ( " keys " ) and game . elapsed > = 40 , " Mom task and clock continue while reading " )
click ( " close_messages " )
check ( not game . viewing_messages and game . overlay == null , " Return to call " )
at ( 56 )
check ( game . notifications . size ( ) == 3 , " Third push " )
at ( 76 )
check ( game . notifications . size ( ) == 4 , " Fourth push " )
check ( game . notifications [ 3 ] . text == " Ты читала новости? Там переговоры, походу скоро все закончится " , " Exact fourth text " )
await capture ( " phone-fourth-push " )
at ( 90 )
check ( game . impacted and game . notifications . size ( ) == 4 , " No fifth message before impact " )
at ( 91.9 )
check ( game . notifications . size ( ) == 4 , " Fifth push waits until after impact " )
game . show_ending ( )
at ( 92 )
check ( game . notifications . size ( ) == 5 and game . notification_card . visible , " Fifth push over ending screen " )
check ( game . notifications [ 4 ] . text == " Кать в твой дом походу попали... " , " Exact fifth text " )
await capture ( " phone-after-impact-push " )
2026-10-30 01:38:31 +02:00
if DisplayServer . get_name ( ) != " headless " :
check ( game . notification_card . size . y < 300 , " Toast stays compact across all five pushes " )
2026-10-29 22:36:22 +02:00
click ( " open_push " )
check ( game . viewing_messages and game . notifications . size ( ) == 5 , " All messages readable after impact " )
await capture ( " phone-inbox " )
at ( 96 )
check ( game . notifications . size ( ) == 5 , " No duplicate messages " )
click ( " close_messages " )
click ( " next " )
check ( game . notifications . is_empty ( ) and game . unread == 0 and not game . notification_card . visible , " Redial resets message history " )
# Use the production delayed transition once: a reader who opens the final
# push must not have the inbox closed by the ending coroutine a moment later.
start ( 2 )
game . qa_mode = false
at ( 90 )
await game . get_tree ( ) . create_timer ( 2.2 ) . timeout
check ( game . notifications . size ( ) == 5 and game . notification_card . visible , " Production post-impact push arrives " )
click ( " open_push " )
await game . get_tree ( ) . create_timer ( 8.0 ) . timeout
check ( game . viewing_messages and game . action_button ( " close_messages " ) != null , " Ending transition preserves open inbox " )
click ( " close_messages " )
check ( game . action_button ( " next " ) != null , " Inbox returns to production ending " )
game . qa_mode = true
2026-10-30 12:31:52 +02:00
start ( 2 )
await escape ( )
game . qa_mode = false
at ( 90.1 )
await game . get_tree ( ) . create_timer ( 9.0 ) . timeout
check ( game . impacted and game . menu_screen == " main " , " Impact and ending transition preserve the open menu " )
check ( game . action_button ( " resume " ) . text == " Итоги звонка " , " Menu updates its return action after disconnect " )
click ( " resume " )
check ( game . menu_screen . is_empty ( ) and game . action_button ( " next " ) != null , " Menu returns to the completed call outcome " )
game . qa_mode = true
2026-10-30 12:49:18 +02:00
await realtime_final_check ( )
2026-10-29 22:31:17 +02:00
if " --phone-real-time " in OS . get_cmdline_user_args ( ) :
await realtime_check ( )
var file := FileAccess . open ( directory ( ) . path_join ( " phone-result.json " ) , FileAccess . WRITE )
file . store_string ( JSON . stringify ( { " passed " : errors . is_empty ( ) , " checks " : checks , " errors " : errors , " routes " : results , " full_route_seconds " : route_time } , " " ) )
file . close ( )
print ( " PHONE_QA " , " PASS " if errors . is_empty ( ) else " FAIL " , " checks= " , checks , " route= " , route_time , " errors= " , errors )
await render ( )
2026-10-30 01:03:42 +02:00
game . soundscape . stop ( )
for player in [ game . voice , game . siren , game . effect , game . hum , game . notification_sound ] :
2026-10-29 22:31:17 +02:00
player . stop ( )
player . stream = null
await game . get_tree ( ) . create_timer ( 0.1 ) . timeout
var tree : SceneTree = game . get_tree ( )
game = null
tree . quit ( 0 if errors . is_empty ( ) else 1 )