package userbehavior

import (
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

var _ = Describe("GTMLead model", func() {
	It("auto migrates and persists a lead row", func() {
		db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
		Expect(err).ToNot(HaveOccurred())

		err = db.AutoMigrate(&GTMLead{})
		Expect(err).ToNot(HaveOccurred())

		contactName := "John Doe"
		companyName := "Test Company"
		headquarter := "San Francisco, CA"
		vertical := "Technology"
		businessModel := "SaaS"
		annualRevenue := "$10M-$50M"
		fundingSeries := "Series B"
		matchedUseCase := "ai_chatbot"

		lead := &GTMLead{
			TenantID:       123,
			Email:          "test@example.com",
			EmailDomain:    "example.com",
			ContactName:    &contactName,
			CompanyName:    &companyName,
			Headquarter:    &headquarter,
			Vertical:       &vertical,
			BusinessModel:  &businessModel,
			AnnualRevenue:  &annualRevenue,
			FundingSeries:  &fundingSeries,
			RawEnrichment:  `{"company": "Test Company", "vertical": "Technology"}`,
			IsQualified:    true,
			MatchedUseCase: &matchedUseCase,
		}

		Expect(db.Create(lead).Error).ToNot(HaveOccurred())
		Expect(lead.ID).ToNot(BeZero())
		Expect(lead.CreatedAt.IsZero()).To(BeFalse())
	})
})
