stats.spec.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { test, expect } from '@playwright/test'
  2. test.describe('Stats/Dashboard E2E Tests', () => {
  3. const username = process.env.TEST_USERNAME || 'admin'
  4. const password = process.env.TEST_PASSWORD || '123456'
  5. async function login(page: any) {
  6. await page.goto('/login')
  7. await page.getByPlaceholder('请输入用户名').fill(username)
  8. await page.getByPlaceholder('请输入密码').fill(password)
  9. await page.getByRole('button', { name: '登 录' }).click()
  10. await expect(page).not.toHaveURL(/\/login/, { timeout: 10000 })
  11. }
  12. test.describe('Dashboard Page', () => {
  13. test.skip('should display dashboard after login', async ({ page }) => {
  14. await login(page)
  15. // Default redirect should be dashboard
  16. await expect(page).toHaveURL(/\/dashboard/)
  17. })
  18. test.skip('should display stats cards', async ({ page }) => {
  19. await login(page)
  20. await page.goto('/dashboard')
  21. // Check for stat card elements
  22. await expect(page.locator('.el-card').first()).toBeVisible()
  23. })
  24. test.skip('should show machine statistics', async ({ page }) => {
  25. await login(page)
  26. await page.goto('/dashboard')
  27. // Look for machine related text
  28. await expect(page.getByText(/机器/)).toBeVisible()
  29. })
  30. test.skip('should show camera statistics', async ({ page }) => {
  31. await login(page)
  32. await page.goto('/dashboard')
  33. // Look for camera related text
  34. await expect(page.getByText(/摄像头/)).toBeVisible()
  35. })
  36. })
  37. test.describe('Navigation', () => {
  38. test.skip('should redirect to dashboard after login', async ({ page }) => {
  39. await login(page)
  40. await expect(page).toHaveURL(/\/dashboard/)
  41. })
  42. })
  43. })