|
1 | 1 | import { test, expect } from '@playwright/test' |
| 2 | +import { navigateAndWait, expectPageLoaded } from './test-helpers' |
2 | 3 |
|
3 | 4 | test.describe('Home Page', () => { |
4 | 5 | test('should load home page', async ({ page }) => { |
5 | 6 | await page.goto('/') |
6 | | - // Title is "LaSuite Meet" (no space) as set in compose.yml |
7 | 7 | await expect(page).toHaveTitle(/LaSuite Meet/i) |
8 | 8 | }) |
9 | 9 |
|
10 | 10 | test('should display heading text when backend is available', async ({ page }) => { |
11 | | - await page.goto('/') |
12 | | - |
13 | | - // Wait for network activity to settle |
14 | | - await page.waitForLoadState('networkidle') |
15 | | - |
16 | | - // The Home component depends on API calls (useConfig, useUser) |
17 | | - // UserAware shows LoadingScreen until isLoggedIn is defined |
18 | | - // This test requires the backend to be running |
19 | | - |
20 | | - // Wait a bit for React to render |
| 11 | + await navigateAndWait(page, '/') |
21 | 12 | await page.waitForTimeout(2000) |
22 | 13 |
|
23 | | - // Check for heading - it may not appear if backend API calls are failing |
24 | 14 | const heading = page.locator('h1').first() |
25 | | - |
26 | | - // Check if heading exists (if backend is available) |
27 | 15 | const headingVisible = await heading.isVisible().catch(() => false) |
28 | 16 |
|
29 | 17 | if (headingVisible) { |
30 | | - // Backend is available - verify heading content |
31 | 18 | const headingText = await heading.textContent() |
32 | 19 | expect(headingText).toBeTruthy() |
33 | 20 | expect(headingText?.trim().length).toBeGreaterThan(0) |
34 | 21 | } else { |
35 | | - // Backend not available - verify page at least loads |
36 | | - // The page should show loading or error state, not be blank |
| 22 | + await expectPageLoaded(page) |
37 | 23 | const body = page.locator('body') |
38 | | - await expect(body).toBeVisible() |
39 | | - |
40 | | - // Check for loading state |
41 | 24 | const hasContent = await body.textContent().then(text => text && text.trim().length > 0) |
42 | 25 | expect(hasContent).toBe(true) |
43 | | - |
44 | | - // Skip test - backend required |
45 | | - test.skip(true, 'Backend API not available - heading requires API calls to render') |
| 26 | + test.skip(true, 'Backend API not available') |
46 | 27 | } |
47 | 28 | }) |
48 | 29 |
|
49 | 30 | test('should have create meeting button when logged out', async ({ page }) => { |
50 | | - await page.goto('/') |
51 | | - await page.waitForLoadState('networkidle') |
52 | | - |
53 | | - // Page should load successfully |
54 | | - await expect(page.locator('body')).toBeVisible() |
| 31 | + await navigateAndWait(page, '/') |
| 32 | + await expectPageLoaded(page) |
55 | 33 | }) |
56 | 34 |
|
57 | 35 | test('should navigate to legal pages', async ({ page }) => { |
58 | | - await page.goto('/') |
59 | | - await page.waitForLoadState('networkidle') |
| 36 | + await navigateAndWait(page, '/') |
60 | 37 |
|
61 | | - // Try to find footer links |
62 | 38 | const footer = page.locator('footer') |
63 | 39 | if (await footer.isVisible()) { |
64 | | - // Check if footer links work |
65 | 40 | const links = footer.locator('a') |
66 | 41 | const count = await links.count() |
67 | 42 | expect(count).toBeGreaterThan(0) |
|
0 commit comments