@@ -58,3 +58,40 @@ test("button in a disabled link exposes its disabled state", async () => {
5858 . element ( page . getByTestId ( "button" ) )
5959 . toHaveAttribute ( "data-disabled" , "true" ) ;
6060} ) ;
61+
62+ test ( "selecting the whole external link does not select any part of the icon" , async ( ) => {
63+ const { container } = await render ( < Link target = "_blank" > mittwald.de</ Link > ) ;
64+ const link = container . querySelector ( '[role="link"]' ) as HTMLElement ;
65+
66+ const range = document . createRange ( ) ;
67+ range . selectNodeContents ( link ) ;
68+ const selection = window . getSelection ( ) ;
69+ selection ?. removeAllRanges ( ) ;
70+ selection ?. addRange ( range ) ;
71+
72+ expect ( selection ?. toString ( ) ) . toBe ( "mittwald.de" ) ;
73+ } ) ;
74+
75+ test ( "selecting the whole download link does not select any part of the icon" , async ( ) => {
76+ const { container } = await render ( < Link download > Download the plans</ Link > ) ;
77+ const link = container . querySelector ( '[role="link"]' ) as HTMLElement ;
78+
79+ const range = document . createRange ( ) ;
80+ range . selectNodeContents ( link ) ;
81+ const selection = window . getSelection ( ) ;
82+ selection ?. removeAllRanges ( ) ;
83+ selection ?. addRange ( range ) ;
84+
85+ expect ( selection ?. toString ( ) ) . toBe ( "Download the plans" ) ;
86+ } ) ;
87+
88+ test ( "the link icon is excluded from text selection" , async ( ) => {
89+ const { container } = await render ( < Link target = "_blank" > mittwald.de</ Link > ) ;
90+ const icon = container . querySelector ( "svg" ) as SVGElement ;
91+ const style = getComputedStyle ( icon ) ;
92+
93+ expect (
94+ style . getPropertyValue ( "user-select" ) ||
95+ style . getPropertyValue ( "-webkit-user-select" ) ,
96+ ) . toBe ( "none" ) ;
97+ } ) ;
0 commit comments