Working version of tabsearch. Added subsequent and fuzzy matching. Need to fix the unit tests

This commit is contained in:
2025-11-16 11:52:22 +01:00
parent 09c4217cb6
commit c38a012c74
9 changed files with 290 additions and 47 deletions

View File

@@ -104,8 +104,8 @@ class TestCommandBind:
assert matches(updated, expected)
@pytest.mark.parametrize("return_values", [
[Div(), Div(), "hello", Div()], # list
(Div(), Div(), "hello", Div()) # tuple
[Div(), Div(id="id1"), "hello", Div(id="id2")], # list
(Div(), Div(id="id1"), "hello", Div(id="id2")) # tuple
])
def test_swap_oob_is_automatically_set_when_multiple_elements_are_returned(self, return_values):
"""Test that hx-swap-oob is automatically set, but not for the first."""
@@ -157,3 +157,29 @@ class TestCommandExecute:
command = Command('test', 'Command description', callback_with_param)
command.execute(client_response={"number": "10"})
def test_swap_oob_is_added_when_multiple_elements_are_returned(self):
"""Test that hx-swap-oob is automatically set, but not for the first."""
def another_callback():
return Div(id="first"), Div(id="second"), "hello", Div(id="third")
command = Command('test', 'Command description', another_callback)
res = command.execute()
assert "hx-swap-oob" not in res[0].attrs
assert res[1].attrs["hx-swap-oob"] == "true"
assert res[3].attrs["hx-swap-oob"] == "true"
def test_swap_oob_is_not_added_when_there_no_id(self):
"""Test that hx-swap-oob is automatically set, but not for the first."""
def another_callback():
return Div(id="first"), Div(), "hello", Div()
command = Command('test', 'Command description', another_callback)
res = command.execute()
assert "hx-swap-oob" not in res[0].attrs
assert "hx-swap-oob" not in res[1].attrs
assert "hx-swap-oob" not in res[3].attrs