Skip to content

Commit 0240acf

Browse files
committed
✅ Add routing e2e tests
1 parent 88096b5 commit 0240acf

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

playwright.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './tests/e2e',
5+
fullyParallel: true,
6+
forbidOnly: !!process.env.CI,
7+
retries: process.env.CI ? 2 : 0,
8+
workers: process.env.CI ? 1 : undefined,
9+
reporter: 'html',
10+
use: {
11+
baseURL: 'http://localhost:8080',
12+
trace: 'on-first-retry',
13+
screenshot: 'only-on-failure',
14+
},
15+
16+
projects: [
17+
{
18+
name: 'chromium',
19+
use: { ...devices['Desktop Chrome'] },
20+
},
21+
],
22+
23+
webServer: {
24+
command: 'echo "Using existing devcontainer web server"',
25+
url: 'http://localhost:8080',
26+
reuseExistingServer: true,
27+
},
28+
});

tests/e2e/routing.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('Routing', () => {
4+
test('Acorn handles the welcome route', async ({ page }) => {
5+
const response = await page.goto('/welcome/');
6+
expect(response?.status()).toBe(200);
7+
await expect(page).toHaveURL('/welcome/');
8+
await expect(page.locator('h1')).toContainText('Welcome to Radicle');
9+
});
10+
11+
test('WordPress admin routes are not intercepted', async ({ page }) => {
12+
const response = await page.goto('/wp-admin/');
13+
expect(response?.status()).toBe(302); // Redirect status
14+
await expect(page).toHaveURL(/wp-login\.php/);
15+
});
16+
17+
test('WordPress handles non-existent routes with 404', async ({ page }) => {
18+
const response = await page.goto('/non-existent-' + Date.now());
19+
expect(response?.status()).toBe(404);
20+
await expect(page.locator('body')).toContainText('Page not found');
21+
await expect(page.locator('body.error404')).toBeVisible();
22+
});
23+
24+
test('WordPress handles default homepage', async ({ page }) => {
25+
const response = await page.goto('/');
26+
expect(response?.status()).toBe(200);
27+
await expect(page.locator('body.home')).toBeVisible();
28+
});
29+
30+
test('WordPress REST API routes work', async ({ request }) => {
31+
const response = await request.get('/wp-json/');
32+
expect(response.status()).toBe(200);
33+
const data = await response.json();
34+
expect(data.name).toBeDefined();
35+
expect(data.url).toBeDefined();
36+
});
37+
38+
test('WordPress search route works', async ({ page }) => {
39+
const response = await page.goto('/?s=test');
40+
expect(response?.status()).toBe(200);
41+
await expect(page.locator('body.search')).toBeVisible();
42+
});
43+
});

0 commit comments

Comments
 (0)