mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-10 02:02:31 +08:00
refactor: add shared fixtures and test.step() patterns
- Add tests/e2e/lib/fixtures.ts with shared test helpers - Add tests/e2e/fixtures/diagrams.ts with XML test data - Add expectBeforeAndAfterReload() helper for persistence tests - Add test.step() for better test reporting in complex tests - Consolidate mock helpers into fixtures module - Reduce code duplication across 17 test files
This commit is contained in:
@@ -1,32 +1,22 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
import { expect, getIframe, openSettings, test } from "./lib/fixtures"
|
||||
|
||||
test.describe("Keyboard Interactions", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto("/", { waitUntil: "networkidle" })
|
||||
await page
|
||||
.locator("iframe")
|
||||
.waitFor({ state: "visible", timeout: 30000 })
|
||||
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
||||
})
|
||||
|
||||
test("Escape closes settings dialog", async ({ page }) => {
|
||||
// Find settings button using aria-label or icon
|
||||
const settingsButton = page.locator(
|
||||
'button[aria-label*="settings"], button:has(svg[class*="settings"])',
|
||||
)
|
||||
await expect(settingsButton).toBeVisible()
|
||||
await settingsButton.click()
|
||||
await openSettings(page)
|
||||
|
||||
// Wait for dialog to appear
|
||||
const dialog = page.locator('[role="dialog"]')
|
||||
await expect(dialog).toBeVisible({ timeout: 5000 })
|
||||
|
||||
// Press Escape and verify dialog closes
|
||||
await page.keyboard.press("Escape")
|
||||
await expect(dialog).not.toBeVisible({ timeout: 2000 })
|
||||
})
|
||||
|
||||
test("page is keyboard accessible", async ({ page }) => {
|
||||
// Verify page has focusable elements
|
||||
const focusableElements = page.locator(
|
||||
'button, [tabindex="0"], input, textarea, a[href]',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user