Skip to content

Commit 0e73626

Browse files
authored
Merge pull request #329 from OpenElements/dev-br-ap
Enhance routing and language switch tests; refactor shortcode handling
2 parents 3866737 + 80bb062 commit 0e73626

10 files changed

Lines changed: 81 additions & 64 deletions

.husky/pre-commit

Lines changed: 0 additions & 12 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"build": "next build",
99
"start": "next start",
1010
"lint": "eslint .",
11-
"test:e2e": "playwright test",
12-
"prepare": "husky"
11+
"test:e2e": "playwright test"
1312
},
1413
"devDependencies": {
1514
"@playwright/test": "^1.55.0",
@@ -26,7 +25,6 @@
2625
"eslint": "^9.39.2",
2726
"eslint-config-next": "^16.1.0",
2827
"eslint-config-prettier": "^10.1.8",
29-
"husky": "^9.1.7",
3028
"npm-run-all": "^4.1.5",
3129
"postcss": "^8.5.6",
3230
"prettier": "^3.8.0",

pnpm-lock.yaml

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/routing.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ export const routing = defineRouting({
77

88
// Used when no locale matches
99
defaultLocale: 'en',
10-
10+
1111
// The prefix for the default locale when it's in the path
12-
localePrefix: 'as-needed'
12+
localePrefix: 'as-needed',
13+
14+
// Keep existing unprefixed URLs stable instead of redirecting based on browser language.
15+
localeDetection: false,
1316
});
1417

1518
// Lightweight wrappers around Next.js' navigation APIs

tests/e2e/code-highlighting.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import { test, expect } from '@playwright/test';
22

33
test.describe('Code highlighting', () => {
44
test('render production-like syntax colors for fenced code blocks', async ({ page }) => {
5-
await page.goto('/posts/2026-03-12-java-modules-encapsulation-internal-packages');
5+
await page.goto('/posts/2023-04-18-detect-null-errors-with-static-analysis', {
6+
waitUntil: 'domcontentloaded',
7+
});
8+
await expect(page.locator('main')).toBeVisible();
69

710
const articleBody = page.locator('main .prose').first();
811
const codeBlock = articleBody.locator('.highlight pre').first();
912
const keywordToken = codeBlock.locator('.token.keyword').first();
10-
const punctuationToken = codeBlock.locator('.token.punctuation').first();
13+
const operatorToken = codeBlock.locator('.token.operator').first();
1114

1215
await expect(codeBlock).toBeVisible();
1316
await expect(codeBlock).toHaveCSS('background-color', 'rgb(39, 40, 34)');
1417
await expect(keywordToken).toHaveCSS('color', 'rgb(102, 217, 239)');
15-
await expect(punctuationToken).toHaveCSS('color', 'rgb(249, 38, 114)');
18+
await expect(operatorToken).toHaveCSS('color', 'rgb(249, 38, 114)');
1619
});
1720
});
Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
import { test, expect } from '@playwright/test';
22

33
test.describe('Markdown shortcode links', () => {
4-
test('render relref links inside markdown link syntax', async ({ page }) => {
5-
await page.goto('/posts/2026-03-12-java-modules-encapsulation-internal-packages');
4+
test('render relref and ref links to post and top-level routes', async ({ page }) => {
5+
await page.goto('/posts/2026-02-10-review-2025', {
6+
waitUntil: 'domcontentloaded',
7+
});
8+
await expect(page.locator('main')).toBeVisible();
69

710
const articleBody = page.locator('main .prose').first();
811
const firstArticleLink = articleBody.locator(
9-
'a[href="/posts/2026-01-27-java-modules-maven4-basics"]',
12+
'a[href="/posts/2025-01-16-open-elements-in-2024"]',
1013
);
11-
const homeworkLink = articleBody.locator(
12-
'a[href="/posts/2026-02-26-java-modules-maven4-basics-homework"]',
14+
const supportCareLink = articleBody.locator(
15+
'a[href="/support-care-maven"]',
1316
);
1417

1518
await expect(firstArticleLink).toBeVisible();
16-
await expect(firstArticleLink).toContainText('first article');
17-
await expect(homeworkLink).toBeVisible();
18-
await expect(homeworkLink).toContainText('homework extension');
19+
await expect(firstArticleLink).toContainText('growth trajectory from 2024');
20+
await expect(supportCareLink.first()).toBeVisible();
1921
});
2022

21-
test('preserve relref fragments inside markdown links', async ({ page }) => {
22-
await page.goto('/posts/2026-02-26-java-modules-maven4-basics-homework');
23+
test('render relref links to nested routes', async ({ page }) => {
24+
await page.goto('/posts/2026-02-10-review-2025', {
25+
waitUntil: 'domcontentloaded',
26+
});
27+
await expect(page.locator('main')).toBeVisible();
2328

2429
const articleBody = page.locator('main .prose').first();
25-
const fragmentLink = articleBody.locator(
26-
'a[href="/posts/2026-01-27-java-modules-maven4-basics#the-module-source-hierarchy"]',
30+
const articleLink = articleBody.locator(
31+
'a[href="/articles/what-is-maven"]',
2732
);
33+
const employeeLink = articleBody.locator('a[href="/employees/jessie"]');
2834

29-
await expect(fragmentLink).toBeVisible();
30-
await expect(fragmentLink).toContainText('module source hierarchy');
35+
await expect(articleLink).toBeVisible();
36+
await expect(articleLink).toContainText('work on Apache Maven');
37+
await expect(employeeLink).toBeVisible();
38+
await expect(employeeLink).toContainText('Jessy Ssebuliba');
3139
});
3240
});

tests/e2e/markdown-tables.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ import { test, expect } from '@playwright/test';
22

33
test.describe('Markdown tables', () => {
44
test('render GFM tables in blog posts', async ({ page }) => {
5-
await page.goto('/posts/2026-03-12-java-modules-encapsulation-internal-packages');
5+
await page.goto('/posts/2020-02-21-adopt-tests', {
6+
waitUntil: 'domcontentloaded',
7+
});
8+
await expect(page.locator('main')).toBeVisible();
69

710
const articleBody = page.locator('main .prose').first();
811
const table = articleBody.locator('table').first();
912

1013
await expect(table).toBeVisible();
11-
await expect(table).toContainText('Aspect');
12-
await expect(table).toContainText('Classpath');
13-
await expect(table).toContainText('Module Path');
14-
await expect(table.locator('tr')).toHaveCount(5);
14+
await expect(table).toContainText('name');
15+
await expect(table).toContainText('openjdk');
16+
await expect(table).toContainText('functional');
17+
await expect(table.locator('tr')).toHaveCount(7);
1518
});
1619
});

tests/e2e/post-heading-anchors.spec.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@ import { test, expect } from '@playwright/test';
22

33
test.describe('Post heading anchors', () => {
44
test('render Hugo-style anchor links for post headlines', async ({ page }) => {
5-
await page.goto('/posts/2026-03-12-java-modules-encapsulation-internal-packages');
5+
await page.goto('/posts/2026-03-05-oss-ai-slop', {
6+
waitUntil: 'domcontentloaded',
7+
});
8+
await expect(page.locator('main')).toBeVisible();
69

710
const articleBody = page.locator('main .prose').first();
811
const punctuatedHeading = articleBody.locator(
9-
'h2#controlling-visibility-with-module-infojava',
12+
'h2#case-study-an-unusual-contribution-trend-in-the-context-of-major-projects',
13+
);
14+
const whyItMattersAnchor = articleBody.locator(
15+
'h2#why-this-ai-slop-matters a[href="#why-this-ai-slop-matters"]',
1016
);
11-
const sourceCodeAnchor = articleBody.locator('h2#source-code a[href="#source-code"]');
1217

1318
await expect(punctuatedHeading).toBeVisible();
1419
await expect(
1520
punctuatedHeading.locator(
16-
'a[href="#controlling-visibility-with-module-infojava"] [data-icon="mdi-link-variant"]',
21+
'a[href="#case-study-an-unusual-contribution-trend-in-the-context-of-major-projects"] [data-icon="mdi-link-variant"]',
1722
),
1823
).toHaveCount(1);
1924

20-
await expect(sourceCodeAnchor).toBeVisible();
21-
await sourceCodeAnchor.click();
22-
await expect(page).toHaveURL(/#source-code$/);
25+
await expect(whyItMattersAnchor).toBeVisible();
26+
await whyItMattersAnchor.click();
27+
await expect(page).toHaveURL(/#why-this-ai-slop-matters$/);
2328
});
2429
});

tests/e2e/post-images-centering.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ async function expectImageToBeCentered(page: Page, imageSelector: string) {
2727

2828
test.describe('Post images', () => {
2929
test('center standalone images in blog posts', async ({ page }) => {
30-
await page.goto('/posts/2025-01-16-open-elements-in-2024');
30+
await page.goto('/posts/2020-02-21-adopt-tests', {
31+
waitUntil: 'domcontentloaded',
32+
});
33+
await expect(page.locator('main')).toBeVisible();
34+
await expectImageToBeCentered(page, 'img[alt="ci pipeline"]');
35+
36+
await page.goto('/posts/2026-03-12-agentic-wallets', {
37+
waitUntil: 'domcontentloaded',
38+
});
39+
await expect(page.locator('main')).toBeVisible();
3140
await expectImageToBeCentered(
3241
page,
33-
'img[alt="Open Elements continues to focus on open source and Java"]',
42+
'img[alt="AI agents are blocked by traditional payment infrastructure that requires human identity verification"]',
3443
);
35-
36-
await page.goto('/posts/2026-01-27-java-modules-maven4-basics');
37-
await expectImageToBeCentered(page, 'img[alt="Module dependencies"]');
38-
39-
await page.goto('/posts/2026-03-05-oss-ai-slop');
40-
await expectImageToBeCentered(page, 'img[alt="Symbolic image of open source maintenance"]');
4144
});
4245
});

tests/e2e/post-language-switch.spec.ts

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

33
test.describe('Blog post language switch', () => {
4+
test('keeps direct English post URLs stable for German browser preferences', async ({ browser }) => {
5+
const context = await browser.newContext({
6+
extraHTTPHeaders: {
7+
'Accept-Language': 'de-DE,de',
8+
},
9+
});
10+
const page = await context.newPage();
11+
12+
await page.goto('/posts/2026/03/12/agentic-wallets-when-ai-agents-need-to-pay');
13+
14+
await expect(page).toHaveURL(/\/posts\/2026\/03\/12\/agentic-wallets-when-ai-agents-need-to-pay\/?$/);
15+
await expect(page.getByRole('heading', { level: 1 })).toContainText('Agentic Wallets');
16+
17+
await context.close();
18+
});
19+
420
test('hides the language switch on an English-only post', async ({ page }) => {
521
await page.goto('/posts/2026-03-12-agentic-wallets');
622

0 commit comments

Comments
 (0)