import React, { isValidElement } from 'react'
import { describe, expect, it } from 'vitest'
import FooterContentPage from '@/components/FooterContentPage'
import AppPrivacyEnPage from './app-privacy-en/page'
import AppPrivacyFrPage from './app-privacy-fr/page'
import AppPrivacyArPage from './app-privacy-ar/page'
import AppTermsEnPage from './app-tc-en/page'
import AppTermsFrPage from './app-tc-fr/page'
import AppTermsArPage from './app-tc-ar/page'

function expectPolicyPage(element: unknown, slug: string, forcedLanguage: string) {
  expect(isValidElement(element)).toBe(true)
  const page = element as React.ReactElement
  expect(page.type).toBe(FooterContentPage)
  expect(page.props.slug).toBe(slug)
  expect(page.props.forcedLanguage).toBe(forcedLanguage)
}

describe('storefront static app policy pages', () => {
  it('binds app privacy pages to explicit locales', () => {
    expectPolicyPage(AppPrivacyEnPage(), 'privacy-policy', 'en')
    expectPolicyPage(AppPrivacyFrPage(), 'privacy-policy', 'fr')
    expectPolicyPage(AppPrivacyArPage(), 'privacy-policy', 'ar')
  })

  it('binds app terms pages to explicit locales and the app terms content slug', () => {
    expectPolicyPage(AppTermsEnPage(), 'general-conditions', 'en')
    expectPolicyPage(AppTermsFrPage(), 'general-conditions', 'fr')
    expectPolicyPage(AppTermsArPage(), 'general-conditions', 'ar')
  })
})
