6
.github/workflows/local-dev.yml
vendored
6
.github/workflows/local-dev.yml
vendored
@@ -24,6 +24,11 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- uses: ./.github/actions/get-docs-early-access
|
||||
if: ${{ github.repository == 'github/docs-internal' }}
|
||||
with:
|
||||
token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }}
|
||||
|
||||
# Note that we don't check out docs-early-access, Elasticsearch,
|
||||
# or any remote translations. Nothing fancy here!
|
||||
|
||||
@@ -42,6 +47,7 @@ jobs:
|
||||
# tests not exiting at the end with a non-zero. Otherwise,
|
||||
# by default failures are marked as "flaky" instead of "failed".
|
||||
PLAYWRIGHT_RETRIES: 0
|
||||
TEST_EARLY_ACCESS: ${{ github.repository == 'github/docs-internal' }}
|
||||
run: npm run playwright-test -- playwright-local-dev
|
||||
|
||||
- name: Start server in the background
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
import { uniq } from 'lodash-es'
|
||||
|
||||
export default function earlyAccessContext(req, res, next) {
|
||||
// Use req.pagePath instead of req.path because req.path is the path
|
||||
// normalized after "converting" that `/_next/data/...` path to the
|
||||
// equivalent path if it had *not* been a client-side routing fetch.
|
||||
const url = req.pagePath.split('/').slice(2)
|
||||
if (
|
||||
!(
|
||||
// Is it `/early-access` or `/enterprise-cloud@latest/early-access`?
|
||||
(
|
||||
(url.length === 2 && url[1] === 'early-access') ||
|
||||
(url.length === 1 && url[0] === 'early-access')
|
||||
)
|
||||
)
|
||||
) {
|
||||
return next()
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
return next(404)
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ describe('rendering early-access', () => {
|
||||
expect(res.statusCode).toBe(404)
|
||||
})
|
||||
|
||||
testViaActionsOnly('the enterprise-cloud TOC is always 404', async () => {
|
||||
const res = await get('/en/enterprise-cloud@latest/early-access')
|
||||
expect(res.statusCode).toBe(404)
|
||||
})
|
||||
|
||||
testViaActionsOnly('TOCs display on category pages', async () => {
|
||||
const $ = await getDOM('/en/early-access/github/enforcing-best-practices-with-github-policies')
|
||||
expect($('ul a').length).toBeGreaterThan(5)
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
const TEST_EARLY_ACCESS = Boolean(JSON.parse(process.env.TEST_EARLY_ACCESS || 'false'))
|
||||
|
||||
test('view home page', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
await expect(page).toHaveTitle(/GitHub Docs/)
|
||||
@@ -32,3 +34,16 @@ test('search "git" and get results', async ({ page }) => {
|
||||
await page.getByTestId('site-search-input').press('Enter')
|
||||
await expect(page.getByRole('heading', { name: /\d+ Search results for "git"/ })).toBeVisible()
|
||||
})
|
||||
|
||||
test('view the early-access links page', async ({ page }) => {
|
||||
if (!TEST_EARLY_ACCESS) return
|
||||
|
||||
await page.goto('/early-access')
|
||||
await expect(page).toHaveURL(/\/en\/early-access/)
|
||||
await page.getByRole('heading', { name: 'Early Access documentation' }).click()
|
||||
const links = await page.$$eval(
|
||||
'#article-contents ul li a',
|
||||
(elements: HTMLAnchorElement[]) => elements,
|
||||
)
|
||||
expect(links.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
@@ -251,7 +251,7 @@ export default function (app) {
|
||||
app.use(haltOnDroppedConnection)
|
||||
|
||||
app.use(robots)
|
||||
app.use(/(\/.*)?\/early-access$/, earlyAccessLinks)
|
||||
app.use(earlyAccessLinks)
|
||||
app.use('/categories.json', asyncMiddleware(categoriesForSupport))
|
||||
app.get('/_500', asyncMiddleware(triggerError))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user