refactor(commands): rename status command to list and update related references

feat(feishu): update card schema to 2.0 and simplify approval card structure

docs(feishu): add documentation for card json schema 2.0 changes
This commit is contained in:
Yuyao Huang
2026-04-01 14:50:30 +08:00
parent 44bd1a4300
commit 26746335c4
7 changed files with 585 additions and 59 deletions
+18 -6
View File
@@ -36,9 +36,14 @@ class TestHelp:
from bot.commands import handle_command
_setup_user()
reply = await handle_command("user_abc123", "//help")
for cmd in ("//new", "//status", "//close", "//switch", "//perm",
"//stop", "//progress", "//direct", "//smart", "//shell"):
for cmd in ("//new", "//list", "//close", "//switch", "//perm",
"//stop", "//progress", "//direct", "//smart", "//shell",
"//help"):
assert cmd in reply, f"Missing {cmd} in help"
# Should NOT list //retry (unimplemented)
assert "//retry" not in reply
# Should list aliases
assert "alias" in reply.lower()
@pytest.mark.asyncio
async def test_h_alias(self):
@@ -184,12 +189,12 @@ class TestSwitch:
# ── //status ────────────────────────────────────────────────────────────────
class TestStatus:
class TestList:
@pytest.mark.asyncio
async def test_no_sessions(self):
from bot.commands import handle_command
_setup_user()
reply = await handle_command("user_abc123", "//status")
reply = await handle_command("user_abc123", "//list")
assert "No active sessions" in reply
@pytest.mark.asyncio
@@ -198,7 +203,7 @@ class TestStatus:
_setup_user()
_add_session("s1")
_add_session("s2")
reply = await handle_command("user_abc123", "//status")
reply = await handle_command("user_abc123", "//list")
assert "s1" in reply
assert "s2" in reply
@@ -207,9 +212,16 @@ class TestStatus:
from bot.commands import handle_command
_setup_user()
_add_session("s1", activate=True)
reply = await handle_command("user_abc123", "//status")
reply = await handle_command("user_abc123", "//list")
assert "" in reply
@pytest.mark.asyncio
async def test_status_alias_still_works(self):
from bot.commands import handle_command
_setup_user()
reply = await handle_command("user_abc123", "//status")
assert "No active sessions" in reply
# ── //perm ──────────────────────────────────────────────────────────────────
+9 -11
View File
@@ -767,20 +767,18 @@ class TestBuildApprovalCard:
assert "权限审批" in card["header"]["title"]["content"]
body_elements = card["body"]["elements"]
# Should have markdown, action, and note elements
tags = [e["tag"] for e in body_elements]
# JSON 2.0: no "action" wrapper, no "note" — buttons are direct elements
assert "action" not in tags
assert "note" not in tags
assert "markdown" in tags
assert "action" in tags
assert "note" in tags
assert tags.count("button") == 2
# Action should have 2 buttons
action_el = next(e for e in body_elements if e["tag"] == "action")
assert len(action_el["actions"]) == 2
# First button should be approve
assert action_el["actions"][0]["value"]["action"] == "approve"
assert action_el["actions"][0]["value"]["conv_id"] == "c1"
# Second button should be deny
assert action_el["actions"][1]["value"]["action"] == "deny"
# Buttons carry approve/deny values
buttons = [e for e in body_elements if e["tag"] == "button"]
assert buttons[0]["value"]["action"] == "approve"
assert buttons[0]["value"]["conv_id"] == "c1"
assert buttons[1]["value"]["action"] == "deny"
# ===========================================================================