@@ -85,89 +85,3 @@ describe('textarea: label rendering', () => {
8585 expect ( labelText . textContent ) . toBe ( 'Label Prop Text' ) ;
8686 } ) ;
8787} ) ;
88-
89- // Accessibility tests for error text announcements to screen readers
90- describe ( 'textarea: error text accessibility' , ( ) => {
91- it ( 'should have error text element with proper structure' , async ( ) => {
92- const page = await newSpecPage ( {
93- components : [ Textarea ] ,
94- html : `<ion-textarea label="Textarea" error-text="This field is required"></ion-textarea>` ,
95- } ) ;
96-
97- const errorTextEl = page . body . querySelector ( 'ion-textarea .error-text' ) ;
98- expect ( errorTextEl ) . not . toBe ( null ) ;
99- expect ( errorTextEl ! . getAttribute ( 'id' ) ) . toContain ( 'error-text' ) ;
100- expect ( errorTextEl ! . textContent ) . toBe ( 'This field is required' ) ;
101- } ) ;
102-
103- it ( 'should set aria-invalid when textarea is invalid' , async ( ) => {
104- const page = await newSpecPage ( {
105- components : [ Textarea ] ,
106- html : `<ion-textarea label="Textarea" error-text="Required field" class="ion-touched ion-invalid"></ion-textarea>` ,
107- } ) ;
108-
109- const nativeTextarea = page . body . querySelector ( 'ion-textarea textarea' ) ! ;
110-
111- // Should be invalid because of the classes
112- expect ( nativeTextarea . getAttribute ( 'aria-invalid' ) ) . toBe ( 'true' ) ;
113- } ) ;
114-
115- it ( 'should set aria-describedby to error text when invalid' , async ( ) => {
116- const page = await newSpecPage ( {
117- components : [ Textarea ] ,
118- html : `<ion-textarea label="Textarea" error-text="Required field" class="ion-touched ion-invalid"></ion-textarea>` ,
119- } ) ;
120-
121- const nativeTextarea = page . body . querySelector ( 'ion-textarea textarea' ) ! ;
122- const errorTextEl = page . body . querySelector ( 'ion-textarea .error-text' ) ! ;
123-
124- // Verify aria-describedby points to error text
125- const errorId = errorTextEl . getAttribute ( 'id' ) ;
126- expect ( nativeTextarea . getAttribute ( 'aria-describedby' ) ) . toBe ( errorId ) ;
127- } ) ;
128-
129- it ( 'should set aria-describedby to helper text when valid' , async ( ) => {
130- const page = await newSpecPage ( {
131- components : [ Textarea ] ,
132- html : `<ion-textarea label="Textarea" helper-text="Enter comments" error-text="Required field"></ion-textarea>` ,
133- } ) ;
134-
135- const nativeTextarea = page . body . querySelector ( 'ion-textarea textarea' ) ! ;
136- const helperTextEl = page . body . querySelector ( 'ion-textarea .helper-text' ) ! ;
137-
138- // When not invalid, should point to helper text
139- const helperId = helperTextEl . getAttribute ( 'id' ) ;
140- expect ( nativeTextarea . getAttribute ( 'aria-describedby' ) ) . toBe ( helperId ) ;
141- expect ( nativeTextarea . getAttribute ( 'aria-invalid' ) ) . toBeNull ( ) ;
142- } ) ;
143-
144- it ( 'should have helper text element with proper structure' , async ( ) => {
145- const page = await newSpecPage ( {
146- components : [ Textarea ] ,
147- html : `<ion-textarea label="Textarea" helper-text="Enter your comments"></ion-textarea>` ,
148- } ) ;
149-
150- const helperTextEl = page . body . querySelector ( 'ion-textarea .helper-text' ) ;
151- expect ( helperTextEl ) . not . toBe ( null ) ;
152- expect ( helperTextEl ! . getAttribute ( 'id' ) ) . toContain ( 'helper-text' ) ;
153- expect ( helperTextEl ! . textContent ) . toBe ( 'Enter your comments' ) ;
154- } ) ;
155-
156- it ( 'should maintain error text content when error text changes dynamically' , async ( ) => {
157- const page = await newSpecPage ( {
158- components : [ Textarea ] ,
159- html : `<ion-textarea label="Textarea"></ion-textarea>` ,
160- } ) ;
161-
162- const textarea = page . body . querySelector ( 'ion-textarea' ) ! ;
163-
164- // Add error text dynamically
165- textarea . setAttribute ( 'error-text' , 'Invalid content' ) ;
166- await page . waitForChanges ( ) ;
167-
168- const errorTextEl = page . body . querySelector ( 'ion-textarea .error-text' ) ;
169- expect ( errorTextEl ) . not . toBe ( null ) ;
170- expect ( errorTextEl ! . getAttribute ( 'id' ) ) . toContain ( 'error-text' ) ;
171- expect ( errorTextEl ! . textContent ) . toBe ( 'Invalid content' ) ;
172- } ) ;
173- } ) ;
0 commit comments