fix: unify row open labels and silent success
All checks were successful
技能自动化发布 / release (push) Successful in 5s
All checks were successful
技能自动化发布 / release (push) Successful in 5s
Rename 打开文件位置 to 打开目录, and print empty SAS message so the host skips 执行成功 after opening Explorer or the browser. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -70,6 +70,9 @@ class TestCmdOpenDirectBrowser:
|
||||
payload = json.loads(out.splitlines()[-1])
|
||||
|
||||
assert payload["success"] is True
|
||||
assert payload["message"] == ""
|
||||
assert payload["type"] == "result"
|
||||
assert payload["status"] == "success"
|
||||
assert payload["data"]["pid"] == 5252
|
||||
assert payload["data"]["browser_exe"] == fake_exe
|
||||
assert spawned["cmd"][0] == fake_exe
|
||||
|
||||
@@ -54,6 +54,9 @@ def test_reveal_profile_opens_dir(clean_db, tmp_path, capsys):
|
||||
out = capsys.readouterr().out.strip()
|
||||
payload = json.loads(out.splitlines()[-1])
|
||||
assert payload["success"] is True
|
||||
assert payload["message"] == ""
|
||||
assert payload["type"] == "result"
|
||||
assert payload["status"] == "success"
|
||||
assert payload["data"]["account_id"] == aid
|
||||
assert payload["data"]["profile_dir"] == called_path
|
||||
|
||||
|
||||
50
tests/test_row_open_actions.py
Normal file
50
tests/test_row_open_actions.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""数据管理行内打开类:label 对齐模板,不与宿主 CRUD 重复。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
||||
def _skill_root() -> str:
|
||||
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def _load_actions() -> list[dict]:
|
||||
path = os.path.join(_skill_root(), "assets", "actions.json")
|
||||
with open(path, encoding="utf-8") as f:
|
||||
manifest = json.load(f)
|
||||
return list(manifest.get("actions") or [])
|
||||
|
||||
|
||||
def _by_id(actions: list[dict], action_id: str) -> dict:
|
||||
for item in actions:
|
||||
if item.get("id") == action_id:
|
||||
return item
|
||||
raise AssertionError(f"missing action {action_id}")
|
||||
|
||||
|
||||
class TestRowOpenActions(unittest.TestCase):
|
||||
def test_reveal_and_open_use_template_labels(self) -> None:
|
||||
actions = _load_actions()
|
||||
reveal = _by_id(actions, "reveal-profile")
|
||||
open_browser = _by_id(actions, "open-browser")
|
||||
self.assertEqual(reveal.get("label"), "打开目录")
|
||||
self.assertEqual(open_browser.get("label"), "打开浏览器")
|
||||
self.assertEqual(reveal.get("placements"), ["row"])
|
||||
self.assertEqual(open_browser.get("placements"), ["row"])
|
||||
self.assertEqual(reveal.get("interaction"), "direct")
|
||||
self.assertEqual(open_browser.get("interaction"), "direct")
|
||||
self.assertFalse(reveal.get("replaces"))
|
||||
self.assertFalse(open_browser.get("replaces"))
|
||||
|
||||
def test_create_takes_over_host_add_without_row_duplicate(self) -> None:
|
||||
create = _by_id(_load_actions(), "account-add-web")
|
||||
self.assertEqual(create.get("replaces"), "create")
|
||||
self.assertEqual(create.get("placements") or [], [])
|
||||
self.assertEqual(create.get("label"), "新增账号")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user