Skip to content

Commit f601874

Browse files
committed
Simplify the defining of constants and access
* Drop repetive constant definition and assignment * Generalize the names of constants * Capitalize constants as per conventions
1 parent 39821d5 commit f601874

File tree

1 file changed

+23
-41
lines changed

1 file changed

+23
-41
lines changed
Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
11
/* eslint-disable no-undef */
22
import { flashClassMap } from '../../../../support/assertions/assertion_constants';
33

4-
const textConstants = {
5-
// Menu options
6-
settingsMenuOption: 'Settings',
7-
appSettingsMenuOption: 'Application Settings',
8-
toolBarConfigMenu: 'Configuration',
9-
10-
// added item information
11-
initialTenantName: 'Test-name',
12-
initialTenantDescription: 'test description',
13-
14-
// List items
15-
accessControlAccordion: 'Access Control',
16-
17-
// flash message assertions
18-
flashMessageOperationAdded: 'added',
19-
flashMessageOperationDeleted: 'delete',
4+
describe('Settings > Application Settings > Access Control', () => {
5+
// Navigation
6+
const PRIMARY_MENU_OPTION = 'Settings';
7+
const SECONDARY_MENU_OPTION = 'Application Settings';
8+
const ACCORDION = 'Access Control';
9+
const TOOLBAR_MENU = 'Configuration';
2010

21-
// Configuration menu options and browser alert text snippets
22-
deleteItem: 'Delete this item',
23-
}
11+
// Created item information
12+
const INITIAL_TENANT_NAME = 'Test-name';
13+
const INITIAL_TENANT_DESCRIPTION = 'test description';
2414

25-
const {
26-
accessControlAccordion,
27-
appSettingsMenuOption,
28-
deleteItem,
29-
flashMessageOperationAdded,
30-
flashMessageOperationDeleted,
31-
initialTenantDescription,
32-
initialTenantName,
33-
settingsMenuOption,
34-
toolBarConfigMenu,
35-
} = textConstants;
15+
// CRUD actions
16+
const FLASH_MESSAGE_OPERATION_ADDED = 'added';
17+
const FLASH_MESSAGE_OPERATION_DELETED = 'delete';
18+
const DELETE_ITEM = 'Delete this item';
3619

37-
describe('Settings > Application Settings > Access Control', () => {
3820
beforeEach(() => {
3921
cy.login();
40-
cy.menu(settingsMenuOption, appSettingsMenuOption);
41-
cy.accordion(accessControlAccordion);
22+
cy.menu(PRIMARY_MENU_OPTION, SECONDARY_MENU_OPTION);
23+
cy.accordion(ACCORDION);
4224
});
4325

4426
it('should be able to create and delete a tenant', () => {
@@ -48,22 +30,22 @@ describe('Settings > Application Settings > Access Control', () => {
4830
'My Company',
4931
]);
5032

51-
cy.toolbar(toolBarConfigMenu, 'Add child Tenant to this Tenant');
52-
cy.getFormInputFieldById('name').type(initialTenantName);
53-
cy.getFormInputFieldById('description').type(initialTenantDescription);
33+
cy.toolbar(TOOLBAR_MENU, 'Add child Tenant to this Tenant');
34+
cy.getFormInputFieldById('name').type(INITIAL_TENANT_NAME);
35+
cy.getFormInputFieldById('description').type(INITIAL_TENANT_DESCRIPTION);
5436
cy.getFormFooterButtonByType('Add', 'submit').click();
55-
cy.expect_flash(flashClassMap.success, flashMessageOperationAdded);
37+
cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_OPERATION_ADDED);
5638
cy.selectAccordionItem([
5739
/^ManageIQ Region/,
5840
'Tenants',
5941
'My Company',
60-
initialTenantName
42+
INITIAL_TENANT_NAME
6143
]);
6244

6345
cy.expect_browser_confirm_with_text({
64-
confirmTriggerFn: () => cy.toolbar(toolBarConfigMenu, deleteItem),
65-
containsText: deleteItem,
46+
confirmTriggerFn: () => cy.toolbar(TOOLBAR_MENU, DELETE_ITEM),
47+
containsText: DELETE_ITEM,
6648
});
67-
cy.expect_flash(flashClassMap.success, flashMessageOperationDeleted);
49+
cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_OPERATION_DELETED);
6850
});
6951
});

0 commit comments

Comments
 (0)