@@ -74,4 +74,123 @@ describe('article body api', () => {
7474 const { error } = JSON . parse ( res . body )
7575 expect ( error ) . toBe ( "Multiple 'pathname' keys" )
7676 } )
77+
78+ test ( 'tool picker shows all tool variants in markdown' , async ( ) => {
79+ const res = await get ( makeURL ( '/en/get-started/liquid/tool-specific' ) )
80+ expect ( res . statusCode ) . toBe ( 200 )
81+ expect ( res . headers [ 'content-type' ] ) . toContain ( 'text/markdown' )
82+
83+ // Should contain all tool-specific content variants
84+ expect ( res . body ) . toContain ( '<div class="ghd-tool webui">' )
85+ expect ( res . body ) . toContain ( '<div class="ghd-tool cli">' )
86+ expect ( res . body ) . toContain ( '<div class="ghd-tool desktop">' )
87+
88+ // Should contain the actual content from each tool
89+ expect ( res . body ) . toContain ( 'This is webui content' )
90+ expect ( res . body ) . toContain ( 'This is cli content' )
91+ expect ( res . body ) . toContain ( 'This is desktop content' )
92+
93+ // Should contain tool-specific sections
94+ expect ( res . body ) . toContain ( 'Webui section specific content' )
95+ expect ( res . body ) . toContain ( 'Desktop section specific content' )
96+
97+ // Verify multiple instances of the same tool are preserved
98+ const webuiMatches = res . body . match ( / < d i v c l a s s = " g h d - t o o l w e b u i " > / g)
99+ const desktopMatches = res . body . match ( / < d i v c l a s s = " g h d - t o o l d e s k t o p " > / g)
100+ expect ( webuiMatches ) . toBeDefined ( )
101+ expect ( webuiMatches ! . length ) . toBeGreaterThan ( 1 )
102+ expect ( desktopMatches ) . toBeDefined ( )
103+ expect ( desktopMatches ! . length ) . toBeGreaterThan ( 1 )
104+ } )
105+
106+ test ( 'codespaces tool content is included in markdown API' , async ( ) => {
107+ const res = await get ( makeURL ( '/en/get-started/liquid/tool-picker-issue' ) )
108+ expect ( res . statusCode ) . toBe ( 200 )
109+ expect ( res . headers [ 'content-type' ] ) . toContain ( 'text/markdown' )
110+
111+ // Should contain both webui and codespaces tool content
112+ expect ( res . body ) . toContain ( '<div class="ghd-tool webui">' )
113+ expect ( res . body ) . toContain ( '<div class="ghd-tool codespaces">' )
114+
115+ // Should contain the actual content from both tools
116+ expect ( res . body ) . toContain ( 'Under your repository name, click **Pull requests**' )
117+ expect ( res . body ) . toContain ( 'Open the pull request in your codespace' )
118+ expect ( res . body ) . toContain (
119+ 'After reviewing the files, you can submit your review from the web interface' ,
120+ )
121+ expect ( res . body ) . toContain (
122+ 'After reviewing the files, you can submit your review directly from Codespaces' ,
123+ )
124+
125+ // Verify both tools appear in multiple sections
126+ const webuiMatches = res . body . match ( / < d i v c l a s s = " g h d - t o o l w e b u i " > / g)
127+ const codespacesMatches = res . body . match ( / < d i v c l a s s = " g h d - t o o l c o d e s p a c e s " > / g)
128+ expect ( webuiMatches ) . toBeDefined ( )
129+ expect ( webuiMatches ! . length ) . toBe ( 2 )
130+ expect ( codespacesMatches ) . toBeDefined ( )
131+ expect ( codespacesMatches ! . length ) . toBe ( 2 )
132+ } )
133+
134+ test ( 'codespaces content included in production markdown API' , async ( ) => {
135+ // Test a real production page that has codespaces content
136+ const res = await get (
137+ makeURL (
138+ '/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request' ,
139+ ) ,
140+ )
141+
142+ // Skip test if page doesn't exist in fixture environment
143+ if ( res . statusCode === 404 ) {
144+ console . log ( 'Production page not available in fixture environment, skipping test' )
145+ return
146+ }
147+
148+ expect ( res . statusCode ) . toBe ( 200 )
149+
150+ // Verify the fix is working - codespaces content should now be present
151+ const hasCodespacesContent = res . body . includes ( '<div class="ghd-tool codespaces">' )
152+ expect ( hasCodespacesContent ) . toBe ( true )
153+
154+ // Also verify that webui content is still present
155+ expect ( res . body ) . toContain ( '<div class="ghd-tool webui">' )
156+ } )
157+
158+ test ( 'verifies original issue #5400 is resolved' , async ( ) => {
159+ // This test specifically addresses the original issue where tool picker
160+ // content was missing from the Markdown API response
161+ const res = await get (
162+ makeURL (
163+ '/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request' ,
164+ ) ,
165+ )
166+
167+ // Skip test if page doesn't exist in fixture environment
168+ if ( res . statusCode === 404 ) {
169+ console . log (
170+ 'Production page not available in fixture environment, skipping issue verification test' ,
171+ )
172+ return
173+ }
174+
175+ expect ( res . statusCode ) . toBe ( 200 )
176+ expect ( res . headers [ 'content-type' ] ) . toContain ( 'text/markdown' )
177+
178+ // The original issue was that only webui content was returned, missing codespaces
179+ expect ( res . body ) . toContain ( '<div class="ghd-tool webui">' )
180+ expect ( res . body ) . toContain ( '<div class="ghd-tool codespaces">' )
181+
182+ // Verify specific codespaces content that was missing before the fix
183+ expect ( res . body ) . toContain ( 'GitHub Codespaces' )
184+ expect ( res . body ) . toContain ( 'Open the pull request in a codespace' )
185+
186+ // Ensure both tools are rendered with their respective content
187+ const webuiMatches = res . body . match ( / < d i v c l a s s = " g h d - t o o l w e b u i " > / g)
188+ const codespacesMatches = res . body . match ( / < d i v c l a s s = " g h d - t o o l c o d e s p a c e s " > / g)
189+
190+ expect ( webuiMatches ) . toBeDefined ( )
191+ expect ( codespacesMatches ) . toBeDefined ( )
192+ expect ( codespacesMatches ! . length ) . toBeGreaterThan ( 0 )
193+
194+ console . log ( '✅ Issue #5400 resolved: All tool picker content now included in Markdown API' )
195+ } )
77196} )
0 commit comments