47 lines
1.6 KiB
GDScript
47 lines
1.6 KiB
GDScript
extends SceneTree
|
|
|
|
const NotesEditor := preload("res://scripts/ui/notes_editor.gd")
|
|
const NotesDialog := preload("res://scripts/ui/notes_dialog.gd")
|
|
const NavigationRoutes := preload("res://scripts/ui/navigation_routes.gd")
|
|
|
|
var failures := 0
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
|
|
func _run() -> void:
|
|
var editor := NotesEditor.new()
|
|
root.add_child(editor)
|
|
await process_frame
|
|
_assert(editor.editor != null, "notes editor should create a text editor")
|
|
_assert(editor.editor.wrap_mode == TextEdit.LINE_WRAPPING_BOUNDARY, "notes should wrap plain text")
|
|
_assert(NavigationRoutes.key_for_screen("notes") == "notes", "notes should have a navigation route")
|
|
var notes_service = root.get_node("NotesService")
|
|
var prior_state: String = notes_service.state
|
|
notes_service.state = "offline"
|
|
_assert(notes_service.status_text().is_empty(), "offline note retries should not leave a persistent status message")
|
|
editor._on_save_succeeded()
|
|
_assert(editor.status_label.text == "Saved", "successful remote saves should show a Saved confirmation")
|
|
editor._clear_saved_status()
|
|
_assert(editor.status_label.text.is_empty(), "the Saved confirmation should clear after its display window")
|
|
notes_service.state = prior_state
|
|
|
|
var dialog := NotesDialog.new()
|
|
root.add_child(dialog)
|
|
await process_frame
|
|
_assert(not dialog.visible, "notes dialog should start hidden")
|
|
_assert(dialog.notes_editor != null, "notes dialog should contain the shared editor")
|
|
|
|
editor.queue_free()
|
|
dialog.queue_free()
|
|
quit(1 if failures > 0 else 0)
|
|
|
|
|
|
func _assert(condition: bool, message: String) -> void:
|
|
if condition:
|
|
return
|
|
failures += 1
|
|
push_error(message)
|