package automationintegration_test

import (
	"testing"

	"github.com/pingcap-inc/nexuscrm-controlplane/packs"
)

const recordChildBarChartRendererID = "app-pack:crm/record-panel/record-child-bar-chart"

func TestStandaloneCRMDistributionHostPrimitivesIncludeRecordChildBarChart(t *testing.T) {
	for _, primitive := range crmDistributionHostPrimitives() {
		if primitive.Kind == "renderer" && primitive.Name == recordChildBarChartRendererID {
			return
		}
	}
	t.Fatalf("standalone CRM host primitives do not include renderer %q", recordChildBarChartRendererID)
}

func registerCRMDistributionHostPrimitivesForTest(t *testing.T) {
	t.Helper()
	registerCRMDistributionHostPrimitives()
}

func registerCRMDistributionHostPrimitives() {
	packs.RegisterDefaultHostPrimitives(crmDistributionHostPrimitives()...)
}

func crmDistributionHostPrimitives() []packs.HostPrimitive {
	return []packs.HostPrimitive{
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/action-renderer/lead-convert"},
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/action-renderer/create-record-from-source"},
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/action-renderer/task-activity-quick-create"},
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/action-renderer/email-compose"},
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/record-panel/activity-timeline"},
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/record-panel/record-activity-feed"},
		packs.HostPrimitive{Kind: "renderer", Name: recordChildBarChartRendererID},
		packs.HostPrimitive{Kind: "renderer", Name: "app-pack:crm/banner/converted-lead"},
	}
}
