1
0
mirror of synced 2025-12-25 02:17:36 -05:00

remove cached-index-names file and dry run sync used for Algolia (#21133)

This commit is contained in:
Rachael Sewell
2021-08-25 15:04:26 -07:00
committed by GitHub
parent 531e636363
commit df16267a8f
7 changed files with 18 additions and 129 deletions

View File

@@ -1,41 +1,30 @@
import { dates, supported } from '../../lib/enterprise-server-releases.js'
import { supported } from '../../lib/enterprise-server-releases.js'
import libLanguages from '../../lib/languages.js'
import { namePrefix } from '../../lib/search/config.js'
import remoteIndexNames from '../../lib/search/cached-index-names.json'
import { expect } from '@jest/globals'
import lunrIndexNames from '../../script/search/lunr-get-index-names.js'
const languageCodes = Object.keys(libLanguages)
describe('search', () => {
test('has remote indexNames in every language for every supported GHE version', () => {
test('has Lunr index for every language for every supported GHE version', () => {
expect(supported.length).toBeGreaterThan(1)
supported.forEach((version) => {
languageCodes.forEach((languageCode) => {
const indexName = `${namePrefix}-${version}-${languageCode}`
// workaround for GHES release branches not in production yet
if (!remoteIndexNames.includes(indexName)) {
const today = getDate()
const releaseDate = getDate(dates[version].releaseDate)
// if the release date is in the future or today, ignore this version;
// this means if the new index is not uploaded at the time of the release,
// the test will not fail until the following day.
if (releaseDate >= today) return
}
expect(remoteIndexNames.includes(indexName)).toBe(true)
const indexRecordName = `${indexName}-records`
expect(lunrIndexNames.includes(indexName)).toBe(true)
expect(lunrIndexNames.includes(indexRecordName)).toBe(true)
})
})
})
test('has remote indexNames in every language for dotcom', async () => {
test('has Lunr index for every language for dotcom', async () => {
expect(languageCodes.length).toBeGreaterThan(0)
languageCodes.forEach((languageCode) => {
const indexName = `${namePrefix}-dotcom-${languageCode}`
expect(remoteIndexNames.includes(indexName)).toBe(true)
const indexRecordName = `${indexName}-records`
expect(lunrIndexNames.includes(indexName)).toBe(true)
expect(lunrIndexNames.includes(indexRecordName)).toBe(true)
})
})
})
function getDate(date) {
const dateObj = date ? new Date(date) : new Date()
return dateObj.toISOString().slice(0, 10)
}