22import { Given , When , Then , setDefaultTimeout } from "@cucumber/cucumber" ;
33import { expectVisibility } from "../services/uiHelper" ;
44import { PlaywrightWorld } from "../support/PlaywrightWorld" ;
5- import { expect } from "@playwright/test " ;
5+ import { clickMenuThenItem } from "../services/commonFunctions " ;
66
77setDefaultTimeout ( 60 * 1000 * 2 ) ;
88
@@ -26,29 +26,11 @@ Given('KafkaConnect satus is: {string}, type is: {string}', async function(this:
2626} ) ;
2727
2828Given ( 'KafkaConnect row menu menu item {string} is clicked' , async function ( this : PlaywrightWorld , menuItem : string ) {
29- const { page } = this ;
30- const rowMenu = this . locators . connectors . rowMenu ;
31- const rowMenuItem = this . locators . connectors . rowMenuItem ( menuItem ) ;
32-
33- async function attemptClick ( ) {
34- await expect ( rowMenu ) . toBeVisible ( { timeout : 5000 } ) ;
35- await expect ( rowMenu ) . toBeEnabled ( { timeout : 5000 } ) ;
36- await rowMenu . scrollIntoViewIfNeeded ( ) ;
37-
38- await rowMenu . click ( ) ;
39-
40- await expect ( rowMenuItem ) . toBeVisible ( { timeout : 5000 } ) ;
41- await rowMenuItem . click ( ) ;
42- }
43-
44- try {
45- await attemptClick ( ) ;
46- } catch ( firstErr ) {
47- await page . reload ( { waitUntil : 'domcontentloaded' } ) ;
48- await page . waitForLoadState ( 'networkidle' , { timeout : 10000 } ) . catch ( ( ) => { } ) ;
49-
50- await attemptClick ( ) ;
51- }
29+ await clickMenuThenItem (
30+ this . page ,
31+ this . locators . connectors . rowMenu ,
32+ this . locators . connectors . rowMenuItem ( menuItem )
33+ ) ;
5234} ) ;
5335
5436When ( 'KafkaConnect connector named: {string} clicked' , async function ( this : PlaywrightWorld , name : string ) {
@@ -64,29 +46,11 @@ Given('KafkaConnect connector page status is: {string}', async function(this: Pl
6446} ) ;
6547
6648When ( 'KafkaConnect connector menu item {string} clicked' , async function ( this : PlaywrightWorld , menuItem : string ) {
67- const { page } = this ;
68- const menuButton = this . locators . connectors . internalMenuButton ;
69- const menuItemLocator = this . locators . connectors . internalMenuButtonItem ( menuItem ) ;
70-
71- async function attemptClick ( ) {
72- await expect ( menuButton ) . toBeVisible ( { timeout : 5000 } ) ;
73- await expect ( menuButton ) . toBeEnabled ( { timeout : 5000 } ) ;
74-
75- await menuButton . click ( ) ;
76-
77- await expect ( menuItemLocator ) . toBeVisible ( { timeout : 5000 } ) ;
78- await menuItemLocator . click ( ) ;
79- }
80-
81- try {
82- await attemptClick ( ) ;
83- } catch ( firstErr ) {
84- await page . reload ( { waitUntil : 'domcontentloaded' } ) ;
85-
86- await page . waitForLoadState ( 'networkidle' , { timeout : 10000 } ) . catch ( ( ) => { } ) ;
87-
88- await attemptClick ( ) ;
89- }
49+ await clickMenuThenItem (
50+ this . page ,
51+ this . locators . connectors . internalMenuButton ,
52+ this . locators . connectors . internalMenuButtonItem ( menuItem )
53+ ) ;
9054} ) ;
9155
9256Given ( 'KafkaConnect connector page state is: {string}' , async function ( this : PlaywrightWorld , state : string ) {
0 commit comments