This commit is contained in:
Kevin Heis 2023-11-13 11:40:33 -08:00 коммит произвёл GitHub
Родитель f86ebbca67
Коммит c0ddefdfcc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
269 изменённых файлов: 179 добавлений и 185 удалений

46
.github/workflows/test.yml поставляемый
Просмотреть файл

@ -38,25 +38,23 @@ jobs:
# Note that *if you add* to this, remember to also add that
# to the **required checks** in the branch protection rules.
name:
# tests/ directory
- content
- rendering
- rendering-fixtures
- routing
- unit
# src/ directory
- archives
- assets
- audit-logs
- automated-pipelines
# - bookmarklets
- changelogs
# - codeql-cli
- color-schemes
- content-linter
- content-render
- data-directory
# - dev-toc
- early-access
- events
# - frame
- fixtures
- frame
- ghes-releases
- github-apps
- graphql
@ -68,12 +66,14 @@ jobs:
# - open-source
- pageinfo
# - pages
- products
- redirects
- release-notes
- rest
- search
- secret-scanning
- shielding
# - tests
# - tools
- versions
- webhooks
@ -103,23 +103,23 @@ jobs:
token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }}
- name: Check the test fixture data (if applicable)
if: ${{ matrix.name == 'rendering-fixtures' }}
if: ${{ matrix.name == 'fixtures' }}
run: ./src/tests/scripts/copy-fixture-data.js --check
# This keeps our fixture content/data in check
- name: Check the test fixture content (if applicable)
if: ${{ matrix.name == 'rendering-fixtures' }}
if: ${{ matrix.name == 'fixtures' }}
env:
ROOT: tests/fixtures
ROOT: src/fixtures/fixtures
run: |
# If either of these fail, it means our fixture content's internal
# links can and should be updated.
./src/links/scripts/update-internal-links.js --dry-run --check --strict \
tests/fixtures/content \
--exclude tests/fixtures/content/get-started/foo/typo-autotitling.md \
--exclude tests/fixtures/content/get-started/foo/anchor-autotitling.md
src/fixtures/fixtures/content \
--exclude src/fixtures/fixtures/content/get-started/foo/typo-autotitling.md \
--exclude src/fixtures/fixtures/content/get-started/foo/anchor-autotitling.md
./src/links/scripts/update-internal-links.js --dry-run --check --strict \
tests/fixtures/data
src/fixtures/fixtures/data
- name: Clone all translations
if: ${{ matrix.name == 'languages' }}
@ -169,7 +169,7 @@ jobs:
- uses: ./.github/actions/warmup-remotejson-cache
# Only the 'routing' tests include end-to-end tests about
# archived enterprise server URLs.
if: ${{ matrix.name == 'routing' }}
if: ${{ matrix.name == 'redirects' }}
- name: Index fixtures into the local Elasticsearch
# For the sake of saving time, only run this step if the group
@ -180,17 +180,11 @@ jobs:
- name: Run tests
env:
DIFF_FILE: get_diff_files.txt
CHANGELOG_CACHE_FILE_PATH: tests/fixtures/changelog-feed.json
CHANGELOG_CACHE_FILE_PATH: src/fixtures/fixtures/changelog-feed.json
# By default, when `process.env.NODE_ENV === 'test'` it forces the
# tests run only in English. The exception is the
# `languages` suite which needs all languages to be set up.
ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }}
ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo' || matrix.name == 'landings' ) && 'tests/fixtures' || '' }}
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo') && 'tests/fixtures/translations' || '' }}
run: |
if [ -d "tests/${{ matrix.name }}/" ]
then
npm test -- tests/${{ matrix.name }}/
else
npm test -- src/${{ matrix.name }}/tests/
fi
ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'pageinfo' || matrix.name == 'landings' ) && 'src/fixtures/fixtures' || '' }}
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'pageinfo') && 'src/fixtures/fixtures/translations' || '' }}
run: npm test -- src/${{ matrix.name }}/tests/

Просмотреть файл

@ -212,7 +212,7 @@ jobs:
- name: Run tests
env:
DIFF_FILE: get_diff_files.txt
CHANGELOG_CACHE_FILE_PATH: tests/fixtures/changelog-feed.json
CHANGELOG_CACHE_FILE_PATH: src/fixtures/fixtures/changelog-feed.json
run: npm test -- {% raw %}tests/${{ matrix.test-group }}/{% endraw %}
```

Просмотреть файл

@ -19,8 +19,8 @@
"build": "next build",
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect src/frame/server.js",
"dev": "cross-env npm start",
"fixture-dev": "cross-env ROOT=tests/fixtures npm start",
"fixture-test": "cross-env ROOT=tests/fixtures npm test -- tests/rendering-fixtures",
"fixture-dev": "cross-env ROOT=src/fixtures/fixtures npm start",
"fixture-test": "cross-env ROOT=src/fixtures/fixtures npm test -- src/fixtures/tests",
"index-test-fixtures": "node src/search/scripts/index-elasticsearch.js -l en -l ja -V ghae -V dotcom --index-prefix tests -- src/search/tests/fixtures/search-indexes",
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
"lint-content": "node src/content-linter/scripts/lint-content.js",
@ -37,7 +37,7 @@
"prestart": "node src/workflows/cmp-files.js package-lock.json .installed.package-lock.json || npm install && cp package-lock.json .installed.package-lock.json",
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon src/frame/server.js",
"start-all-languages": "cross-env NODE_ENV=development nodemon src/frame/server.js",
"start-for-playwright": "cross-env ROOT=tests/fixtures TRANSLATIONS_FIXTURE_ROOT=tests/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test node src/frame/server.js",
"start-for-playwright": "cross-env ROOT=src/fixtures/fixtures TRANSLATIONS_FIXTURE_ROOT=src/fixtures/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test node src/frame/server.js",
"sync-rest": "node src/rest/scripts/update-files.js",
"sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices",
"sync-search-ghes-release": "cross-env GHES_RELEASE=1 start-server-and-test sync-search-server 4002 sync-search-indices",
@ -200,8 +200,8 @@
"testPathIgnorePatterns": [
"node_modules/",
"vendor/",
"tests/fixtures/",
"tests/helpers/"
"src/fixtures/fixtures/",
"src/tests/helpers/"
]
},
"dependencies": {

Просмотреть файл

@ -10,7 +10,7 @@ import { defineConfig, devices } from '@playwright/test'
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
testDir: './src/fixtures/tests',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {

Просмотреть файл

@ -1,7 +1,7 @@
import { describe, jest, test } from '@jest/globals'
import enterpriseServerReleases from '#src/versions/lib/enterprise-server-releases.js'
import { get, getDOM } from '../../../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'
jest.useFakeTimers({ legacyFakeTimers: true })

Просмотреть файл

@ -95,7 +95,7 @@ async function main(opts) {
}
}
const roots = ['tests', 'contributing', 'src', 'assets']
const roots = ['contributing', 'src', 'assets']
for (const root of roots) {
sourceFiles.push(

Просмотреть файл

@ -3,7 +3,7 @@ import sharp from 'sharp'
import { fileTypeFromBuffer } from 'file-type'
import { SURROGATE_ENUMS } from '#src/frame/middleware/set-fastly-surrogate-key.js'
import { get, head } from '../../../tests/helpers/e2etest.js'
import { get, head } from '#src/tests/helpers/e2etest.js'
describe('dynamic assets', () => {
jest.setTimeout(3 * 60 * 1000)

Просмотреть файл

@ -1,7 +1,7 @@
import nock from 'nock'
import { expect, jest } from '@jest/globals'
import { checkCachingHeaders } from '../../../tests/helpers/caching-headers.js'
import { checkCachingHeaders } from '#src/tests/helpers/caching-headers.js'
import { setDefaultFastlySurrogateKey } from '#src/frame/middleware/set-fastly-surrogate-key.js'
import archivedEnterpriseVersionsAssets from '#src/archives/middleware/archived-enterprise-versions-assets.js'

Просмотреть файл

@ -3,8 +3,8 @@ import path from 'path'
import { jest, expect } from '@jest/globals'
import { get } from '../../../tests/helpers/e2etest.js'
import { checkCachingHeaders } from '../../../tests/helpers/caching-headers.js'
import { get } from '#src/tests/helpers/e2etest.js'
import { checkCachingHeaders } from '#src/tests/helpers/caching-headers.js'
function getNextStaticAsset(directory) {
const root = path.join('.next', 'static', directory)

Просмотреть файл

@ -1,6 +1,6 @@
import { expect } from '@jest/globals'
import { getDOM } from '../../../tests/helpers/e2etest.js'
import { getDOM } from '#src/tests/helpers/e2etest.js'
import { allVersions } from '#src/versions/lib/all-versions.js'
import { getAuditLogEvents } from '../lib/index.js'

Просмотреть файл

@ -4,7 +4,7 @@ import cheerio from 'cheerio'
import { jest, test } from '@jest/globals'
import { loadPages } from '#src/frame/lib/page-data.js'
import { get } from '../../../tests/helpers/e2etest.js'
import { get } from '#src/tests/helpers/e2etest.js'
// Get a list of the autogenerated pages
const pageList = await loadPages(undefined, ['en'])

Просмотреть файл

@ -10,7 +10,7 @@ describe('getChangelogItems module', () => {
beforeAll(async () => {
const rssFeedContent = await fs.readFile(
path.join(process.cwd(), 'tests/fixtures/rss-feed.xml'),
path.join(process.cwd(), 'src/fixtures/fixtures/rss-feed.xml'),
'utf8',
)

Просмотреть файл

@ -1,6 +1,6 @@
import { loadPages, loadPageMap } from '#src/frame/lib/page-data.js'
import loadRedirects from '#src/redirects/lib/precompile.js'
import { checkURL } from '../../../tests/helpers/check-url.js'
import { checkURL } from '#src/tests/helpers/check-url.js'
const pageList = await loadPages(undefined, ['en'])
const pages = await loadPageMap(pageList)

Просмотреть файл

@ -5,7 +5,7 @@ import semver from 'semver'
import featureVersionsSchema from '../lib/feature-versions-schema.js'
import { getDeepDataByLanguage } from '#src/data-directory/lib/get-data.js'
import { formatAjvErrors } from '../../../tests/helpers/schemas.js'
import { formatAjvErrors } from '#src/tests/helpers/schemas.js'
/*
NOTE: This test suite does NOT validate the `versions` frontmatter in content files.

Просмотреть файл

@ -4,7 +4,7 @@ import { runRule } from '../../lib/init-test.js'
import { frontmatterHiddenDocs } from '../../lib/linting-rules/frontmatter-hidden-docs.js'
const ACTIONS_FIXTURE = 'src/content-linter/tests/fixtures/actions/hidden.md'
const EARLY_ACCESS_FIXTURE = 'tests/fixtures/content/early-access/secrets/early-days.md'
const EARLY_ACCESS_FIXTURE = 'src/fixtures/fixtures/content/early-access/secrets/early-days.md'
const EXPERIMENTAL_FIXTURE = 'src/content-linter/tests/fixtures/actions/experimental.md'
const fmOptions = { markdownlintOptions: { frontMatter: null } }

Просмотреть файл

@ -10,7 +10,7 @@ describe(liquidDataReferencesDefined.names.join(' - '), () => {
const envVarValueBefore = process.env.ROOT
beforeAll(() => {
process.env.ROOT = path.join('tests', 'fixtures')
process.env.ROOT = path.join('src', 'fixtures', 'fixtures')
})
afterAll(() => {

Просмотреть файл

@ -8,7 +8,7 @@ describe(liquidIfTags.names.join(' - '), () => {
const envVarValueBefore = process.env.ROOT
beforeAll(() => {
process.env.ROOT = path.join('tests', 'fixtures')
process.env.ROOT = path.join('src', 'fixtures', 'fixtures')
})
afterAll(() => {
@ -39,7 +39,7 @@ describe(liquidIfVersionTags.names.join(' - '), () => {
const envVarValueBefore = process.env.ROOT
beforeAll(() => {
process.env.ROOT = path.join('tests', 'fixtures')
process.env.ROOT = path.join('src', 'fixtures', 'fixtures')
})
afterAll(() => {

Просмотреть файл

Просмотреть файл

@ -3,7 +3,7 @@ import { afterAll, beforeAll, expect, describe, it } from '@jest/globals'
import Page from '#src/frame/lib/page.js'
import languages from '#src/languages/lib/languages.js'
import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js'
import { DataDirectory } from '../../../tests/helpers/data-directory.js'
import { DataDirectory } from '#src/tests/helpers/data-directory.js'
describe('data tag', () => {
let dd
@ -30,7 +30,7 @@ describe('data tag', () => {
it('should render fine if data is found', async () => {
const page = await Page.init({
relativePath: 'liquid-tags/good-data-variable.md',
basePath: './tests/fixtures',
basePath: './src/fixtures/fixtures',
languageCode: 'en',
})
const context = {
@ -47,7 +47,7 @@ describe('data tag', () => {
it('should throw if the data tag is used with something unrecognized', async () => {
const page = await Page.init({
relativePath: 'liquid-tags/bad-data-variable.md',
basePath: './tests/fixtures',
basePath: './src/fixtures/fixtures',
languageCode: 'en',
})
const context = {

Просмотреть файл

@ -1,7 +1,7 @@
import { afterAll, jest, beforeAll, expect } from '@jest/globals'
import { liquid } from '#src/content-render/index.js'
import languages from '#src/languages/lib/languages.js'
import { DataDirectory } from '../../../tests/helpers/data-directory.js'
import { DataDirectory } from '#src/tests/helpers/data-directory.js'
describe('liquid helper tags', () => {
jest.setTimeout(60 * 1000)

Просмотреть файл

@ -33,7 +33,7 @@ import path from 'path'
import { jest } from '@jest/globals'
import { head, get } from '../../../tests/helpers/e2etest.js'
import { head, get } from '#src/tests/helpers/e2etest.js'
import { loadPages } from '#src/frame/lib/page-data.js'
const EMPTY = Symbol('EMPTY')

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -9,7 +9,7 @@ import {
getDeepDataByLanguage,
getUIDataMerged,
} from '#src/data-directory/lib/get-data.js'
import { DataDirectory } from '../helpers/data-directory.js'
import { DataDirectory } from '#src/tests/helpers/data-directory.js'
describe('get-data', () => {
let dd

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -3,8 +3,8 @@ import path from 'path'
import { expect } from '@jest/globals'
import { testViaActionsOnly } from '../../../tests/helpers/conditional-runs.js'
import { get, getDOM } from '../../../tests/helpers/e2etest.js'
import { testViaActionsOnly } from '#src/tests/helpers/conditional-runs.js'
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
describe('cloning early-access', () => {
testViaActionsOnly('the content directory exists', async () => {

Просмотреть файл

@ -1,7 +1,7 @@
import { expect, jest, test } from '@jest/globals'
import { get, getDOM } from '../../../tests/helpers/e2etest.js'
import { get, getDOM } from '#src/tests/helpers/e2etest.js'
import { describeIfDocsEarlyAccess } from '../../../tests/helpers/conditional-runs.js'
import { describeIfDocsEarlyAccess } from '#src/tests/helpers/conditional-runs.js'
import languages from '#src/languages/lib/languages.js'
const VALID_EARLY_ACCESS_URI = '/early-access/github/save-time-with-slash-commands'

Просмотреть файл

@ -1,5 +1,5 @@
import { expect, jest } from '@jest/globals'
import { post } from '../../../tests/helpers/e2etest.js'
import { post } from '#src/tests/helpers/e2etest.js'
describe('POST /events', () => {
jest.setTimeout(60 * 1000)

Просмотреть файл

0
src/fixtures/README.md Normal file
Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -17,7 +17,7 @@ have to worry about breaking tests of functionality.
## How to write fixtured based rendering tests
The content is in `tests/fixtures/content/` (and `tests/fixtures/data/`)
The content is in `src/fixtures/fixtures/content/` (and `src/fixtures/fixtures/data/`)
is a cut down version of the real `content/` (and `data/`) at the root.
It doesn't have nearly as many pages and if you look closely you'll see
references and mentions to unrealistic things like "foo" or "HubGit"
@ -26,7 +26,7 @@ with any silly name, the code is modular and good.
### Quickstart
Navigate around in `tests/fixtures/content/` and familiarize yourself
Navigate around in `src/fixtures/fixtures/content/` and familiarize yourself
with the directory structure. The only things that are "identical" to the
real content is the top-level product names which match the real content.
Deeper than the product level, the names and directories can be whatever
@ -47,13 +47,13 @@ action.
Feel free to create sub-directories or new files. For example, if it's
about end-to-end testing a new custom Liquid tag called
`lib/liquid-tags/snacks.js` you create a new test called
`tests/rendering-fixtures/snack.js`. (And equally, you might want to create
`tests/fixtures/content/get-started/foo/snacking.md`)
`src/fixtures/tests/snack.js`. (And equally, you might want to create
`src/fixtures/fixtures/content/get-started/foo/snacking.md`)
To run the tests use:
```shell
ROOT=tests/fixtures jest tests/rendering-fixtures/
ROOT=src/fixtures/fixtures jest src/fixtures/tests
```
### Exceptions

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше