Skip to content

Commit f8ffebb

Browse files
committed
Replace UI creation of service template with factories (catalog)
Note, the resource actions aren't required for the test but creating the service template in the UI does create them so they been kept to match the UI behavior.
1 parent f5ecaa4 commit f8ffebb

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

cypress/e2e/ui/Services/Catalogs/catalog.cy.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const TEST_DESCRIPTION = 'Test-Description';
2727

2828
// Config options
2929
const CONFIG_TOOLBAR_BUTTON = 'Configuration';
30-
const ADD_CATALOG_ITEM_CONFIG_OPTION = 'Add a New Catalog Item';
3130
const ADD_CATALOG_CONFIG_OPTION = 'Add a New Catalog';
3231
const EDIT_CATALOG_CONFIG_OPTION = 'Edit this Item';
3332
const REMOVE_CATALOG_CONFIG_OPTION = 'Remove Catalog';
@@ -39,7 +38,6 @@ const CANCEL_BUTTON_TEXT = 'Cancel';
3938
const RESET_BUTTON_TEXT = 'Reset';
4039

4140
// Flash message text snippets
42-
const FLASH_MESSAGE_ADDED = 'added';
4341
const FLASH_MESSAGE_SAVED = 'saved';
4442
const FLASH_MESSAGE_CANCELLED = 'cancelled';
4543
const FLASH_MESSAGE_DELETED = 'delete';
@@ -50,19 +48,7 @@ const BROWSER_ALERT_REMOVE_CONFIRM_TEXT = 'removed';
5048

5149
// Accordion items
5250
const CATALOGS_ACCORDION_ITEM = 'Catalogs';
53-
const CATALOG_ITEMS_ACCORDION_ITEM = 'Catalog Items';
5451
const ALL_CATALOGS_ACCORDION_ITEM = 'All Catalogs';
55-
const ALL_CATALOG_ITEMS_ACCORDION_ITEM = 'All Catalog Items';
56-
const UNASSIGNED_ACCORDION_ITEM = 'Unassigned';
57-
58-
function addCatalogItem(catalogItemName) {
59-
cy.toolbar(CONFIG_TOOLBAR_BUTTON, ADD_CATALOG_ITEM_CONFIG_OPTION);
60-
cy.contains('button[data-id="st_prov_type"]', 'Choose').click();
61-
cy.contains('.form-group ul.dropdown-menu li a', 'Generic').click();
62-
cy.get('input#name').type(catalogItemName);
63-
cy.contains('#form_buttons_div button', ADD_BUTTON_TEXT).click();
64-
cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_ADDED);
65-
}
6652

6753
function validateElements({ isEditForm }) {
6854
cy.expect_explorer_title(FORM_HEADER);
@@ -126,19 +112,27 @@ function validateElements({ isEditForm }) {
126112

127113
describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Configuration > Add a New Catalog', () => {
128114
beforeEach(() => {
115+
cy.appFactories([
116+
['create', 'service_template', {name: CATALOG_ITEM_NAME_1, generic_subtype: 'custom', prov_type: 'generic', display: true}],
117+
]).then((results) => {
118+
cy.appFactories([
119+
['create', 'resource_action', {action: 'Provision', resource_id: results[0].id, resource_type: 'ServiceTemplate'}],
120+
['create', 'resource_action', {action: 'Retirement', resource_id: results[0].id, resource_type: 'ServiceTemplate'}]
121+
])
122+
});
123+
124+
cy.appFactories([
125+
['create', 'service_template', {name: CATALOG_ITEM_NAME_2, generic_subtype: 'custom', prov_type: 'generic', display: true}],
126+
]).then((results) => {
127+
cy.appFactories([
128+
['create', 'resource_action', {action: 'Provision', resource_id: results[0].id, resource_type: 'ServiceTemplate'}],
129+
['create', 'resource_action', {action: 'Retirement', resource_id: results[0].id, resource_type: 'ServiceTemplate'}]
130+
])
131+
});
132+
129133
cy.login();
130134
cy.menu(SERVICES_MENU_OPTION, CATALOGS_MENU_OPTION);
131135

132-
// TODO: replace with better data setup approach
133-
// Adding 2 catalog items first before validating Catalog form
134-
cy.accordion(CATALOG_ITEMS_ACCORDION_ITEM);
135-
cy.selectAccordionItem([
136-
ALL_CATALOG_ITEMS_ACCORDION_ITEM,
137-
UNASSIGNED_ACCORDION_ITEM,
138-
]);
139-
addCatalogItem(CATALOG_ITEM_NAME_1);
140-
addCatalogItem(CATALOG_ITEM_NAME_2);
141-
142136
cy.accordion(CATALOGS_ACCORDION_ITEM);
143137
cy.selectAccordionItem([ALL_CATALOGS_ACCORDION_ITEM]);
144138
});

0 commit comments

Comments
 (0)