Skip to content

Commit 6acf386

Browse files
authored
Fix release notes YAML test to properly render liquid variables (#56160)
1 parent fca9c6c commit 6acf386

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/release-notes/tests/yaml.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { beforeAll, describe, expect, test } from 'vitest'
66
import yaml from 'js-yaml'
77

88
import { liquid } from '@/content-render/index.js'
9+
import { getDataByLanguage } from '@/data-directory/lib/get-data.js'
10+
import { allVersions } from '@/versions/lib/all-versions.js'
911

1012
interface ReleaseNoteContent {
1113
intro: string
@@ -34,7 +36,7 @@ describe('lint enterprise release notes', () => {
3436
yamlContent = yaml.load(fileContents) as ReleaseNoteContent
3537
})
3638

37-
test('contains valid liquid', () => {
39+
test('contains valid liquid', async () => {
3840
const { intro, sections } = yamlContent
3941
let toLint: Record<string, string> = { intro }
4042
for (const key in sections) {
@@ -54,9 +56,28 @@ describe('lint enterprise release notes', () => {
5456
})
5557
}
5658

59+
// Create context with site data for rendering liquid variables
60+
const context = {
61+
currentLanguage: 'en',
62+
currentVersionObj: allVersions['free-pro-team@latest'],
63+
site: {
64+
data: {
65+
reusables: getDataByLanguage('reusables', 'en'),
66+
variables: getDataByLanguage('variables', 'en'),
67+
ui: getDataByLanguage('ui', 'en'),
68+
},
69+
},
70+
}
71+
5772
for (const key in toLint) {
5873
if (!toLint[key]) continue
74+
// First check if liquid parses correctly
5975
expect(() => liquid.parse(toLint[key]), `${key} contains invalid liquid`).not.toThrow()
76+
// Then check if liquid renders correctly with context
77+
await expect(
78+
liquid.parseAndRender(toLint[key], context),
79+
`${key} contains liquid that fails to render`,
80+
).resolves.not.toThrow()
6081
}
6182
})
6283

0 commit comments

Comments
 (0)