@@ -202,7 +202,6 @@ function resetParentTenantForm() {
202202 ) ;
203203}
204204
205- // TODO: Aside from test that validates deletion, replace with a more reliable cleanup mechanism when ready
206205function deleteAccordionItems ( accordionsToDelete ) {
207206 cy . get ( `#${ ACCESS_CONTROL_ACCORDION_ITEM_ID } li.list-group-item` ) . each (
208207 ( item ) => {
@@ -261,28 +260,6 @@ function editQuotasTable(quotaName = ALLOCATED_STORAGE_QUOTA, quotaValue) {
261260 } ) ;
262261}
263262
264- function rollbackQuotas ( ) {
265- cy . toolbar ( CONFIG_TOOLBAR_BUTTON , MANAGE_QUOTAS_CONFIG_OPTION ) ;
266- let quotaDisabled = false ;
267- cy . get ( '#rbac_details .miq-data-table table tbody tr' ) . each ( ( row ) => {
268- const quotaValueInputWrapper = row . find ( 'div.bx--text-input-wrapper' ) ;
269- const isEnabled = ! quotaValueInputWrapper . hasClass (
270- 'bx--text-input-wrapper--readonly'
271- ) ;
272- if ( isEnabled ) {
273- quotaDisabled = true ;
274- cy . wrap ( row ) . find ( 'span.bx--toggle__switch' ) . click ( ) ;
275- }
276- } ) ;
277- // Save the form only if any quotas are reverted to disabled.
278- cy . then ( ( ) => {
279- if ( quotaDisabled ) {
280- // Saving the form
281- saveFormWithOptionalFlashCheck ( { assertFlashMessage : false } ) ;
282- }
283- } ) ;
284- }
285-
286263describe ( 'Automate Tenant form operations: Settings > Application Settings > Access Control > Tenants' , ( ) => {
287264 beforeEach ( ( ) => {
288265 cy . login ( ) ;
@@ -301,6 +278,10 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
301278 cy . toolbar ( CONFIG_TOOLBAR_BUTTON , EDIT_TENANT_CONFIG_OPTION ) ;
302279 } ) ;
303280
281+ afterEach ( ( ) => {
282+ confirmUiNavigation ( ( ) => resetParentTenantForm ( ) ) ;
283+ } ) ;
284+
304285 it ( 'Validate Edit tenant form elements' , ( ) => {
305286 validateFormElements ( ) ;
306287 } ) ;
@@ -325,27 +306,27 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
325306 ) ;
326307 saveFormWithOptionalFlashCheck ( { apiMethod : 'PUT' } ) ;
327308 } ) ;
309+ } ) ;
328310
311+ describe ( 'Validate Add Project to parent tenant' , ( ) => {
329312 afterEach ( ( ) => {
330- confirmUiNavigation ( ( ) => resetParentTenantForm ( ) ) ;
313+ cy . appDbState ( 'restore' ) ;
331314 } ) ;
332- } ) ;
333315
334- describe ( 'Validate Add Project to parent tenant' , ( ) => {
335316 it ( 'Validate Add Project function' , ( ) => {
336317 addProjectToTenant ( ) ;
337318 } ) ;
338-
339- afterEach ( ( ) => {
340- confirmUiNavigation ( ( ) => deleteAccordionItems ( [ PROJECT_NAME_VALUE ] ) ) ;
341- } ) ;
342319 } ) ;
343320
344321 describe ( 'Validate Manage Quotas in parent tenant' , ( ) => {
345322 beforeEach ( ( ) => {
346323 cy . toolbar ( CONFIG_TOOLBAR_BUTTON , MANAGE_QUOTAS_CONFIG_OPTION ) ;
347324 } ) ;
348325
326+ afterEach ( ( ) => {
327+ cy . appDbState ( 'restore' ) ;
328+ } ) ;
329+
349330 it ( 'Validate Reset & Cancel buttons in Manage Quotas form' , ( ) => {
350331 cy . getFormFooterButtonByTypeWithText ( {
351332 buttonText : RESET_BUTTON_TEXT ,
@@ -360,10 +341,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
360341 editQuotasTable ( ALLOCATED_STORAGE_QUOTA , '10' ) ;
361342 saveFormWithOptionalFlashCheck ( ) ;
362343 } ) ;
363-
364- afterEach ( ( ) => {
365- confirmUiNavigation ( ( ) => rollbackQuotas ( ) ) ;
366- } ) ;
367344 } ) ;
368345 } ) ;
369346
@@ -373,6 +350,10 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
373350 cy . toolbar ( CONFIG_TOOLBAR_BUTTON , ADD_CHILD_TENANT_CONFIG_OPTION ) ;
374351 } ) ;
375352
353+ afterEach ( ( ) => {
354+ cy . appDbState ( 'restore' ) ;
355+ } ) ;
356+
376357 it ( 'Validate Add child tenant form elements' , ( ) => {
377358 validateFormElements ( false ) ;
378359 } ) ;
@@ -415,12 +396,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
415396 ) ;
416397 cancelFormWithOptionalFlashCheck ( false ) ;
417398 } ) ;
418-
419- afterEach ( ( ) => {
420- confirmUiNavigation ( ( ) =>
421- deleteAccordionItems ( [ INITIAL_CHILD_TENANT_NAME ] )
422- ) ;
423- } ) ;
424399 } ) ;
425400
426401 describe ( 'Validate Edit child tenant' , ( ) => {
@@ -429,6 +404,10 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
429404 cy . toolbar ( CONFIG_TOOLBAR_BUTTON , EDIT_TENANT_CONFIG_OPTION ) ;
430405 } ) ;
431406
407+ afterEach ( ( ) => {
408+ cy . appDbState ( 'restore' ) ;
409+ } ) ;
410+
432411 it ( 'Validate Edit child tenant form elements' , ( ) => {
433412 validateFormElements ( ) ;
434413 cancelFormWithOptionalFlashCheck ( ) ;
@@ -454,20 +433,17 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
454433 ) ;
455434 saveFormWithOptionalFlashCheck ( { apiMethod : 'PUT' } ) ;
456435 } ) ;
457-
458- afterEach ( ( ) => {
459- deleteAccordionItems ( [
460- INITIAL_CHILD_TENANT_NAME ,
461- EDITED_TENANT_NAME_VALUE ,
462- ] ) ;
463- } ) ;
464436 } ) ;
465437
466438 describe ( 'Validate Add Project to child tenant' , ( ) => {
467439 beforeEach ( ( ) => {
468440 createAndSelectChildTenant ( ) ;
469441 } ) ;
470442
443+ afterEach ( ( ) => {
444+ cy . appDbState ( 'restore' ) ;
445+ } ) ;
446+
471447 it ( 'Validate Add Project function' , ( ) => {
472448 addProjectToTenant ( ) ;
473449 } ) ;
@@ -477,13 +453,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
477453 deleteAccordionItems ( [ INITIAL_CHILD_TENANT_NAME ] ) ;
478454 cy . expect_flash ( flashClassMap . error , FLASH_MESSAGE_CANT_DELETE ) ;
479455 } ) ;
480-
481- afterEach ( ( ) => {
482- confirmUiNavigation ( ( ) => {
483- deleteAccordionItems ( [ PROJECT_NAME_VALUE ] ) ;
484- deleteAccordionItems ( [ INITIAL_CHILD_TENANT_NAME ] ) ;
485- } ) ;
486- } ) ;
487456 } ) ;
488457
489458 describe ( 'Validate Manage Quotas in child tenant' , ( ) => {
@@ -492,6 +461,10 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
492461 cy . toolbar ( CONFIG_TOOLBAR_BUTTON , MANAGE_QUOTAS_CONFIG_OPTION ) ;
493462 } ) ;
494463
464+ afterEach ( ( ) => {
465+ cy . appDbState ( 'restore' ) ;
466+ } ) ;
467+
495468 it ( 'Validate Reset & Cancel buttons in Manage Quotas form' , ( ) => {
496469 cy . getFormFooterButtonByTypeWithText ( {
497470 buttonText : RESET_BUTTON_TEXT ,
@@ -506,12 +479,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
506479 editQuotasTable ( ALLOCATED_VM_QUOTA , '10' ) ;
507480 saveFormWithOptionalFlashCheck ( ) ;
508481 } ) ;
509-
510- afterEach ( ( ) => {
511- confirmUiNavigation ( ( ) => {
512- deleteAccordionItems ( [ INITIAL_CHILD_TENANT_NAME ] ) ;
513- } ) ;
514- } ) ;
515482 } ) ;
516483 } ) ;
517484} ) ;
0 commit comments