This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/handlers/composability_test.go
Jeffrey Smith 98fd3eb3e6
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m44s
CI/CD / test-sqlite (push) Successful in 2m54s
CI/CD / build-and-deploy (push) Successful in 52s
Feat v0.8.5 extension composability (#72)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
2026-04-03 11:33:47 +00:00

98 lines
2.2 KiB
Go

package handlers
import (
"testing"
)
func TestValidateComposabilityFields_ValidSlots(t *testing.T) {
m := map[string]any{
"slots": map[string]any{
"toolbar-actions": map[string]any{
"description": "Toolbar action buttons",
"context": map[string]any{
"noteId": "string",
},
},
},
}
if err := ValidateComposabilityFields(m); err != "" {
t.Errorf("expected valid, got: %s", err)
}
}
func TestValidateComposabilityFields_SlotMissingDescription(t *testing.T) {
m := map[string]any{
"slots": map[string]any{
"toolbar": map[string]any{
"context": map[string]any{},
},
},
}
if err := ValidateComposabilityFields(m); err == "" {
t.Error("expected error for slot missing description")
}
}
func TestValidateComposabilityFields_SlotsNotObject(t *testing.T) {
m := map[string]any{
"slots": "bad",
}
if err := ValidateComposabilityFields(m); err == "" {
t.Error("expected error for non-object slots")
}
}
func TestValidateComposabilityFields_ValidContributes(t *testing.T) {
m := map[string]any{
"contributes": map[string]any{
"notes:toolbar-actions": map[string]any{
"label": "Dictate",
"icon": "🎤",
},
},
}
if err := ValidateComposabilityFields(m); err != "" {
t.Errorf("expected valid, got: %s", err)
}
}
func TestValidateComposabilityFields_ContributesMissingColon(t *testing.T) {
m := map[string]any{
"contributes": map[string]any{
"toolbar-actions": map[string]any{
"label": "Bad",
},
},
}
if err := ValidateComposabilityFields(m); err == "" {
t.Error("expected error for contributes key without colon")
}
}
func TestValidateComposabilityFields_Empty(t *testing.T) {
m := map[string]any{
"id": "test",
}
if err := ValidateComposabilityFields(m); err != "" {
t.Errorf("expected valid for manifest without slots/contributes, got: %s", err)
}
}
func TestValidateComposabilityFields_BothValid(t *testing.T) {
m := map[string]any{
"slots": map[string]any{
"my-slot": map[string]any{
"description": "A slot",
},
},
"contributes": map[string]any{
"other:their-slot": map[string]any{
"label": "Hello",
},
},
}
if err := ValidateComposabilityFields(m); err != "" {
t.Errorf("expected valid, got: %s", err)
}
}