Skip to content

Commit 382a1f1

Browse files
committed
Add e2e test to verify post->attachment linking
1 parent a775753 commit 382a1f1

10 files changed

Lines changed: 64 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
code in assets
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
code in root
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
code in grid vs flexbox

src/ssg/e2e-tests/magazine/fixtures/fs/content/demos/CSS/Grid/Grid vs Flexbox/post.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
date: 2025-11-10
33
maker: +authors/enes
44
tags: [css, grid, flex, layout]
5+
code: +code.htm
56
---
67
A versus
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
code in grid
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
code in css
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
code in demos

src/ssg/e2e-tests/magazine/fixtures/fs/theme/keep/templates/pages/post/Demo.hbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
{{/if}}
3636
</div>
3737

38+
<div>
39+
{{#if code}}
40+
Maker: <a data-code-link href="{{code.permalink}}">{{code.title}} ({{code.content}})</a>
41+
{{/if}}
42+
</div>
43+
3844
<div>
3945
{{#if links.relations}}
4046
Relations:

src/ssg/e2e-tests/magazine/fixtures/model.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ const FIXTURE_CONTENT_MODEL = {
563563
{
564564
title: 'Grid vs Flexbox',
565565
maker: { title: 'Mustafa Enes', slug: 'enes' },
566+
code: { title: 'code.htm', slug: 'code.htm', permalink: '/demos/css/grid/grid-vs-flexbox/code.htm', content: 'code in grid vs flexbox' },
566567
date: '2025-11-10',
567568
permalink: '/demos/css/grid/grid-vs-flexbox',
568569
contentType: 'Demo',
@@ -1111,6 +1112,10 @@ const FIXTURE_CONTENT_MODEL = {
11111112
}
11121113
],
11131114
assets: [
1115+
{
1116+
title: 'code.htm',
1117+
permalink: '/assets/code.htm'
1118+
},
11141119
{
11151120
title: 'an asset',
11161121
permalink: '/assets/an asset'
@@ -1119,6 +1124,10 @@ const FIXTURE_CONTENT_MODEL = {
11191124
title: 'some.jpeg',
11201125
permalink: '/assets/some.jpeg'
11211126
},
1127+
{
1128+
title: 'code.htm',
1129+
permalink: '/assets/code.htm'
1130+
},
11221131
{
11231132
title: 'here.mp4',
11241133
permalink: '/assets/here.mp4'
@@ -1141,4 +1150,4 @@ const FIXTURE_CONTENT_MODEL = {
11411150
module.exports = {
11421151
FIXTURE_SETTINGS,
11431152
FIXTURE_CONTENT_MODEL
1144-
}
1153+
}

src/ssg/e2e-tests/magazine/post.test.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,46 @@ test('E2E Magazine - Post Pages', async t => {
259259
}
260260
})
261261

262+
t.test('Verify Demo post code link', async t => {
263+
for (const post of allPosts) {
264+
if (post.contentType !== 'Demo') {
265+
continue
266+
}
267+
268+
if (!post.code) {
269+
continue
270+
}
271+
272+
const postPath = await resolvePostPath(rootDirectory, exportDirectory, post.permalink)
273+
274+
try {
275+
const postHtml = await readFile(postPath, { encoding: 'utf-8' })
276+
const $ = load(postHtml)
277+
const codeLink = $('[data-code-link]')
278+
279+
t.ok(
280+
codeLink.text().includes(post.code.title),
281+
`${post.permalink} code link has correct title`
282+
)
283+
284+
t.equal(
285+
codeLink.attr('href'),
286+
post.code.permalink,
287+
`${post.permalink} code link has correct href`
288+
)
289+
290+
t.ok(
291+
codeLink.text().includes(post.code.content),
292+
`${post.permalink} code link has correct content`
293+
)
294+
} catch (err) {
295+
t.fail(
296+
`${post.permalink} Demo code link: ${err.message}`
297+
)
298+
}
299+
}
300+
})
301+
262302
t.test('Verify Book/Article post author link', async t => {
263303
for (const post of allPosts) {
264304
if (post.contentType !== 'Book' && post.contentType !== 'Article') {
@@ -385,4 +425,4 @@ test('E2E Magazine - Post Pages', async t => {
385425
}
386426
})
387427

388-
})
428+
})

0 commit comments

Comments
 (0)