Skip to content

Commit ba852a5

Browse files
authored
test(smoke): check a rendered Skill page in production (#445)
1 parent 3bd6047 commit ba852a5

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎scripts/lib/production-smoke.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ export const PRODUCTION_SMOKE_EXPECTATIONS: SmokeExpectation[] = [
9797
{ path: '/', status: 200, bodyContains: ['<h1', 'Hyped agent skills'] },
9898
{ path: '/alt', status: 301, location: '/' },
9999
{ path: '/skills', status: 200, bodyContains: ['<h1'] },
100+
// Exercise Skill data and behavior rules, which category pages do not read.
101+
// The heading marker and text must render, even when an error page answers 200.
102+
{
103+
path: '/gh/anthropics/skills/skill-creator',
104+
status: 200,
105+
bodyContains: ['<h1 id="skill-heading"', '/skill-creator</h1>'],
106+
},
100107
{ path: '/community', status: 200, bodyContains: ['<h1'] },
101108
{ path: '/collections', status: 301, location: '/community' },
102109
{ path: '/guides', status: 410 },

‎test/unit/production-smoke.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ import {
88
} from '../../scripts/lib/production-smoke'
99

1010
describe('production smoke contract', () => {
11+
it.each([
12+
[500, '<h1>Server error</h1>', 'status_mismatch'],
13+
[200, '<h1>Skill unavailable</h1>', 'content_missing'],
14+
[200, '<script>{"name":"skill-creator"}</script>', 'content_missing'],
15+
])('rejects a broken Skill page with status %s', async (status, body, reason) => {
16+
const path = '/gh/anthropics/skills/skill-creator'
17+
const result = await runProductionSmoke({
18+
baseUrl: 'https://skilld.dev',
19+
attempts: 1,
20+
wait: async () => {},
21+
fetch: async (input) => {
22+
const url = new URL(input)
23+
if (url.pathname === path)
24+
return new Response(body, { status })
25+
const expectation = PRODUCTION_SMOKE_EXPECTATIONS.find(item => item.path === `${url.pathname}${url.search}`)
26+
const content = expectation?.bodyContains?.join('') ?? ''
27+
return new Response(`${content}${url.pathname === ASSET_COHERENCE_PATH ? '<script src="/_nuxt/v2/app.js"></script>' : ''}`, {
28+
status: expectation?.status ?? 200,
29+
headers: { 'content-type': 'text/html', ...(expectation?.location ? { location: expectation.location } : {}) },
30+
})
31+
},
32+
})
33+
expect(result).toEqual({
34+
_tag: 'failed',
35+
failures: [expect.objectContaining({ path, result: expect.objectContaining({ reason }) })],
36+
})
37+
})
38+
1139
it('covers the public routes implicated by the closed incidents', () => {
1240
expect(PRODUCTION_SMOKE_EXPECTATIONS).toEqual(expect.arrayContaining([
1341
// The homepage asserts its own hero words, because the page's error

0 commit comments

Comments
 (0)