import { describe, expect, it } from 'vitest'
import type { CatalogPublicResponse } from '@zync/types'

function footerShouldBeHidden(data: CatalogPublicResponse): boolean {
  const tier = data.tenantBranding.tenantTier
  return Boolean(data.tenantBranding.customDomain) && (tier === 'enterprise' || tier === 'white_label')
}

describe('public catalog page response contract', () => {
  it('carries tenant tier so the page can apply the powered-by footer rule from the spec', () => {
    const response: CatalogPublicResponse = {
      template: { content: { sections: [] } },
      share: {
        id: 'share-1',
        settings: {},
        utmParams: { utmSource: null, utmMedium: null, utmCampaign: null },
      },
      tenantBranding: {
        tenantId: 'tenant-1',
        tenantTier: 'enterprise',
        tenantName: 'Acme',
        logoR2Key: null,
        primaryColor: null,
        customDomain: 'catalog.acme.test',
      },
      leadForm: null,
    }

    expect(footerShouldBeHidden(response)).toBe(true)
  })
})
