fix(webui): correct SkillHub skill detail links

This commit is contained in:
Xubin Ren committed 2026-10-08 13:24:19 +08:00
1 parent 29f27dcf5d
commit 3865bde3fe
4 files changed
+51 -5

No files matched your search

+1 -1
View File
@@ -821,7 +821,7 @@ def _skillhub_skill(
"provider": _PROVIDER_SKILLHUB,
"installs": installs if isinstance(installs, int) and installs >= 0 else 0,
"downloads": downloads if isinstance(downloads, int) and downloads >= 0 else 0,
"url": f"{_SKILLHUB_PAGE_BASE_URL}/{quote(handle.strip(), safe='')}/"
"url": f"{_SKILLHUB_PAGE_BASE_URL}/skills/{quote(handle.strip(), safe='')}/"
f"{quote(skill_id, safe='')}",
"installed": skill_id in installed,
"install_supported": True,
+41 -1
View File
@@ -160,7 +160,7 @@ async def test_search_skillhub_skills_normalizes_provider_metadata(
"provider": "skillhub",
"installs": 11831,
"downloads": 142525,
"url": "https://skillhub.cn/tencent-adm/ima-skills",
"url": "https://skillhub.cn/skills/tencent-adm/ima-skills",
"installed": False,
"install_supported": True,
"metric": "installs_total",
@@ -171,6 +171,46 @@ async def test_search_skillhub_skills_normalizes_provider_metadata(
]
@pytest.mark.asyncio
@pytest.mark.parametrize("listing", ["search", "trending"])
async def test_skillhub_listings_link_to_public_skill_details(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
listing: str,
) -> None:
row = {
"slug": "mail-agent-goose",
"displayName": "邮件管理器",
"namespace": {"handle": "user_a3ed06bc"},
"version": "2.2.0",
"homepage": "https://api.skillhub.cn/user_a3ed06bc/mail-agent-goose",
}
def respond(request: httpx.Request) -> httpx.Response:
if listing == "search":
assert request.url.path == "/api/v1/search"
return httpx.Response(200, json={"results": [row]})
assert request.url.path == "/api/v1/showcase/trending"
return httpx.Response(200, json={"skills": [row]})
monkeypatch.setattr(
"nanobot.webui.skills_marketplace._skillhub_client",
lambda: httpx.AsyncClient(transport=httpx.MockTransport(respond)),
)
if listing == "search":
payload = await search_marketplace_skills(
"@user_a3ed06bc/mail-agent-goose", tmp_path, provider="skillhub",
)
else:
payload = await trending_marketplace_skills(tmp_path, provider="skillhub")
assert len(payload["skills"]) == 1
assert payload["skills"][0]["url"] == (
"https://skillhub.cn/skills/user_a3ed06bc/mail-agent-goose"
)
@pytest.mark.asyncio
async def test_trending_marketplace_skills_diversifies_sources_and_keeps_rank(
tmp_path: Path,
+8 -2
View File
@@ -1549,7 +1549,7 @@ describe("App layout", () => {
provider: "skillhub",
installs: 11_831,
downloads: 142_525,
url: "https://skillhub.cn/tencent-adm/ima-skills",
url: "https://skillhub.cn/skills/tencent-adm/ima-skills",
installed: false,
install_supported: true,
metric: "installs_total",
@@ -1589,7 +1589,7 @@ describe("App layout", () => {
provider: "skillhub",
installs: 693,
downloads: 7_718,
url: "https://skillhub.cn/ivangdavila/react",
url: "https://skillhub.cn/skills/ivangdavila/react",
installed: false,
install_supported: true,
metric: "installs_total",
@@ -1619,6 +1619,9 @@ describe("App layout", () => {
).not.toBeInTheDocument();
expect(screen.getByText("find-skills")).toBeInTheDocument();
expect(screen.getByText("ima-skills")).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Open ima-skills on SkillHub" })).toHaveAttribute(
"href", "https://skillhub.cn/skills/tencent-adm/ima-skills",
);
expect(screen.getAllByText("SkillHub")).toHaveLength(2);
expect(screen.getAllByText("skills.sh")).toHaveLength(2);
expect(screen.getByText(/14,481 installs \/ 24h/)).toBeInTheDocument();
@@ -1643,6 +1646,9 @@ describe("App layout", () => {
});
expect(await screen.findByText("React Testing")).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Open React on SkillHub" })).toHaveAttribute(
"href", "https://skillhub.cn/skills/ivangdavila/react",
);
fireEvent.click(screen.getByRole("button", { name: "Install React Testing" }));
expect(
await screen.findByRole("heading", { name: "Install React Testing?" }),
+1 -1
View File
@@ -268,7 +268,7 @@ describe("SkillsMarketplace", () => {
const skill = {
id: "skillhub:react-testing", skill_id: "react-testing", name: "React Testing",
source: "react-testing", provider: "skillhub" as const, installs: 42,
url: "https://skillhub.cn/react-testing", installed: false, install_supported: true,
url: "https://skillhub.cn/skills/react-testing", installed: false, install_supported: true,
metric: "installs_total" as const, rank: 1,
};
let resolveTrending!: (value: Awaited<ReturnType<typeof fetchTrendingMarketplaceSkills>>) => void;