Skip to content

Commit 83b8cba

Browse files
committed
adjust tests for mobile responsiveness
1 parent 9fee1e6 commit 83b8cba

10 files changed

Lines changed: 168 additions & 149 deletions

File tree

app/components/toolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function Toolbar({ chartRef, className, handleDownloadImage }: Props) {
4949
</button>
5050
<button
5151
className="hidden md:block control-button"
52+
title="downloadImage"
5253
onClick={handleDownloadImage}
5354
>
5455
<Download />

app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export default function Home() {
275275

276276
return (
277277
<main className="h-[100dvh]">
278-
<div className='md:flex md:flex-col hidden h-screen'>
278+
<div className='md:flex md:flex-col hidden h-screen' id='desktop'>
279279
<header className="flex flex-col text-xl">
280280
<div className="flex items-center justify-between py-4 px-8">
281281
<div className="flex gap-4 items-center">
@@ -441,7 +441,7 @@ export default function Home() {
441441
</Panel>
442442
</PanelGroup>
443443
</div>
444-
<div className='flex flex-col md:hidden h-full overflow-hidden'>
444+
<div className='flex flex-col md:hidden h-full overflow-hidden' id='mobile'>
445445
<header className='flex justify-center items-center relative bg-gray-100'>
446446
<Link href="https://www.falkordb.com" target='_blank'>
447447
<Image priority style={{ width: 'auto', height: '70px', background: "transparent" }} src="/code-graph-logo.svg" alt="FalkorDB" width={0} height={0} />

e2e/config/constants.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export const GRAPH_ID = "GraphRAG-SDK";
2-
export const PROJECT_NAME = "GraphRAG-SDK";
3-
export const PROJECT_CLICK = "flask";
4-
export const CHAT_OPTTIONS_COUNT = 1;
1+
export const GRAPHRAG_SDK = "GraphRAG-SDK";
2+
export const FLASK_GRAPH = "flask";
3+
export const CHAT_OPTTIONS_COUNT = 6;
54
export const Node_Question = "how many nodes do we have?";
65
export const Edge_Question = "how many edges do we have?";

e2e/logic/POM/codeGraph.ts

Lines changed: 93 additions & 78 deletions
Large diffs are not rendered by default.

e2e/logic/utils.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,20 @@ export const waitForStableText = async (locator: Locator, timeout: number = 5000
3434
return stableText;
3535
};
3636

37-
export const waitForElementToBeVisible = async (locator:Locator,time=500,retry=10):Promise<boolean> => {
38-
39-
while(retry > 0){
40-
if(await locator.isVisible()){
41-
return true
42-
}
43-
retry = retry-1
44-
await delay(time)
37+
export const waitForElementToBeVisible = async (locator: Locator, time = 500, retry = 10): Promise<boolean> => {
38+
for (let i = 0; i < retry; i++) {
39+
try {
40+
if (await locator.isVisible()) {
41+
return true;
42+
}
43+
} catch (error) {
44+
console.error(`Error checking element visibility: ${error}`);
45+
}
46+
await new Promise(resolve => setTimeout(resolve, time)); // Delay
4547
}
46-
return false
47-
}
48+
return false;
49+
};
50+
4851

4952
export function findNodeByName(nodes: { name: string }[], nodeName: string): any {
5053
return nodes.find((node) => node.name === nodeName);

e2e/tests/canvas.spec.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";
22
import BrowserWrapper from "../infra/ui/browserWrapper";
33
import CodeGraph from "../logic/POM/codeGraph";
44
import urls from "../config/urls.json";
5-
import { GRAPH_ID, PROJECT_NAME } from "../config/constants";
5+
import { GRAPHRAG_SDK } from "../config/constants";
66
import { delay, findNodeByName } from "../logic/utils";
77
import { nodesPath, categories, nodes, graphs } from "../config/testData";
88
import { ApiCalls } from "../logic/api/apiCalls";
@@ -21,7 +21,7 @@ test.describe("Canvas tests", () => {
2121

2222
test(`Verify zoom in functionality on canvas`, async () => {
2323
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
24-
await codeGraph.selectGraph(GRAPH_ID);
24+
await codeGraph.selectGraph(GRAPHRAG_SDK);
2525
const initialGraph = await codeGraph.getCanvasScaling();
2626
await codeGraph.clickZoomIn();
2727
await codeGraph.clickZoomIn();
@@ -32,7 +32,7 @@ test.describe("Canvas tests", () => {
3232

3333
test(`Verify zoom out functionality on canvas`, async () => {
3434
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
35-
await codeGraph.selectGraph(GRAPH_ID);
35+
await codeGraph.selectGraph(GRAPHRAG_SDK);
3636
const initialGraph = await codeGraph.getCanvasScaling();
3737
await codeGraph.clickZoomOut();
3838
await codeGraph.clickZoomOut();
@@ -43,7 +43,7 @@ test.describe("Canvas tests", () => {
4343

4444
test(`Verify center graph button centers nodes in canvas`, async () => {
4545
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
46-
await codeGraph.selectGraph(GRAPH_ID);
46+
await codeGraph.selectGraph(GRAPHRAG_SDK);
4747
await codeGraph.clickCenter();
4848
const initialGraph = await codeGraph.getCanvasScaling();
4949
await codeGraph.clickZoomOut();
@@ -57,7 +57,7 @@ test.describe("Canvas tests", () => {
5757
nodes.slice(0,2).forEach((node) => {
5858
test(`Validate node hide functionality via element menu in canvas for ${node.nodeName}`, async () => {
5959
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
60-
await codeGraph.selectGraph(GRAPH_ID);
60+
await codeGraph.selectGraph(GRAPHRAG_SDK);
6161
const initialGraph = await codeGraph.getGraphDetails();
6262
const convertCoordinates = await codeGraph.transformNodeCoordinates(initialGraph);
6363
const targetNode = findNodeByName(convertCoordinates, node.nodeName);
@@ -72,7 +72,7 @@ test.describe("Canvas tests", () => {
7272
nodes.slice(0,2).forEach((node) => {
7373
test(`Validate unhide node functionality after hiding a node in canvas for ${node.nodeName}`, async () => {
7474
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
75-
await codeGraph.selectGraph(GRAPH_ID);
75+
await codeGraph.selectGraph(GRAPHRAG_SDK);
7676
const initialGraph = await codeGraph.getGraphDetails();
7777
const convertCoordinates = await codeGraph.transformNodeCoordinates(initialGraph);
7878
const targetNode = findNodeByName(convertCoordinates, node.nodeName);
@@ -89,7 +89,7 @@ test.describe("Canvas tests", () => {
8989
const checkboxIndex = index + 1;
9090
test(`Verify that unchecking the ${category} checkbox hides ${category} nodes on the canvas`, async () => {
9191
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
92-
await codeGraph.selectGraph(GRAPH_ID);
92+
await codeGraph.selectGraph(GRAPHRAG_SDK);
9393
await codeGraph.selectCodeGraphCheckbox(checkboxIndex.toString());
9494
const result = await codeGraph.getGraphDetails();
9595
const findItem = result.categories.find((item: { name: string; }) => item.name === category)
@@ -100,8 +100,9 @@ test.describe("Canvas tests", () => {
100100
nodesPath.forEach((path) => {
101101
test(`Verify "Clear graph" button resets canvas view for path ${path.firstNode} and ${path.secondNode}`, async () => {
102102
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
103-
await codeGraph.selectGraph(GRAPH_ID);
104-
await codeGraph.clickOnShowPathBtn();
103+
await browser.setPageToFullScreen();
104+
await codeGraph.selectGraph(GRAPHRAG_SDK);
105+
await codeGraph.clickOnShowPathBtn("Show the path");
105106
await codeGraph.insertInputForShowPath("1", path.firstNode);
106107
await codeGraph.insertInputForShowPath("2", path.secondNode);
107108
const initialGraph = await codeGraph.getGraphDetails();
@@ -127,12 +128,12 @@ test.describe("Canvas tests", () => {
127128
expect(result.elements.links.length).toBeGreaterThan(1);
128129
});
129130
})
130-
131+
131132
for (let index = 0; index < 3; index++) {
132133
const nodeIndex: number = index + 1;
133134
test(`Validate canvas node dragging for node: ${index}`, async () => {
134135
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
135-
await codeGraph.selectGraph(GRAPH_ID);
136+
await codeGraph.selectGraph(GRAPHRAG_SDK);
136137
const initialGraph = await codeGraph.getGraphDetails();
137138
const convertCoordinates = await codeGraph.transformNodeCoordinates(initialGraph);
138139
await codeGraph.changeNodePosition(convertCoordinates[nodeIndex].screenX, convertCoordinates[nodeIndex].screenY);
@@ -144,21 +145,21 @@ test.describe("Canvas tests", () => {
144145

145146
test(`Validate node and edge counts in canvas match API data`, async () => {
146147
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
147-
await codeGraph.selectGraph(GRAPH_ID);
148+
await codeGraph.selectGraph(GRAPHRAG_SDK);
148149
const { nodes, edges } = await codeGraph.getMetricsPanelInfo();
149150
const api = new ApiCalls();
150-
const response = await api.projectInfo(PROJECT_NAME);
151+
const response = await api.projectInfo(GRAPHRAG_SDK);
151152
expect(response.result.info.node_count).toEqual(parseInt(nodes));
152153
expect(response.result.info.edge_count).toEqual(parseInt(edges));
153154
});
154155

155156

156157
test(`Validate displayed nodes match API response after selecting a graph via UI`, async () => {
157158
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
158-
await codeGraph.selectGraph(GRAPH_ID);
159+
await codeGraph.selectGraph(GRAPHRAG_SDK);
159160
const graphData = await codeGraph.getGraphDetails();
160161
const api = new ApiCalls();
161-
const response = await api.getProject(PROJECT_NAME);
162+
const response = await api.getProject(GRAPHRAG_SDK);
162163
const isMatching = graphData.elements.nodes.slice(0, 2).every(
163164
(node: any, index: number) => node.name === response.result.entities.nodes[index].properties.name
164165
);
@@ -168,8 +169,8 @@ test.describe("Canvas tests", () => {
168169
nodesPath.forEach(({firstNode, secondNode}) => {
169170
test(`Verify successful node path connection in canvas between ${firstNode} and ${secondNode} via UI`, async () => {
170171
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
171-
await codeGraph.selectGraph(GRAPH_ID);
172-
await codeGraph.clickOnShowPathBtn();
172+
await codeGraph.selectGraph(GRAPHRAG_SDK);
173+
await codeGraph.clickOnShowPathBtn("Show the path");
173174
await codeGraph.insertInputForShowPath("1", firstNode);
174175
await codeGraph.insertInputForShowPath("2", secondNode);
175176
const result = await codeGraph.getGraphDetails();
@@ -183,16 +184,16 @@ test.describe("Canvas tests", () => {
183184
nodesPath.forEach((path) => {
184185
test(`Validate node path connection in canvas ui and confirm via api for path ${path.firstNode} and ${path.secondNode}`, async () => {
185186
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
186-
await codeGraph.selectGraph(GRAPH_ID);
187-
await codeGraph.clickOnShowPathBtn();
187+
await codeGraph.selectGraph(GRAPHRAG_SDK);
188+
await codeGraph.clickOnShowPathBtn("Show the path");
188189
await codeGraph.insertInputForShowPath("1", path.firstNode);
189190
await codeGraph.insertInputForShowPath("2", path.secondNode);
190191
const result = await codeGraph.getGraphDetails();
191192
const firstNodeRes = findNodeByName(result.elements.nodes, path.firstNode);
192193
const secondNodeRes = findNodeByName(result.elements.nodes, path.secondNode);
193194

194195
const api = new ApiCalls();
195-
const response = await api.showPath(PROJECT_NAME ,firstNodeRes.id, secondNodeRes.id);
196+
const response = await api.showPath(GRAPHRAG_SDK ,firstNodeRes.id, secondNodeRes.id);
196197
const callsRelationObject = response.result.paths[0].find(item => item.relation === "CALLS")
197198
expect(callsRelationObject?.src_node).toBe(firstNodeRes.id);
198199
expect(callsRelationObject?.dest_node).toBe(secondNodeRes.id);
@@ -201,7 +202,7 @@ test.describe("Canvas tests", () => {
201202

202203
test(`Verify file download is triggered and saved after clicking download`, async () => {
203204
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
204-
await codeGraph.selectGraph(GRAPH_ID);
205+
await codeGraph.selectGraph(GRAPHRAG_SDK);
205206
const download = await codeGraph.downloadImage();
206207
const downloadPath = await download.path();
207208
expect(fs.existsSync(downloadPath)).toBe(true);
@@ -211,7 +212,7 @@ test.describe("Canvas tests", () => {
211212
test(`Verify tooltip appears when hovering over node: ${node.nodeName}`, async () => {
212213
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
213214
await browser.setPageToFullScreen();
214-
await codeGraph.selectGraph(GRAPH_ID);
215+
await codeGraph.selectGraph(GRAPHRAG_SDK);
215216
await codeGraph.getGraphDetails();
216217
await codeGraph.fillSearchBar(node.nodeName);
217218
await codeGraph.selectSearchBarOptionBtn("1");

e2e/tests/chat.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import BrowserWrapper from "../infra/ui/browserWrapper";
33
import urls from "../config/urls.json";
44
import { ApiCalls } from "../logic/api/apiCalls";
55
import CodeGraph from "../logic/POM/codeGraph";
6-
import { CHAT_OPTTIONS_COUNT, GRAPH_ID, Node_Question, PROJECT_NAME } from "../config/constants";
6+
import { CHAT_OPTTIONS_COUNT, GRAPHRAG_SDK, Node_Question, } from "../config/constants";
77
import { delay } from "../logic/utils";
88
import { nodesPath } from "../config/testData";
99

@@ -20,15 +20,15 @@ test.describe("Chat tests", () => {
2020

2121
test(`Validate clicking the lightbulb button displays the correct options at the end of the chat`, async () => {
2222
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
23-
await chat.selectGraph(GRAPH_ID);
23+
await chat.selectGraph(GRAPHRAG_SDK);
2424
await chat.clickOnLightBulbBtn();
2525
const count = await chat.getLastChatElementButtonCount();
2626
expect(count).toBe(CHAT_OPTTIONS_COUNT);
2727
});
2828

2929
test(`Validate that multiple consecutive questions receive individual answers`, async () => {
3030
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
31-
await chat.selectGraph(GRAPH_ID);
31+
await chat.selectGraph(GRAPHRAG_SDK);
3232
const isLoadingArray: boolean[] = [];
3333

3434
for (let i = 0; i < 3; i++) {
@@ -45,7 +45,7 @@ test.describe("Chat tests", () => {
4545

4646
test("Verify auto-scroll and manual scroll in chat", async () => {
4747
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
48-
await chat.selectGraph(GRAPH_ID);
48+
await chat.selectGraph(GRAPHRAG_SDK);
4949
for (let i = 0; i < 3; i++) {
5050
await chat.sendMessage(Node_Question);
5151
await delay(3000);
@@ -61,7 +61,7 @@ test.describe("Chat tests", () => {
6161

6262
test(`Validate consistent UI responses for repeated questions in chat`, async () => {
6363
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
64-
await chat.selectGraph(GRAPH_ID);
64+
await chat.selectGraph(GRAPHRAG_SDK);
6565
const responses: string[] = [];
6666
for (let i = 0; i < 3; i++) {
6767
await chat.sendMessage(Node_Question);
@@ -76,9 +76,9 @@ test.describe("Chat tests", () => {
7676

7777
test(`Validate UI response matches API response for a given question in chat`, async () => {
7878
const api = new ApiCalls();
79-
const apiResponse = await api.askQuestion(PROJECT_NAME, Node_Question);
79+
const apiResponse = await api.askQuestion(GRAPHRAG_SDK, Node_Question);
8080
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
81-
await chat.selectGraph(GRAPH_ID);
81+
await chat.selectGraph(GRAPHRAG_SDK);
8282
await delay(3000);
8383
await chat.sendMessage(Node_Question);
8484
const uiResponse = await chat.getTextInLastChatElement();
@@ -90,8 +90,8 @@ test.describe("Chat tests", () => {
9090
nodesPath.forEach((path) => {
9191
test(`Verify successful node path connection between two nodes in chat for ${path.firstNode} and ${path.secondNode}`, async () => {
9292
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
93-
await chat.selectGraph(GRAPH_ID);
94-
await chat.clickOnShowPathBtn();
93+
await chat.selectGraph(GRAPHRAG_SDK);
94+
await chat.clickOnShowPathBtn("Show the path");
9595
await chat.insertInputForShowPath("1", path.firstNode);
9696
await chat.insertInputForShowPath("2", path.secondNode);
9797
expect(await chat.isNodeVisibleInLastChatPath(path.firstNode)).toBe(true);
@@ -102,8 +102,8 @@ test.describe("Chat tests", () => {
102102
nodesPath.forEach((path) => {
103103
test(`Verify unsuccessful node path connection between two nodes in chat for ${path.firstNode} and ${path.secondNode}`, async () => {
104104
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
105-
await chat.selectGraph(GRAPH_ID);
106-
await chat.clickOnShowPathBtn();
105+
await chat.selectGraph(GRAPHRAG_SDK);
106+
await chat.clickOnShowPathBtn("Show the path");
107107
await chat.insertInputForShowPath("1", path.secondNode);
108108
await chat.insertInputForShowPath("2", path.firstNode);
109109
await delay(500);
@@ -113,20 +113,20 @@ test.describe("Chat tests", () => {
113113

114114
test("Validate error notification and its closure when sending an empty question in chat", async () => {
115115
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
116-
await chat.selectGraph(GRAPH_ID);
116+
await chat.selectGraph(GRAPHRAG_SDK);
117117
await chat.clickAskQuestionBtn();
118118
expect(await chat.isNotificationError()).toBe(true);
119119
await chat.clickOnNotificationErrorCloseBtn();
120120
expect(await chat.isNotificationError()).toBe(false);
121121
});
122122

123-
for (let index = 0; index < 5; index++) {
123+
for (let index = 1; index < 6; index++) {
124124
const questionNumber = index + 1;
125125
test(`Validate displaying question ${index} in chat after selection from options menu`, async () => {
126126
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
127-
await chat.selectGraph(GRAPH_ID);
128-
await chat.clickOnQuestionOptionsMenu();
129-
const selectedQuestion = await chat.selectAndGetQuestionInOptionsMenu(questionNumber.toString());
127+
await chat.selectGraph(GRAPHRAG_SDK);
128+
await chat.clickOnLightBulbBtn();
129+
const selectedQuestion = await chat.selectAndGetQuestionInOptionsMenu(questionNumber.toString());
130130
expect(selectedQuestion).toEqual(await chat.getLastQuestionInChat())
131131
const result = await chat.getTextInLastChatElement();
132132
expect(result).toBeDefined();

e2e/tests/navBar.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test.describe(' Navbar tests', () => {
2121
})
2222

2323
const navitems: { navItem: string; expectedRes: string }[] = [
24-
{ navItem: "Home", expectedRes: urls.falkorDBUrl },
24+
{ navItem: "Main Website", expectedRes: urls.falkorDBUrl },
2525
{ navItem: "Github", expectedRes: urls.falkorDbGithubUrl }
2626
];
2727

0 commit comments

Comments
 (0)