utils/kuhy_credit/godot/tests/test_demo_e2e.gd
Krzysztof kuhy Rudnicki d696189a2e
Some checks are pending
file length / file-length (push) Waiting to run
kuhy_credit drift / drift (push) Waiting to run
kuhy_credit tests / python (push) Waiting to run
kuhy_credit tests / web (push) Waiting to run
kuhy_credit tests / flutter (push) Waiting to run
kuhy_credit tests / godot (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
kuhy_credit: Flutter example, CI fixes
- Flutter example gets its android and web platform dirs (label
  "Credit" for the launcher contract); logo painter moves to a part
  file to stay under 250 lines.
- Godot click tests size the headless window to 640x360 (the official
  build opens 64x64 and drops clicks outside it) and hide GUT's GUI.
- godot/test.sh writes godot output to files, not $(...), and fails
  when fewer tests ran than tests/ declares.
- README Python snippet passes ruff format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:49:46 +01:00

32 lines
1.1 KiB
GDScript

extends "res://tests/click_test.gd"
## E2E: the demo scene, two clicks through the viewport, the URL that would open.
const CreditData = preload("res://addons/kuhy_credit/credit_data.gd")
const Demo = preload("res://demo/demo.tscn")
func _click(at: Vector2) -> void:
for pressed in [true, false]:
var ev := InputEventMouseButton.new()
ev.button_index = MOUSE_BUTTON_LEFT
ev.pressed = pressed
ev.position = at
ev.global_position = at
get_viewport().push_input(ev, true)
await wait_process_frames(2)
func test_two_clicks_open_the_website() -> void:
var demo: Control = Demo.instantiate()
add_child_autofree(demo)
await wait_process_frames(2)
var opened: Array[String] = []
demo.credit.opener = func(url: String) -> void: opened.append(url)
assert_false(demo.credit.is_open())
await _click(demo.credit.logo.get_global_rect().get_center())
assert_true(demo.credit.is_open())
assert_eq(opened, [] as Array[String])
await _click(demo.credit.panel.get_global_rect().get_center())
assert_eq(opened, [CreditData.URL] as Array[String])
assert_false(demo.credit.is_open())