11import { Locator , Page } from "playwright" ;
22import BasePage from "../../infra/ui/basePage" ;
3- import { delay } from "../utils" ;
3+ import { waitToBeEnabled } from "../utils" ;
44
55export default class CodeGraph extends BasePage {
66 /* NavBar Locators*/
@@ -33,6 +33,42 @@ export default class CodeGraph extends BasePage {
3333 return this . page . locator ( "//main[@data-name='main-chat']/*[last()]/p" ) ;
3434 }
3535
36+ private get typeUrlInput ( ) : Locator {
37+ return this . page . locator ( "//div[@role='dialog']/form/input" ) ;
38+ }
39+
40+ private get createBtnInCreateProjectDialog ( ) : Locator {
41+ return this . page . locator ( "//div[@role='dialog']/form//following::button//p[contains(text(), 'Create')]" )
42+ }
43+
44+ private get createProjectWaitDialog ( ) : Locator {
45+ return this . page . locator ( "//div[@role='dialog']//div//h2[contains(text(), 'THANK YOU FOR A NEW REQUEST')]" )
46+ }
47+
48+ private get dialogCreatedGraphsList ( ) : ( graph : string ) => Locator {
49+ return ( graph : string ) => this . page . locator ( `//div[@role='presentation']/div//span[2][contains(text(), '${ graph } ')]` ) ;
50+ }
51+
52+ private get searchBarInput ( ) : Locator {
53+ return this . page . locator ( "//div[@data-name='search-bar']/input" ) ;
54+ }
55+
56+ private get searchBarAutoCompleteOptions ( ) : Locator {
57+ return this . page . locator ( "//div[@data-name='search-bar']/div/button" ) ;
58+ }
59+
60+ private get searchBarElements ( ) : Locator {
61+ return this . page . locator ( "//div[@data-name='search-bar']/div/button/div/p[1]" ) ;
62+ }
63+
64+ private get searchBarOptionBtn ( ) : ( buttonNum : string ) => Locator {
65+ return ( buttonNum : string ) => this . page . locator ( `//div[@data-name='search-bar']//button[${ buttonNum } ]` ) ;
66+ }
67+
68+ private get searchBarList ( ) : Locator {
69+ return this . page . locator ( "//div[@data-name='search-bar-list']" ) ;
70+ }
71+
3672 /* Chat Locators */
3773 private get showPathBtn ( ) : Locator {
3874 return this . page . locator ( "//button[contains(@class, 'Tip')]" ) ;
@@ -74,7 +110,7 @@ export default class CodeGraph extends BasePage {
74110 return ( inputNum : string ) => this . page . locator ( `(//main[@data-name='main-chat']//input)[1]/following::div[${ inputNum } ]//button[1]` ) ;
75111 }
76112
77- private get notificationNoPathFound ( ) : Locator {
113+ private get notificationError ( ) : Locator {
78114 return this . page . locator ( "//div[@role='region']//ol//li" ) ;
79115 }
80116
@@ -115,7 +151,7 @@ export default class CodeGraph extends BasePage {
115151 }
116152
117153 async sendMessage ( message : string ) {
118- await this . askquestionInput . isEnabled ( ) ;
154+ await waitToBeEnabled ( this . askquestionInput ) ;
119155 await this . askquestionInput . fill ( message ) ;
120156 await this . askquestionBtn . click ( ) ;
121157 }
@@ -160,11 +196,12 @@ export default class CodeGraph extends BasePage {
160196 }
161197
162198 async isNodeVisibleInLastChatPath ( node : string ) : Promise < boolean > {
199+ await this . locateNodeInLastChatPath ( node ) . waitFor ( { state : 'visible' } ) ;
163200 return await this . locateNodeInLastChatPath ( node ) . isVisible ( ) ;
164201 }
165202
166- async isNotificationNoPathFound ( ) : Promise < boolean > {
167- return await this . notificationNoPathFound . isVisible ( ) ;
203+ async isNotificationError ( ) : Promise < boolean > {
204+ return await this . notificationError . isVisible ( ) ;
168205 }
169206
170207 /* CodeGraph functionality */
@@ -173,4 +210,49 @@ export default class CodeGraph extends BasePage {
173210 await this . selectGraphInComboBox ( graph ) . waitFor ( { state : 'visible' } )
174211 await this . selectGraphInComboBox ( graph ) . click ( ) ;
175212 }
213+
214+ async createProject ( url : string ) : Promise < void > {
215+ await this . clickCreateNewProjectBtn ( ) ;
216+ await this . typeUrlInput . fill ( url ) ;
217+ await this . createBtnInCreateProjectDialog . click ( ) ;
218+ await this . createProjectWaitDialog . waitFor ( { state : 'hidden' } ) ;
219+ }
220+
221+ async isGraphCreated ( graph : string ) : Promise < boolean > {
222+ await this . comboBoxbtn . click ( ) ;
223+ return await this . dialogCreatedGraphsList ( graph ) . isVisible ( ) ;
224+ }
225+
226+ async fillSearchBar ( searchValue : string ) : Promise < void > {
227+ await this . searchBarInput . fill ( searchValue ) ;
228+ }
229+
230+ async getSearchAutoCompleteCount ( ) : Promise < number > {
231+ return await this . searchBarAutoCompleteOptions . count ( ) ;
232+ }
233+
234+ async getSearchBarElementsText ( ) : Promise < string [ ] > {
235+ return await this . searchBarElements . allTextContents ( ) ;
236+ }
237+
238+ async selectSearchBarOptionBtn ( buttonNum : string ) : Promise < void > {
239+ await this . searchBarOptionBtn ( buttonNum ) . click ( ) ;
240+ }
241+
242+ async getSearchBarInputValue ( ) : Promise < string > {
243+ return await this . searchBarInput . inputValue ( ) ;
244+ }
245+
246+
247+ async scrollToBottomInSearchBarList ( ) : Promise < void > {
248+ await this . searchBarList . evaluate ( ( element ) => {
249+ element . scrollTop = element . scrollHeight ;
250+ } ) } ;
251+
252+ async isScrolledToBottomInSearchBarList ( ) : Promise < boolean > {
253+ return await this . searchBarList . evaluate ( ( element ) => {
254+ return element . scrollTop + element . clientHeight >= element . scrollHeight ;
255+ } ) ;
256+ }
257+
176258}
0 commit comments