import { describe, expect, it } from 'vitest'

import { renderNotificationText, typeGroupMap } from '../src/routes/notifications.render'

describe('notification renderer', () => {
  it('renders stored notifications.* keys into localized text', () => {
    const rendered = renderNotificationText(
      'notifications.task_comment.title',
      'notifications.task_comment.body',
      {
        commenterName: 'Dana',
        commentPreview: 'Looks good',
      },
      'he-IL',
    )

    expect(rendered.title).toBe('תגובה חדשה על משימה')
    expect(rendered.body).toBe('Dana הגיב: Looks good')
  })

  it('renders trial-expiring notifications that live under the plural namespace', () => {
    const rendered = renderNotificationText(
      'notifications.trial_expiring.title',
      'notifications.trial_expiring.body',
      { days: '3' },
      'en-US',
    )

    expect(rendered.title).toBe('Trial expiring soon')
    expect(rendered.body).toBe('Your trial expires in 3 days. Upgrade to keep access.')
  })
})

describe('notification type groups', () => {
  it('keeps operational lifecycle notifications in the system filter', () => {
    expect(typeGroupMap.system).toEqual(
      expect.arrayContaining([
        'trial_expiring',
        'quota_warning',
        'member_invited',
        'role_changed',
      ]),
    )
  })
})
