import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import React from 'react'
import BuilderClientPage from '@/components/BuilderClientPage'
import I18nProvider from '@/components/I18nProvider'
import en from '@/messages/en.json'
import ko from '@/messages/ko.json'

describe('i18n regression - misc labels (title/preview/sections)', () => {
  function renderWith(locale: 'en' | 'ko') {
    const messages = locale === 'en' ? en : ko
    return render(
      <I18nProvider locale={locale} messages={messages as unknown as Record<string, string>}>
        <BuilderClientPage />
      </I18nProvider>
    )
  }

  it('en: builder title, preview text, sections heading present', () => {
    renderWith('en')
    expect(screen.getByRole('heading', { name: 'Landing Page Builder' })).toBeInTheDocument()
    expect(screen.getByText('Preview (static)')).toBeInTheDocument()
    expect(screen.getByText('Sections')).toBeInTheDocument()
  })

  it('ko: builder title, preview text, sections heading present', () => {
    renderWith('ko')
    expect(screen.getByRole('heading', { name: '랜딩 페이지 빌더' })).toBeInTheDocument()
    expect(screen.getByText('미리보기(정적)')).toBeInTheDocument()
    expect(screen.getByText('섹션')).toBeInTheDocument()
  })
})
