Skip to content

Commit 540e706

Browse files
authored
Merge pull request #1121 from trycompai/main
[comp] Production Deploy
2 parents 57d86e1 + 9db890c commit 540e706

65 files changed

Lines changed: 1026 additions & 3642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ jobs:
198198
UPSTASH_REDIS_REST_TOKEN: dummy-token
199199
RESEND_API_KEY: dummy-resend-key
200200
TRIGGER_SECRET_KEY: dummy-trigger-key
201-
STRIPE_SECRET_KEY: sk_test_dummy_key_for_ci_builds
202-
STRIPE_WEBHOOK_SECRET: whsec_test_dummy_webhook_secret
203201

204202
- name: Start server
205203
run: |
@@ -282,8 +280,6 @@ jobs:
282280
UPSTASH_REDIS_REST_TOKEN: dummy-token
283281
RESEND_API_KEY: dummy-resend-key
284282
TRIGGER_SECRET_KEY: dummy-trigger-key
285-
STRIPE_SECRET_KEY: sk_test_dummy_key_for_ci_builds
286-
STRIPE_WEBHOOK_SECRET: whsec_test_dummy_webhook_secret
287283

288284
- name: Run E2E tests
289285
run: |
@@ -305,8 +301,6 @@ jobs:
305301
UPSTASH_REDIS_REST_TOKEN: dummy-token
306302
RESEND_API_KEY: dummy-resend-key
307303
TRIGGER_SECRET_KEY: dummy-trigger-key
308-
STRIPE_SECRET_KEY: sk_test_dummy_key_for_ci_builds
309-
STRIPE_WEBHOOK_SECRET: whsec_test_dummy_webhook_secret
310304

311305
- name: Generate test summary
312306
if: always()

.github/workflows/quick-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ jobs:
7474
UPSTASH_REDIS_REST_TOKEN: dummy-token
7575
RESEND_API_KEY: dummy-resend-key
7676
TRIGGER_SECRET_KEY: dummy-trigger-key
77-
STRIPE_SECRET_KEY: sk_test_dummy_key_for_ci_builds
78-
STRIPE_WEBHOOK_SECRET: whsec_test_dummy_webhook_secret
7977

8078
- name: Post test results to PR
8179
if: failure() && github.event_name == 'pull_request'

.github/workflows/test-quick.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,3 @@ jobs:
9494
UPSTASH_REDIS_REST_TOKEN: dummy-token
9595
RESEND_API_KEY: dummy-resend-key
9696
TRIGGER_SECRET_KEY: dummy-trigger-key
97-
STRIPE_SECRET_KEY: sk_test_dummy_key_for_ci_builds
98-
STRIPE_WEBHOOK_SECRET: whsec_test_dummy_webhook_secret

apps/app/.env.example

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ RESEND_API_KEY="" # Resend Dashboard -> API Keys
2222
UPSTASH_REDIS_REST_URL="" # Upstash Console -> Redis -> Create Database
2323
UPSTASH_REDIS_REST_TOKEN="" # Found in the same database details page
2424

25-
# Payment Processing
26-
# Stripe (https://dashboard.stripe.com/apikeys)
27-
STRIPE_SECRET_KEY="" # Stripe Dashboard -> Developers -> API keys
28-
STRIPE_WEBHOOK_SECRET="" # Stripe Dashboard -> Developers -> Webhooks
29-
3025
# File Storage
3126
# Upload Thing (https://uploadthing.com/dashboard)
3227
UPLOADTHING_TOKEN="" # Upload Thing Dashboard -> API Keys

apps/app/e2e/simple-auth.spec.ts

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,53 @@
11
import { expect, test } from '@playwright/test';
2+
import { authenticateTestUser } from './utils/auth-helpers';
23

34
test('simple auth flow', async ({ page, context, browserName }) => {
4-
// Create a test user and authenticate
5-
const testEmail = `test-${Date.now()}@example.com`;
6-
7-
console.log(`[${browserName}] Starting test with email: ${testEmail}`);
8-
9-
const response = await context.request.post('http://localhost:3000/api/auth/test-login', {
10-
data: {
11-
email: testEmail,
12-
name: 'Test User',
13-
},
14-
timeout: 30000, // 30 second timeout
5+
const testEmail = `test-${Date.now()}-${Math.random().toString(36).substring(7)}-${browserName}@example.com`;
6+
7+
// Authenticate user
8+
await authenticateTestUser(page, {
9+
email: testEmail,
10+
name: 'Test User',
11+
skipOrg: false,
12+
hasAccess: true,
1513
});
1614

17-
// Add debugging for all browsers
18-
if (!response.ok()) {
19-
console.error(`[${browserName}] Test login failed:`, {
20-
status: response.status(),
21-
statusText: response.statusText(),
22-
});
23-
try {
24-
const body = await response.text();
25-
console.error(`[${browserName}] Response body:`, body);
26-
} catch (e) {
27-
console.error(`[${browserName}] Could not read response body`);
28-
}
29-
}
30-
31-
expect(response.ok()).toBeTruthy();
32-
const data = await response.json();
33-
expect(data.success).toBe(true);
34-
expect(data.user).toBeDefined();
35-
expect(data.user.email).toBe(testEmail);
36-
expect(data.user.emailVerified).toBe(true);
37-
3815
// Verify session cookie was set
3916
const cookies = await context.cookies();
4017
const sessionCookie = cookies.find((c) => c.name === 'better-auth.session_token');
4118
expect(sessionCookie).toBeDefined();
42-
expect(sessionCookie?.httpOnly).toBe(true);
4319

44-
// Navigate to auth page - should be redirected since we're authenticated
45-
await page.goto('http://localhost:3000/auth', { waitUntil: 'domcontentloaded' });
20+
// Navigate to root first to let the user settle into their authenticated state
21+
await page.goto('/', { waitUntil: 'domcontentloaded' });
22+
await page.waitForTimeout(3000); // Wait for all redirects to complete
23+
24+
const afterRootUrl = page.url();
25+
console.log('URL after navigating to root:', afterRootUrl);
26+
27+
// Now navigate to auth page - should be redirected since we're authenticated
28+
await page.goto('/auth', { waitUntil: 'domcontentloaded' });
4629

47-
// Wait for the redirect to happen
48-
// Since we know we should be redirected, wait for URL change
49-
let retries = 0;
50-
const maxRetries = 10;
30+
// Wait for redirect away from auth
31+
await page.waitForURL((url) => !url.toString().includes('/auth'), { timeout: 5000 });
5132

52-
while (page.url().includes('/auth') && retries < maxRetries) {
53-
await page.waitForTimeout(500);
54-
retries++;
33+
// If we're on root, wait for the subsequent redirect to final destination
34+
if (new URL(page.url()).pathname === '/') {
35+
console.log('On root route, waiting for final redirect...');
36+
await page.waitForURL((url) => new URL(url).pathname !== '/', { timeout: 5000 });
5537
}
5638

5739
const currentUrl = page.url();
40+
console.log('Final URL after auth redirect:', currentUrl);
5841

59-
// Verify we're redirected to an authenticated route
6042
expect(currentUrl).not.toContain('/auth');
6143

62-
// Common authenticated routes include /setup, /dashboard, /upgrade, or organization-specific routes
44+
// User should be on one of these meaningful authenticated routes
6345
const isAuthenticatedRoute =
64-
currentUrl.includes('/setup') ||
65-
currentUrl.includes('/dashboard') ||
66-
currentUrl.includes('/upgrade') ||
67-
currentUrl.includes('/org_');
46+
currentUrl.includes('/setup') || // Setup flow
47+
currentUrl.match(/\/org_[a-zA-Z0-9]+\//) !== null || // Organization pages
48+
currentUrl.includes('/upgrade') || // Upgrade page
49+
currentUrl.includes('/no-access') || // No access page
50+
currentUrl.includes('/onboarding'); // Onboarding flow
6851

6952
expect(isAuthenticatedRoute).toBeTruthy();
7053
});

apps/app/e2e/tests/middleware-onboarding.spec.ts

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@ test.describe('Middleware Onboarding Behavior', () => {
1818
});
1919

2020
// Try to access organization page
21-
await page.goto('/');
22-
23-
// Should NOT be redirected to onboarding
24-
await page.waitForTimeout(2000); // Give time for any redirects
25-
expect(page.url()).not.toContain('/onboarding');
26-
27-
// Should be on an authenticated page (org page, frameworks, etc)
28-
const isOnOrgPage =
29-
page.url().includes('/org_') ||
30-
page.url().includes('/frameworks') ||
31-
page.url().includes('/setup');
32-
expect(isOnOrgPage).toBeTruthy();
21+
await page.goto('/', { waitUntil: 'domcontentloaded' });
22+
23+
// Wait for all redirects to complete
24+
await page.waitForTimeout(3000); // Just wait for redirects to settle
25+
26+
const currentUrl = page.url();
27+
console.log('Current URL after navigation:', currentUrl);
28+
29+
expect(currentUrl).not.toContain('/onboarding');
30+
31+
// Should be on an authenticated page - could be org page or setup (if activeOrgId not set)
32+
const isOnValidPage =
33+
currentUrl.match(/\/org_[a-zA-Z0-9]+\//) !== null || // Organization routes
34+
currentUrl.match(/\/setup\/[a-zA-Z0-9]+/) !== null || // Dynamic setup URLs
35+
currentUrl.includes('/upgrade'); // Upgrade page
36+
37+
expect(isOnValidPage).toBeTruthy();
3338
});
3439

3540
test('user without org is redirected to setup', async ({ page }) => {
@@ -43,19 +48,32 @@ test.describe('Middleware Onboarding Behavior', () => {
4348
});
4449

4550
// Navigate to root
46-
await page.goto('/');
51+
await page.goto('/', { waitUntil: 'domcontentloaded' });
4752

48-
// Should be redirected to setup
49-
await page.waitForURL(/\/setup\/[a-zA-Z0-9]+/, { timeout: 10000 });
50-
expect(page.url()).toContain('/setup/');
53+
// Wait for redirects
54+
await page.waitForTimeout(2000);
55+
56+
const currentUrl = page.url();
57+
console.log('User without org redirected to:', currentUrl);
58+
59+
// Should be redirected to setup (with dynamic ID)
60+
expect(currentUrl).toMatch(/\/setup\/[a-zA-Z0-9]+/);
5161
});
5262

5363
test('unauthenticated user is redirected to auth', async ({ page }) => {
54-
// Try to access protected route without auth
55-
await page.goto('/org_123/frameworks');
64+
// Try to access protected route without auth, expecting redirect
65+
const response = await page.goto('/org_123/frameworks', {
66+
waitUntil: 'commit', // Just wait for navigation to start, not complete
67+
});
68+
69+
// Wait a bit for redirect
70+
await page.waitForTimeout(1000);
71+
72+
// Check final URL
73+
const currentUrl = page.url();
74+
console.log('Unauthenticated user redirected to:', currentUrl);
5675

5776
// Should be redirected to auth
58-
await page.waitForURL(/\/auth/, { timeout: 5000 });
59-
expect(page.url()).toContain('/auth');
77+
expect(currentUrl).toContain('/auth');
6078
});
6179
});

apps/app/e2e/tests/onboarding.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { fillFormField, generateTestData, waitForURL } from '../utils/helpers';
55
// Increase test timeout for complex flows
66
test.describe.configure({ timeout: 60000 });
77

8-
test.describe('Onboarding Flow', () => {
8+
// DEPRECATED: This test file is for the old full onboarding flow.
9+
// The new split onboarding flow is tested in split-onboarding.spec.ts
10+
test.describe.skip('Onboarding Flow (DEPRECATED)', () => {
911
test.beforeEach(async ({ page }) => {
1012
// Clear any existing auth state
1113
await clearAuth(page);
@@ -388,7 +390,7 @@ test.describe('Onboarding Flow', () => {
388390
});
389391
});
390392

391-
test.describe('Setup Page Components', () => {
393+
test.describe.skip('Setup Page Components (DEPRECATED)', () => {
392394
test.beforeEach(async ({ page }) => {
393395
const testData = generateTestData();
394396

0 commit comments

Comments
 (0)