@@ -27,7 +27,6 @@ const TEST_DESCRIPTION = 'Test-Description';
2727
2828// Config options
2929const CONFIG_TOOLBAR_BUTTON = 'Configuration' ;
30- const ADD_CATALOG_ITEM_CONFIG_OPTION = 'Add a New Catalog Item' ;
3130const ADD_CATALOG_CONFIG_OPTION = 'Add a New Catalog' ;
3231const EDIT_CATALOG_CONFIG_OPTION = 'Edit this Item' ;
3332const REMOVE_CATALOG_CONFIG_OPTION = 'Remove Catalog' ;
@@ -39,7 +38,6 @@ const CANCEL_BUTTON_TEXT = 'Cancel';
3938const RESET_BUTTON_TEXT = 'Reset' ;
4039
4140// Flash message text snippets
42- const FLASH_MESSAGE_ADDED = 'added' ;
4341const FLASH_MESSAGE_SAVED = 'saved' ;
4442const FLASH_MESSAGE_CANCELLED = 'cancelled' ;
4543const FLASH_MESSAGE_DELETED = 'delete' ;
@@ -50,19 +48,7 @@ const BROWSER_ALERT_REMOVE_CONFIRM_TEXT = 'removed';
5048
5149// Accordion items
5250const CATALOGS_ACCORDION_ITEM = 'Catalogs' ;
53- const CATALOG_ITEMS_ACCORDION_ITEM = 'Catalog Items' ;
5451const 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
6753function validateElements ( { isEditForm } ) {
6854 cy . expect_explorer_title ( FORM_HEADER ) ;
@@ -126,19 +112,27 @@ function validateElements({ isEditForm }) {
126112
127113describe ( '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