test(api): cover skillsSharedWith in the targets list

Code review of the target-page warning found the new targets API field
only had a unit test on the config helper. The handler is what the UI
reads, so check that it names targets writing the same skills folder and
leaves out one that writes elsewhere.

Release-As: 0.25.4
This commit is contained in:
Willie
2026-10-09 01:28:28 +08:00
parent 5f81209c6c
commit eabe5fbc10
@@ -44,6 +44,7 @@ type skillsTargetItem struct {
SkillsEnabled bool `json:"skillsEnabled"`
SkillsReadFrom []string `json:"skillsReadFrom"`
SkillsAlsoReadBy []string `json:"skillsAlsoReadBy"`
SkillsSharedWith []string `json:"skillsSharedWith"`
LinkedCount int `json:"linkedCount"`
}
@@ -99,6 +100,19 @@ func TestSkillsOffPreview_SharedFolder(t *testing.T) {
}
}
func TestListTargets_NamesTargetsSharingASkillsFolder(t *testing.T) {
shared := filepath.Join(t.TempDir(), "agents", "skills")
s, _ := newTestServerWithTargets(t, map[string]string{"universal": shared, "codex": shared, "claude": filepath.Join(t.TempDir(), "claude", "skills")})
items := listSkillsTargets(t, s)
if !slices.Equal(items["universal"].SkillsSharedWith, []string{"codex"}) || !slices.Equal(items["codex"].SkillsSharedWith, []string{"universal"}) {
t.Errorf("universal = %+v, codex = %+v", items["universal"], items["codex"])
}
if len(items["claude"].SkillsSharedWith) != 0 {
t.Errorf("claude = %+v, want no sharing", items["claude"])
}
}
func TestUpdateTarget_SkillsOffDetachesAndPersists(t *testing.T) {
s, _, _, gemini := newSkillsOffServer(t)