Use test() instead of it() (#50151)
This commit is contained in:
@@ -4,8 +4,6 @@ import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releas
|
|||||||
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
|
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
|
||||||
import { SURROGATE_ENUMS } from '#src/frame/middleware/set-fastly-surrogate-key.js'
|
import { SURROGATE_ENUMS } from '#src/frame/middleware/set-fastly-surrogate-key.js'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('enterprise deprecation', () => {
|
describe('enterprise deprecation', () => {
|
||||||
jest.setTimeout(60 * 1000)
|
jest.setTimeout(60 * 1000)
|
||||||
|
|
||||||
@@ -189,7 +187,7 @@ describe('does not render survey prompt or contribution button', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('JS and CSS assets', () => {
|
describe('JS and CSS assets', () => {
|
||||||
it('returns the expected CSS file > 2.18', async () => {
|
test('returns the expected CSS file > 2.18', async () => {
|
||||||
const result = await get('/enterprise/2.18/dist/index.css', {
|
const result = await get('/enterprise/2.18/dist/index.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.18',
|
Referrer: '/en/enterprise/2.18',
|
||||||
@@ -203,7 +201,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
|
expect(result.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected CSS file', async () => {
|
test('returns the expected CSS file', async () => {
|
||||||
const result = await get('/stylesheets/index.css', {
|
const result = await get('/stylesheets/index.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.13',
|
Referrer: '/en/enterprise/2.13',
|
||||||
@@ -214,7 +212,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('text/css; charset=utf-8')
|
expect(result.headers['content-type']).toBe('text/css; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected JS file > 2.18 by using Referrer', async () => {
|
test('returns the expected JS file > 2.18 by using Referrer', async () => {
|
||||||
const result = await get('/enterprise/2.18/dist/index.js', {
|
const result = await get('/enterprise/2.18/dist/index.js', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.18',
|
Referrer: '/en/enterprise/2.18',
|
||||||
@@ -225,7 +223,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
|
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it("cannot return the archived asset if there's no Referrer", async () => {
|
test("cannot return the archived asset if there's no Referrer", async () => {
|
||||||
const result = await get('/enterprise/2.18/dist/index.js', {
|
const result = await get('/enterprise/2.18/dist/index.js', {
|
||||||
headers: {
|
headers: {
|
||||||
// No Referrer header set at all.
|
// No Referrer header set at all.
|
||||||
@@ -234,7 +232,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.statusCode).toBe(404)
|
expect(result.statusCode).toBe(404)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('cannot return the archived asset if empty Referrer', async () => {
|
test('cannot return the archived asset if empty Referrer', async () => {
|
||||||
const result = await get('/enterprise/2.18/dist/index.js', {
|
const result = await get('/enterprise/2.18/dist/index.js', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '',
|
Referrer: '',
|
||||||
@@ -243,7 +241,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.statusCode).toBe(404)
|
expect(result.statusCode).toBe(404)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected JS file', async () => {
|
test('returns the expected JS file', async () => {
|
||||||
const result = await get('/javascripts/index.js', {
|
const result = await get('/javascripts/index.js', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.13',
|
Referrer: '/en/enterprise/2.13',
|
||||||
@@ -254,7 +252,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
|
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected image', async () => {
|
test('returns the expected image', async () => {
|
||||||
const result = await get('/assets/images/octicons/hamburger.svg', {
|
const result = await get('/assets/images/octicons/hamburger.svg', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.17',
|
Referrer: '/en/enterprise/2.17',
|
||||||
@@ -265,7 +263,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('image/svg+xml; charset=utf-8')
|
expect(result.headers['content-type']).toBe('image/svg+xml; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected node_modules', async () => {
|
test('returns the expected node_modules', async () => {
|
||||||
const result = await get(
|
const result = await get(
|
||||||
'/node_modules/instantsearch.js/dist/instantsearch.production.min.js',
|
'/node_modules/instantsearch.js/dist/instantsearch.production.min.js',
|
||||||
{
|
{
|
||||||
@@ -279,7 +277,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
|
expect(result.headers['content-type']).toBe('application/javascript; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected favicon', async () => {
|
test('returns the expected favicon', async () => {
|
||||||
const result = await get('/assets/images/site/favicon.svg', {
|
const result = await get('/assets/images/site/favicon.svg', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.18',
|
Referrer: '/en/enterprise/2.18',
|
||||||
@@ -290,7 +288,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('image/svg+xml; charset=utf-8')
|
expect(result.headers['content-type']).toBe('image/svg+xml; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the expected CSS file ( <2.13 )', async () => {
|
test('returns the expected CSS file ( <2.13 )', async () => {
|
||||||
const result = await get('/assets/stylesheets/application.css', {
|
const result = await get('/assets/stylesheets/application.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.12',
|
Referrer: '/en/enterprise/2.12',
|
||||||
@@ -301,7 +299,7 @@ describe('JS and CSS assets', () => {
|
|||||||
expect(result.headers['content-type']).toBe('text/css; charset=utf-8')
|
expect(result.headers['content-type']).toBe('text/css; charset=utf-8')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('ignores invalid paths', async () => {
|
test('ignores invalid paths', async () => {
|
||||||
const result = await get('/pizza/index.css', {
|
const result = await get('/pizza/index.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise/2.13',
|
Referrer: '/en/enterprise/2.13',
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ describe('archived enterprise static assets', () => {
|
|||||||
|
|
||||||
afterAll(() => nock.cleanAll())
|
afterAll(() => nock.cleanAll())
|
||||||
|
|
||||||
it('should proxy if the static asset is prefixed', async () => {
|
test('should proxy if the static asset is prefixed', async () => {
|
||||||
const req = mockRequest('/enterprise/2.21/_next/static/foo.css', {
|
const req = mockRequest('/enterprise/2.21/_next/static/foo.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/enterprise/2.21',
|
Referrer: '/enterprise/2.21',
|
||||||
@@ -115,7 +115,7 @@ describe('archived enterprise static assets', () => {
|
|||||||
checkCachingHeaders(res, false, 60)
|
checkCachingHeaders(res, false, 60)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should proxy if the Referrer header indicates so on home page', async () => {
|
test('should proxy if the Referrer header indicates so on home page', async () => {
|
||||||
const req = mockRequest('/_next/static/only-on-proxy.css', {
|
const req = mockRequest('/_next/static/only-on-proxy.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/enterprise/2.21',
|
Referrer: '/enterprise/2.21',
|
||||||
@@ -131,7 +131,7 @@ describe('archived enterprise static assets', () => {
|
|||||||
checkCachingHeaders(res, false, 60)
|
checkCachingHeaders(res, false, 60)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should proxy if the Referrer header indicates so on sub-page', async () => {
|
test('should proxy if the Referrer header indicates so on sub-page', async () => {
|
||||||
const req = mockRequest('/_next/static/only-on-2.3.css', {
|
const req = mockRequest('/_next/static/only-on-2.3.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise-server@2.3/some/page',
|
Referrer: '/en/enterprise-server@2.3/some/page',
|
||||||
@@ -147,7 +147,7 @@ describe('archived enterprise static assets', () => {
|
|||||||
checkCachingHeaders(res, false, 60)
|
checkCachingHeaders(res, false, 60)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('might still 404 even with the right referrer', async () => {
|
test('might still 404 even with the right referrer', async () => {
|
||||||
const req = mockRequest('/_next/static/fourofour.css', {
|
const req = mockRequest('/_next/static/fourofour.css', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise-server@2.3/some/page',
|
Referrer: '/en/enterprise-server@2.3/some/page',
|
||||||
@@ -166,7 +166,7 @@ describe('archived enterprise static assets', () => {
|
|||||||
expect(nexted).toBe(true)
|
expect(nexted).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('404 on the proxy but actually present here', async () => {
|
test('404 on the proxy but actually present here', async () => {
|
||||||
const req = mockRequest('/assets/images/site/logo.png', {
|
const req = mockRequest('/assets/images/site/logo.png', {
|
||||||
headers: {
|
headers: {
|
||||||
Referrer: '/en/enterprise-server@2.3/some/page',
|
Referrer: '/en/enterprise-server@2.3/some/page',
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ function getNextStaticAsset(directory) {
|
|||||||
describe('static assets', () => {
|
describe('static assets', () => {
|
||||||
jest.setTimeout(60 * 1000)
|
jest.setTimeout(60 * 1000)
|
||||||
|
|
||||||
it('should serve /assets/cb-* with optimal headers', async () => {
|
test('should serve /assets/cb-* with optimal headers', async () => {
|
||||||
const res = await get('/assets/cb-1234/images/site/logo.png')
|
const res = await get('/assets/cb-1234/images/site/logo.png')
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
checkCachingHeaders(res)
|
checkCachingHeaders(res)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should serve /assets/ with optimal headers', async () => {
|
test('should serve /assets/ with optimal headers', async () => {
|
||||||
const res = await get('/assets/images/site/logo.png')
|
const res = await get('/assets/images/site/logo.png')
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
checkCachingHeaders(res, true)
|
checkCachingHeaders(res, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should serve /_next/static/ with optimal headers', async () => {
|
test('should serve /_next/static/ with optimal headers', async () => {
|
||||||
// This picks the first one found. We just need it to be anything
|
// This picks the first one found. We just need it to be anything
|
||||||
// that actually resolves.
|
// that actually resolves.
|
||||||
const filePath = getNextStaticAsset('css')
|
const filePath = getNextStaticAsset('css')
|
||||||
@@ -38,26 +38,26 @@ describe('static assets', () => {
|
|||||||
checkCachingHeaders(res)
|
checkCachingHeaders(res)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should 404 on /assets/cb-* with plain text', async () => {
|
test('should 404 on /assets/cb-* with plain text', async () => {
|
||||||
const res = await get('/assets/cb-1234/never/heard/of.png')
|
const res = await get('/assets/cb-1234/never/heard/of.png')
|
||||||
expect(res.statusCode).toBe(404)
|
expect(res.statusCode).toBe(404)
|
||||||
expect(res.headers['content-type']).toContain('text/plain')
|
expect(res.headers['content-type']).toContain('text/plain')
|
||||||
// Only a tiny amount of Cache-Control on these
|
// Only a tiny amount of Cache-Control on these
|
||||||
checkCachingHeaders(res, true, 60)
|
checkCachingHeaders(res, true, 60)
|
||||||
})
|
})
|
||||||
it('should 404 on /assets/ with plain text', async () => {
|
test('should 404 on /assets/ with plain text', async () => {
|
||||||
const res = await get('/assets/never/heard/of.png')
|
const res = await get('/assets/never/heard/of.png')
|
||||||
expect(res.statusCode).toBe(404)
|
expect(res.statusCode).toBe(404)
|
||||||
expect(res.headers['content-type']).toContain('text/plain')
|
expect(res.headers['content-type']).toContain('text/plain')
|
||||||
checkCachingHeaders(res, true, 60)
|
checkCachingHeaders(res, true, 60)
|
||||||
})
|
})
|
||||||
it('should 404 on /_next/static/ with plain text', async () => {
|
test('should 404 on /_next/static/ with plain text', async () => {
|
||||||
const res = await get('/_next/static/never/heard/of.css')
|
const res = await get('/_next/static/never/heard/of.css')
|
||||||
expect(res.statusCode).toBe(404)
|
expect(res.statusCode).toBe(404)
|
||||||
expect(res.headers['content-type']).toContain('text/plain')
|
expect(res.headers['content-type']).toContain('text/plain')
|
||||||
checkCachingHeaders(res, true, 60)
|
checkCachingHeaders(res, true, 60)
|
||||||
})
|
})
|
||||||
it("should redirect if the URLisn't all lowercase", async () => {
|
test("should redirect if the URLisn't all lowercase", async () => {
|
||||||
// Directory
|
// Directory
|
||||||
{
|
{
|
||||||
const res = await get('/assets/images/SITE/logo.png')
|
const res = await get('/assets/images/SITE/logo.png')
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
} from '../../lib/index.js'
|
} from '../../lib/index.js'
|
||||||
|
|
||||||
describe('audit log event fitering', () => {
|
describe('audit log event fitering', () => {
|
||||||
it('matches single allowlist value', () => {
|
test('matches single allowlist value', () => {
|
||||||
const eventsToProcess = [
|
const eventsToProcess = [
|
||||||
{
|
{
|
||||||
action: 'repo.create',
|
action: 'repo.create',
|
||||||
@@ -17,7 +17,7 @@ describe('audit log event fitering', () => {
|
|||||||
expect(filteredEvents[0].action).toEqual('repo.create')
|
expect(filteredEvents[0].action).toEqual('repo.create')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('matches multiple allowlist values', () => {
|
test('matches multiple allowlist values', () => {
|
||||||
const eventsToProcess = [
|
const eventsToProcess = [
|
||||||
{
|
{
|
||||||
action: 'repo.create',
|
action: 'repo.create',
|
||||||
@@ -36,7 +36,7 @@ describe('audit log event fitering', () => {
|
|||||||
expect(filteredEvents.length).toEqual(2)
|
expect(filteredEvents.length).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not match non-matching allowlist value', () => {
|
test('does not match non-matching allowlist value', () => {
|
||||||
const eventsToProcess = [
|
const eventsToProcess = [
|
||||||
{
|
{
|
||||||
action: 'repo.create',
|
action: 'repo.create',
|
||||||
@@ -49,7 +49,7 @@ describe('audit log event fitering', () => {
|
|||||||
expect(filteredEvents.length).toBe(0)
|
expect(filteredEvents.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('ghes filters and updates multiple ghes versions', () => {
|
test('ghes filters and updates multiple ghes versions', () => {
|
||||||
const eventsToProcess = [
|
const eventsToProcess = [
|
||||||
{
|
{
|
||||||
action: 'repo.create',
|
action: 'repo.create',
|
||||||
@@ -101,7 +101,7 @@ describe('audit log event fitering', () => {
|
|||||||
expect(auditLogPage in currentEvents['ghes-3.12']).toBeFalsy()
|
expect(auditLogPage in currentEvents['ghes-3.12']).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the correct event fields data', () => {
|
test('gets the correct event fields data', () => {
|
||||||
const eventsToProcess = [
|
const eventsToProcess = [
|
||||||
{
|
{
|
||||||
action: 'repo.create',
|
action: 'repo.create',
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ describe('getChangelogItems module', () => {
|
|||||||
|
|
||||||
afterAll(() => nock.cleanAll())
|
afterAll(() => nock.cleanAll())
|
||||||
|
|
||||||
it('changelog contains 3 items', async () => {
|
test('changelog contains 3 items', async () => {
|
||||||
expect(changelog.length).toEqual(3)
|
expect(changelog.length).toEqual(3)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('each changelog item has expected title, date, and href', async () => {
|
test('each changelog item has expected title, date, and href', async () => {
|
||||||
const expectedChangelogValues = [
|
const expectedChangelogValues = [
|
||||||
{
|
{
|
||||||
title: 'Authentication token format updates are generally available',
|
title: 'Authentication token format updates are generally available',
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import yaml from 'js-yaml'
|
import yaml from 'js-yaml'
|
||||||
import { readFile } from 'fs/promises'
|
import { readFile } from 'fs/promises'
|
||||||
import walk from 'walk-sync'
|
import walk from 'walk-sync'
|
||||||
import { jest } from '@jest/globals'
|
|
||||||
|
|
||||||
import { liquid } from '#src/content-render/index.js'
|
import { liquid } from '#src/content-render/index.js'
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ const yamlWalkOptions = {
|
|||||||
}
|
}
|
||||||
const yamlFileList = walk(learningTrackRootPath, yamlWalkOptions).sort()
|
const yamlFileList = walk(learningTrackRootPath, yamlWalkOptions).sort()
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('lint learning tracks', () => {
|
describe('lint learning tracks', () => {
|
||||||
if (yamlFileList.length < 1) return
|
if (yamlFileList.length < 1) return
|
||||||
|
|
||||||
@@ -26,7 +23,7 @@ describe('lint learning tracks', () => {
|
|||||||
yamlContent = await yaml.load(fileContents)
|
yamlContent = await yaml.load(fileContents)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('contains valid liquid', () => {
|
test('contains valid liquid', () => {
|
||||||
const toLint = []
|
const toLint = []
|
||||||
Object.values(yamlContent).forEach(({ title, description }) => {
|
Object.values(yamlContent).forEach(({ title, description }) => {
|
||||||
toLint.push(title)
|
toLint.push(title)
|
||||||
|
|||||||
@@ -5,13 +5,10 @@ import walk from 'walk-sync'
|
|||||||
import { zip } from 'lodash-es'
|
import { zip } from 'lodash-es'
|
||||||
import yaml from 'js-yaml'
|
import yaml from 'js-yaml'
|
||||||
import fs from 'fs/promises'
|
import fs from 'fs/promises'
|
||||||
import { jest } from '@jest/globals'
|
|
||||||
|
|
||||||
import languages from '#src/languages/lib/languages.js'
|
import languages from '#src/languages/lib/languages.js'
|
||||||
import { getDiffFiles } from '../lib/diff-files.js'
|
import { getDiffFiles } from '../lib/diff-files.js'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, '../../..')
|
const rootDir = path.join(__dirname, '../../..')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { afterAll, beforeAll, expect, describe, it } from '@jest/globals'
|
import { afterAll, beforeAll, expect, describe } from '@jest/globals'
|
||||||
|
|
||||||
import Page from '#src/frame/lib/page.js'
|
import Page from '#src/frame/lib/page.js'
|
||||||
import languages from '#src/languages/lib/languages.js'
|
import languages from '#src/languages/lib/languages.js'
|
||||||
@@ -27,7 +27,7 @@ describe('data tag', () => {
|
|||||||
languages.en.dir = enDirBefore
|
languages.en.dir = enDirBefore
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render fine if data is found', async () => {
|
test('should render fine if data is found', async () => {
|
||||||
const page = await Page.init({
|
const page = await Page.init({
|
||||||
relativePath: 'liquid-tags/good-data-variable.md',
|
relativePath: 'liquid-tags/good-data-variable.md',
|
||||||
basePath: './src/fixtures/fixtures',
|
basePath: './src/fixtures/fixtures',
|
||||||
@@ -44,7 +44,7 @@ describe('data tag', () => {
|
|||||||
// which we control the value of here in the test.
|
// which we control the value of here in the test.
|
||||||
expect(rendered.includes('Foo')).toBeTruthy()
|
expect(rendered.includes('Foo')).toBeTruthy()
|
||||||
})
|
})
|
||||||
it('should throw if the data tag is used with something unrecognized', async () => {
|
test('should throw if the data tag is used with something unrecognized', async () => {
|
||||||
const page = await Page.init({
|
const page = await Page.init({
|
||||||
relativePath: 'liquid-tags/bad-data-variable.md',
|
relativePath: 'liquid-tags/bad-data-variable.md',
|
||||||
basePath: './src/fixtures/fixtures',
|
basePath: './src/fixtures/fixtures',
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { renderContent } from '#src/content-render/index.js'
|
import { renderContent } from '#src/content-render/index.js'
|
||||||
|
|
||||||
describe('octicon tag', () => {
|
describe('octicon tag', () => {
|
||||||
it('renders the expected octicon', async () => {
|
test('renders the expected octicon', async () => {
|
||||||
const actual = await renderContent('{% octicon "check" %}')
|
const actual = await renderContent('{% octicon "check" %}')
|
||||||
expect(actual).toContain('<svg ')
|
expect(actual).toContain('<svg ')
|
||||||
expect(actual).toContain('class="octicon octicon-check"')
|
expect(actual).toContain('class="octicon octicon-check"')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the expected octicon with an option', async () => {
|
test('renders the expected octicon with an option', async () => {
|
||||||
const actual = await renderContent('{% octicon "check" width="64" %}')
|
const actual = await renderContent('{% octicon "check" width="64" %}')
|
||||||
expect(actual).toContain('<svg ')
|
expect(actual).toContain('<svg ')
|
||||||
expect(actual).toContain('class="octicon octicon-check"')
|
expect(actual).toContain('class="octicon octicon-check"')
|
||||||
expect(actual).toContain('width="64"')
|
expect(actual).toContain('width="64"')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the expected octicon with multiple options', async () => {
|
test('renders the expected octicon with multiple options', async () => {
|
||||||
const actual = await renderContent('{% octicon "check" width="64" aria-label="A checkmark" %}')
|
const actual = await renderContent('{% octicon "check" width="64" aria-label="A checkmark" %}')
|
||||||
expect(actual).toContain('<svg ')
|
expect(actual).toContain('<svg ')
|
||||||
expect(actual).toContain('class="octicon octicon-check"')
|
expect(actual).toContain('class="octicon octicon-check"')
|
||||||
@@ -22,20 +22,20 @@ describe('octicon tag', () => {
|
|||||||
expect(actual).toContain('aria-label="A checkmark"')
|
expect(actual).toContain('aria-label="A checkmark"')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('uses label to set aria-label', async () => {
|
test('uses label to set aria-label', async () => {
|
||||||
const actual = await renderContent('{% octicon "check" label="A checkmark" %}')
|
const actual = await renderContent('{% octicon "check" label="A checkmark" %}')
|
||||||
expect(actual).toContain('<svg ')
|
expect(actual).toContain('<svg ')
|
||||||
expect(actual).toContain('class="octicon octicon-check"')
|
expect(actual).toContain('class="octicon octicon-check"')
|
||||||
expect(actual).toContain('aria-label="A checkmark"')
|
expect(actual).toContain('aria-label="A checkmark"')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error with invalid syntax', async () => {
|
test('throws an error with invalid syntax', async () => {
|
||||||
await expect(renderContent('{% octicon 123 %}')).rejects.toThrowError(
|
await expect(renderContent('{% octicon 123 %}')).rejects.toThrowError(
|
||||||
'Syntax Error in tag \'octicon\' - Valid syntax: octicon "<name>" <key="value">',
|
'Syntax Error in tag \'octicon\' - Valid syntax: octicon "<name>" <key="value">',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error with a non-existant octicon', async () => {
|
test('throws an error with a non-existant octicon', async () => {
|
||||||
await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects.toThrowError(
|
await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects.toThrowError(
|
||||||
'Octicon pizza-patrol does not exist',
|
'Octicon pizza-patrol does not exist',
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('Hydro', () => {
|
|||||||
nock.cleanAll()
|
nock.cleanAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('publishes a single event', async () => {
|
test('publishes a single event', async () => {
|
||||||
const scope = nock(endpoint, {
|
const scope = nock(endpoint, {
|
||||||
reqheaders: {
|
reqheaders: {
|
||||||
Authorization: /^Hydro \w{64}$/,
|
Authorization: /^Hydro \w{64}$/,
|
||||||
@@ -33,7 +33,7 @@ describe('Hydro', () => {
|
|||||||
expect(scope.isDone()).toBeTruthy()
|
expect(scope.isDone()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('publishes many events in one request', async () => {
|
test('publishes many events in one request', async () => {
|
||||||
const scope = nock(endpoint, {
|
const scope = nock(endpoint, {
|
||||||
reqheaders: {
|
reqheaders: {
|
||||||
Authorization: /^Hydro \w{64}$/,
|
Authorization: /^Hydro \w{64}$/,
|
||||||
@@ -66,7 +66,7 @@ describe('Hydro', () => {
|
|||||||
expect(scope.isDone()).toBeTruthy()
|
expect(scope.isDone()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('422 with JSON error', async () => {
|
test('422 with JSON error', async () => {
|
||||||
// Hydro will return 422 errors with the body being a string of
|
// Hydro will return 422 errors with the body being a string of
|
||||||
// JSON serialized information. Some of the errors are operational
|
// JSON serialized information. Some of the errors are operational
|
||||||
// and something we don't need to send to Failbot.
|
// and something we don't need to send to Failbot.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ expect.extend({
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('formatErrors', () => {
|
describe('formatErrors', () => {
|
||||||
it('should produce objects that match the validation spec', () => {
|
test('should produce objects that match the validation spec', () => {
|
||||||
// Produce an error
|
// Produce an error
|
||||||
const { errors } = validateJson({ type: 'string' }, 0)
|
const { errors } = validateJson({ type: 'string' }, 0)
|
||||||
const formattedErrors = formatErrors(errors, '')
|
const formattedErrors = formatErrors(errors, '')
|
||||||
|
|||||||
@@ -46,18 +46,18 @@ describe('POST /events', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should record a page event', async () => {
|
test('should record a page event', async () => {
|
||||||
const { statusCode } = await checkEvent(pageExample)
|
const { statusCode } = await checkEvent(pageExample)
|
||||||
expect(statusCode).toBe(200)
|
expect(statusCode).toBe(200)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should require a type', async () => {
|
test('should require a type', async () => {
|
||||||
const { statusCode, body } = await checkEvent({ ...pageExample, type: undefined })
|
const { statusCode, body } = await checkEvent({ ...pageExample, type: undefined })
|
||||||
expect(statusCode).toBe(400)
|
expect(statusCode).toBe(400)
|
||||||
expect(body).toEqual('{"message":"Invalid type"}')
|
expect(body).toEqual('{"message":"Invalid type"}')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should require an event_id in uuid', async () => {
|
test('should require an event_id in uuid', async () => {
|
||||||
const { statusCode } = await checkEvent({
|
const { statusCode } = await checkEvent({
|
||||||
...pageExample,
|
...pageExample,
|
||||||
context: {
|
context: {
|
||||||
@@ -68,7 +68,7 @@ describe('POST /events', () => {
|
|||||||
expect(statusCode).toBe(400)
|
expect(statusCode).toBe(400)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should require a user in uuid', async () => {
|
test('should require a user in uuid', async () => {
|
||||||
const { statusCode } = await checkEvent({
|
const { statusCode } = await checkEvent({
|
||||||
...pageExample,
|
...pageExample,
|
||||||
context: {
|
context: {
|
||||||
@@ -79,7 +79,7 @@ describe('POST /events', () => {
|
|||||||
expect(statusCode).toBe(400)
|
expect(statusCode).toBe(400)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should require a version', async () => {
|
test('should require a version', async () => {
|
||||||
const { statusCode } = await checkEvent({
|
const { statusCode } = await checkEvent({
|
||||||
...pageExample,
|
...pageExample,
|
||||||
context: {
|
context: {
|
||||||
@@ -90,7 +90,7 @@ describe('POST /events', () => {
|
|||||||
expect(statusCode).toBe(400)
|
expect(statusCode).toBe(400)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should require created timestamp', async () => {
|
test('should require created timestamp', async () => {
|
||||||
const { statusCode } = await checkEvent({
|
const { statusCode } = await checkEvent({
|
||||||
...pageExample,
|
...pageExample,
|
||||||
context: {
|
context: {
|
||||||
@@ -101,7 +101,7 @@ describe('POST /events', () => {
|
|||||||
expect(statusCode).toBe(400)
|
expect(statusCode).toBe(400)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not allow a honeypot token', async () => {
|
test('should not allow a honeypot token', async () => {
|
||||||
const { statusCode } = await checkEvent({
|
const { statusCode } = await checkEvent({
|
||||||
...pageExample,
|
...pageExample,
|
||||||
context: {
|
context: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { parseUserAgent } from '../components/user-agent.ts'
|
import { parseUserAgent } from '../components/user-agent.ts'
|
||||||
|
|
||||||
describe('parseUserAgent', () => {
|
describe('parseUserAgent', () => {
|
||||||
it('android, chrome', () => {
|
test('android, chrome', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36'
|
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -9,7 +9,7 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('chrome')
|
expect(browser).toBe('chrome')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('ios, safari', () => {
|
test('ios, safari', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -17,7 +17,7 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('safari')
|
expect(browser).toBe('safari')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('windows, edge', () => {
|
test('windows, edge', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -25,7 +25,7 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('edge')
|
expect(browser).toBe('edge')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('mac, edge', () => {
|
test('mac, edge', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203'
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -33,7 +33,7 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('edge')
|
expect(browser).toBe('edge')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('mac, safari', () => {
|
test('mac, safari', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -41,7 +41,7 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('safari')
|
expect(browser).toBe('safari')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('windows, chrome', () => {
|
test('windows, chrome', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36'
|
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -49,14 +49,14 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('chrome')
|
expect(browser).toBe('chrome')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('linux, firefox', () => {
|
test('linux, firefox', () => {
|
||||||
const ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1'
|
const ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
expect(os).toBe('linux')
|
expect(os).toBe('linux')
|
||||||
expect(browser).toBe('firefox')
|
expect(browser).toBe('firefox')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('mac, opera', () => {
|
test('mac, opera', () => {
|
||||||
const ua =
|
const ua =
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 OPR/101.0.0.0'
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 OPR/101.0.0.0'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
@@ -64,7 +64,7 @@ describe('parseUserAgent', () => {
|
|||||||
expect(browser).toBe('opera')
|
expect(browser).toBe('opera')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('other, other', () => {
|
test('other, other', () => {
|
||||||
const ua = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
|
const ua = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
|
||||||
const { os, browser } = parseUserAgent(ua)
|
const { os, browser } = parseUserAgent(ua)
|
||||||
expect(os).toBe('other')
|
expect(os).toBe('other')
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ function allowIndex(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('block robots', () => {
|
describe('block robots', () => {
|
||||||
it('allows crawling of the homepage and English content', async () => {
|
test('allows crawling of the homepage and English content', async () => {
|
||||||
expect(allowIndex('/')).toBe(true)
|
expect(allowIndex('/')).toBe(true)
|
||||||
expect(allowIndex('/en')).toBe(true)
|
expect(allowIndex('/en')).toBe(true)
|
||||||
expect(allowIndex('/en/articles/verifying-your-email-address')).toBe(true)
|
expect(allowIndex('/en/articles/verifying-your-email-address')).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('disallows crawling of WIP products', async () => {
|
test('disallows crawling of WIP products', async () => {
|
||||||
const wipProductIds = Object.values(productMap)
|
const wipProductIds = Object.values(productMap)
|
||||||
.filter((product) => product.wip)
|
.filter((product) => product.wip)
|
||||||
.map((product) => product.id)
|
.map((product) => product.id)
|
||||||
@@ -34,7 +34,7 @@ describe('block robots', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('disallows crawling of early access "hidden" products', async () => {
|
test('disallows crawling of early access "hidden" products', async () => {
|
||||||
const hiddenProductIds = Object.values(productMap)
|
const hiddenProductIds = Object.values(productMap)
|
||||||
.filter((product) => product.hidden)
|
.filter((product) => product.hidden)
|
||||||
.map((product) => product.id)
|
.map((product) => product.id)
|
||||||
@@ -53,7 +53,7 @@ describe('block robots', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('allows crawling of non-WIP products', async () => {
|
test('allows crawling of non-WIP products', async () => {
|
||||||
expect('actions' in productMap).toBe(true)
|
expect('actions' in productMap).toBe(true)
|
||||||
expect(allowIndex('/en/actions')).toBe(true)
|
expect(allowIndex('/en/actions')).toBe(true)
|
||||||
expect(allowIndex('/en/actions/overview')).toBe(true)
|
expect(allowIndex('/en/actions/overview')).toBe(true)
|
||||||
@@ -64,7 +64,7 @@ describe('block robots', () => {
|
|||||||
).toBe(true)
|
).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('disallows crawling of deprecated enterprise releases', async () => {
|
test('disallows crawling of deprecated enterprise releases', async () => {
|
||||||
enterpriseServerReleases.deprecated.forEach((version) => {
|
enterpriseServerReleases.deprecated.forEach((version) => {
|
||||||
const blockedPaths = [
|
const blockedPaths = [
|
||||||
`/en/enterprise-server@${version}/actions`,
|
`/en/enterprise-server@${version}/actions`,
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ describe('Page class', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('includes videos specified in the featuredLinks frontmatter', async () => {
|
test('includes videos specified in the featuredLinks frontmatter', async () => {
|
||||||
expect(page.featuredLinks.videos).toStrictEqual([
|
expect(page.featuredLinks.videos).toStrictEqual([
|
||||||
{
|
{
|
||||||
title: 'codespaces',
|
title: 'codespaces',
|
||||||
@@ -283,7 +283,7 @@ describe('Page class', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('introLinks', () => {
|
describe('introLinks', () => {
|
||||||
it('includes the links specified in the introLinks frontmatter', async () => {
|
test('includes the links specified in the introLinks frontmatter', async () => {
|
||||||
const page = await Page.init({
|
const page = await Page.init({
|
||||||
relativePath: 'article-with-introLinks.md',
|
relativePath: 'article-with-introLinks.md',
|
||||||
basePath: path.join(__dirname, '../../../src/fixtures/fixtures'),
|
basePath: path.join(__dirname, '../../../src/fixtures/fixtures'),
|
||||||
@@ -298,7 +298,7 @@ describe('Page class', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Page.parseFrontmatter()', () => {
|
describe('Page.parseFrontmatter()', () => {
|
||||||
it('throws an error on bad input', () => {
|
test('throws an error on bad input', () => {
|
||||||
const markdown = null
|
const markdown = null
|
||||||
expect(() => {
|
expect(() => {
|
||||||
Page.parseFrontmatter('some/file.md', markdown)
|
Page.parseFrontmatter('some/file.md', markdown)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ versions:
|
|||||||
`
|
`
|
||||||
|
|
||||||
describe('frontmatter', () => {
|
describe('frontmatter', () => {
|
||||||
it('parses frontmatter and content in a given string (no options required)', () => {
|
test('parses frontmatter and content in a given string (no options required)', () => {
|
||||||
const { data, content, errors } = parse(fixture1)
|
const { data, content, errors } = parse(fixture1)
|
||||||
expect(data.title).toBe('Hello, World')
|
expect(data.title).toBe('Hello, World')
|
||||||
expect(data.meaning_of_life).toBe(42)
|
expect(data.meaning_of_life).toBe(42)
|
||||||
@@ -27,13 +27,13 @@ describe('frontmatter', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('frontmatter.stringify', () => {
|
describe('frontmatter.stringify', () => {
|
||||||
it('is exported', () => {
|
test('is exported', () => {
|
||||||
expect(typeof parse.stringify).toBe('function')
|
expect(typeof parse.stringify).toBe('function')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('YML parsing errors', () => {
|
describe('YML parsing errors', () => {
|
||||||
it('creates errors if YML has an unescaped quote', () => {
|
test('creates errors if YML has an unescaped quote', () => {
|
||||||
const fixture = `---
|
const fixture = `---
|
||||||
intro: 'I've got an unescaped quote'
|
intro: 'I've got an unescaped quote'
|
||||||
---
|
---
|
||||||
@@ -50,7 +50,7 @@ I am content.
|
|||||||
expect(errors[0]).toEqual(expectedError)
|
expect(errors[0]).toEqual(expectedError)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates errors if YML has incorrect indentation', () => {
|
test('creates errors if YML has incorrect indentation', () => {
|
||||||
const fixture = `---
|
const fixture = `---
|
||||||
title: Hello, World
|
title: Hello, World
|
||||||
intro: 'I have a bad leading space'
|
intro: 'I have a bad leading space'
|
||||||
@@ -70,7 +70,7 @@ I am content.
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('schema', () => {
|
describe('schema', () => {
|
||||||
it('is optional', () => {
|
test('is optional', () => {
|
||||||
const schema = {
|
const schema = {
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
@@ -89,7 +89,7 @@ I am content.
|
|||||||
expect(errors.length).toBe(0)
|
expect(errors.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates errors if frontmatter does not conform to schema', () => {
|
test('creates errors if frontmatter does not conform to schema', () => {
|
||||||
const schema = {
|
const schema = {
|
||||||
properties: {
|
properties: {
|
||||||
meaning_of_life: {
|
meaning_of_life: {
|
||||||
@@ -117,7 +117,7 @@ I am content.
|
|||||||
expect(errors[0]).toEqual(expectedError)
|
expect(errors[0]).toEqual(expectedError)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates errors if versions frontmatter does not match semver format', () => {
|
test('creates errors if versions frontmatter does not match semver format', () => {
|
||||||
const schema = { type: 'object', required: ['versions'], properties: {} }
|
const schema = { type: 'object', required: ['versions'], properties: {} }
|
||||||
schema.properties.versions = Object.assign({}, frontmatterSchema.properties.versions)
|
schema.properties.versions = Object.assign({}, frontmatterSchema.properties.versions)
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ I am content.
|
|||||||
expect(errors[0]).toEqual(expectedError)
|
expect(errors[0]).toEqual(expectedError)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates errors if required frontmatter is not present', () => {
|
test('creates errors if required frontmatter is not present', () => {
|
||||||
const schema = {
|
const schema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['yet_another_key'],
|
required: ['yet_another_key'],
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import { describe, jest } from '@jest/globals'
|
|||||||
|
|
||||||
const AZURE_STORAGE_URL = 'githubdocs.azureedge.net'
|
const AZURE_STORAGE_URL = 'githubdocs.azureedge.net'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('server', () => {
|
describe('server', () => {
|
||||||
jest.setTimeout(60 * 1000)
|
jest.setTimeout(60 * 1000)
|
||||||
|
|
||||||
@@ -269,7 +267,7 @@ describe('server', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('static routes', () => {
|
describe('static routes', () => {
|
||||||
it('serves content from the /assets directory', async () => {
|
test('serves content from the /assets directory', async () => {
|
||||||
const res = await get('/assets/images/site/be-social.gif')
|
const res = await get('/assets/images/site/be-social.gif')
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
expect(res.headers['cache-control']).toContain('public')
|
expect(res.headers['cache-control']).toContain('public')
|
||||||
@@ -283,7 +281,7 @@ describe('static routes', () => {
|
|||||||
expect(res.headers['last-modified']).toBeTruthy()
|
expect(res.headers['last-modified']).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rewrites /assets requests from a cache-busting prefix', async () => {
|
test('rewrites /assets requests from a cache-busting prefix', async () => {
|
||||||
// The rewrite-asset-urls.js Markdown plugin will do this to img tags.
|
// The rewrite-asset-urls.js Markdown plugin will do this to img tags.
|
||||||
const res = await get('/assets/cb-123456/images/site/be-social.gif')
|
const res = await get('/assets/cb-123456/images/site/be-social.gif')
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
@@ -293,7 +291,7 @@ describe('static routes', () => {
|
|||||||
expect(res.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
|
expect(res.headers['surrogate-key']).toBe(SURROGATE_ENUMS.MANUAL)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('no manual surrogate key for /assets requests without caching-busting prefix', async () => {
|
test('no manual surrogate key for /assets requests without caching-busting prefix', async () => {
|
||||||
const res = await get('/assets/images/site/be-social.gif')
|
const res = await get('/assets/images/site/be-social.gif')
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
expect(res.headers['set-cookie']).toBeUndefined()
|
expect(res.headers['set-cookie']).toBeUndefined()
|
||||||
@@ -305,7 +303,7 @@ describe('static routes', () => {
|
|||||||
expect(surrogateKeySplit.includes(makeLanguageSurrogateKey())).toBeTruthy()
|
expect(surrogateKeySplit.includes(makeLanguageSurrogateKey())).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('serves schema files from the /data/graphql directory at /public', async () => {
|
test('serves schema files from the /data/graphql directory at /public', async () => {
|
||||||
const res = await get('/public/schema.docs.graphql')
|
const res = await get('/public/schema.docs.graphql')
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
expect(res.headers['cache-control']).toContain('public')
|
expect(res.headers['cache-control']).toContain('public')
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('creating a changelog from old schema and new schema', () => {
|
|||||||
MockDate.reset()
|
MockDate.reset()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds a diff of schema changes, upcoming changes, and preview changes', async () => {
|
test('finds a diff of schema changes, upcoming changes, and preview changes', async () => {
|
||||||
const oldSchemaString = `
|
const oldSchemaString = `
|
||||||
type PreviewType {
|
type PreviewType {
|
||||||
field1(changeTypeArgument: Int): Int
|
field1(changeTypeArgument: Int): Int
|
||||||
@@ -94,7 +94,7 @@ upcoming_changes:
|
|||||||
expect(entry).toEqual(expectedChangelogEntry)
|
expect(entry).toEqual(expectedChangelogEntry)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns null when there isnt any difference', async () => {
|
test('returns null when there isnt any difference', async () => {
|
||||||
const schemaString = `
|
const schemaString = `
|
||||||
type Query {
|
type Query {
|
||||||
i: Int!
|
i: Int!
|
||||||
@@ -106,7 +106,7 @@ upcoming_changes:
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Preparing preview links', () => {
|
describe('Preparing preview links', () => {
|
||||||
it('fixes preview names', () => {
|
test('fixes preview names', () => {
|
||||||
// These two are special cases
|
// These two are special cases
|
||||||
expect(cleanPreviewTitle('UpdateRefsPreview')).toEqual('Update refs preview')
|
expect(cleanPreviewTitle('UpdateRefsPreview')).toEqual('Update refs preview')
|
||||||
expect(cleanPreviewTitle('MergeInfoPreview')).toEqual('Merge info preview')
|
expect(cleanPreviewTitle('MergeInfoPreview')).toEqual('Merge info preview')
|
||||||
@@ -116,7 +116,7 @@ describe('Preparing preview links', () => {
|
|||||||
expect(cleanPreviewTitle('nice preview')).toEqual('nice preview')
|
expect(cleanPreviewTitle('nice preview')).toEqual('nice preview')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates anchors from preview titles', () => {
|
test('creates anchors from preview titles', () => {
|
||||||
expect(previewAnchor('Merge info preview')).toEqual('merge-info-preview')
|
expect(previewAnchor('Merge info preview')).toEqual('merge-info-preview')
|
||||||
expect(previewAnchor('some.punct123 preview')).toEqual('somepunct123-preview')
|
expect(previewAnchor('some.punct123 preview')).toEqual('somepunct123-preview')
|
||||||
})
|
})
|
||||||
@@ -127,7 +127,7 @@ describe('updating the changelog file', () => {
|
|||||||
MockDate.reset()
|
MockDate.reset()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('modifies the entry object and the file on disk', async () => {
|
test('modifies the entry object and the file on disk', async () => {
|
||||||
const testTargetPath = 'src/graphql/tests/fixtures/example-changelog.json'
|
const testTargetPath = 'src/graphql/tests/fixtures/example-changelog.json'
|
||||||
const previousContents = await fs.readFile(testTargetPath)
|
const previousContents = await fs.readFile(testTargetPath)
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ describe('FailBot', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('.report', () => {
|
describe('.report', () => {
|
||||||
it('returns early if `HAYSTACK_URL` is not set', async () => {
|
test('returns early if `HAYSTACK_URL` is not set', async () => {
|
||||||
const result = await FailBot.report()
|
const result = await FailBot.report()
|
||||||
expect(result).toBeUndefined()
|
expect(result).toBeUndefined()
|
||||||
expect(requestBodiesSent.length).toBe(0)
|
expect(requestBodiesSent.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sends the expected report', async () => {
|
test('sends the expected report', async () => {
|
||||||
process.env.HAYSTACK_URL = 'https://haystack.example.com'
|
process.env.HAYSTACK_URL = 'https://haystack.example.com'
|
||||||
const err = new Error('Kaboom')
|
const err = new Error('Kaboom')
|
||||||
const backendPromises = FailBot.report(err, { foo: 'bar' })
|
const backendPromises = FailBot.report(err, { foo: 'bar' })
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releas
|
|||||||
import { get } from '#src/tests/helpers/e2etest.js'
|
import { get } from '#src/tests/helpers/e2etest.js'
|
||||||
import readJsonFile from '#src/frame/lib/read-json-file.js'
|
import readJsonFile from '#src/frame/lib/read-json-file.js'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('developer redirects', () => {
|
describe('developer redirects', () => {
|
||||||
jest.setTimeout(10 * 60 * 1000)
|
jest.setTimeout(10 * 60 * 1000)
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { jest } from '@jest/globals'
|
|||||||
|
|
||||||
import { head } from '#src/tests/helpers/e2etest.js'
|
import { head } from '#src/tests/helpers/e2etest.js'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('developer.github.com redirects', () => {
|
describe('developer.github.com redirects', () => {
|
||||||
jest.setTimeout(60 * 1000)
|
jest.setTimeout(60 * 1000)
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import {
|
|||||||
supported,
|
supported,
|
||||||
oldestSupported,
|
oldestSupported,
|
||||||
} from '#src/versions/lib/enterprise-server-releases.js'
|
} from '#src/versions/lib/enterprise-server-releases.js'
|
||||||
|
|
||||||
const previousEnterpriserServerVersion = supported[1]
|
const previousEnterpriserServerVersion = supported[1]
|
||||||
|
|
||||||
describe('getRedirect basics', () => {
|
describe('getRedirect basics', () => {
|
||||||
it('should sometimes not correct the version prefix', () => {
|
test('should sometimes not correct the version prefix', () => {
|
||||||
// This essentially tests legacy entries that come from the
|
// This essentially tests legacy entries that come from the
|
||||||
// `developer.json` file. Normally, we would have first
|
// `developer.json` file. Normally, we would have first
|
||||||
// rewritten `/enterprise/3.0` to `/enterprise-server@3.0`
|
// rewritten `/enterprise/3.0` to `/enterprise-server@3.0`
|
||||||
@@ -27,7 +28,7 @@ describe('getRedirect basics', () => {
|
|||||||
expect(getRedirect(uri, ctx)).toBe('/en/something/else')
|
expect(getRedirect(uri, ctx)).toBe('/en/something/else')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return undefined if nothing could be found', () => {
|
test('should return undefined if nothing could be found', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
@@ -35,7 +36,7 @@ describe('getRedirect basics', () => {
|
|||||||
expect(getRedirect('/foo/pizza', ctx)).toBeUndefined()
|
expect(getRedirect('/foo/pizza', ctx)).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should just inject language on version "home pages"', () => {
|
test('should just inject language on version "home pages"', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
@@ -52,7 +53,7 @@ describe('getRedirect basics', () => {
|
|||||||
expect(getRedirect('/enterprise-server', ctx)).toBe(`/en/enterprise-server@${latestStable}`)
|
expect(getRedirect('/enterprise-server', ctx)).toBe(`/en/enterprise-server@${latestStable}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should always "remove" the free-pro-team prefix', () => {
|
test('should always "remove" the free-pro-team prefix', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {
|
redirects: {
|
||||||
@@ -67,7 +68,7 @@ describe('getRedirect basics', () => {
|
|||||||
expect(getRedirect('/free-pro-team@latest/github', ctx)).toBe('/en/github')
|
expect(getRedirect('/free-pro-team@latest/github', ctx)).toBe('/en/github')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle some odd exceptions', () => {
|
test('should handle some odd exceptions', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
@@ -84,7 +85,7 @@ describe('getRedirect basics', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should figure out redirect based on presence of pages in certain cases', () => {
|
test('should figure out redirect based on presence of pages in certain cases', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {
|
pages: {
|
||||||
[`/en/enterprise-server@${previousEnterpriserServerVersion}/foo/bar`]: null,
|
[`/en/enterprise-server@${previousEnterpriserServerVersion}/foo/bar`]: null,
|
||||||
@@ -104,7 +105,7 @@ describe('getRedirect basics', () => {
|
|||||||
).toBe(`/en/enterprise-server@${previousEnterpriserServerVersion}/admin/github-management`)
|
).toBe(`/en/enterprise-server@${previousEnterpriserServerVersion}/admin/github-management`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should always correct the old enterprise prefix', () => {
|
test('should always correct the old enterprise prefix', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {
|
redirects: {
|
||||||
@@ -129,7 +130,7 @@ describe('getRedirect basics', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not do anything on some prefixes', () => {
|
test('should not do anything on some prefixes', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
@@ -140,7 +141,7 @@ describe('getRedirect basics', () => {
|
|||||||
expect(getRedirect(`/en/enterprise-cloud@latest/user/foo`, ctx)).toBeUndefined()
|
expect(getRedirect(`/en/enterprise-cloud@latest/user/foo`, ctx)).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should redirect both the prefix and the path needs to change', () => {
|
test('should redirect both the prefix and the path needs to change', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {
|
redirects: {
|
||||||
@@ -155,7 +156,7 @@ describe('getRedirect basics', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work for some deprecated enterprise-server URLs too', () => {
|
test('should work for some deprecated enterprise-server URLs too', () => {
|
||||||
// Starting with enterprise-server 3.0, we have made redirects become
|
// Starting with enterprise-server 3.0, we have made redirects become
|
||||||
// a *function* rather than a lookup on a massive object.
|
// a *function* rather than a lookup on a massive object.
|
||||||
const ctx = {
|
const ctx = {
|
||||||
@@ -168,7 +169,7 @@ describe('getRedirect basics', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('github-ae@latest', () => {
|
describe('github-ae@latest', () => {
|
||||||
it('home page should redirect to enterprise-cloud home page', () => {
|
test('home page should redirect to enterprise-cloud home page', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
@@ -176,7 +177,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest', ctx)).toBe('/en/enterprise-cloud@latest')
|
expect(getRedirect('/github-ae@latest', ctx)).toBe('/en/enterprise-cloud@latest')
|
||||||
expect(getRedirect('/en/github-ae@latest', ctx)).toBe('/en/enterprise-cloud@latest')
|
expect(getRedirect('/en/github-ae@latest', ctx)).toBe('/en/enterprise-cloud@latest')
|
||||||
})
|
})
|
||||||
it('should redirect to home page for admin/release-notes', () => {
|
test('should redirect to home page for admin/release-notes', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
@@ -184,7 +185,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest/admin/release-notes', ctx)).toBe('/en')
|
expect(getRedirect('/github-ae@latest/admin/release-notes', ctx)).toBe('/en')
|
||||||
expect(getRedirect('/en/github-ae@latest/admin/release-notes', ctx)).toBe('/en')
|
expect(getRedirect('/en/github-ae@latest/admin/release-notes', ctx)).toBe('/en')
|
||||||
})
|
})
|
||||||
it('a page that does exits, without correction, in enterprise-cloud', () => {
|
test('a page that does exits, without correction, in enterprise-cloud', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {
|
pages: {
|
||||||
'/en/enterprise-cloud@latest/foo': null,
|
'/en/enterprise-cloud@latest/foo': null,
|
||||||
@@ -194,7 +195,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest/foo', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
expect(getRedirect('/github-ae@latest/foo', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
||||||
expect(getRedirect('/en/github-ae@latest/foo', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
expect(getRedirect('/en/github-ae@latest/foo', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
||||||
})
|
})
|
||||||
it("a page that doesn't exist in enterprise-cloud but in FPT", () => {
|
test("a page that doesn't exist in enterprise-cloud but in FPT", () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {
|
pages: {
|
||||||
'/en/foo': true,
|
'/en/foo': true,
|
||||||
@@ -204,7 +205,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest/foo', ctx)).toBe('/en/foo')
|
expect(getRedirect('/github-ae@latest/foo', ctx)).toBe('/en/foo')
|
||||||
expect(getRedirect('/en/github-ae@latest/foo', ctx)).toBe('/en/foo')
|
expect(getRedirect('/en/github-ae@latest/foo', ctx)).toBe('/en/foo')
|
||||||
})
|
})
|
||||||
it("a page that doesn't exist in enterprise-cloud or in FPT", () => {
|
test("a page that doesn't exist in enterprise-cloud or in FPT", () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {
|
pages: {
|
||||||
'/en/foo': true,
|
'/en/foo': true,
|
||||||
@@ -214,7 +215,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest/bar', ctx)).toBe('/en')
|
expect(getRedirect('/github-ae@latest/bar', ctx)).toBe('/en')
|
||||||
expect(getRedirect('/en/github-ae@latest/bar', ctx)).toBe('/en')
|
expect(getRedirect('/en/github-ae@latest/bar', ctx)).toBe('/en')
|
||||||
})
|
})
|
||||||
it('a URL with legacy redirects, that redirects to enterprise-cloud', () => {
|
test('a URL with legacy redirects, that redirects to enterprise-cloud', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {
|
pages: {
|
||||||
'/en/foo': true,
|
'/en/foo': true,
|
||||||
@@ -227,7 +228,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest/food', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
expect(getRedirect('/github-ae@latest/food', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
||||||
expect(getRedirect('/en/github-ae@latest/food', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
expect(getRedirect('/en/github-ae@latest/food', ctx)).toBe('/en/enterprise-cloud@latest/foo')
|
||||||
})
|
})
|
||||||
it("a URL with legacy redirects, that can't redirect to enterprise-cloud", () => {
|
test("a URL with legacy redirects, that can't redirect to enterprise-cloud", () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {
|
pages: {
|
||||||
'/en/foo': true,
|
'/en/foo': true,
|
||||||
@@ -240,7 +241,7 @@ describe('github-ae@latest', () => {
|
|||||||
expect(getRedirect('/github-ae@latest/food', ctx)).toBe('/en/foo')
|
expect(getRedirect('/github-ae@latest/food', ctx)).toBe('/en/foo')
|
||||||
expect(getRedirect('/en/github-ae@latest/food', ctx)).toBe('/en/foo')
|
expect(getRedirect('/en/github-ae@latest/food', ctx)).toBe('/en/foo')
|
||||||
})
|
})
|
||||||
it('should 404 if nothing matches at all', () => {
|
test('should 404 if nothing matches at all', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
pages: {},
|
pages: {},
|
||||||
redirects: {},
|
redirects: {},
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import nock from 'nock'
|
|||||||
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
|
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
|
||||||
import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releases.js'
|
import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releases.js'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('release notes', () => {
|
describe('release notes', () => {
|
||||||
jest.setTimeout(60 * 1000)
|
jest.setTimeout(60 * 1000)
|
||||||
|
|
||||||
@@ -29,13 +27,13 @@ describe('release notes', () => {
|
|||||||
|
|
||||||
afterAll(() => nock.cleanAll())
|
afterAll(() => nock.cleanAll())
|
||||||
|
|
||||||
it('redirects to the release notes on enterprise.github.com if none are present for this version here', async () => {
|
test('redirects to the release notes on enterprise.github.com if none are present for this version here', async () => {
|
||||||
const res = await get('/en/enterprise-server@2.19/admin/release-notes')
|
const res = await get('/en/enterprise-server@2.19/admin/release-notes')
|
||||||
expect(res.statusCode).toBe(302)
|
expect(res.statusCode).toBe(302)
|
||||||
expect(res.headers.location).toBe('https://enterprise.github.com/releases/2.19.0/notes')
|
expect(res.headers.location).toBe('https://enterprise.github.com/releases/2.19.0/notes')
|
||||||
})
|
})
|
||||||
|
|
||||||
it("renders the release-notes layout if this version's release notes are in this repo", async () => {
|
test("renders the release-notes layout if this version's release notes are in this repo", async () => {
|
||||||
const oldestSupportedGhes = enterpriseServerReleases.oldestSupported
|
const oldestSupportedGhes = enterpriseServerReleases.oldestSupported
|
||||||
const res = await get(`/en/enterprise-server@${oldestSupportedGhes}/admin/release-notes`)
|
const res = await get(`/en/enterprise-server@${oldestSupportedGhes}/admin/release-notes`)
|
||||||
expect(res.statusCode).toBe(200)
|
expect(res.statusCode).toBe(200)
|
||||||
@@ -46,19 +44,19 @@ describe('release notes', () => {
|
|||||||
).toBe(true)
|
).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('404 if a bogus version is requested', async () => {
|
test('404 if a bogus version is requested', async () => {
|
||||||
const res = await get('/en/enterprise-server@12345/admin/release-notes')
|
const res = await get('/en/enterprise-server@12345/admin/release-notes')
|
||||||
expect(res.statusCode).toBe(404)
|
expect(res.statusCode).toBe(404)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('404 if a the pathname only ends with the /release-notes', async () => {
|
test('404 if a the pathname only ends with the /release-notes', async () => {
|
||||||
const res = await get(`/en/enterprise-server@latest/ANY/release-notes`, {
|
const res = await get(`/en/enterprise-server@latest/ANY/release-notes`, {
|
||||||
followAllRedirects: true,
|
followAllRedirects: true,
|
||||||
})
|
})
|
||||||
expect(res.statusCode).toBe(404)
|
expect(res.statusCode).toBe(404)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('404 if a the pathname only ends with the /admin', async () => {
|
test('404 if a the pathname only ends with the /admin', async () => {
|
||||||
const res = await get(`/en/enterprise-server@latest/ANY/admin`, {
|
const res = await get(`/en/enterprise-server@latest/ANY/admin`, {
|
||||||
followAllRedirects: true,
|
followAllRedirects: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import yaml from 'js-yaml'
|
|||||||
import { readFile } from 'fs/promises'
|
import { readFile } from 'fs/promises'
|
||||||
import walk from 'walk-sync'
|
import walk from 'walk-sync'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { jest } from '@jest/globals'
|
|
||||||
|
|
||||||
import { liquid } from '#src/content-render/index.js'
|
import { liquid } from '#src/content-render/index.js'
|
||||||
|
|
||||||
@@ -14,8 +13,6 @@ const yamlWalkOptions = {
|
|||||||
}
|
}
|
||||||
const yamlFileList = walk(ghesReleaseNoteRootPath, yamlWalkOptions).sort()
|
const yamlFileList = walk(ghesReleaseNoteRootPath, yamlWalkOptions).sort()
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
describe('lint enterprise release notes', () => {
|
describe('lint enterprise release notes', () => {
|
||||||
if (yamlFileList.length < 1) return
|
if (yamlFileList.length < 1) return
|
||||||
describe.each(yamlFileList)('%s', (yamlAbsPath) => {
|
describe.each(yamlFileList)('%s', (yamlAbsPath) => {
|
||||||
@@ -27,7 +24,7 @@ describe('lint enterprise release notes', () => {
|
|||||||
yamlContent = yaml.load(fileContents)
|
yamlContent = yaml.load(fileContents)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('contains valid liquid', () => {
|
test('contains valid liquid', () => {
|
||||||
const { intro, sections } = yamlContent
|
const { intro, sections } = yamlContent
|
||||||
let toLint = { intro }
|
let toLint = { intro }
|
||||||
for (const key in sections) {
|
for (const key in sections) {
|
||||||
@@ -51,7 +48,7 @@ describe('lint enterprise release notes', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const currentWeeksFound = []
|
const currentWeeksFound = []
|
||||||
it('does not have more than one yaml file with currentWeek set to true', () => {
|
test('does not have more than one yaml file with currentWeek set to true', () => {
|
||||||
if (!yamlAbsPath.includes('data/release-notes/github-ae')) return
|
if (!yamlAbsPath.includes('data/release-notes/github-ae')) return
|
||||||
if (yamlContent.currentWeek) currentWeeksFound.push(relativePath)
|
if (yamlContent.currentWeek) currentWeeksFound.push(relativePath)
|
||||||
const errorMessage = `Found more than one file with currentWeek set to true: ${currentWeeksFound.join(
|
const errorMessage = `Found more than one file with currentWeek set to true: ${currentWeeksFound.join(
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { jest } from '@jest/globals'
|
|
||||||
|
|
||||||
import { getJsonValidator } from '#src/tests/lib/validate-json-schema.js'
|
import { getJsonValidator } from '#src/tests/lib/validate-json-schema.js'
|
||||||
import { allVersions } from '#src/versions/lib/all-versions.js'
|
import { allVersions } from '#src/versions/lib/all-versions.js'
|
||||||
import { latest } from '#src/versions/lib/enterprise-server-releases.js'
|
import { latest } from '#src/versions/lib/enterprise-server-releases.js'
|
||||||
@@ -7,8 +5,6 @@ import schema from '#src/tests/helpers/schemas/versions-schema.js'
|
|||||||
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js'
|
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js'
|
||||||
import { formatAjvErrors } from '#src/tests/helpers/schemas.js'
|
import { formatAjvErrors } from '#src/tests/helpers/schemas.js'
|
||||||
|
|
||||||
jest.useFakeTimers({ legacyFakeTimers: true })
|
|
||||||
|
|
||||||
const validate = getJsonValidator(schema)
|
const validate = getJsonValidator(schema)
|
||||||
|
|
||||||
describe('versions module', () => {
|
describe('versions module', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user