import { test, expect } from '@playwright/test'

test.use({ storageState: 'tests/e2e/.auth/user.json' })

test.describe('NameTag — Name Override Fields', () => {
  test('service edit page has moderator and preacher name override fields', async ({ page }) => {
    await page.goto('/services')

    const editLinks = page.getByRole('link', { name: /Bearbeiten/i })
    const count = await editLinks.count()
    if (count === 0) {
      test.skip(true, 'No services available in test DB')
      return
    }

    await editLinks.first().click()
    await page.waitForURL(/\/services\/\d+\/edit/)

    await expect(page.getByTestId('moderator-name-override')).toBeVisible()
    await expect(page.getByTestId('preacher-name-override')).toBeVisible()
  })

  test('Settings page Namenseinblender section has macro UUID field', async ({ page }) => {
    await page.goto('/settings')
    await page.getByTestId('settings-submenu-namenseinblender').first().click()
    await expect(page.getByTestId('namenseinblender-macro')).toBeVisible()
    await expect(page.getByTestId('namenseinblender-macro-name')).toBeVisible()
  })
})
