@@ -122,11 +122,46 @@ describe('Webhooks transformer', () => {
122122 const res = await get ( makeURL ( '/en/webhooks/webhook-events-and-payloads' ) )
123123 expect ( res . statusCode ) . toBe ( 200 )
124124
125- // NOTE: The current webhook source data does not include payloadExample fields,
126- // so this section won't appear in the output. The transformer code (lines 115-120)
127- // is ready to display payload examples if/when they are added to the source data.
128- // For now, we just verify the transformer doesn't crash on missing examples.
125+ // Payload examples are deliberately omitted from the article API output to save space.
126+ // The property tables describe the payload structure instead.
127+ expect ( res . body ) . not . toContain ( '### Webhook payload example' )
128+ expect ( res . body ) . not . toMatch ( / ` ` ` j s o n / )
129+ } )
130+
131+ test ( 'common parameters are extracted into a shared section' , async ( ) => {
132+ const res = await get ( makeURL ( '/en/webhooks/webhook-events-and-payloads' ) )
129133 expect ( res . statusCode ) . toBe ( 200 )
134+
135+ // Should have a common parameters section at the top
136+ expect ( res . body ) . toContain ( '## Common payload parameters' )
137+ expect ( res . body ) . toContain ( 'Most webhook events include these standard parameters' )
138+
139+ // Common params like 'sender' and 'repository' should appear in the common section
140+ // (they're in 60%+ of webhook events)
141+ const commonSection = res . body . split ( '## Common payload parameters' ) [ 1 ] ?. split ( '\n## ' ) [ 0 ] || ''
142+ expect ( commonSection ) . toContain ( '`sender`' )
143+ expect ( commonSection ) . toContain ( '`repository`' )
144+ } )
145+
146+ test ( 'common parameters are not repeated in individual webhook sections' , async ( ) => {
147+ const res = await get ( makeURL ( '/en/webhooks/webhook-events-and-payloads' ) )
148+ expect ( res . statusCode ) . toBe ( 200 )
149+
150+ // Find individual webhook sections after the common section
151+ const sections = res . body . split ( '\n## ' )
152+ const webhookSections = sections . filter (
153+ ( s : string ) => ! s . startsWith ( 'Common payload parameters' ) && ! s . startsWith ( sections [ 0 ] ) , // skip content before first ##
154+ )
155+
156+ // In individual webhook parameter tables, common params should not appear
157+ for ( const section of webhookSections . slice ( 0 , 3 ) ) {
158+ // If the section has a parameter table
159+ if ( section . includes ( '#### Webhook payload object parameters' ) ) {
160+ const tableContent = section . split ( '#### Webhook payload object parameters' ) [ 1 ] || ''
161+ // 'sender' should NOT appear in individual tables
162+ expect ( tableContent ) . not . toMatch ( / \| \s * ` s e n d e r ` \s * \| / )
163+ }
164+ }
130165 } )
131166
132167 test ( 'Non-webhooks pages are not transformed' , async ( ) => {
0 commit comments