@@ -4,12 +4,7 @@ import { readdirSync, readFileSync } from 'fs'
44import path from 'path'
55
66import { get , getDOM } from '../helpers/e2etest.js'
7- import getRest , {
8- categoriesWithoutSubcategories ,
9- REST_DATA_DIR ,
10- REST_SCHEMA_FILENAME ,
11- } from '../../src/rest/lib/index.js'
12- import { getEnabledForApps } from '../../src/github-apps/lib/index.js'
7+ import getRest , { REST_DATA_DIR , REST_SCHEMA_FILENAME } from '../../src/rest/lib/index.js'
138import { isApiVersioned , allVersions } from '../../lib/all-versions.js'
149import { getDiffOpenAPIContentRest } from '../../src/rest/scripts/test-open-api-schema.js'
1510
@@ -65,52 +60,6 @@ describe('REST references docs', () => {
6560 }
6661 } )
6762
68- // Checks every version of the
69- // /rest/overview/endpoints-available-for-github-apps page
70- // and ensures that all sections in the openapi schema
71- // are present in the page.
72- test ( 'loads operations enabled for GitHub Apps' , async ( ) => {
73- const flatMapping = getFlatMappingWithCalendarDates ( )
74-
75- for ( const [ version , versionValue ] of Object . entries ( flatMapping ) ) {
76- const schemaSlugs = [ ]
77- const enabledForApps = await getEnabledForApps ( version , versionValue . apiVersion )
78-
79- // using the static file, generate the expected slug for each operation
80- for ( const [ key , value ] of Object . entries ( enabledForApps ) ) {
81- schemaSlugs . push (
82- ...value . map (
83- ( item ) =>
84- `/en${
85- versionValue . url === '' ? versionValue . url : `/${ versionValue . url } `
86- } /rest/${ key } ${
87- categoriesWithoutSubcategories . includes ( key ) ? '' : '/' + item . subcategory
88- } #${ item . slug } `
89- )
90- )
91- }
92- // get all of the href attributes in the anchor tags
93- const $ = await getDOM (
94- `/en/${ versionValue . url } /rest/overview/endpoints-available-for-github-apps${
95- versionValue . apiVersion ? `?apiVersion=${ versionValue . apiVersion } ` : ''
96- } `
97- )
98- const domH3Ids = $ ( '#article-contents a' )
99- . map ( ( i , a ) => $ ( a ) . attr ( 'href' ) )
100- . get ( )
101- expect ( schemaSlugs . every ( ( slug ) => domH3Ids . includes ( slug ) ) ) . toBe ( true )
102- }
103- } )
104-
105- test ( 'falls back when unsupported calendar version provided' , async ( ) => {
106- const res = await get (
107- `/en/rest/overview/endpoints-available-for-github-apps?${ new URLSearchParams ( {
108- apiVersion : 'junk' ,
109- } ) } `
110- )
111- expect ( res . statusCode ) . toBe ( 200 )
112- } )
113-
11463 test ( 'test the latest version of the OpenAPI schema categories/subcategories to see if it matches the content/rest directory' , async ( ) => {
11564 const differences = await getDiffOpenAPIContentRest ( )
11665 const errorMessage = formatErrors ( differences )
@@ -175,31 +124,3 @@ If you come across this error in an Update OpenAPI Descriptions PR it's likely t
175124If you have any questions contact #docs-engineering, #docs-content, or #docs-apis-and-events if you need help.`
176125 return errorMessage
177126}
178-
179- // This gets a flat mapping for all REST versions (versioned and unversioned) and creates a mapping between
180- // the full name of the version including calendar dates to its url name and apiVersion if it exists.
181- // Example:
182- // {
183- // free-pro-team@latest: { url: '', apiVersion: 2022-08-09 }
184- // free-pro-team@latest: { url: '', apiVersion: 2022-11-14 }
185- // enterprise-cloud@latest: { url: 'enterprise-cloud@latest , apiVersion: 2022-11-14 }
186- // enterprise-server@3.6: { url: enterprise-server@3.6 }
187- // }
188- function getFlatMappingWithCalendarDates ( ) {
189- const flatMapping = { }
190-
191- for ( const version in allVersions ) {
192- if ( isApiVersioned ( version ) ) {
193- for ( const apiVersion of allVersions [ version ] . apiVersions ) {
194- flatMapping [ allVersions [ version ] . version ] = {
195- url : `${ version === 'free-pro-team@latest' ? '' : allVersions [ version ] . version } ` ,
196- apiVersion,
197- }
198- }
199- } else {
200- flatMapping [ allVersions [ version ] . version ] = { url : allVersions [ version ] . version }
201- }
202- }
203-
204- return flatMapping
205- }
0 commit comments