import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'

function readLocale(locale: 'en' | 'he'): Record<string, string> {
  return JSON.parse(
    readFileSync(join(process.cwd(), 'src', 'i18n', `${locale}.json`), 'utf8'),
  ) as Record<string, string>
}

describe('upgrade modal i18n contract', () => {
  it('defines the spec-required Hebrew copy and feature labels', () => {
    const he = readLocale('he')

    expect(he['upgrade-modal.title']).toBe('שדרג את התוכנית שלך')
    expect(he['upgrade-modal.context_line']).toBe('תצטרך {{tier}} כדי להשתמש ב-{{feature}}')
    expect(he['upgrade-modal.period_monthly']).toBe('חודשי')
    expect(he['upgrade-modal.period_annual']).toBe('שנתי — חסוך 17%')
    expect(he['upgrade-modal.annual_billed_as']).toBe('חיוב שנתי: {{amount}} ₪ (10 תשלומים)')
    expect(he['upgrade-modal.cta_current']).toBe('תוכנית נוכחית')
    expect(he['upgrade-modal.cta_upgrade']).toBe('שדרג ל-{{tier}}')
    expect(he['upgrade-modal.cta_contact']).toBe('צור קשר עם מכירות →')
    expect(he['upgrade-modal.cta_null_adapter']).toBe('צור קשר כדי לשדרג →')
    expect(he['upgrade-modal.ask_admin_title']).toBe('רק מנהל יכול לשדרג')
    expect(he['upgrade-modal.ask_admin_body']).toBe(
      'רק בעל חשבון או מנהל יכולים לשדרג את התוכנית. פנה למנהל המערכת שלך.',
    )
    expect(he['upgrade-modal.close']).toBe('סגור')
    expect(he['upgrade-modal.see_full_plan']).toBe('ראה פרטי תוכנית מלאים')
    expect(he['upgrade-modal.recommended_badge']).toBe('★ מומלץ')
    expect(he['upgrade-modal.current_plan_badge']).toBe('תוכנית נוכחית')
    expect(he['upgrade-modal.price_free']).toBe('חינם לתמיד')
    expect(he['upgrade-modal.price_contact']).toBe('צור קשר')
    expect(he['upgrade-modal.error_checkout']).toBe('שגיאה ביצירת הזמנה — נסה שוב')
    expect(he['upgrade-modal.error_no_provider']).toBe(
      'ספק התשלום אינו מוגדר — צור קשר עם התמיכה',
    )
    expect(he['upgrade-modal.features.team_1']).toBe('חבר צוות 1')
    expect(he['upgrade-modal.features.modules_basic']).toBe('מודולים בסיסיים')
    expect(he['upgrade-modal.features.storage_1gb']).toBe('1 GB אחסון')
    expect(he['upgrade-modal.features.ai']).toBe('AI אסיסטנט')
    expect(he['upgrade-modal.features.white_label']).toBe('ברנד לבן')
    expect(he['upgrade-modal.features.custom_domain']).toBe('דומיין מותאם')
    expect(he['upgrade-modal.features.api']).toBe('גישת API')
    expect(he['upgrade-modal.features.support_priority4']).toBe('תמיכה: עדיפות, 4 ש׳')
    expect(he['plan.upgrade.success']).toBe('התוכנית שודרגה בהצלחה! התוכנית החדשה שלך פעילה.')
  })
})
