import { test, expect } from '@playwright/test'
import { requireKbxScenario, scenarioTitle } from './helpers/kbxScenario'

const orderKeyboard = requireKbxScenario('scenario.oms.order-register.keyboard')
const shellDirty = requireKbxScenario('scenario.shell.unsaved-tab')

test(scenarioTitle(orderKeyboard.id), async ({ page }) => {
  await page.goto('/oms/orders/register')
  await page.keyboard.press('F2')
  await expect(page.getByRole('dialog')).toBeVisible()
  await page.keyboard.press('Escape')
  await page.keyboard.press('F8')
  // Host app should seed synthetic lookup data and assert saved/problem outcome.
})

test(scenarioTitle(shellDirty.id), async ({ page }) => {
  await page.goto('/oms/orders/register')
  await page.getByLabel('수취인').fill('테스트수취인')
  await page.getByRole('button', { name: /주문등록.*닫기|닫기/ }).click()
  await expect(page.getByText('저장하지 않은 변경사항이 있습니다.')).toBeVisible()
})
