Skip to content

Commit d1d2635

Browse files
committed
test(textarea): remove duplicate checks
1 parent 7a2a990 commit d1d2635

1 file changed

Lines changed: 9 additions & 31 deletions

File tree

core/src/components/textarea/test/form/textarea.e2e.ts

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,16 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
166166
}
167167
});
168168

169-
// Click submit button - form should submit since validation passes
169+
// Click submit button and wait for any async operations to complete
170170
await submitButton.click();
171-
172-
// Wait for any async operations to complete
173171
await page.waitForChanges();
174172

175-
// Verify that the form's validation passed
176-
const formValidity = await page.evaluate(() => {
177-
const form = document.querySelector('form');
178-
return form ? form.checkValidity() : null;
173+
// Verify that the textarea's value is set
174+
const textareaValue = await textarea.evaluate((el: HTMLIonTextareaElement) => {
175+
const nativeTextarea = el.shadowRoot?.querySelector('textarea') as HTMLTextAreaElement | null;
176+
return nativeTextarea?.value ?? '';
179177
});
180-
expect(formValidity).toBe(true);
178+
expect(textareaValue).toBe('Test value');
181179

182180
// Verify that the formData is set
183181
const formData = await page.evaluate(() => {
@@ -228,32 +226,12 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
228226
}
229227
});
230228

231-
// Click submit button - form should submit since validation passes
229+
// Click submit button and wait for any async operations to complete
232230
await submitButton.click();
233-
234-
// Wait for any async operations to complete
235231
await page.waitForChanges();
236232

237-
// Verify that the formData is set
238-
let formData = await page.evaluate(() => {
239-
const form = document.querySelector('form');
240-
if (!form) {
241-
return null;
242-
}
243-
const formData = new FormData(form);
244-
const entries: Record<string, string> = {};
245-
for (const [key, value] of formData.entries()) {
246-
entries[key] = value.toString();
247-
}
248-
return entries;
249-
});
250-
expect(formData).toBeDefined();
251-
expect(formData?.['textarea']).toBe('Test value');
252-
253-
// Click reset button - form should reset
233+
// Click reset button and wait for any async operations to complete
254234
await resetButton.click();
255-
256-
// Wait for any async operations to complete
257235
await page.waitForChanges();
258236

259237
// Verify that the textarea's value is cleared
@@ -264,7 +242,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
264242
expect(textareaValue).toBe('');
265243

266244
// Verify that the formData is cleared
267-
formData = await page.evaluate(() => {
245+
const formData = await page.evaluate(() => {
268246
const form = document.querySelector('form');
269247
if (!form) {
270248
return null;

0 commit comments

Comments
 (0)