mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-11 02:28:30 +08:00
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
This commit is contained in:
51
tests/e2e/smoke.spec.ts
Normal file
51
tests/e2e/smoke.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
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,
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user