@@ -13,6 +13,7 @@ import {
1313 mockGetDatabaseEngineConfigs ,
1414 mockGetDatabaseTypes ,
1515 mockUpdateDatabase ,
16+ mockUpdateDatabaseError ,
1617} from 'support/intercepts/databases' ;
1718import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags' ;
1819import { ui } from 'support/ui' ;
@@ -190,11 +191,11 @@ const addConfigsToUI = (
190191 cy . get ( `[name="${ flatKey } "]` ) . should ( 'be.visible' ) . clear ( ) ;
191192 cy . get ( `[name="${ flatKey } "]` ) . type ( additionalConfigs [ flatKey ] ) ;
192193 } else {
193- // Fallback: Material-UI Autocomplete (like synchronous_replication)
194+ // Fallback
195+ ui . autocomplete . find ( ) . first ( ) . scrollIntoView ( ) ;
194196 ui . autocomplete
195197 . find ( )
196198 . first ( )
197- . scrollIntoView ( )
198199 . should ( 'be.visible' )
199200 . clear ( )
200201 . type ( `${ additionalConfigs [ flatKey ] } ` ) ;
@@ -272,6 +273,7 @@ describe('Update database clusters', () => {
272273 } ) ;
273274
274275 // Confirms all the buttons are in the initial state - enabled/disabled
276+ ui . cdsButton . findButtonByTitle ( 'Configure' ) . scrollIntoView ( ) ;
275277 ui . cdsButton
276278 . findButtonByTitle ( 'Configure' )
277279 . should ( 'be.visible' )
@@ -283,26 +285,23 @@ describe('Update database clusters', () => {
283285 . findButtonByTitle ( 'Add' )
284286 . should ( 'exist' )
285287 . should ( 'be.disabled' ) ;
286- ui . button
287- . findByTitle ( 'Save' )
288- . scrollIntoView ( )
289- . should ( 'be.visible' )
290- . should ( 'be.disabled' ) ;
288+ ui . button . findByTitle ( 'Save' ) . should ( 'exist' ) . should ( 'be.disabled' ) ;
291289
292290 ui . button
293291 . findByTitle ( 'Cancel' )
294- . scrollIntoView ( )
295- . should ( 'be.visible' )
292+ . should ( 'exist' )
296293 . should ( 'be.enabled' )
297294 . click ( ) ;
298295
296+ ui . cdsButton . findButtonByTitle ( 'Configure' ) . scrollIntoView ( ) ;
299297 ui . cdsButton
300298 . findButtonByTitle ( 'Configure' )
301299 . should ( 'be.visible' )
302300 . should ( 'be.enabled' )
303301 . click ( ) ;
304302
305303 ui . drawer . findByTitle ( 'Advanced Configuration' ) . should ( 'be.visible' ) ;
304+ cy . get ( '[aria-label="Close drawer"]' ) . scrollIntoView ( ) ;
306305 cy . get ( '[aria-label="Close drawer"]' )
307306 . should ( 'be.visible' )
308307 . should ( 'be.enabled' )
@@ -353,6 +352,7 @@ describe('Update database clusters', () => {
353352 cy . wait ( [ '@getDatabase' , '@getDatabaseTypes' ] ) ;
354353
355354 // Expand configure drawer to add configs
355+ ui . cdsButton . findButtonByTitle ( 'Configure' ) . scrollIntoView ( ) ;
356356 ui . cdsButton
357357 . findButtonByTitle ( 'Configure' )
358358 . should ( 'be.visible' )
@@ -370,31 +370,50 @@ describe('Update database clusters', () => {
370370 true
371371 ) ;
372372
373+ const isSyncReplicationQuorum =
374+ singleConfig [ 'synchronous_replication' ] === 'quorum' ;
375+ const isInvaliClusterSize =
376+ database . cluster_size < 3 && isSyncReplicationQuorum ;
377+
373378 // Update advanced configurations with the newly added config
374- mockUpdateDatabase ( database . id , database . engine , {
375- ...database ,
376- engine_config : {
377- ...( database . engine_config as ConfigCategoryValues ) ,
378- [ engineType ] : {
379- ...( existingConfig as ConfigCategoryValues ) ,
380- ...singleConfig ,
379+ if ( isInvaliClusterSize ) {
380+ mockUpdateDatabaseError (
381+ database . id ,
382+ database . engine ,
383+ 'engine_config.synchronous_replication' ,
384+ 'synchronous_replication is only supported for clusters with 3 nodes'
385+ ) . as ( 'updateAdvancedConfiguration' ) ;
386+ } else {
387+ mockUpdateDatabase ( database . id , database . engine , {
388+ ...database ,
389+ engine_config : {
390+ ...( database . engine_config as ConfigCategoryValues ) ,
391+ [ engineType ] : {
392+ ...( existingConfig as ConfigCategoryValues ) ,
393+ ...singleConfig ,
394+ } ,
381395 } ,
382- } ,
383- } ) . as ( 'updateAdvancedConfiguration' ) ;
384-
396+ } ) . as ( 'updateAdvancedConfiguration' ) ;
397+ }
385398 // Save or Save and Restart Services as per the config added
386399 ui . button
387400 . findByTitle ( saveRestartButton )
388- . scrollIntoView ( )
389- . should ( 'be.visible' )
401+ . should ( 'exist' )
390402 . should ( 'be.enabled' )
391403 . click ( ) ;
392404 cy . wait ( '@updateAdvancedConfiguration' ) ;
393405
394- // Confirms newly added advacned Config on the Configuration tab tableview
395- cy . findByText ( `${ engineType } .${ Object . keys ( singleConfig ) [ 0 ] } ` ) . should (
396- 'be.visible'
397- ) ;
406+ if ( isInvaliClusterSize ) {
407+ // Verify error message is displayed for invalid synchronous replication
408+ cy . findByText (
409+ / s y n c h r o n o u s _ r e p l i c a t i o n i s o n l y s u p p o r t e d f o r c l u s t e r s w i t h 3 n o d e s / i
410+ ) . should ( 'be.visible' ) ;
411+ } else {
412+ // Confirms newly added advanced Config on the Configuration tab tableview
413+ cy . findByText (
414+ `${ engineType } .${ Object . keys ( singleConfig ) [ 0 ] } `
415+ ) . should ( 'be.visible' ) ;
416+ }
398417 } ) ;
399418
400419 /*
@@ -441,6 +460,7 @@ describe('Update database clusters', () => {
441460 cy . wait ( [ '@getDatabase' , '@getDatabaseTypes' ] ) ;
442461
443462 // Expand configure drawer to add configs
463+ ui . cdsButton . findButtonByTitle ( 'Configure' ) . scrollIntoView ( ) ;
444464 ui . cdsButton
445465 . findButtonByTitle ( 'Configure' )
446466 . should ( 'be.visible' )
@@ -466,35 +486,55 @@ describe('Update database clusters', () => {
466486 }
467487 } ) ;
468488
489+ const isSyncReplicationQuorum =
490+ allConfig [ 'synchronous_replication' ] === 'quorum' ;
491+ const isInvalidClusterSize =
492+ database . cluster_size < 3 && isSyncReplicationQuorum ;
493+
469494 // Update advanced configurations with the newly added config
470- mockUpdateDatabase ( database . id , database . engine , {
471- ...database ,
472- engine_config : {
473- ...( database . engine_config as ConfigCategoryValues ) ,
474- [ engineType ] : {
475- ...( existingConfig as ConfigCategoryValues ) ,
476- ...nestedConfig ,
495+ if ( isInvalidClusterSize ) {
496+ mockUpdateDatabaseError (
497+ database . id ,
498+ database . engine ,
499+ 'engine_config.synchronous_replication' ,
500+ 'synchronous_replication is only supported for clusters with 3 nodes'
501+ ) . as ( 'updateAdvancedConfiguration' ) ;
502+ } else {
503+ mockUpdateDatabase ( database . id , database . engine , {
504+ ...database ,
505+ engine_config : {
506+ ...( database . engine_config as ConfigCategoryValues ) ,
507+ [ engineType ] : {
508+ ...( existingConfig as ConfigCategoryValues ) ,
509+ ...nestedConfig ,
510+ } ,
511+ ...topLevelConfig ,
477512 } ,
478- ...topLevelConfig ,
479- } ,
480- } ) . as ( 'updateAdvancedConfiguration' ) ;
513+ } ) . as ( 'updateAdvancedConfiguration' ) ;
514+ }
481515
482516 // Save or Save and Restart Services as per the config added
483517 ui . button
484518 . findByTitle ( saveRestartButton )
485- . scrollIntoView ( )
486- . should ( 'be.visible' )
519+ . should ( 'exist' )
487520 . should ( 'be.enabled' )
488521 . click ( ) ;
489522 cy . wait ( '@updateAdvancedConfiguration' ) ;
490523
491- // Confirms newly added advacned Config on the Configuration tab tableview
492- Object . keys ( nestedConfig ) . forEach ( ( key ) => {
493- cy . findByText ( `${ engineType } .${ key } ` ) . should ( 'be.visible' ) ;
494- } ) ;
495- Object . keys ( topLevelConfig ) . forEach ( ( key ) => {
496- cy . findByText ( `${ key } ` ) . should ( 'be.visible' ) ;
497- } ) ;
524+ if ( isInvalidClusterSize ) {
525+ // Verify error message is displayed for invalid synchronous replication
526+ cy . findByText (
527+ / s y n c h r o n o u s _ r e p l i c a t i o n i s o n l y s u p p o r t e d f o r c l u s t e r s w i t h 3 n o d e s / i
528+ ) . should ( 'be.visible' ) ;
529+ } else {
530+ // Confirms newly added advanced Config on the Configuration tab tableview
531+ Object . keys ( nestedConfig ) . forEach ( ( key ) => {
532+ cy . findByText ( `${ engineType } .${ key } ` ) . should ( 'be.visible' ) ;
533+ } ) ;
534+ Object . keys ( topLevelConfig ) . forEach ( ( key ) => {
535+ cy . findByText ( `${ key } ` ) . should ( 'be.visible' ) ;
536+ } ) ;
537+ }
498538 } ) ;
499539
500540 /*
@@ -538,6 +578,7 @@ describe('Update database clusters', () => {
538578 cy . wait ( [ '@getDatabase' , '@getDatabaseTypes' ] ) ;
539579
540580 // Expand configure drawer to add configs
581+ ui . cdsButton . findButtonByTitle ( 'Configure' ) . scrollIntoView ( ) ;
541582 ui . cdsButton
542583 . findButtonByTitle ( 'Configure' )
543584 . should ( 'be.visible' )
0 commit comments