Skip to content

Commit

Permalink
be loud about failed learning track processing (github#25370)
Browse files Browse the repository at this point in the history
* be loud about failed learning track processing

* rendering test

* undo whitespace cleanup
  • Loading branch information
peterbe authored Feb 15, 2022
1 parent 1c1dd28 commit 2f4af03
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/process-learning-tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default async function processLearningTracks(rawLearningTracks, context)

// Find the data for the current product and track name.
const track = context.site.data['learning-tracks'][context.currentProduct][renderedTrackName]
if (!track) continue
if (!track) {
throw new Error(`no learning track called '${renderedTrackName}'.`)
}

// If there is no `versions` prop in the learning track frontmatter, assume the track should display in all versions.
if (track.versions) {
Expand Down
28 changes: 28 additions & 0 deletions tests/rendering/pages-with-learning-tracks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { jest, beforeAll, expect } from '@jest/globals'

import { getDOM } from '../helpers/supertest.js'
import { loadPages } from '../../lib/page-data.js'

describe('process learning tracks', () => {
let pageList

// Because calling `loadPages` will trigger a warmup, this can potentially
// be very slow in CI. So we need a timeout.
jest.setTimeout(60 * 1000)

beforeAll(async () => {
// Only doing English because they're the only files we do PRs for.
pageList = (await loadPages()).filter((page) => page.languageCode === 'en')
})

test('pages with learningTracks ', async () => {
for (const page of pageList) {
if (page.learningTracks && page.learningTracks.length > 0) {
for (const permalink of page.permalinks) {
const $ = await getDOM(permalink.href)
expect($('[data-testid="learning-track"]').length).toBeGreaterThanOrEqual(1)
}
}
}
})
})

0 comments on commit 2f4af03

Please sign in to comment.