Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/[lang]/blog/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const relatedPosts = [...tagged, ...untagged].slice(0, 3);
as="a"
variant="secondary"
size="sm"
href={`https://github.com/expressjs/expressjs.com/edit/main/src/content/blog/${Astro.params.slug}`}
href={`https://github.com/expressjs/expressjs.com/edit/main/${post.filePath}`}
>
<Icon name="github" aria-hidden="true" />
{t('page.editOnGitHub')}
Expand Down
32 changes: 32 additions & 0 deletions tests/e2e/blog.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { test, expect } from '@playwright/test';
import enStrings from '../../src/i18n/ui/en.json' with { type: 'json' };

const EDIT_URL_BASE = 'https://github.com/expressjs/expressjs.com/edit/main/src/content/blog';

/**
* Blog Post E2E Tests
*
* The post URL is a lowercased slug without an extension, so the edit link has to
* point at the source file itself. Cover a mixed-case `.md` and a mixed-case `.mdx`.
*/
const posts = [
{
url: '/en/blog/2024-10-01-herodevs-partnership-announcement',
file: '2024-10-01-HeroDevs-partnership-announcement.md',
},
{
url: '/en/blog/2026-10-28-cve-2026-111181',
file: '2026-10-28-CVE-2026-111181.mdx',
},
];

test.describe('Blog Post', () => {
for (const { url, file } of posts) {
test(`should link to the source file of ${file} for editing`, async ({ page }) => {
await page.goto(url);

const editLink = page.getByRole('link', { name: enStrings.page.editOnGitHub });
await expect(editLink).toHaveAttribute('href', `${EDIT_URL_BASE}/${file}`);
});
}
});
Loading