Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions daslib/imgui_editor_playwright.das
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ def public ne_wait_widget(s : EditorSession; subpath : string; timeout_sec : flo
return wait_for_widget(s.app, "{s.canvas}/{subpath}", timeout_sec)
}

def public ne_wait_visible(s : EditorSession; subpath : string; timeout_sec : float = 6.0f) : JsonValue? {
//! Poll until `{canvas}/{subpath}` is present AND painted this frame. Use for re-showable
//! widgets (context-menu items, popups): existence-only (ne_wait_widget) can stale-pass on a
//! cached registry entry before the menu actually repaints.
return wait_for_visible(s.app, "{s.canvas}/{subpath}", timeout_sec)
}

def public ne_wait_selected(s : EditorSession; id : int; timeout_sec : float = 5.0f) : JsonValue? {
//! Poll until node `id` is selected. Gate a selection-dependent chord (Ctrl+D / Ctrl+C) on
//! the click's real effect, not a frame/time guess. Returns the snapshot, or null on timeout.
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_context_menus.das
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_context_menus(t : T?) {

// ---- node menu: right-click node A's body, pick "Delete node" ----
right_click(d, node_center(snap, "{canvas}/node_1"))
var menuSnap = ne_wait_widget(s, "NODE_MENU/DEL_ITEM", 6.0f)
var menuSnap = ne_wait_visible(s, "NODE_MENU/DEL_ITEM", 6.0f)
t |> success(menuSnap != null, "right-click on node opened its context menu")
click(d, del_item)
var gone = wait_until_sec(d, 6.0f) $(var sn) {
Expand All @@ -58,7 +58,7 @@ def test_context_menus(t : T?) {

// ---- background menu: right-click empty canvas, pick "Node" ----
right_click(d, (720.0, 430.0))
var bgSnap = ne_wait_widget(s, "BG_MENU/ADD_ITEM", 6.0f)
var bgSnap = ne_wait_visible(s, "BG_MENU/ADD_ITEM", 6.0f)
t |> success(bgSnap != null, "right-click on empty canvas opened the background menu")
click(d, add_item)
var spawned = ne_wait_widget(s, "node_200", 6.0f)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_delete_and_select.das
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_delete_and_select(t : T?) {
var ev : array<JsonValue?>
ev |> click_at(0, (title_x, title_y), 200, 0)
post_command(d, "imgui_mouse_play", JV((events = ev)))
wait_for_mouse_idle(d)
let selected = wait_until_sec(d, 6.0f) $(var sn) {
return find_widget(sn, "{canvas}/node_2")?["payload"]?["selected"] ?? false
}
Expand All @@ -46,6 +47,7 @@ def test_delete_and_select(t : T?) {
let del = int(ImGuiKey.Delete)
post_command(d, "imgui_key_press", JV((key = del)))
post_command(d, "imgui_key_release", JV((key = del)))
wait_for_key_idle(d, 4.0f)
var gone = wait_until_sec(d, 6.0f) $(var sn) {
return !widget_exists(sn, "{canvas}/node_2")
}
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/test_shader_graph.das
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,11 @@ def test_shader_graph(t : T?) {
var ev : array<JsonValue?>
ev |> click_at(0, (900.0, 450.0), 150, 1)
post_command(d, "imgui_mouse_play", JV((events = ev)))
wait_for_mouse_idle(d)

// The right-click opens the popup → its menu_labels register.
var snapMenu = ne_wait_widget(s, "BG_CTX/CREATE_TEX", 6.0f)
// The right-click popup is re-showable — gate on actual paint, not stale registry
// existence (ne_wait_widget can pass on a cached menu entry from a prior open).
var snapMenu = ne_wait_visible(s, "BG_CTX/CREATE_TEX", 6.0f)
t |> success(snapMenu != null, "right-click opened the Create-Node menu")
if (snapMenu != null) {
t |> success(widget_exists(snapMenu, "{s.canvas}/BG_CTX/CREATE_ADD"),
Expand Down Expand Up @@ -356,8 +358,8 @@ def test_shader_graph(t : T?) {
// Inject a drag-release from pin 8 (Multiply's output) dropped at canvas (600,450).
ne_new_node_drag(s, 8, 600.0, 450.0)

// The release opens the Create+Connect menu → its items register at full path.
var snapMenu = ne_wait_widget(s, "BG_CTX/CREATE_ADD", 6.0f)
// The release opens the Create+Connect menu (re-showable popup) → gate on paint.
var snapMenu = ne_wait_visible(s, "BG_CTX/CREATE_ADD", 6.0f)
t |> success(snapMenu != null, "drag-release opened the create-node menu")
if (snapMenu != null) {
// Telemetry: the editor recorded the drag (source pin + drop point).
Expand Down
2 changes: 1 addition & 1 deletion utils/node_editor2rst.das
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def document_module_imgui_editor_playwright() {
group_by_regex("Session", mod, %regex~^ne_open$%%),
group_by_regex("Actions", mod, %regex~^(ne_select_node|ne_select_link|ne_clear_selection|ne_shortcut|ne_add_link|ne_delete_node|ne_delete_link|ne_move_node|ne_new_node_drag|ne_flow)$%%),
group_by_regex("Snapshots & queries", mod, %regex~^(ne_snapshot|ne_node_count|ne_payload|ne_node|ne_node_exists|ne_node_selected)$%%),
group_by_regex("Polling / await", mod, %regex~^(ne_wait_widget|ne_wait_selected|ne_wait_payload_str|ne_wait_shortcut)$%%),
group_by_regex("Polling / await", mod, %regex~^(ne_wait_widget|ne_wait_visible|ne_wait_selected|ne_wait_payload_str|ne_wait_shortcut)$%%),
hide_group(group_by_regex("Internal", mod, %regex~^(_|priv_).*%%))
)
document("Editor playwright — node-editor-aware test layer over imgui_playwright (EditorSession + ne_* helpers)", mod, "imgui_editor_playwright.rst", groups)
Expand Down
Loading