From 8c83130f67bcba0e14646cfff6079cfa0dd126e0 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Sun, 8 Feb 2026 13:48:32 -0500 Subject: [PATCH] Add test for alias exact match over prefix --- tests/test_prefix_matching.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_prefix_matching.py b/tests/test_prefix_matching.py index adf73ac..02e1996 100644 --- a/tests/test_prefix_matching.py +++ b/tests/test_prefix_matching.py @@ -213,3 +213,23 @@ async def test_prefix_match_with_args(player, clean_registry): output = "".join([call[0][0] for call in player.writer.write.call_args_list]) assert "Handler called with args: the floor" in output + + +@pytest.mark.asyncio +async def test_alias_exact_match_over_prefix_collision(player, clean_registry): + """Test alias exact match wins over prefix when otherwise ambiguous.""" + commands.register( + CommandDefinition( + name="look", aliases=["l"], handler=dummy_handler, mode="normal" + ) + ) + commands.register( + CommandDefinition(name="list", handler=dummy_handler, mode="normal") + ) + + await commands.dispatch(player, "l") + output = "".join([call[0][0] for call in player.writer.write.call_args_list]) + + # Should call handler (exact match on alias), not show ambiguous + assert "Handler called" in output + assert "or" not in output