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 - sidebar add actions (en/ko)', () => {
  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 labels exist', () => {
    renderWith('en')
    expect(screen.getByRole('button', { name: 'Add Hero' })).toBeInTheDocument()
    expect(screen.getByRole('button', { name: 'Add FAQ' })).toBeInTheDocument()
    expect(screen.getByRole('button', { name: 'Add CTA' })).toBeInTheDocument()
  })

  it('ko labels exist', () => {
    renderWith('ko')
    expect(screen.getByRole('button', { name: '히어로 추가' })).toBeInTheDocument()
    expect(screen.getByRole('button', { name: 'FAQ 추가' })).toBeInTheDocument()
    expect(screen.getByRole('button', { name: 'CTA 추가' })).toBeInTheDocument()
  })
})
