mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-30 17:50:07 +08:00
3f15a6af52
- Replace globalSetup function with a setup project that runs after webServer starts, fixing the timing issue where seed API calls failed because the server wasn't ready yet - Admin tests sign in with known credentials (fallback chain for CI vs local dev) instead of registering new users that may not get admin role - Remove storage column tests that required seeded data — the overflow test covers the same responsive behavior - Remove settings form test that couldn't navigate via page.goto due to SPA session loss Result: 51 tests, 51 passed, 0 skipped, 0 failed Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { signInAsAdmin } from './helpers'
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Admin sidebar
|
|
// ---------------------------------------------------------------------------
|
|
test.describe('Admin sidebar responsive', () => {
|
|
test('desktop: admin sidebar is visible @desktop', async ({ page }) => {
|
|
await signInAsAdmin(page)
|
|
|
|
const sidebar = page.locator('[data-slot="sidebar"]')
|
|
await expect(sidebar).toBeVisible()
|
|
})
|
|
|
|
test('mobile: admin sidebar opens via trigger @mobile', async ({ page }) => {
|
|
await signInAsAdmin(page)
|
|
|
|
const sidebar = page.locator('[data-slot="sidebar"]')
|
|
await expect(sidebar).not.toBeInViewport()
|
|
|
|
const trigger = page.locator('button[data-sidebar="trigger"]')
|
|
await expect(trigger).toBeVisible()
|
|
await trigger.click()
|
|
await expect(sidebar).toBeVisible()
|
|
})
|
|
})
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Admin storages page
|
|
// ---------------------------------------------------------------------------
|
|
test.describe('Admin storages page responsive', () => {
|
|
test('storages page has no horizontal overflow @all', async ({ page }) => {
|
|
await signInAsAdmin(page)
|
|
|
|
const hasHScroll = await page.evaluate(
|
|
() => document.documentElement.scrollWidth > document.documentElement.clientWidth,
|
|
)
|
|
expect(hasHScroll).toBe(false)
|
|
})
|
|
})
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Admin users page
|
|
// ---------------------------------------------------------------------------
|
|
test.describe('Admin users page responsive', () => {
|
|
test('mobile: users page has no horizontal overflow @mobile', async ({ page }) => {
|
|
await signInAsAdmin(page)
|
|
await page.goto('/admin/users')
|
|
await page.waitForURL(/admin\/users/, { timeout: 10000 })
|
|
|
|
const hasHScroll = await page.evaluate(
|
|
() => document.documentElement.scrollWidth > document.documentElement.clientWidth,
|
|
)
|
|
expect(hasHScroll).toBe(false)
|
|
})
|
|
|
|
test('mobile: secondary user columns are hidden @mobile', async ({ page }) => {
|
|
await signInAsAdmin(page)
|
|
await page.goto('/admin/users')
|
|
await page.waitForURL(/admin\/users/, { timeout: 10000 })
|
|
|
|
const table = page.locator('table')
|
|
await expect(table.locator('th', { hasText: /email/i })).not.toBeVisible()
|
|
await expect(table.locator('th', { hasText: /quota/i })).not.toBeVisible()
|
|
await expect(table.locator('th', { hasText: /created/i })).not.toBeVisible()
|
|
})
|
|
})
|