Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/lib/production-smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ export const PRODUCTION_SMOKE_EXPECTATIONS: SmokeExpectation[] = [
{ path: '/', status: 200, bodyContains: ['<h1', 'Hyped agent skills'] },
{ path: '/alt', status: 301, location: '/' },
{ path: '/skills', status: 200, bodyContains: ['<h1'] },
// Exercise Skill data and behavior rules, which category pages do not read.
// The heading marker and text must render, even when an error page answers 200.
{
path: '/gh/anthropics/skills/skill-creator',
status: 200,
bodyContains: ['<h1 id="skill-heading"', '/skill-creator</h1>'],
},
{ path: '/community', status: 200, bodyContains: ['<h1'] },
{ path: '/collections', status: 301, location: '/community' },
{ path: '/guides', status: 410 },
Expand Down
28 changes: 28 additions & 0 deletions test/unit/production-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,34 @@ import {
} from '../../scripts/lib/production-smoke'

describe('production smoke contract', () => {
it.each([
[500, '<h1>Server error</h1>', 'status_mismatch'],
[200, '<h1>Skill unavailable</h1>', 'content_missing'],
[200, '<script>{"name":"skill-creator"}</script>', 'content_missing'],
])('rejects a broken Skill page with status %s', async (status, body, reason) => {
const path = '/gh/anthropics/skills/skill-creator'
const result = await runProductionSmoke({
baseUrl: 'https://skilld.dev',
attempts: 1,
wait: async () => {},
fetch: async (input) => {
const url = new URL(input)
if (url.pathname === path)
return new Response(body, { status })
const expectation = PRODUCTION_SMOKE_EXPECTATIONS.find(item => item.path === `${url.pathname}${url.search}`)
const content = expectation?.bodyContains?.join('') ?? ''
return new Response(`${content}${url.pathname === ASSET_COHERENCE_PATH ? '<script src="/_nuxt/v2/app.js"></script>' : ''}`, {
status: expectation?.status ?? 200,
headers: { 'content-type': 'text/html', ...(expectation?.location ? { location: expectation.location } : {}) },
})
},
})
expect(result).toEqual({
_tag: 'failed',
failures: [expect.objectContaining({ path, result: expect.objectContaining({ reason }) })],
})
})

it('covers the public routes implicated by the closed incidents', () => {
expect(PRODUCTION_SMOKE_EXPECTATIONS).toEqual(expect.arrayContaining([
// The homepage asserts its own hero words, because the page's error
Expand Down