Skip to content

Commit 0eb43d5

Browse files
committed
test(docs): cover review regressions through public interfaces
1 parent 64d0d86 commit 0eb43d5

2 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎apps/docs/scripts/test-docs-interfaces-e2e.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ await check('Discovery pagination has no gaps, duplicates or unbounded pages', a
115115
}
116116
})
117117

118+
await check('Malformed canonical paths are rejected without blocking the HTTP worker', async () => {
119+
const malformed = `/${'a'.repeat(24)}!`
120+
const response = await fetch(
121+
new URL(`/api/docs/page?path=${encodeURIComponent(malformed)}`, base),
122+
{
123+
signal: AbortSignal.timeout(2000),
124+
}
125+
)
126+
assert(response.status === 400, 'Malformed path was not rejected')
127+
})
128+
118129
await check('Unknown pages and arbitrary URL inputs fail explicitly', async () => {
119130
assert(
120131
(await get('/api/docs/page?path=/no-such-document')).status === 404,

‎apps/docs/scripts/test-navigation-e2e.ts‎

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mkdir, writeFile } from 'node:fs/promises'
1+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
22
import { dirname, join } from 'node:path'
33
import {
44
type Browser,
@@ -89,6 +89,10 @@ async function verifyClientMetadata(page: Page, path: string, title: string) {
8989
'content',
9090
description ?? ''
9191
)
92+
await expect(page.locator('link[rel="alternate"][type="text/plain"]')).toHaveAttribute(
93+
'href',
94+
`${canonicalOrigin}/llms.txt`
95+
)
9296
return {
9397
path,
9498
title: await page.title(),
@@ -807,6 +811,99 @@ try {
807811

808812
const languageContext = await browser.newContext({ viewport: { width: 1440, height: 1000 } })
809813
try {
814+
await check(
815+
'Later request variants stay selected and copy the chosen streaming example',
816+
async () => {
817+
const page = await languageContext.newPage()
818+
try {
819+
if (engine === 'chromium')
820+
await languageContext.grantPermissions(['clipboard-read', 'clipboard-write'])
821+
await open(page, '/api-reference/workflows/executeWorkflowV2')
822+
const picker = page.getByRole('button', { name: /^Request example:/ })
823+
for (const language of ['Go', 'JavaScript']) {
824+
const label = `${language} — Request example 3`
825+
await picker.click()
826+
await page.getByRole('menuitemradio', { name: label, exact: true }).click()
827+
await expect(picker).toHaveAccessibleName(`Request example: ${label}`)
828+
const sample = page
829+
.getByRole('region', { name: 'Request', exact: true })
830+
.filter({ visible: true })
831+
.locator('code')
832+
await expect(sample).toContainText('stream')
833+
if (engine === 'chromium') {
834+
await page.getByRole('button', { name: 'Copy request', exact: true }).click()
835+
await expect
836+
.poll(() => page.evaluate(() => navigator.clipboard.readText()))
837+
.toBe(await sample.textContent())
838+
}
839+
await picker.click()
840+
await expect(
841+
page.getByRole('menuitemradio', { name: label, exact: true })
842+
).toHaveAttribute('aria-checked', 'true')
843+
await page.keyboard.press('Escape')
844+
}
845+
} finally {
846+
await page.close()
847+
}
848+
}
849+
)
850+
await check(
851+
'MCP tabs with multiword labels retain accessible panel relationships',
852+
async () => {
853+
const page = await languageContext.newPage()
854+
try {
855+
await open(page, '/mcp/overview')
856+
for (const label of ['Claude Code', 'VS Code']) {
857+
const tab = page.getByRole('tab', { name: label, exact: true })
858+
await tab.click()
859+
const id = await tab.getAttribute('aria-controls')
860+
expect(id).toBeTruthy()
861+
expect(id).not.toMatch(/\s/)
862+
const panel = page.locator(`[id="${id}"]`)
863+
await expect(panel).toBeVisible()
864+
await expect(panel).toHaveAccessibleName(label)
865+
}
866+
} finally {
867+
await page.close()
868+
}
869+
}
870+
)
871+
await check(
872+
'Workflow output copy, download and Markdown preserve typed data',
873+
async () => {
874+
const page = await languageContext.newPage()
875+
try {
876+
await languageContext.grantPermissions(['clipboard-read', 'clipboard-write'])
877+
await open(page, '/tables/using-in-workflows')
878+
const expected = {
879+
rows: [{ id: 'row_8f2c', data: { company: 'Acme', status: 'unprocessed' } }],
880+
rowCount: 1,
881+
totalCount: 42,
882+
}
883+
await page.getByRole('button', { name: 'Copy full output', exact: true }).click()
884+
await expect
885+
.poll(async () => JSON.parse(await page.evaluate(() => navigator.clipboard.readText())))
886+
.toEqual(expected)
887+
const pending = page.waitForEvent('download')
888+
await page.getByRole('button', { name: 'Download full output', exact: true }).click()
889+
const download = await pending
890+
const file = await download.path()
891+
if (!file) throw new Error('Output download has no artifact')
892+
expect(JSON.parse(await readFile(file, 'utf8'))).toEqual(expected)
893+
const response = await page.request.get(
894+
new URL('/tables/using-in-workflows.md', target).href
895+
)
896+
expect(response.ok()).toBe(true)
897+
const markdown = await response.text()
898+
const output = /Output from table1\s+```json\n([\s\S]*?)\n```/.exec(markdown)?.[1]
899+
expect(output).toBeTruthy()
900+
expect(JSON.parse(output ?? '')).toEqual(expected)
901+
} finally {
902+
await page.close()
903+
}
904+
},
905+
engine === 'webkit' ? 'Clipboard readback requires Chromium permissions.' : undefined
906+
)
810907
await check('API language preference survives navigation and reload', async () => {
811908
const page = await languageContext.newPage()
812909
await open(page, '/api-reference/workflows/listWorkflows')
@@ -958,6 +1055,7 @@ try {
9581055
async () => {
9591056
await legacy.addInitScript(() => {
9601057
Object.defineProperty(window, 'ClipboardItem', { value: undefined })
1058+
Object.defineProperty(AbortSignal, 'timeout', { value: undefined })
9611059
const write = navigator.clipboard.writeText.bind(navigator.clipboard)
9621060
navigator.clipboard.writeText = (text) => {
9631061
document.documentElement.dataset.clipboardActivation = String(

0 commit comments

Comments
 (0)