@@ -126,6 +126,38 @@ export default class SchemaPage extends GraphPage {
126
126
return this . page . locator ( `//ul[@id='TypeList']//div[@role="option"]` ) ;
127
127
}
128
128
129
+ private get LabelDataPanel ( ) : Locator {
130
+ return this . page . locator ( "//div[contains(@class, 'DataPanel')]//li//button" ) ;
131
+ }
132
+
133
+ private get clearRelationBtnInDataPanel ( ) : Locator {
134
+ return this . page . locator ( `//button[contains(text(), 'Clear')]` ) ;
135
+ }
136
+
137
+ private get swapRelationBtnInDataPanel ( ) : Locator {
138
+ return this . page . locator ( `//button[contains(text(), 'Swap')]` ) ;
139
+ }
140
+
141
+ private get relationshipNodes ( ) : ( keyIndex : string ) => Locator {
142
+ return ( keyIndex : string ) => this . page . locator ( `//div[@id='relationship-controls']/div[1]/div[${ keyIndex } ]` ) ;
143
+ }
144
+
145
+ private get lastSchemaAttributeValue ( ) : Locator {
146
+ return this . page . locator ( '//div[contains(@id, "tableContent")]//tr[last()]//td[1]' ) ;
147
+ }
148
+
149
+ private get actionButtonInLastAttributeRow ( ) : ( action : string ) => Locator {
150
+ return ( action : string ) => this . page . locator ( `//div[contains(@id, "tableContent")]//tr[last()]/td[last()]//button[contains(text(), '${ action } ')]` ) ;
151
+ }
152
+
153
+ private get saveAttributeBtnInSchemaDataPanel ( ) : Locator {
154
+ return this . page . locator ( '//div[contains(@id, "tableContent")]//button[contains(text(), "Save")]' ) ;
155
+ }
156
+
157
+ private get attributesStatsInSchemaDataPanel ( ) : Locator {
158
+ return this . page . locator ( '(//div[contains(@id, "headerDataPanel")]//p)[last()]' ) ;
159
+ }
160
+
129
161
async clickAddNewSchemaBtn ( ) : Promise < void > {
130
162
await interactWhenVisible ( this . addSchemaBtnInNavBar , el => el . click ( ) , "add new schema button" ) ;
131
163
}
@@ -174,7 +206,7 @@ export default class SchemaPage extends GraphPage {
174
206
await interactWhenVisible ( this . activeDescInputInDataPanel , el => el . fill ( desc ) , "desc input in data panel" ) ;
175
207
}
176
208
177
- async getDescInDataPanelAttr ( descIndex : string ) : Promise < string | null > {
209
+ async getFirstDescInDataPanelAttr ( descIndex : string ) : Promise < string | null > {
178
210
return await interactWhenVisible ( this . descInDataPanel ( descIndex ) , el => el . textContent ( ) , "desc input in data panel" ) ;
179
211
}
180
212
@@ -226,6 +258,7 @@ export default class SchemaPage extends GraphPage {
226
258
}
227
259
228
260
async getAttributeRowsCount ( ) : Promise < number > {
261
+ await this . page . waitForTimeout ( 500 ) ;
229
262
return await this . attributeRows . count ( ) ;
230
263
}
231
264
@@ -252,11 +285,51 @@ export default class SchemaPage extends GraphPage {
252
285
async clickSearchedType ( ) : Promise < void > {
253
286
await interactWhenVisible ( this . selectSearchType , el => el . click ( ) , "type search input" ) ;
254
287
}
288
+
289
+ async hoverOnLabelDataPanel ( ) : Promise < void > {
290
+ await interactWhenVisible ( this . LabelDataPanel , async ( el ) => { await el . hover ( ) ; } , `Header data panel list` ) ;
291
+ }
292
+
293
+ async clickOnDeleteLabel ( ) : Promise < void > {
294
+ await interactWhenVisible ( this . LabelDataPanel . first ( ) , async ( el ) => { await el . click ( ) ; } , `Header data panel list` ) ;
295
+ }
296
+
297
+ async clickClearRelationBtnInDataPanel ( ) : Promise < void > {
298
+ await interactWhenVisible ( this . clearRelationBtnInDataPanel , el => el . click ( ) , "clear relation button in data panel" ) ;
299
+ }
300
+
301
+ async clickSwapRelationBtnInDataPanel ( ) : Promise < void > {
302
+ await interactWhenVisible ( this . swapRelationBtnInDataPanel , el => el . click ( ) , "swap relation button in data panel" ) ;
303
+ }
304
+
305
+ async findRelationshipNodes ( key : string ) : Promise < string | null > {
306
+ return await interactWhenVisible ( this . relationshipNodes ( key ) , el => el . textContent ( ) , "swap relation button in data panel" ) ;
307
+ }
308
+
309
+ async hoverLastSchemaAttributeValue ( ) : Promise < void > {
310
+ await interactWhenVisible ( this . lastSchemaAttributeValue , async ( el ) => { await el . hover ( ) ; } , `last schema attribute value` ) ;
311
+ }
312
+
313
+ async clickActionButtonInLastAttributeRow ( action : string ) : Promise < void > {
314
+ await interactWhenVisible ( this . actionButtonInLastAttributeRow ( action ) , async ( el ) => { await el . click ( ) ; } , `action buttonn in last attribute row` ) ;
315
+ }
316
+
317
+ async clickSaveAttributeBtnInSchemaDataPanel ( ) : Promise < void > {
318
+ await interactWhenVisible ( this . saveAttributeBtnInSchemaDataPanel , el => el . click ( ) , "save attribute button in data panel" ) ;
319
+ }
320
+
321
+ async getAttributesStatsInSchemaDataPanel ( ) : Promise < string | null > {
322
+ return await interactWhenVisible ( this . attributesStatsInSchemaDataPanel , el => el . textContent ( ) , "attr stats in data panel" ) ;
323
+ }
255
324
256
325
async isCategoriesPanelBtnHidden ( ) : Promise < boolean > {
257
326
return await this . categoriesPanelBtn . isHidden ( ) ;
258
327
}
259
328
329
+ async getCategoriesPanelCount ( ) : Promise < number > {
330
+ return await this . categoriesPanelBtn . count ( ) ;
331
+ }
332
+
260
333
async addSchema ( schemaName : string ) : Promise < void > {
261
334
await this . clickAddNewSchemaBtn ( ) ;
262
335
await this . fillSchemaNameInput ( schemaName ) ;
@@ -272,28 +345,53 @@ export default class SchemaPage extends GraphPage {
272
345
await this . clickCreateNewNodeBtnInDataPanel ( ) ;
273
346
}
274
347
348
+ async modifyNodeLabel ( x : number , y : number , title : string ) : Promise < void > {
349
+ await this . nodeClick ( x , y ) ;
350
+ await this . hoverOnLabelDataPanel ( ) ;
351
+ await this . clickAddBtnInHeaderDataPanel ( ) ;
352
+ await this . insertDataPanelHeader ( title ) ;
353
+ await this . clickSaveBtnInHeaderDataPanel ( ) ;
354
+ await this . clickOnDeleteLabel ( ) ;
355
+ }
356
+
275
357
async deleteNode ( x : number , y : number ) : Promise < void > {
276
358
await this . nodeClick ( x , y ) ;
277
359
await this . clickDeleteNodeInDataPanel ( ) ;
278
360
await this . clickConfirmDeleteNodeInDataPanel ( ) ;
279
361
}
280
362
281
- async addLabel ( title : string ) : Promise < void > {
363
+ async addRelationLabel ( title : string ) : Promise < void > {
282
364
await this . clickAddRelation ( ) ;
283
365
await this . clickAddBtnInHeaderDataPanel ( ) ;
284
366
await this . insertDataPanelHeader ( title ) ;
285
367
await this . clickSaveBtnInHeaderDataPanel ( ) ;
286
368
}
287
369
370
+ async clearNodeRelation ( ) : Promise < void > {
371
+ await this . clickAddRelation ( ) ;
372
+ await this . selectFirstTwoNodesForRelation ( ) ;
373
+ await this . clickClearRelationBtnInDataPanel ( ) ;
374
+ }
375
+
376
+ async swapNodesInRelation ( ) : Promise < void > {
377
+ await this . clickAddRelation ( ) ;
378
+ await this . selectFirstTwoNodesForRelation ( ) ;
379
+ await this . clickSwapRelationBtnInDataPanel ( ) ;
380
+ }
381
+
288
382
async prepareRelation ( title : string , key : string , type : string , desc : string , unique : boolean , required : boolean ) : Promise < void > {
289
- await this . addLabel ( title ) ;
383
+ await this . addRelationLabel ( title ) ;
290
384
await this . addAttribute ( key , type , desc , unique , required ) ;
291
385
}
292
-
293
- async clickRelationBetweenNodes ( ) : Promise < void > {
386
+
387
+ async selectFirstTwoNodesForRelation ( ) : Promise < void > {
294
388
const schema = await this . getNodeScreenPositions ( 'schema' ) ;
295
389
await this . nodeClick ( schema [ 0 ] . screenX , schema [ 0 ] . screenY ) ;
296
390
await this . nodeClick ( schema [ 1 ] . screenX , schema [ 1 ] . screenY ) ;
391
+ }
392
+
393
+ async clickRelationBetweenNodes ( ) : Promise < void > {
394
+ await this . selectFirstTwoNodesForRelation ( ) ;
297
395
await this . clickCreateNewEdgeBtnInDataPanel ( ) ;
298
396
}
299
397
@@ -321,5 +419,18 @@ export default class SchemaPage extends GraphPage {
321
419
}
322
420
await this . clickAddActiveBtnInDataPanel ( ) ;
323
421
}
422
+
423
+ async deleteAttriubute ( ) : Promise < void > {
424
+ await this . hoverLastSchemaAttributeValue ( ) ;
425
+ await this . clickActionButtonInLastAttributeRow ( 'Delete' ) ;
426
+ await this . clickConfirmDeleteNodeInDataPanel ( ) ;
427
+ }
428
+
429
+ async modifyAttriubuteDesc ( desc : string ) : Promise < void > {
430
+ await this . hoverLastSchemaAttributeValue ( ) ;
431
+ await this . clickActionButtonInLastAttributeRow ( 'Edit' ) ;
432
+ await this . insertActiveDescInputInDataPanelAttr ( desc ) ;
433
+ await this . clickSaveAttributeBtnInSchemaDataPanel ( ) ;
434
+ }
324
435
325
436
}
0 commit comments