Skip to content

Commit 5d5c3e9

Browse files
authored
add context to liquid rendering in linting tests (github#26055)
* HACK * back * remove consolelog * remove debugging * remove more debugging
1 parent fcda086 commit 5d5c3e9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/linting/lint-files.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import allowedVersionOperators from '../../lib/liquid-tags/ifversion-supported-o
2525
import semver from 'semver'
2626
import { jest } from '@jest/globals'
2727
import { getDiffFiles } from '../helpers/diff-files.js'
28+
import loadSiteData from '../../lib/site-data.js'
2829

2930
jest.useFakeTimers('legacy')
3031

@@ -410,6 +411,9 @@ if (
410411

411412
describe('lint markdown content', () => {
412413
if (mdToLint.length < 1) return
414+
415+
const siteData = loadSiteData()
416+
413417
describe.each(mdToLint)('%s', (markdownRelPath, markdownAbsPath) => {
414418
let content,
415419
ast,
@@ -453,12 +457,14 @@ describe('lint markdown content', () => {
453457
}
454458
})
455459

460+
const context = { site: siteData.en.site }
461+
456462
// visit is not async-friendly so we need to do an async map to parse the YML snippets
457463
yamlScheduledWorkflows = (
458464
await Promise.all(
459465
yamlScheduledWorkflows.map(async (snippet) => {
460466
// If we don't parse the Liquid first, yaml loading chokes on {% raw %} tags
461-
const rendered = await renderContent.liquid.parseAndRender(snippet)
467+
const rendered = await renderContent.liquid.parseAndRender(snippet, context)
462468
const parsed = yaml.load(rendered)
463469
return parsed.on.schedule
464470
})
@@ -1031,6 +1037,9 @@ describe('lint GHAE release notes', () => {
10311037

10321038
describe('lint learning tracks', () => {
10331039
if (learningTracksToLint.length < 1) return
1040+
1041+
const siteData = loadSiteData()
1042+
10341043
describe.each(learningTracksToLint)('%s', (yamlRelPath, yamlAbsPath) => {
10351044
let dictionary
10361045
let dictionaryError = false
@@ -1066,7 +1075,7 @@ describe('lint learning tracks', () => {
10661075
const productVersions = getApplicableVersions(data.versions, productTocPath)
10671076

10681077
const featuredTracks = {}
1069-
const context = { enterpriseServerVersions }
1078+
const context = { enterpriseServerVersions, site: siteData.en.site }
10701079

10711080
// For each of the product's versions, render the learning track data and look for a featured track.
10721081
await Promise.all(

0 commit comments

Comments
 (0)