Skip to content

Commit f63a54e

Browse files
committed
fix: update E2E tests to use CONSOLE_BASE for consistent routing
1 parent f1c2fc1 commit f63a54e

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

e2e/console-rendering.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from '@playwright/test';
2-
import { waitForReactMount } from './helpers';
2+
import { waitForReactMount, CONSOLE_BASE } from './helpers';
33

44
/**
55
* Console rendering & navigation E2E tests.
@@ -35,7 +35,7 @@ test.describe('Console Rendering', () => {
3535
}
3636
});
3737

38-
await page.goto('/');
38+
await page.goto(`${CONSOLE_BASE}/`);
3939
await waitForReactMount(page);
4040

4141
expect(
@@ -45,7 +45,7 @@ test.describe('Console Rendering', () => {
4545
});
4646

4747
test('should resolve client-side routes without blank content', async ({ page }) => {
48-
await page.goto('/');
48+
await page.goto(`${CONSOLE_BASE}/`);
4949
await waitForReactMount(page);
5050

5151
// After routing, the page should have meaningful DOM content
@@ -56,7 +56,7 @@ test.describe('Console Rendering', () => {
5656
test('should serve index.html for SPA fallback routes', async ({ page }) => {
5757
// Vercel blank-page issues often stem from missing SPA rewrites.
5858
// Navigate to a deep route — the server must return index.html (not 404).
59-
const response = await page.goto('/apps/default/some-object');
59+
const response = await page.goto(`${CONSOLE_BASE}/apps/default/some-object`);
6060
expect(response?.status(), 'Deep route returned non-200 status').toBeLessThan(400);
6161

6262
await waitForReactMount(page);
@@ -70,7 +70,7 @@ test.describe('Console Rendering', () => {
7070
test('should include the MSW service worker in the build output', async ({ page }) => {
7171
// The mock server requires mockServiceWorker.js to be served from /public.
7272
// If it's missing, the app may hang during bootstrap.
73-
const response = await page.request.get('/mockServiceWorker.js');
73+
const response = await page.request.get(`${CONSOLE_BASE}/mockServiceWorker.js`);
7474

7575
// In production builds without MSW, 404 is acceptable.
7676
// But if the build includes it, it must be valid JS.

e2e/helpers/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import type { Page } from '@playwright/test';
22

3+
/**
4+
* Base path for the console app.
5+
* Matches `base` in `apps/console/vite.config.ts` (defaults to '/console/').
6+
*/
7+
export const CONSOLE_BASE = '/console';
8+
39
/** Wait for React to mount (at least one child inside #root). */
410
export async function waitForReactMount(page: Page) {
511
await page.waitForFunction(

e2e/mobile-viewport.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect, devices } from '@playwright/test';
2-
import { waitForReactMount } from './helpers';
2+
import { waitForReactMount, CONSOLE_BASE } from './helpers';
33

44
/**
55
* P5.5 Mobile viewport tests for the Console app.
@@ -38,14 +38,14 @@ test.describe('P5.5 Mobile Viewport Tests', () => {
3838
const errors: string[] = [];
3939
page.on('pageerror', (err) => errors.push(err.message));
4040

41-
await page.goto('/');
41+
await page.goto(`${CONSOLE_BASE}/`);
4242
await waitForReactMount(page);
4343

4444
expect(errors, 'Uncaught JS errors on mobile viewport').toEqual([]);
4545
});
4646

4747
test('should render meaningful content (no blank page)', async ({ page }) => {
48-
await page.goto('/');
48+
await page.goto(`${CONSOLE_BASE}/`);
4949
await waitForReactMount(page);
5050

5151
const root = page.locator('#root');
@@ -55,19 +55,19 @@ test.describe('P5.5 Mobile Viewport Tests', () => {
5555
});
5656

5757
test('should have viewport meta tag with viewport-fit=cover', async ({ page }) => {
58-
await page.goto('/');
58+
await page.goto(`${CONSOLE_BASE}/`);
5959
const meta = page.locator('meta[name="viewport"]');
6060
await expect(meta).toHaveAttribute('content', /viewport-fit=cover/);
6161
});
6262

6363
test('should have PWA manifest link', async ({ page }) => {
64-
await page.goto('/');
64+
await page.goto(`${CONSOLE_BASE}/`);
6565
const manifestLink = page.locator('link[rel="manifest"]');
6666
await expect(manifestLink).toBeAttached();
6767
});
6868

6969
test('should not have horizontal overflow', async ({ page }) => {
70-
await page.goto('/');
70+
await page.goto(`${CONSOLE_BASE}/`);
7171
await waitForReactMount(page);
7272

7373
const hasOverflow = await page.evaluate(() => {
@@ -77,7 +77,7 @@ test.describe('P5.5 Mobile Viewport Tests', () => {
7777
});
7878

7979
test('should have touch targets ≥ 44px for interactive elements', async ({ page }) => {
80-
await page.goto('/');
80+
await page.goto(`${CONSOLE_BASE}/`);
8181
await waitForReactMount(page);
8282

8383
// Check all visible buttons have reasonable touch target size

e2e/smoke.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from '@playwright/test';
2-
import { waitForReactMount } from './helpers';
2+
import { waitForReactMount, CONSOLE_BASE } from './helpers';
33

44
/**
55
* Smoke tests for the console production build.
@@ -18,15 +18,15 @@ test.describe('Console App – Smoke', () => {
1818
const errors: string[] = [];
1919
page.on('pageerror', (err) => errors.push(err.message));
2020

21-
await page.goto('/');
21+
await page.goto(`${CONSOLE_BASE}/`);
2222
await waitForReactMount(page);
2323

2424
// The page must not have thrown any uncaught exceptions
2525
expect(errors, 'Uncaught JS errors during page load').toEqual([]);
2626
});
2727

2828
test('should render React content inside #root', async ({ page }) => {
29-
await page.goto('/');
29+
await page.goto(`${CONSOLE_BASE}/`);
3030
await waitForReactMount(page);
3131

3232
// #root must exist and have child elements (React mounted successfully)
@@ -37,7 +37,7 @@ test.describe('Console App – Smoke', () => {
3737
});
3838

3939
test('should not show a blank page (meaningful text rendered)', async ({ page }) => {
40-
await page.goto('/');
40+
await page.goto(`${CONSOLE_BASE}/`);
4141
await waitForReactMount(page);
4242

4343
// Wait for visible text to appear (SPA may still be rendering after mount)
@@ -64,19 +64,19 @@ test.describe('Console App – Smoke', () => {
6464
}
6565
});
6666

67-
await page.goto('/');
67+
await page.goto(`${CONSOLE_BASE}/`);
6868
await page.waitForLoadState('networkidle');
6969

7070
expect(failedAssets, 'Critical assets returned HTTP errors').toEqual([]);
7171
});
7272

7373
test('should have correct page title', async ({ page }) => {
74-
await page.goto('/');
74+
await page.goto(`${CONSOLE_BASE}/`);
7575
await expect(page).toHaveTitle(/ObjectStack|ObjectUI|Console/i);
7676
});
7777

7878
test('should show the app shell or loading screen', async ({ page }) => {
79-
await page.goto('/');
79+
await page.goto(`${CONSOLE_BASE}/`);
8080

8181
// Either the app shell (nav / sidebar) or the loading screen should appear
8282
// within a reasonable time. Both are acceptable initial states.

e2e/view-workflows.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from '@playwright/test';
2-
import { waitForReactMount } from './helpers';
2+
import { waitForReactMount, CONSOLE_BASE } from './helpers';
33

44
/**
55
* Critical view workflow E2E tests.
@@ -15,7 +15,7 @@ import { waitForReactMount } from './helpers';
1515
*/
1616

1717
/** Base path for the default app — mirrors route: /apps/:appName/:objectName */
18-
const APP_BASE = '/apps/default';
18+
const APP_BASE = `${CONSOLE_BASE}/apps/default`;
1919

2020
/**
2121
* Waits for the app shell to be fully interactive (sidebar or main nav visible).

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default defineConfig({
6363
*/
6464
webServer: {
6565
command: 'pnpm turbo run build --filter=@object-ui/console && pnpm --filter @object-ui/console preview --port 4173',
66-
url: 'http://localhost:4173',
66+
url: 'http://localhost:4173/console/',
6767
reuseExistingServer: !process.env.CI,
6868
timeout: 180 * 1000,
6969
},

0 commit comments

Comments
 (0)