1
0
mirror of synced 2025-12-30 12:02:01 -05:00
Files
docs/tests/rendering/rest.js
Peter Bengtsson 8362602503 do rendering end-to-end tests with a real server (#26169)
* reinstate

* start server manually

* routing tests too

* skip more

* sleep more and fail if not 200

* use e2etest for content/ too

* feedbacked
2022-03-18 17:06:12 -04:00

42 lines
1.6 KiB
JavaScript

import { jest } from '@jest/globals'
import { getDOM } from '../helpers/e2etest.js'
import getRest, { getEnabledForApps } from '../../lib/rest/index.js'
import { allVersions } from '../../lib/all-versions.js'
describe('REST references docs', () => {
jest.setTimeout(3 * 60 * 1000)
test('loads schema data for all versions', async () => {
for (const version in allVersions) {
const checksRestOperations = getRest(version, 'checks')
const $ = await getDOM(`/en/${version}/rest/reference/checks`)
const domH3Ids = $('h3')
.map((i, h3) => $(h3).attr('id'))
.get()
const schemaSlugs = Object.values(checksRestOperations)
.flat()
.map((operation) => operation.slug)
expect(schemaSlugs.every((slug) => domH3Ids.includes(slug))).toBe(true)
}
})
test('loads operations enabled for GitHub Apps', async () => {
const enableForApps = await getEnabledForApps()
for (const version in allVersions) {
const schemaSlugs = []
// using the static file, generate the expected slug for each operation
for (const [key, value] of Object.entries(enableForApps[version])) {
schemaSlugs.push(...value.map((item) => `/en/rest/reference/${key}#${item.slug}`))
}
// get all of the href attributes in the anchor tags
const $ = await getDOM(`/en/${version}/rest/overview/endpoints-available-for-github-apps`)
const domH3Ids = $('#article-contents a')
.map((i, a) => $(a).attr('href'))
.get()
expect(schemaSlugs.every((slug) => domH3Ids.includes(slug))).toBe(true)
}
})
})