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
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
98 lines
2.2 KiB
Go
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)
|
|
}
|
|
}
|