package packs

import (
	"strings"
	"testing"
)

func TestSourceBackedPresentationBuildersStayOutOfGeneralBuilderFile(t *testing.T) {
	generalSrc := readPacksSourceForStructureTest(t, "source_backed_component_builders.go")
	presentationSrc := readPacksSourceForStructureTest(t, "source_backed_presentation_component_builders.go")

	for _, symbol := range []string{
		"func (b *sourceBackedComponentBuildContext) buildRelatedListRule(",
		"func (b *sourceBackedComponentBuildContext) buildPageLayout(",
		"func (b *sourceBackedComponentBuildContext) buildLayoutAssignment(",
		"func (b *sourceBackedComponentBuildContext) buildReportType(",
		"func (b *sourceBackedComponentBuildContext) buildUIAction(",
		"func (b *sourceBackedComponentBuildContext) buildSearchScopeOrder(",
		"func (b *sourceBackedComponentBuildContext) buildSearchAllDefaultFields(",
		"func (b *sourceBackedComponentBuildContext) buildHrefRewriteFields(",
	} {
		if strings.Contains(generalSrc, symbol) {
			t.Fatalf("source_backed_component_builders.go still owns presentation-builder symbol %q", symbol)
		}
		if !strings.Contains(presentationSrc, symbol) {
			t.Fatalf("source_backed_presentation_component_builders.go is missing presentation-builder symbol %q", symbol)
		}
	}

	if !strings.Contains(generalSrc, "func attachSourceBackedComponentBuildHandlers(") {
		t.Fatal("source_backed_component_builders.go must still attach ComponentKind build handlers")
	}
}
