package extensionflow

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

// TestKnownActionName proves the closed explicit capability→Action map
// (stage-6 final-review blocker 1c refinement): the five GitHub/Gitea tools map
// to their canonical kebab Action names, and any unknown tool fails closed
// (returns ok=false) instead of being silently normalized — eliminating the
// collision risk of a global _→- replacement.
func TestKnownActionName(t *testing.T) {
	known := []struct {
		tool   string
		action string
	}{
		{"watch_pull_request", "watch-pull-request"},
		{"list_watches", "list-watches"},
		{"pause_watch", "pause-watch"},
		{"resume_watch", "resume-watch"},
		{"unwatch", "unwatch"},
	}
	for _, c := range known {
		action, ok := extensionActionNameForAppCapability(c.tool)
		assert.True(t, ok, "known tool %q must be in the closed map", c.tool)
		assert.Equal(t, c.action, action)
	}

	// Unknown tools fail closed (not silently normalized to a collision-prone form).
	for _, unknown := range []string{"unknown_tool", "watch_pull_request_review", "a_b", ""} {
		_, ok := extensionActionNameForAppCapability(unknown)
		assert.False(t, ok, "unknown tool %q must NOT be silently normalized", unknown)
	}
}
