Skip to content

Commit b7d9077

Browse files
committed
update tests
1 parent 6d00525 commit b7d9077

File tree

3 files changed

+102
-12
lines changed

3 files changed

+102
-12
lines changed

.github/workflows/playwright.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,18 @@ jobs:
4444

4545
- name: 🚀 Start Frontend App (Background)
4646
run: |
47+
echo "🔧 Environment variables:"
48+
echo "NODE_ENV: $NODE_ENV"
49+
echo "NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:0:10}..."
50+
echo ""
51+
echo "🚀 Starting server..."
4752
node apps/frontend/.next/standalone/apps/frontend/server.js &
48-
echo "FRONTEND_PID=$!" >> $GITHUB_ENV
53+
SERVER_PID=$!
54+
echo "FRONTEND_PID=$SERVER_PID" >> $GITHUB_ENV
55+
echo "✅ Server started with PID: $SERVER_PID"
56+
sleep 2
57+
echo "📊 Server process status:"
58+
ps aux | grep $SERVER_PID || echo "❌ Server process not found"
4959
shell: bash
5060
env:
5161
NODE_ENV: production
@@ -55,19 +65,42 @@ jobs:
5565

5666
- name: ⏳ Wait for Frontend to be Ready
5767
run: |
58-
echo "Waiting for frontend to start on http://localhost:3000..."
59-
timeout 20s bash -c 'until curl -f http://localhost:3000 > /dev/null 2>&1; do
60-
echo "Waiting for frontend..."
68+
echo "⏳ Waiting for frontend to start on http://localhost:3000..."
69+
ATTEMPT=0
70+
MAX_ATTEMPTS=20
71+
72+
until curl -f http://localhost:3000 > /dev/null 2>&1; do
73+
ATTEMPT=$((ATTEMPT + 1))
74+
echo "🔄 Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting for frontend..."
75+
76+
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
77+
echo "❌ Frontend failed to start after $MAX_ATTEMPTS attempts"
78+
echo "📊 Current processes:"
79+
ps aux | grep -E "(node|next)" | grep -v grep
80+
echo "🔍 Checking port 3000:"
81+
netstat -tulpn | grep 3000 || echo "No process on port 3000"
82+
exit 1
83+
fi
84+
6185
sleep 3
62-
done'
63-
echo "Frontend is ready!"
86+
done
87+
88+
echo "✅ Frontend is ready!"
6489
shell: bash
6590

66-
- name: 🔍 Health Check
91+
- name: 🔍 Detailed Health Check
6792
run: |
68-
echo "Running health check..."
69-
curl -f http://localhost:3000 -I | head -5
70-
echo "Health check passed!"
93+
echo "🏥 Running detailed health check..."
94+
echo "📡 HTTP response:"
95+
curl -f http://localhost:3000 -I | head -10
96+
echo ""
97+
echo "📄 Basic page content:"
98+
curl -s http://localhost:3000 | head -20
99+
echo ""
100+
echo "🔗 Testing login page:"
101+
curl -s http://localhost:3000/login | head -10 || echo "❌ Login page not accessible"
102+
echo ""
103+
echo "✅ Health check completed!"
71104
shell: bash
72105

73106
- name: 🧪 Run Playwright E2E Tests

packages/e2e-frontend/multi-device.spec.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,44 @@ async function createContext(
77
password: string,
88
viewport: { width: number; height: number }
99
) {
10+
console.log(`🖥️ Creating context for ${email} with viewport ${viewport.width}x${viewport.height}`);
11+
1012
const context = await browser.newContext({ viewport });
1113
const page = await context.newPage();
1214

15+
// Test basic connectivity
16+
console.log('🌐 Testing basic connectivity...');
17+
try {
18+
await page.goto('/', { waitUntil: 'networkidle', timeout: 30000 });
19+
console.log('🔗 Root page URL:', page.url());
20+
21+
// Check if page loaded successfully
22+
const title = await page.title();
23+
console.log('📄 Page title:', title);
24+
} catch (error) {
25+
console.log('❌ Failed to load root page:', error instanceof Error ? error.message : String(error));
26+
}
27+
1328
const login = new LoginPage(page);
1429
await login.goto();
1530
console.log('🔗 URL after login.goto():', page.url());
1631

1732
await login.login(email, password);
1833
console.log('🔗 URL after login.login():', page.url());
1934

20-
await page.waitForURL('/en');
21-
console.log("🔗 URL after waitForURL('/en'):", page.url());
35+
console.log('⏳ Waiting for URL to change to /en...');
36+
try {
37+
await page.waitForURL('/en', { timeout: 30000 });
38+
console.log("✅ URL after waitForURL('/en'):", page.url());
39+
} catch (error) {
40+
console.log('❌ waitForURL failed:', error instanceof Error ? error.message : String(error));
41+
console.log('🔗 Current URL:', page.url());
42+
43+
// Take screenshot for debugging
44+
await page.screenshot({ path: `debug-${email}-failed.png` });
45+
throw error;
46+
}
47+
2248
await expect(page.locator('text=Logged in')).toBeVisible();
2349
return { context, page };
2450
}

packages/e2e-frontend/pages/login.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,43 @@ export class LoginPage {
1818
}
1919

2020
async goto() {
21+
console.log('🔗 Navigating to login page...');
2122
await this.page.goto('/en/login');
23+
console.log('🔗 Current URL after goto:', this.page.url());
24+
25+
// Wait for page to be fully loaded
26+
await this.page.waitForLoadState('networkidle');
27+
console.log('✅ Login page loaded successfully');
2228
}
2329

2430
async login(email: string, password: string) {
31+
console.log('📝 Starting login process...');
32+
console.log('🔗 Current URL before login:', this.page.url());
33+
34+
// Check if form elements are available
35+
await this.emailInput.waitFor({ state: 'visible', timeout: 10000 });
36+
await this.passwordInput.waitFor({ state: 'visible', timeout: 10000 });
37+
await this.submitButton.waitFor({ state: 'visible', timeout: 10000 });
38+
39+
console.log('📧 Filling email field...');
2540
await this.emailInput.fill(email);
41+
42+
console.log('🔒 Filling password field...');
2643
await this.passwordInput.fill(password);
44+
45+
console.log('🔗 URL before submit:', this.page.url());
46+
console.log('🖱️ Clicking submit button...');
2747
await this.submitButton.click();
48+
49+
console.log('🔗 URL immediately after submit:', this.page.url());
50+
51+
// Wait for navigation to complete
52+
try {
53+
await this.page.waitForLoadState('networkidle', { timeout: 15000 });
54+
console.log('🔗 URL after navigation:', this.page.url());
55+
} catch (error) {
56+
console.log('⚠️ Navigation timeout or error:', error instanceof Error ? error.message : String(error));
57+
console.log('🔗 Final URL:', this.page.url());
58+
}
2859
}
2960
}

0 commit comments

Comments
 (0)