Files
zpan/e2e/responsive-admin.spec.ts
T
saltbo 3f15a6af52 fix(e2e): eliminate all skipped tests with setup project and admin login
- 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>
2026-04-12 21:08:01 -04:00

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()
})
})