@@ -8,6 +8,8 @@ class BOCategoriesCreatePage extends BOBasePage implements BOCategoriesCreatePag
88
99 public readonly pageTitleEdit : string ;
1010
11+ private readonly formCategory : string ;
12+
1113 private readonly nameInput : string ;
1214
1315 private readonly displayedToggleInput : ( toggle : number ) => string ;
@@ -53,6 +55,7 @@ class BOCategoriesCreatePage extends BOBasePage implements BOCategoriesCreatePag
5355 this . pageTitleEdit = 'Editing category ' ;
5456
5557 // Selectors
58+ this . formCategory = '#main-div .content-div form' ;
5659 this . nameInput = '#category_name_1' ;
5760 this . displayedToggleInput = ( toggle : number ) => `#category_active_${ toggle } ` ;
5861 this . descriptionIframe = '#category_description_1_ifr' ;
@@ -79,10 +82,18 @@ class BOCategoriesCreatePage extends BOBasePage implements BOCategoriesCreatePag
7982 /*
8083 Methods
8184 */
85+ /**
86+ * Returns the Identifier of the category
87+ * @param page {Page} Browser tab
88+ * @return {Promise<number> }
89+ */
90+ async getIDCategory ( page : Page ) : Promise < number > {
91+ return parseInt ( await page . locator ( this . formCategory ) . getAttribute ( 'data-id' ) ?? '' , 10 ) ;
92+ }
8293
8394 /**
8495 * Select all groups
85- * @param page
96+ * @param page {Page} Browser tab
8697 * @return {Promise<void> }
8798 */
8899 async selectAllGroups ( page : Page ) : Promise < void > {
@@ -136,7 +147,9 @@ class BOCategoriesCreatePage extends BOBasePage implements BOCategoriesCreatePag
136147 await this . setValue ( page , this . rootCategoryNameInput , categoryData . name ) ;
137148 await this . setChecked ( page , this . rootCategoryDisplayedToggleInput ( categoryData . displayed ? 1 : 0 ) ) ;
138149 await this . setValueOnTinymceInput ( page , this . rootCategoryDescriptionIframe , categoryData . description ) ;
139- await this . uploadFile ( page , this . rootCategoryCoverImage , `${ categoryData . name } .jpg` ) ;
150+ if ( categoryData . coverImage ) {
151+ await this . uploadFile ( page , this . rootCategoryCoverImage , categoryData . coverImage ) ;
152+ }
140153 await this . setValue ( page , this . rootCategoryMetaTitleInput , categoryData . metaTitle ) ;
141154 await this . setValue ( page , this . rootCategoryMetaDescriptionTextarea , categoryData . metaDescription ) ;
142155 await this . selectAllGroups ( page ) ;
0 commit comments