import { describe, it, expect } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import React from 'react'
import { NextIntlClientProvider } from 'next-intl'
import enMessages from '@/messages/en.json'
import BuilderClientPage from '@/components/BuilderClientPage'

const messages: Record<string, string> = enMessages as Record<string, string>

describe('BuilderClientPage - features/testimonials preview', () => {
  it('사이드바 카드 클릭으로 features/testimonials 섹션이 추가되고 프리뷰에 표기된다', () => {
    render(
      <NextIntlClientProvider locale="en" messages={messages}>
        <BuilderClientPage />
      </NextIntlClientProvider>
    )

    // features 추가
    fireEvent.click(screen.getByTestId('card-features'))
    // testimonials 추가
    fireEvent.click(screen.getByTestId('card-testimonials'))

    // 프리뷰에서 섹션 요약 표기 확인
    expect(screen.getByText(/features — items: 3/)).toBeInTheDocument()
    expect(screen.getByText(/testimonials — items: 2/)).toBeInTheDocument()
  })
})
