extends SceneTree const EntryShell = preload("res://entry/entry_shell.gd") const SettingsStore = preload("res://entry/settings_store.gd") const DraftService = preload("res://entry/initial_company_draft_service.gd") const DRAFT_PATH := "user://dev2_company_commit_touch_draft.json" const COMPANY_PATH := "user://dev2_company_commit_touch_company.json" const SEED := "0f1e2d3c4b5a69788796a5b4c3d2e1f0" var failures: Array[String] = [] func _initialize() -> void: call_deferred("run_test") func run_test() -> void: root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS # Single target size (owner policy): every screen is authored at 1280x720. root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_KEEP root.content_scale_size = Vector2i(1280, 720) root.size = Vector2i(1280, 720) _cleanup() var service = DraftService.new() service.path = DRAFT_PATH service.company_path = COMPANY_PATH service.begin_or_load(SEED) var shell = EntryShell.new() shell.auto_start = false shell.initial_company_service.path = DRAFT_PATH shell.initial_company_service.company_path = COMPANY_PATH root.add_child(shell) await _frames(3) shell.settings = SettingsStore.new().defaults() shell.settings.setup_completed = true shell.settings.locale = "en" shell.show_title() await _frames(2) await _touch(shell.find_child("TitleNewGame", true, false)) var page = shell.initial_company_page await _touch(page.find_child("CandidateSelect_0", true, false)) await _touch(page.find_child("CandidateSelect_2", true, false)) await _touch(page.find_child("ReviewCompany", true, false)) expect(page.mode == "review", "parsed touch reaches Review") await _touch(page.find_child("ReviewRevise", true, false)) expect(page.mode == "choice" and page.draft.selected_offer_ids.size() == 2, "parsed touch Revise keeps the pair") await _touch(page.find_child("ReviewCompany", true, false)) await _touch(page.find_child("CreateCompany", true, false)) expect(shell.current_screen == "guild_handoff", "parsed touch creates the Company and reaches Guild") await _touch(shell.find_child("GuildSettings", true, false)) expect(shell.current_screen == "settings", "parsed touch opens Settings from Guild") await _touch(shell.find_child("SettingsBack", true, false)) expect(shell.current_screen == "guild_handoff", "parsed touch Settings Back returns to Guild") await _touch(shell.find_child("GuildTitle", true, false)) expect(shell.current_screen == "title", "parsed touch reaches Title from Guild") await _touch(shell.find_child("TitleContinue", true, false)) expect(shell.current_screen == "guild_handoff", "parsed touch Continue returns to Guild") var loaded: Dictionary = service.load_company() expect(loaded.ok and loaded.company.owned_recruits.size() == 2, "touch path persisted exactly two Company members") shell.queue_free() await _frames(3) _cleanup() if failures.is_empty(): print("ABG_DEV2_COMMIT_TOUCH_OK parsed_screen_touch=true review_revise_create_guild_settings_title_continue=true") quit(0) else: for failure in failures: push_error(failure) quit(1) func _touch(control: Control) -> void: var center := root.get_final_transform() * control.get_global_rect().get_center() var press := InputEventScreenTouch.new() press.position = center press.pressed = true press.index = 0 Input.parse_input_event(press) await _frames(2) var release := InputEventScreenTouch.new() release.position = center release.pressed = false release.index = 0 Input.parse_input_event(release) await _frames(5) func _cleanup() -> void: for base in [DRAFT_PATH, COMPANY_PATH]: for suffix in ["", ".bak", ".candidate", ".bak.candidate", ".corrupt"]: var file_path := "%s%s" % [base, suffix] if FileAccess.file_exists(file_path): DirAccess.remove_absolute(file_path) func _frames(count: int) -> void: for frame in range(count): await process_frame func expect(condition: bool, message: String) -> void: if not condition: failures.append("DEV-2 Company commit touch: %s" % message)