Add regression tests for Blade wire:click binding

Covers all three repaired shapes directly: a call with its own
arguments binds the bare name, a directive carrying a modifier like
prevent still binds, and a magic action such as set is left
unbound rather than fabricating an edge to nothing.

(cherry picked from commit 0f7ce0c449)
This commit is contained in:
ayushcodes10 authored and safishamsi committed 2026-10-27 17:21:29 +00:00
1 parent e7f0405934
commit d94f59c713
1 file changed
+41
+41
View File
@@ -31,3 +31,44 @@ def test_blade_extends_links_view_to_its_layout(tmp_path):
assert ("page.blade.php", "layouts.app") in _edge_labels(result, "extends")
# existing @include behaviour is preserved
assert ("page.blade.php", "partials.nav") in _edge_labels(result, "includes")
def test_blade_wire_click_binds_the_bare_method_name(tmp_path):
# wire:click="deleteItem(5)" bound to the literal argument-bearing text,
# a node no real method ever matches — the call's own argument is not
# part of the method's name.
page = tmp_path / "page.blade.php"
page.write_text(
'<div wire:click="deleteItem(5)">Delete</div>\n'
'<div wire:click="save">Save</div>\n',
encoding="utf-8",
)
result = extract([page], cache_root=tmp_path)
bindings = _edge_labels(result, "binds_method")
assert ("page.blade.php", "deleteItem") in bindings
assert ("page.blade.php", "save") in bindings
def test_blade_wire_click_with_a_modifier_is_still_bound(tmp_path):
# wire:click.prevent="submit" never matched the bare wire:click= pattern
# at all, so the binding silently vanished.
page = tmp_path / "page.blade.php"
page.write_text('<div wire:click.prevent="submit">Submit</div>\n', encoding="utf-8")
result = extract([page], cache_root=tmp_path)
assert ("page.blade.php", "submit") in _edge_labels(result, "binds_method")
def test_blade_wire_click_magic_action_is_not_bound(tmp_path):
# $set/$emit/$toggle/$refresh are Livewire's own runtime actions, not a
# method the component defines — binding one fabricates an edge to
# something that does not exist.
page = tmp_path / "page.blade.php"
page.write_text("<div wire:click=\"$set('foo', 1)\">Reset</div>\n", encoding="utf-8")
result = extract([page], cache_root=tmp_path)
assert _edge_labels(result, "binds_method") == set()