@@ -219,21 +219,25 @@ vi.mock("@/components/shared/query-code-editor", () => ({
219219 language,
220220 value,
221221 copyValue,
222+ showLineNumbers = true ,
222223 } : {
223224 ariaLabel : string ;
224225 language ?: string ;
225226 value : string ;
226227 copyValue ?: string ;
228+ showLineNumbers ?: boolean ;
227229 } ) => (
228230 < div
229231 data-testid = "query-code-editor"
230232 data-aria-label = { ariaLabel }
231233 data-language = { language }
234+ data-show-line-numbers = { String ( showLineNumbers ) }
232235 >
233236 < span > { ariaLabel } </ span >
234237 < span > { value } </ span >
235238 < button
236239 type = "button"
240+ aria-label = { `Copy ${ ariaLabel } ` }
237241 onClick = { ( ) => mockClipboardWriteText ( copyValue ?? value ) }
238242 >
239243 Copy editor code
@@ -255,7 +259,22 @@ vi.mock("@/components/icons/services/IconServices", () => ({
255259} ) ) ;
256260
257261vi . mock ( "@/components/ui/code-snippet/code-snippet" , ( ) => ( {
258- CodeSnippet : ( { value } : { value : string } ) => < span > { value } </ span > ,
262+ CodeSnippet : ( {
263+ value,
264+ formatter,
265+ ariaLabel = "Copy to clipboard" ,
266+ } : {
267+ value : string ;
268+ formatter ?: ( value : string ) => string ;
269+ ariaLabel ?: string ;
270+ } ) => (
271+ < div data-testid = "code-snippet" >
272+ < span > { formatter ? formatter ( value ) : value } </ span >
273+ < button type = "button" onClick = { ( ) => mockClipboardWriteText ( value ) } >
274+ { ariaLabel }
275+ </ button >
276+ </ div >
277+ ) ,
259278} ) ) ;
260279
261280vi . mock ( "@/components/ui/custom/custom-link" , ( ) => ( {
@@ -592,7 +611,7 @@ describe("ResourceDetailDrawerContent — Fix 2: Remediation heading labels", ()
592611 expect ( allText ) . toContain ( "CLI Command" ) ;
593612 } ) ;
594613
595- it ( "should render remediation snippets with the shared code editor and copy CLI without the visual prompt" , async ( ) => {
614+ it ( "should render CLI remediation in the code editor without line numbers and copy without the visual prompt" , async ( ) => {
596615 // Given
597616 const user = userEvent . setup ( ) ;
598617 render (
@@ -612,17 +631,19 @@ describe("ResourceDetailDrawerContent — Fix 2: Remediation heading labels", ()
612631
613632 // When
614633 const editors = screen . getAllByTestId ( "query-code-editor" ) ;
615- await user . click (
616- within ( editors [ 0 ] ) . getByRole ( "button" , { name : "Copy editor code" } ) ,
617- ) ;
634+ await user . click ( screen . getByRole ( "button" , { name : "Copy CLI Command" } ) ) ;
618635
619636 // Then
620637 expect ( editors ) . toHaveLength ( 3 ) ;
638+ expect ( editors [ 0 ] ) . toHaveAttribute ( "data-aria-label" , "CLI Command" ) ;
639+ expect ( editors [ 0 ] ) . toHaveAttribute ( "data-show-line-numbers" , "false" ) ;
640+ expect ( editors [ 1 ] ) . toHaveAttribute ( "data-show-line-numbers" , "true" ) ;
641+ expect ( editors [ 2 ] ) . toHaveAttribute ( "data-show-line-numbers" , "true" ) ;
621642 expect ( mockClipboardWriteText ) . toHaveBeenCalledWith ( "aws s3 ..." ) ;
622643 expect ( screen . getByText ( "$ aws s3 ..." ) ) . toBeInTheDocument ( ) ;
623644 } ) ;
624645
625- it ( "should pass syntax highlighting languages to each remediation editor " , ( ) => {
646+ it ( "should pass syntax highlighting languages to all remediation editors " , ( ) => {
626647 // Given
627648 render (
628649 < ResourceDetailDrawerContent
@@ -643,10 +664,12 @@ describe("ResourceDetailDrawerContent — Fix 2: Remediation heading labels", ()
643664 const editors = screen . getAllByTestId ( "query-code-editor" ) ;
644665
645666 // Then
667+ expect ( editors ) . toHaveLength ( 3 ) ;
646668 expect ( editors [ 0 ] ) . toHaveAttribute ( "data-language" , "shell" ) ;
647669 expect ( editors [ 1 ] ) . toHaveAttribute ( "data-language" , "hcl" ) ;
648670 expect ( editors [ 2 ] ) . toHaveAttribute ( "data-language" , "yaml" ) ;
649671 expect ( editors [ 0 ] ) . toHaveAttribute ( "data-aria-label" , "CLI Command" ) ;
672+ expect ( editors [ 1 ] ) . toHaveAttribute ( "data-aria-label" , "Terraform" ) ;
650673 expect ( editors [ 2 ] ) . toHaveAttribute ( "data-aria-label" , "CloudFormation" ) ;
651674 } ) ;
652675} ) ;
0 commit comments