@@ -4,7 +4,7 @@ import CodeGraph from "../logic/POM/codeGraph";
44import urls from "../config/urls.json" ;
55import { GRAPH_ID , Node_Add_Edge , Node_Import_Data , PROJECT_NAME } from "../config/constants" ;
66import { delay } from "../logic/utils" ;
7- import { searchData , specialCharacters } from "../config/testData" ;
7+ import { searchData , specialCharacters , nodesPath } from "../config/testData" ;
88import { CanvasAnalysisResult } from "../logic/canvasAnalysis" ;
99import { ApiCalls } from "../logic/api/apiCalls" ;
1010
@@ -39,7 +39,6 @@ test.describe("Code graph tests", () => {
3939 const codeGraph = await browser . createNewPage ( CodeGraph , urls . baseUrl ) ;
4040 await codeGraph . selectGraph ( GRAPH_ID ) ;
4141 await codeGraph . fillSearchBar ( searchInput ) ;
42- await delay ( 1000 ) ;
4342 await codeGraph . selectSearchBarOptionBtn ( "1" ) ;
4443 expect ( await codeGraph . getSearchBarInputValue ( ) ) . toBe (
4544 completedSearchInput
@@ -208,12 +207,100 @@ test.describe("Code graph tests", () => {
208207 return await codeGraph . getNodeDetailsHeader ( ) ;
209208 } )
210209 ) ;
210+ await codeGraph . clickOnNodeDetailsCloseBtn ( ) ;
211211 const api = new ApiCalls ( ) ;
212212 const response = await api . getProject ( PROJECT_NAME ) ;
213213 const nodeExists = response . result . entities . nodes . some ( ( node ) =>
214214 result . some ( ( resItem ) => resItem . includes ( node . properties . name . toUpperCase ( ) ) )
215215 ) ;
216216 expect ( nodeExists ) . toBe ( true )
217217 } ) ;
218+
219+
220+ test ( `Validate copy to clipboard functionality for node and verify with api` , async ( ) => {
221+ const codeGraph = await browser . createNewPage ( CodeGraph , urls . baseUrl ) ;
222+ await browser . setPageToFullScreen ( ) ;
223+ await codeGraph . selectGraph ( GRAPH_ID ) ;
224+ await codeGraph . fillSearchBar ( Node_Import_Data ) ;
225+ await codeGraph . selectSearchBarOptionBtn ( "1" ) ;
226+ const analysis = await codeGraph . getCanvasAnalysis ( ) ;
227+ await codeGraph . rightClickOnNode ( analysis . green [ 0 ] . x , analysis . green [ 0 ] . y ) ;
228+ const result = await codeGraph . clickOnCopySrcOnNode ( ) ;
229+ const api = new ApiCalls ( ) ;
230+ const response = await api . getProject ( PROJECT_NAME ) ;
231+ const foundNode = response . result . entities . nodes . find ( node => node . properties ?. name === Node_Import_Data ) ;
232+ expect ( foundNode ?. properties . src ) . toBe ( result ) ;
233+ } ) ;
234+
235+ test ( `Verify searching for node focus on correct node in canvas` , async ( ) => {
236+ const codeGraph = await browser . createNewPage ( CodeGraph , urls . baseUrl ) ;
237+ await browser . setPageToFullScreen ( ) ;
238+ await codeGraph . selectGraph ( GRAPH_ID ) ;
239+ await codeGraph . fillSearchBar ( Node_Import_Data ) ;
240+ await codeGraph . selectSearchBarOptionBtn ( "1" ) ;
241+ const result = await codeGraph . getCanvasAnalysis ( ) ;
242+ await codeGraph . rightClickOnNode ( result . green [ 0 ] . x , result . green [ 0 ] . y ) ;
243+ const header = await codeGraph . getNodeDetailsHeader ( ) ;
244+ await codeGraph . clickOnNodeDetailsCloseBtn ( ) ;
245+ expect ( header ) . toContain ( Node_Import_Data . toUpperCase ( ) )
246+ } ) ;
247+
248+ nodesPath . forEach ( ( { firstNode, secondNode} ) => {
249+ test ( `Verify successful node path connection in canvas between ${ firstNode } and ${ secondNode } via UI` , async ( ) => {
250+ const codeGraph = await browser . createNewPage ( CodeGraph , urls . baseUrl ) ;
251+ await codeGraph . selectGraph ( GRAPH_ID ) ;
252+ await codeGraph . clickOnshowPathBtn ( ) ;
253+ await codeGraph . insertInputForShowPath ( "1" , firstNode ) ;
254+ await codeGraph . insertInputForShowPath ( "2" , secondNode ) ;
255+ const result = await codeGraph . getCanvasAnalysis ( ) ;
256+ console . log ( result ) ;
257+
258+ const res = [ ] ;
259+ for ( const node of result . green ) {
260+ await codeGraph . rightClickOnNode ( node . x , node . y ) ;
261+ const details = await codeGraph . getNodeDetailsHeader ( ) ;
262+ await codeGraph . clickOnNodeDetailsCloseBtn ( ) ;
263+ res . push ( details ) ;
264+ }
265+ console . log ( res ) ;
266+
267+ expect ( res . some ( ( item ) => item . includes ( firstNode . toUpperCase ( ) ) ) ) . toBe ( true ) ;
268+ expect ( res . some ( ( item ) => item . includes ( secondNode . toUpperCase ( ) ) ) ) . toBe ( true ) ;
269+ } ) ;
270+ } )
271+
272+ test ( `Validate node path connection in canvas ui and confirm via api` , async ( ) => {
273+ const codeGraph = await browser . createNewPage ( CodeGraph , urls . baseUrl ) ;
274+ await codeGraph . selectGraph ( GRAPH_ID ) ;
275+ await codeGraph . clickOnshowPathBtn ( ) ;
276+ await codeGraph . insertInputForShowPath ( "1" , Node_Import_Data ) ;
277+ await codeGraph . insertInputForShowPath ( "2" , Node_Add_Edge ) ;
278+ const result = await codeGraph . getCanvasAnalysis ( ) ;
279+
280+ const res = [ ] ;
281+ for ( const node of result . green ) {
282+ await codeGraph . rightClickOnNode ( node . x , node . y ) ;
283+ const details = await codeGraph . getNodeDetailsHeader ( ) ;
284+ const nodeID = await codeGraph . getNodedetailsPanelID ( ) ;
285+ await codeGraph . clickOnNodeDetailsCloseBtn ( ) ;
286+ res . push ( { details, nodeID} ) ;
287+ }
288+ const ids : Set < string > = new Set (
289+ res . filter ( item => item . details . includes ( Node_Import_Data . toUpperCase ( ) ) || item . details . includes ( Node_Add_Edge . toUpperCase ( ) ) ) . map ( item => item . nodeID )
290+ ) ;
291+ const sortedIds = Array . from ( ids ) . map ( id => parseInt ( id , 10 ) ) . sort ( ( a , b ) => a - b ) ;
292+ const api = new ApiCalls ( ) ;
293+ const response = await api . showPath ( PROJECT_NAME , sortedIds [ 0 ] . toString ( ) , sortedIds [ 1 ] . toString ( ) ) ;
294+ const containsDetails = res . some ( resItem =>
295+ response . result . paths . some ( path =>
296+ path . some ( item =>
297+ item . properties ?. name
298+ ? resItem . details . toUpperCase ( ) . includes ( item . properties . name . toUpperCase ( ) )
299+ : false
300+ )
301+ )
302+ ) ;
303+ expect ( containsDetails ) . toBe ( true ) ;
304+ } ) ;
218305
219306} ) ;
0 commit comments