Files
next-ai-draw-io/tests/e2e/smoke.spec.ts
dayuan.jiang 74fbb629e7 test: add Vitest and Playwright testing infrastructure
- Add Vitest for unit tests (39 tests)
  - cached-responses.test.ts
  - ai-providers.test.ts
  - chat-helpers.test.ts
  - utils.test.ts
- Add Playwright for E2E tests (3 smoke tests)
  - Homepage load
  - Japanese locale
  - Settings dialog
- Add CI workflow (.github/workflows/test.yml)
- Add vitest.config.mts and playwright.config.ts
- Update .gitignore for test artifacts
2026-01-04 19:33:02 +09:00

52 lines
1.7 KiB
TypeScript

import { expect, test } from "@playwright/test"
test.describe("Smoke Tests", () => {
test("homepage loads without errors", async ({ page }) => {
const errors: string[] = []
page.on("pageerror", (err) => errors.push(err.message))
await page.goto("/", { waitUntil: "networkidle" })
await expect(page).toHaveTitle(/Draw\.io/i, { timeout: 10000 })
// Wait for draw.io iframe to be present
const iframe = page.locator("iframe")
await expect(iframe).toBeVisible({ timeout: 30000 })
expect(errors).toEqual([])
})
test("Japanese locale page loads", async ({ page }) => {
const errors: string[] = []
page.on("pageerror", (err) => errors.push(err.message))
await page.goto("/ja", { waitUntil: "networkidle" })
await expect(page).toHaveTitle(/Draw\.io/i, { timeout: 10000 })
const iframe = page.locator("iframe")
await expect(iframe).toBeVisible({ timeout: 30000 })
expect(errors).toEqual([])
})
test("settings dialog opens", async ({ page }) => {
await page.goto("/")
// Wait for page to load
await page
.locator("iframe")
.waitFor({ state: "visible", timeout: 30000 })
// Click settings button (gear icon)
const settingsButton = page.locator(
'button[aria-label*="settings"], button:has(svg[class*="lucide-settings"])',
)
if (await settingsButton.isVisible()) {
await settingsButton.click()
// Check if settings dialog appears
await expect(page.locator('[role="dialog"]')).toBeVisible({
timeout: 5000,
})
}
})
})