Skip to content

Commit b1e633c

Browse files
committed
canvas tests (#258, #262)
1 parent 19fcbd6 commit b1e633c

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

e2e/logic/POM/codeGraph.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ export default class CodeGraph extends BasePage {
136136
private get removeNodeViaElementMenu(): Locator {
137137
return this.page.locator("//button[@title='Remove']");
138138
}
139-
139+
140+
private get codeGraphCheckbox(): (checkbox: string) => Locator {
141+
return (checkbox: string) => this.page.locator(`(//button[@role='checkbox'])[${checkbox}]`);
142+
}
143+
144+
private get clearGraphBtn(): Locator {
145+
return this.page.locator("//button[p[text()='Clear Graph']]");
146+
}
147+
140148
/* NavBar functionality */
141149
async clickOnFalkorDbLogo(): Promise<Page> {
142150
await this.page.waitForLoadState('networkidle');
@@ -266,7 +274,6 @@ export default class CodeGraph extends BasePage {
266274
return await this.searchBarInput.inputValue();
267275
}
268276

269-
270277
async scrollToBottomInSearchBarList(): Promise<void> {
271278
await this.searchBarList.evaluate((element) => {
272279
element.scrollTop = element.scrollHeight;
@@ -279,7 +286,7 @@ export default class CodeGraph extends BasePage {
279286
}
280287

281288
/* Canvas functionality */
282-
289+
283290
async getCanvasAnalysis(): Promise<CanvasAnalysisResult> {
284291
await delay(2000);
285292
return await analyzeCanvasWithLocator(this.canvasElement);
@@ -307,5 +314,12 @@ export default class CodeGraph extends BasePage {
307314
const adjustedY = boundingBox.y + Math.round(y);
308315
await this.page.mouse.click(adjustedX, adjustedY, { button: 'right' });
309316
}
310-
317+
318+
async selectCodeGraphCheckbox(checkbox: string): Promise<void> {
319+
await this.codeGraphCheckbox(checkbox).click();
320+
}
321+
322+
async clickOnClearGraphBtn(): Promise<void> {
323+
await this.clearGraphBtn.click();
324+
}
311325
}

e2e/tests/codeGraph.spec.ts

Lines changed: 27 additions & 1 deletion
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 } from "../config/constants";
5+
import { GRAPH_ID, Node_Add_Edge, Node_Import_Data } from "../config/constants";
66
import { delay } from "../logic/utils";
77
import { searchData, specialCharacters } from "../config/testData";
88
import { CanvasAnalysisResult } from "../logic/canvasAnalysis";
@@ -126,4 +126,30 @@ test.describe("Code graph tests", () => {
126126
expect(initialNodeAnalysis.red.length).toBeGreaterThan(updatedNodeAnalysis.red.length);
127127
});
128128

129+
colors.forEach((color, index) => {
130+
const checkboxIndex = index + 1;
131+
test(`Verify that unchecking the ${color} checkbox hides ${color} nodes on the canvas`, async () => {
132+
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
133+
await codeGraph.selectGraph(GRAPH_ID);
134+
await codeGraph.selectCodeGraphCheckbox(checkboxIndex.toString());
135+
const result = await codeGraph.getCanvasAnalysis();
136+
expect(result[color].length).toBe(0);
137+
});
138+
})
139+
140+
test(`Verify "Clear graph" button resets canvas view`, async () => {
141+
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
142+
await codeGraph.selectGraph(GRAPH_ID);
143+
const initialAnalysis = await codeGraph.getCanvasAnalysis();
144+
const initialNodeCount = initialAnalysis.green.length + initialAnalysis.yellow.length + initialAnalysis.red.length;
145+
await codeGraph.clickOnshowPathBtn();
146+
await codeGraph.insertInputForShowPath("1", Node_Import_Data);
147+
await codeGraph.insertInputForShowPath("2", Node_Add_Edge);
148+
await codeGraph.clickOnClearGraphBtn();
149+
const finalAnalysis = await codeGraph.getCanvasAnalysis();
150+
const finalNodeCount = finalAnalysis.green.length + finalAnalysis.yellow.length + finalAnalysis.red.length;
151+
expect(initialNodeCount).toBe(finalNodeCount);
152+
153+
});
154+
129155
});

0 commit comments

Comments
 (0)