@@ -20,6 +20,13 @@ const MOCK_APP_CONFIG: AppConfig = {
20
20
value : "My App" ,
21
21
default : "Default App"
22
22
} ,
23
+ {
24
+ name : "description" ,
25
+ title : "Application Description" ,
26
+ type : "textarea" ,
27
+ value : "This is my application\nIt does amazing things" ,
28
+ default : "Enter description here..."
29
+ } ,
23
30
{
24
31
name : "enable_feature" ,
25
32
title : "Enable Feature" ,
@@ -57,6 +64,13 @@ const MOCK_APP_CONFIG: AppConfig = {
57
64
type : "text" ,
58
65
value : "localhost" ,
59
66
default : "localhost"
67
+ } ,
68
+ {
69
+ name : "db_config" ,
70
+ title : "Database Configuration" ,
71
+ type : "textarea" ,
72
+ value : "" ,
73
+ default : "# Database configuration\nhost: localhost\nport: 5432"
60
74
}
61
75
]
62
76
}
@@ -143,11 +157,13 @@ describe.each([
143
157
144
158
// Check that form fields are rendered for the active tab
145
159
expect ( screen . getByTestId ( "config-item-app_name" ) ) . toBeInTheDocument ( ) ;
160
+ expect ( screen . getByTestId ( "config-item-description" ) ) . toBeInTheDocument ( ) ;
146
161
expect ( screen . getByTestId ( "config-item-enable_feature" ) ) . toBeInTheDocument ( ) ;
147
162
expect ( screen . getByTestId ( "config-item-auth_type" ) ) . toBeInTheDocument ( ) ;
148
163
149
164
// Check that the database tab is not rendered
150
165
expect ( screen . queryByTestId ( "config-item-db_host" ) ) . not . toBeInTheDocument ( ) ;
166
+ expect ( screen . queryByTestId ( "config-item-db_config" ) ) . not . toBeInTheDocument ( ) ;
151
167
152
168
// Check next button
153
169
const nextButton = screen . getByTestId ( "config-next-button" ) ;
@@ -224,20 +240,24 @@ describe.each([
224
240
225
241
// Initially, Settings tab should be active
226
242
expect ( screen . getByTestId ( "config-item-app_name" ) ) . toBeInTheDocument ( ) ;
243
+ expect ( screen . getByTestId ( "config-item-description" ) ) . toBeInTheDocument ( ) ;
227
244
expect ( screen . getByTestId ( "config-item-enable_feature" ) ) . toBeInTheDocument ( ) ;
228
245
expect ( screen . getByTestId ( "config-item-auth_type" ) ) . toBeInTheDocument ( ) ;
229
246
230
247
// Check that the database tab is not rendered
231
248
expect ( screen . queryByTestId ( "config-item-db_host" ) ) . not . toBeInTheDocument ( ) ;
249
+ expect ( screen . queryByTestId ( "config-item-db_config" ) ) . not . toBeInTheDocument ( ) ;
232
250
233
251
// Click on Database tab
234
252
fireEvent . click ( screen . getByTestId ( "config-tab-database" ) ) ;
235
253
236
254
// Database tab content should be visible
237
255
expect ( screen . getByTestId ( "config-item-db_host" ) ) . toBeInTheDocument ( ) ;
256
+ expect ( screen . getByTestId ( "config-item-db_config" ) ) . toBeInTheDocument ( ) ;
238
257
239
258
// Settings tab content should not be visible
240
259
expect ( screen . queryByTestId ( "config-item-app_name" ) ) . not . toBeInTheDocument ( ) ;
260
+ expect ( screen . queryByTestId ( "config-item-description" ) ) . not . toBeInTheDocument ( ) ;
241
261
expect ( screen . queryByTestId ( "config-item-enable_feature" ) ) . not . toBeInTheDocument ( ) ;
242
262
expect ( screen . queryByTestId ( "config-item-auth_type" ) ) . not . toBeInTheDocument ( ) ;
243
263
} ) ;
@@ -263,6 +283,52 @@ describe.each([
263
283
expect ( appNameInput ) . toHaveValue ( "New App Name" ) ;
264
284
} ) ;
265
285
286
+ it ( "handles textarea input changes correctly" , async ( ) => {
287
+ renderWithProviders ( < ConfigurationStep onNext = { mockOnNext } /> , {
288
+ wrapperProps : {
289
+ authenticated : true ,
290
+ target : target ,
291
+ } ,
292
+ } ) ;
293
+
294
+ // Wait for loading to complete
295
+ await waitFor ( ( ) => {
296
+ expect ( screen . queryByTestId ( "configuration-step-loading" ) ) . not . toBeInTheDocument ( ) ;
297
+ } ) ;
298
+
299
+ // Find and update textarea input
300
+ const descriptionTextarea = screen . getByTestId ( "textarea-input-description" ) ;
301
+ fireEvent . change ( descriptionTextarea , { target : { value : "New multi-line\ndescription text" } } ) ;
302
+
303
+ // Verify the value was updated
304
+ expect ( descriptionTextarea ) . toHaveValue ( "New multi-line\ndescription text" ) ;
305
+ } ) ;
306
+
307
+ it ( "renders textarea with correct initial values" , async ( ) => {
308
+ renderWithProviders ( < ConfigurationStep onNext = { mockOnNext } /> , {
309
+ wrapperProps : {
310
+ authenticated : true ,
311
+ target : target ,
312
+ } ,
313
+ } ) ;
314
+
315
+ // Wait for loading to complete
316
+ await waitFor ( ( ) => {
317
+ expect ( screen . queryByTestId ( "configuration-step-loading" ) ) . not . toBeInTheDocument ( ) ;
318
+ } ) ;
319
+
320
+ // Check textarea with value
321
+ const descriptionTextarea = screen . getByTestId ( "textarea-input-description" ) ;
322
+ expect ( descriptionTextarea ) . toHaveValue ( "This is my application\nIt does amazing things" ) ;
323
+
324
+ // Switch to database tab
325
+ fireEvent . click ( screen . getByTestId ( "config-tab-database" ) ) ;
326
+
327
+ // Check textarea with empty value
328
+ const dbConfigTextarea = screen . getByTestId ( "textarea-input-db_config" ) ;
329
+ expect ( dbConfigTextarea ) . toHaveValue ( "" ) ;
330
+ } ) ;
331
+
266
332
it ( "handles checkbox changes correctly" , async ( ) => {
267
333
renderWithProviders ( < ConfigurationStep onNext = { mockOnNext } /> , {
268
334
wrapperProps : {
@@ -350,6 +416,9 @@ describe.each([
350
416
const appNameInput = screen . getByTestId ( "text-input-app_name" ) ;
351
417
fireEvent . change ( appNameInput , { target : { value : "Updated App Name" } } ) ;
352
418
419
+ const descriptionTextarea = screen . getByTestId ( "textarea-input-description" ) ;
420
+ fireEvent . change ( descriptionTextarea , { target : { value : "Updated multi-line\ndescription text" } } ) ;
421
+
353
422
const enableFeatureCheckbox = screen . getByTestId ( "bool-input-enable_feature" ) ;
354
423
fireEvent . click ( enableFeatureCheckbox ) ;
355
424
@@ -364,6 +433,10 @@ describe.each([
364
433
const dbHostInput = screen . getByTestId ( "text-input-db_host" ) ;
365
434
fireEvent . change ( dbHostInput , { target : { value : "Updated DB Host" } } ) ;
366
435
436
+ // Change textarea input
437
+ const dbConfigTextarea = screen . getByTestId ( "textarea-input-db_config" ) ;
438
+ fireEvent . change ( dbConfigTextarea , { target : { value : "# Updated config\nhost: updated-host\nport: 5432" } } ) ;
439
+
367
440
// Submit form
368
441
const nextButton = screen . getByTestId ( "config-next-button" ) ;
369
442
fireEvent . click ( nextButton ) ;
@@ -381,9 +454,11 @@ describe.each([
381
454
expect ( submittedValues ! ) . toMatchObject ( {
382
455
values : {
383
456
app_name : "Updated App Name" ,
457
+ description : "Updated multi-line\ndescription text" ,
384
458
enable_feature : "1" ,
385
459
auth_type : "auth_type_anonymous" ,
386
- db_host : "Updated DB Host"
460
+ db_host : "Updated DB Host" ,
461
+ db_config : "# Updated config\nhost: updated-host\nport: 5432"
387
462
}
388
463
} ) ;
389
464
} ) ;
@@ -438,6 +513,10 @@ describe.each([
438
513
const appNameInput = screen . getByTestId ( "text-input-app_name" ) ;
439
514
fireEvent . change ( appNameInput , { target : { value : "Only Changed Field" } } ) ;
440
515
516
+ // Change the description textarea
517
+ const descriptionTextarea = screen . getByTestId ( "textarea-input-description" ) ;
518
+ fireEvent . change ( descriptionTextarea , { target : { value : "Only changed description" } } ) ;
519
+
441
520
// Change the auth type
442
521
const anonymousRadio = screen . getByTestId ( "radio-input-auth_type_anonymous" ) ;
443
522
fireEvent . click ( anonymousRadio ) ;
@@ -459,11 +538,13 @@ describe.each([
459
538
expect ( submittedValues ! ) . toMatchObject ( {
460
539
values : {
461
540
app_name : "Only Changed Field" ,
541
+ description : "Only changed description" ,
462
542
auth_type : "auth_type_anonymous"
463
543
}
464
544
} ) ;
465
545
expect ( submittedValues ! . values ) . not . toHaveProperty ( "enable_feature" ) ;
466
- expect ( submittedValues ! . values ) . not . toHaveProperty ( "database_type" ) ;
546
+ expect ( submittedValues ! . values ) . not . toHaveProperty ( "db_host" ) ;
547
+ expect ( submittedValues ! . values ) . not . toHaveProperty ( "db_config" ) ;
467
548
} ) ;
468
549
469
550
describe ( "Radio button behavior" , ( ) => {
0 commit comments