package bootstrapimpl

import (
	"testing"

	"github.com/nexuscrm/shared/pkg/constants"
)

func TestFolderSharingModelsDeclaredInSystemTables(t *testing.T) {
	want := map[string]string{
		"ReportFolder":          string(constants.SharingModelFolderSharing),
		"Report":                string(constants.SharingModelFolderContentSharing),
		"Dashboard":             string(constants.SharingModelFolderContentSharing),
		"_System_EmailTemplate": string(constants.SharingModelFolderContentSharing),
		"DashboardComponent":    string(constants.SharingModelControlledByParent),
	}

	for _, def := range GetManagedTableDefinitions() {
		expected, ok := want[def.TableName]
		if !ok {
			continue
		}
		if def.SharingModel != expected {
			t.Fatalf("%s sharingModel = %q, want %q", def.TableName, def.SharingModel, expected)
		}
		delete(want, def.TableName)
	}

	for tableName := range want {
		t.Fatalf("%s missing from system_tables.json", tableName)
	}
}
