Skip to content

Commit fbd8102

Browse files
authored
Merge pull request #9684 from jrafanie/revert-9660-9658-and-part-of-9633
Rollback the tenant test changes due to timing issue failures
2 parents 57c322d + 9c20c47 commit fbd8102

File tree

1 file changed

+60
-27
lines changed

1 file changed

+60
-27
lines changed

cypress/e2e/ui/Settings/Application-Settings/tenant.cy.js

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ function resetParentTenantForm() {
202202
);
203203
}
204204

205+
// TODO: Aside from test that validates deletion, replace with a more reliable cleanup mechanism when ready
205206
function deleteAccordionItems(accordionsToDelete) {
206207
cy.get(`#${ACCESS_CONTROL_ACCORDION_ITEM_ID} li.list-group-item`).each(
207208
(item) => {
@@ -260,6 +261,28 @@ function editQuotasTable(quotaName = ALLOCATED_STORAGE_QUOTA, quotaValue) {
260261
});
261262
}
262263

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+
263286
describe('Automate Tenant form operations: Settings > Application Settings > Access Control > Tenants', () => {
264287
beforeEach(() => {
265288
cy.login();
@@ -278,10 +301,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
278301
cy.toolbar(CONFIG_TOOLBAR_BUTTON, EDIT_TENANT_CONFIG_OPTION);
279302
});
280303

281-
afterEach(() => {
282-
confirmUiNavigation(() => resetParentTenantForm());
283-
});
284-
285304
it('Validate Edit tenant form elements', () => {
286305
validateFormElements();
287306
});
@@ -306,27 +325,27 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
306325
);
307326
saveFormWithOptionalFlashCheck({ apiMethod: 'PUT' });
308327
});
309-
});
310328

311-
describe('Validate Add Project to parent tenant', () => {
312329
afterEach(() => {
313-
cy.appDbState('restore');
330+
confirmUiNavigation(() => resetParentTenantForm());
314331
});
332+
});
315333

334+
describe('Validate Add Project to parent tenant', () => {
316335
it('Validate Add Project function', () => {
317336
addProjectToTenant();
318337
});
338+
339+
afterEach(() => {
340+
confirmUiNavigation(() => deleteAccordionItems([PROJECT_NAME_VALUE]));
341+
});
319342
});
320343

321344
describe('Validate Manage Quotas in parent tenant', () => {
322345
beforeEach(() => {
323346
cy.toolbar(CONFIG_TOOLBAR_BUTTON, MANAGE_QUOTAS_CONFIG_OPTION);
324347
});
325348

326-
afterEach(() => {
327-
cy.appDbState('restore');
328-
});
329-
330349
it('Validate Reset & Cancel buttons in Manage Quotas form', () => {
331350
cy.getFormFooterButtonByTypeWithText({
332351
buttonText: RESET_BUTTON_TEXT,
@@ -341,6 +360,10 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
341360
editQuotasTable(ALLOCATED_STORAGE_QUOTA, '10');
342361
saveFormWithOptionalFlashCheck();
343362
});
363+
364+
afterEach(() => {
365+
confirmUiNavigation(() => rollbackQuotas());
366+
});
344367
});
345368
});
346369

@@ -350,10 +373,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
350373
cy.toolbar(CONFIG_TOOLBAR_BUTTON, ADD_CHILD_TENANT_CONFIG_OPTION);
351374
});
352375

353-
afterEach(() => {
354-
cy.appDbState('restore');
355-
});
356-
357376
it('Validate Add child tenant form elements', () => {
358377
validateFormElements(false);
359378
});
@@ -396,6 +415,12 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
396415
);
397416
cancelFormWithOptionalFlashCheck(false);
398417
});
418+
419+
afterEach(() => {
420+
confirmUiNavigation(() =>
421+
deleteAccordionItems([INITIAL_CHILD_TENANT_NAME])
422+
);
423+
});
399424
});
400425

401426
describe('Validate Edit child tenant', () => {
@@ -404,10 +429,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
404429
cy.toolbar(CONFIG_TOOLBAR_BUTTON, EDIT_TENANT_CONFIG_OPTION);
405430
});
406431

407-
afterEach(() => {
408-
cy.appDbState('restore');
409-
});
410-
411432
it('Validate Edit child tenant form elements', () => {
412433
validateFormElements();
413434
cancelFormWithOptionalFlashCheck();
@@ -433,17 +454,20 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
433454
);
434455
saveFormWithOptionalFlashCheck({ apiMethod: 'PUT' });
435456
});
457+
458+
afterEach(() => {
459+
deleteAccordionItems([
460+
INITIAL_CHILD_TENANT_NAME,
461+
EDITED_TENANT_NAME_VALUE,
462+
]);
463+
});
436464
});
437465

438466
describe('Validate Add Project to child tenant', () => {
439467
beforeEach(() => {
440468
createAndSelectChildTenant();
441469
});
442470

443-
afterEach(() => {
444-
cy.appDbState('restore');
445-
});
446-
447471
it('Validate Add Project function', () => {
448472
addProjectToTenant();
449473
});
@@ -453,6 +477,13 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
453477
deleteAccordionItems([INITIAL_CHILD_TENANT_NAME]);
454478
cy.expect_flash(flashClassMap.error, FLASH_MESSAGE_CANT_DELETE);
455479
});
480+
481+
afterEach(() => {
482+
confirmUiNavigation(() => {
483+
deleteAccordionItems([PROJECT_NAME_VALUE]);
484+
deleteAccordionItems([INITIAL_CHILD_TENANT_NAME]);
485+
});
486+
});
456487
});
457488

458489
describe('Validate Manage Quotas in child tenant', () => {
@@ -461,10 +492,6 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
461492
cy.toolbar(CONFIG_TOOLBAR_BUTTON, MANAGE_QUOTAS_CONFIG_OPTION);
462493
});
463494

464-
afterEach(() => {
465-
cy.appDbState('restore');
466-
});
467-
468495
it('Validate Reset & Cancel buttons in Manage Quotas form', () => {
469496
cy.getFormFooterButtonByTypeWithText({
470497
buttonText: RESET_BUTTON_TEXT,
@@ -479,6 +506,12 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
479506
editQuotasTable(ALLOCATED_VM_QUOTA, '10');
480507
saveFormWithOptionalFlashCheck();
481508
});
509+
510+
afterEach(() => {
511+
confirmUiNavigation(() => {
512+
deleteAccordionItems([INITIAL_CHILD_TENANT_NAME]);
513+
});
514+
});
482515
});
483516
});
484517
});

0 commit comments

Comments
 (0)