Skip to content

Commit 43be395

Browse files
committed
cleanup
1 parent b7d9077 commit 43be395

File tree

4 files changed

+74
-67
lines changed

4 files changed

+74
-67
lines changed

β€Ž.github/workflows/playwright.ymlβ€Ž

Lines changed: 70 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,61 @@ on:
66
workflow_dispatch:
77

88
jobs:
9+
detect-e2e-projects:
10+
name: πŸ” Detect Changed Projects
11+
runs-on: ubuntu-22.04
12+
outputs:
13+
e2e_packages: ${{ steps.detect.outputs.e2e_packages }}
14+
steps:
15+
- name: πŸ“₯ Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
- name: πŸ’» Node setup
19+
uses: ./.github/actions/node-setup
20+
21+
- name: 🧩 Detect changed apps and related E2E packages
22+
id: detect
23+
run: |
24+
echo "πŸ” Detecting changed packages..."
25+
CHANGED=$(pnpm turbo run build --filter=[HEAD^1]... --dry=json | jq -r '.packages[].name' | tr '\n' ' ')
26+
echo "Changed packages: $CHANGED"
27+
28+
E2E_PACKAGES=""
29+
for PKG in $CHANGED; do
30+
NAME=$(echo "$PKG" | sed 's/@infinum\///')
31+
E2E_NAME="e2e-$NAME"
32+
if [ -d "packages/$E2E_NAME" ]; then
33+
E2E_PACKAGES="$E2E_PACKAGES $E2E_NAME"
34+
fi
35+
done
36+
37+
if [ -z "$E2E_PACKAGES" ]; then
38+
echo "⚠️ No changed E2E packages found. Defaulting to e2e-frontend."
39+
E2E_PACKAGES="e2e-frontend"
40+
fi
41+
42+
echo "βœ… Detected E2E packages: $E2E_PACKAGES"
43+
44+
# Convert space-separated list into JSON array for matrix
45+
JSON_ARRAY=$(jq -cn --arg list "$E2E_PACKAGES" '{e2e_packages: ($list | split(" ") | map(select(length > 0)))}')
46+
echo "$JSON_ARRAY"
47+
echo "e2e_packages=$(echo $JSON_ARRAY | jq -r '.e2e_packages | @json')" >> $GITHUB_OUTPUT
48+
949
e2e-tests:
10-
name: πŸ§ͺ E2E Tests
11-
timeout-minutes: 60
50+
name: πŸ§ͺ Run E2E Tests (${{ matrix.e2e_package }})
51+
needs: detect-e2e-projects
1252
runs-on: ubuntu-22.04
53+
timeout-minutes: 60
54+
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
e2e_package: ${{ fromJSON(needs.detect-e2e-projects.outputs.e2e_packages) }}
1359

1460
env:
1561
NODE_ENV: test
1662
NEXTAUTH_SECRET: 'test-secret-for-ci-only'
63+
NEXTAUTH_URL: 'http://localhost:3000'
1764
NEXT_PUBLIC_EXAMPLE_VARIABLE: 'CI Test Variable'
1865
PRIVATE_EXAMPLE_VARIABLE: 'Private CI Test Variable'
1966
CI: true
@@ -38,80 +85,59 @@ jobs:
3885
with:
3986
browsers: 'chromium'
4087

41-
- name: πŸ—οΈ Build Frontend App
42-
run: pnpm --filter @infinum/frontend build
88+
# Build only the related app (derived from e2e-{project})
89+
- name: πŸ—οΈ Build Related App
90+
run: |
91+
APP_NAME=$(echo "${{ matrix.e2e_package }}" | sed 's/^e2e-//')
92+
echo "πŸ—οΈ Building @infinum/$APP_NAME..."
93+
pnpm --filter @infinum/$APP_NAME build
4394
shell: bash
4495

45-
- name: πŸš€ Start Frontend App (Background)
96+
- name: πŸš€ Start Related App (Background)
4697
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..."
52-
node apps/frontend/.next/standalone/apps/frontend/server.js &
98+
APP_NAME=$(echo "${{ matrix.e2e_package }}" | sed 's/^e2e-//')
99+
echo "πŸš€ Starting $APP_NAME..."
100+
node apps/$APP_NAME/.next/standalone/apps/$APP_NAME/server.js &
53101
SERVER_PID=$!
54102
echo "FRONTEND_PID=$SERVER_PID" >> $GITHUB_ENV
55-
echo "βœ… Server started with PID: $SERVER_PID"
103+
echo "βœ… $APP_NAME started with PID: $SERVER_PID"
56104
sleep 2
57-
echo "πŸ“Š Server process status:"
58105
ps aux | grep $SERVER_PID || echo "❌ Server process not found"
59106
shell: bash
60107
env:
61108
NODE_ENV: production
62109
NEXTAUTH_SECRET: 'test-secret-for-ci-only'
110+
NEXTAUTH_URL: 'http://localhost:3000'
63111
NEXT_PUBLIC_EXAMPLE_VARIABLE: 'CI Test Variable'
64112
PRIVATE_EXAMPLE_VARIABLE: 'Private CI Test Variable'
65113

66-
- name: ⏳ Wait for Frontend to be Ready
114+
- name: ⏳ Wait for App to be Ready
67115
run: |
68-
echo "⏳ Waiting for frontend to start on http://localhost:3000..."
116+
echo "⏳ Waiting for app to start on http://localhost:3000..."
69117
ATTEMPT=0
70118
MAX_ATTEMPTS=20
71119
72120
until curl -f http://localhost:3000 > /dev/null 2>&1; do
73121
ATTEMPT=$((ATTEMPT + 1))
74-
echo "πŸ”„ Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting for frontend..."
122+
echo "πŸ”„ Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting..."
75123
76124
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
77-
echo "❌ Frontend failed to start after $MAX_ATTEMPTS attempts"
78-
echo "πŸ“Š Current processes:"
125+
echo "❌ App failed to start after $MAX_ATTEMPTS attempts"
79126
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"
82127
exit 1
83128
fi
84-
85129
sleep 3
86130
done
87-
88-
echo "βœ… Frontend is ready!"
131+
echo "βœ… App is ready!"
89132
shell: bash
90133

91-
- name: πŸ” Detailed Health Check
134+
- name: πŸ§ͺ Run Playwright Tests for ${{ matrix.e2e_package }}
92135
run: |
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!"
136+
echo "🎬 Running pnpm ${{ matrix.e2e_package }}..."
137+
pnpm ${{ matrix.e2e_package }}
104138
shell: bash
105139

106-
- name: πŸ§ͺ Run Playwright E2E Tests
107-
run: |
108-
echo "🎬 Starting Playwright E2E Tests..."
109-
echo "================================================"
110-
pnpm e2e
111-
echo "================================================"
112-
echo "βœ… E2E Tests completed!"
113-
114-
- name: πŸ›‘ Stop Frontend App
140+
- name: πŸ›‘ Stop App
115141
shell: bash
116142
if: always()
117143
run: |

β€Žapps/frontend/src/app/[locale]/(public)/_components/LoginForm/LoginForm.tsxβ€Ž

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ export const LoginForm = () => {
1717
e.preventDefault();
1818
setError('');
1919

20-
// for testing purposes
21-
if (password === 'invalid') {
22-
setError('Invalid password');
23-
return;
24-
}
25-
2620
const res = await signIn('credentials', {
2721
redirect: false,
2822
email,

β€Žpackages/e2e-frontend/home.spec.tsβ€Ž

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ export const test = base.extend<{
99
await loginPage.goto();
1010
await loginPage.login('[email protected]', 'password123');
1111

12-
console.log('πŸ”— URL after login.goto():', page.url());
13-
1412
await page.waitForURL('/en');
1513

1614
const homePage = {
@@ -27,8 +25,6 @@ test.describe('Home Page', () => {
2725
test('should match home-page-content screenshot', async ({ page, browserName, homePage }) => {
2826
await homePage.goto();
2927

30-
console.log('πŸ”— URL after login.goto():', page.url());
31-
3228
// run `playwright test --update-snapshots` to update the screenshot
3329
const screenshotPath = `reports/screenshots/${browserName}-home-en.png`;
3430

β€Žpackages/e2e-frontend/multi-device.spec.tsβ€Ž

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@ 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-
1210
const context = await browser.newContext({ viewport });
1311
const page = await context.newPage();
1412

1513
// Test basic connectivity
16-
console.log('🌐 Testing basic connectivity...');
14+
1715
try {
1816
await page.goto('/', { waitUntil: 'networkidle', timeout: 30000 });
19-
console.log('πŸ”— Root page URL:', page.url());
2017

2118
// Check if page loaded successfully
2219
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-
}
20+
} catch (error) {}
2721

2822
const login = new LoginPage(page);
2923
await login.goto();
@@ -32,14 +26,11 @@ async function createContext(
3226
await login.login(email, password);
3327
console.log('πŸ”— URL after login.login():', page.url());
3428

35-
console.log('⏳ Waiting for URL to change to /en...');
3629
try {
3730
await page.waitForURL('/en', { timeout: 30000 });
38-
console.log("βœ… URL after waitForURL('/en'):", page.url());
31+
console.log('πŸ”— Successfully navigated to /en');
3932
} catch (error) {
40-
console.log('❌ waitForURL failed:', error instanceof Error ? error.message : String(error));
41-
console.log('πŸ”— Current URL:', page.url());
42-
33+
console.log('πŸ”— Failed to navigate to /en, current URL:', page.url());
4334
// Take screenshot for debugging
4435
await page.screenshot({ path: `debug-${email}-failed.png` });
4536
throw error;

0 commit comments

Comments
Β (0)