@@ -125,6 +125,7 @@ export default sitesPage;
125125export class SitesRowObject {
126126 constructor ( ) { }
127127
128+ index : number ;
128129 element : Cypress . Chainable < JQuery < HTMLElement > > ;
129130 siteId : number ;
130131 units : string ;
@@ -134,6 +135,7 @@ export class SitesRowObject {
134135 deleteBtn : Cypress . Chainable < JQuery < HTMLElement > > ;
135136
136137 getRow ( rowNum ) : Promise < SitesRowObject > {
138+ this . index = rowNum ;
137139 this . element = cy . get ( 'tbody > tr' ) . eq ( rowNum - 1 ) ;
138140 if ( this . element ) {
139141 this . siteId = + ( this . element . find ( '#siteUUId' ) . invoke ( 'text' ) ) ;
@@ -146,6 +148,13 @@ export class SitesRowObject {
146148 }
147149 return this ;
148150 }
151+
152+ openRowMenu ( ) {
153+ const index = this . index - 1 ;
154+ cy . get ( `#action-items-${ index } #actionMenu` ) . should ( 'be.visible' ) . click ( ) ;
155+ cy . wait ( 200 ) ;
156+ }
157+
149158 closeEditModal ( clickCancel = false ) {
150159 if ( clickCancel ) {
151160 sitesPage . siteEditCancelBtn ( ) . click ( ) ;
@@ -156,22 +165,10 @@ export class SitesRowObject {
156165 sitesPage . sitesManageTagsBtn ( ) . should ( 'be.visible' , { timeout : 40000 } ) ;
157166 }
158167
159- getRow ( rowNum ) : Promise < SitesRowObject > {
160- this . element = Cypress . $$ ( 'tbody > tr' ) . eq ( rowNum - 1 ) ;
161- if ( this . element ) {
162- this . siteId = + this . element . find ( '#siteUUId' ) . text ( ) ;
163- this . units = this . element . find ( '#units' ) . text ( ) ;
164- this . siteName = this . element . find ( '#siteName' ) . text ( ) ;
165- const list = this . element . find ( 'mat-chip-list mat-chip > span' ) ;
166- this . tags = Promise . all ( list . map ( ( _ , element ) => Cypress . $ ( element ) . text ( ) ) ) ;
167- this . editBtn = this . element . find ( '#editSiteBtn' ) ;
168- this . deleteBtn = this . element . find ( '#deleteSiteBtn' ) ;
169- }
170- return this ;
171- }
172-
173168 openEditModal ( site ?: { name ?: string ; tags ?: string [ ] } ) {
174- this . editBtn . click ( ) ;
169+ const index = this . index - 1 ;
170+ this . openRowMenu ( ) ;
171+ cy . get ( `#editSiteBtn${ index } ` ) . should ( 'be.visible' ) . click ( ) ;
175172 cy . wait ( 500 ) ;
176173 sitesPage . siteEditCancelBtn ( ) . should ( 'be.visible' , { timeout : 40000 } ) ;
177174 if ( site ) {
@@ -196,7 +193,9 @@ export class SitesRowObject {
196193 }
197194
198195 openDeleteModal ( ) {
199- this . deleteBtn . click ( ) ;
196+ const index = this . index - 1 ;
197+ this . openRowMenu ( ) ;
198+ cy . get ( `#deleteSiteBtn${ index } ` ) . should ( 'be.visible' ) . click ( ) ;
200199 cy . wait ( 500 ) ;
201200 sitesPage . siteDeleteCancelBtn ( ) . should ( 'be.visible' , { timeout : 40000 } ) . click ( ) ;
202201 }
0 commit comments