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

test('添加功能', async ({ page }) => {
  page.on('pageerror', (exception) => expect(exception).toBeNull())
  await page.goto('tabs#with-add')

  const container = page.locator('#with-add')
  const tabs = container.locator('.tiny-tabs')
  const tabItems = tabs.getByRole('tab')
  const newTabItem = tabItems.last()
  const add = tabs.locator('.tiny-tabs__new-tab')
  const content = tabs.getByRole('tabpanel')
  const modal = page.locator('.tiny-modal').first()

  await expect(tabItems).toHaveCount(2)
  await add.click()
  await expect(tabItems).toHaveCount(3)
  await newTabItem.click()
  await expect(newTabItem).toHaveClass(/is-active/)
  await expect(content).toHaveText(/动态增加/)
  await modal.isVisible()
})
