Skip to content

Commit a4f60a9

Browse files
committed
tests (#265, #287, #288, #289)
1 parent b1e633c commit a4f60a9

File tree

5 files changed

+118
-4
lines changed

5 files changed

+118
-4
lines changed

app/components/chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
498498
</button>
499499
<form className="grow flex items-center border rounded-md px-2" onSubmit={sendQuery}>
500500
<DropdownMenuTrigger asChild>
501-
<button className="bg-gray-200 p-2 rounded-md hover:bg-gray-300">
501+
<button data-name="questionOptionsMenu" className="bg-gray-200 p-2 rounded-md hover:bg-gray-300">
502502
<ArrowDown color="white" />
503503
</button>
504504
</DropdownMenuTrigger>

e2e/logic/POM/codeGraph.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ export default class CodeGraph extends BasePage {
2121
return this.page.locator("//div[@role='dialog']")
2222
}
2323

24+
private get tipBtn(): Locator {
25+
return this.page.locator("//button[@title='Tip']")
26+
}
27+
28+
private get genericMenu(): Locator {
29+
return this.page.locator("//div[contains(@role, 'menu')]")
30+
}
31+
32+
private get tipMenuCloseBtn(): Locator {
33+
return this.page.locator("//div[@role='menu']//button[@title='Close']")
34+
}
35+
2436
/* CodeGraph Locators*/
2537
private get comboBoxbtn(): Locator {
2638
return this.page.locator("//button[@role='combobox']")
@@ -115,6 +127,22 @@ export default class CodeGraph extends BasePage {
115127
return this.page.locator("//div[@role='region']//ol//li");
116128
}
117129

130+
private get notificationErrorCloseBtn(): Locator {
131+
return this.page.locator("//div[@role='region']//ol//li/button");
132+
}
133+
134+
private get questionOptionsMenu(): Locator {
135+
return this.page.locator("//button[@data-name='questionOptionsMenu']");
136+
}
137+
138+
private get selectQuestionInMenu(): (questionNumber: string) => Locator {
139+
return (questionNumber: string) => this.page.locator(`//div[contains(@role, 'menu')]/button[${questionNumber}]`);
140+
}
141+
142+
private get lastQuestionInChat(): Locator {
143+
return this.page.locator("//main[@data-name='main-chat']/*[last()-1]/p");
144+
}
145+
118146
/* Canvas Locators*/
119147

120148
private get canvasElement(): Locator {
@@ -172,6 +200,18 @@ export default class CodeGraph extends BasePage {
172200
return await this.createNewProjectDialog.isVisible();
173201
}
174202

203+
async clickonTipBtn(): Promise<void> {
204+
await this.tipBtn.click();
205+
}
206+
207+
async isTipMenuVisible(): Promise<boolean> {
208+
return await this.genericMenu.isVisible();
209+
}
210+
211+
async clickonTipMenuCloseBtn(): Promise<void> {
212+
await this.tipMenuCloseBtn.click();
213+
}
214+
175215
/* Chat functionality */
176216
async clickOnshowPathBtn(): Promise<void> {
177217
await this.showPathBtn.click();
@@ -232,9 +272,27 @@ export default class CodeGraph extends BasePage {
232272
}
233273

234274
async isNotificationError(): Promise<boolean> {
275+
await delay(500);
235276
return await this.notificationError.isVisible();
236277
}
237278

279+
async clickOnNotificationErrorCloseBtn(): Promise<void> {
280+
await this.notificationErrorCloseBtn.click();
281+
}
282+
283+
async clickOnQuestionOptionsMenu(): Promise<void> {
284+
await this.questionOptionsMenu.click();
285+
}
286+
287+
async selectAndGetQuestionInOptionsMenu(questionNumber: string): Promise<string> {
288+
await this.selectQuestionInMenu(questionNumber).click();
289+
return await this.selectQuestionInMenu(questionNumber).innerHTML();
290+
}
291+
292+
async getLastQuestionInChat(): Promise<string> {
293+
return await this.lastQuestionInChat.innerText();
294+
}
295+
238296
/* CodeGraph functionality */
239297
async selectGraph(graph: string): Promise<void> {
240298
await this.comboBoxbtn.click();
@@ -322,4 +380,18 @@ export default class CodeGraph extends BasePage {
322380
async clickOnClearGraphBtn(): Promise<void> {
323381
await this.clearGraphBtn.click();
324382
}
383+
384+
async changeNodePosition(x: number, y: number): Promise<void> {
385+
const box = (await this.canvasElement.boundingBox())!;
386+
const targetX = x + 100;
387+
const targetY = y + 50;
388+
const absStartX = box.x + x;
389+
const absStartY = box.y + y;
390+
const absEndX = box.x + targetX;
391+
const absEndY = box.y + targetY;
392+
await this.page.mouse.move(absStartX, absStartY);
393+
await this.page.mouse.down();
394+
await this.page.mouse.move(absEndX, absEndY);
395+
await this.page.mouse.up();
396+
}
325397
}

e2e/tests/chat.spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,24 @@ test.describe("Chat tests", () => {
7676
expect(await chat.isNotificationError()).toBe(true);
7777
});
7878

79-
test("Validate error notification when sending an empty question in chat", async () => {
79+
test("Validate error notification and its closure when sending an empty question in chat", async () => {
8080
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
8181
await chat.selectGraph(GRAPH_ID);
8282
await chat.clickAskquestionBtn();
83-
await delay(500);
8483
expect(await chat.isNotificationError()).toBe(true);
84+
await chat.clickOnNotificationErrorCloseBtn();
85+
expect(await chat.isNotificationError()).toBe(false);
8586
});
87+
88+
for (let index = 0; index < 5; index++) {
89+
const questionNumber = index + 1;
90+
test(`Validate displaying question ${index} in chat after selection from options menu`, async () => {
91+
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
92+
await chat.selectGraph(GRAPH_ID);
93+
await chat.clickOnQuestionOptionsMenu();
94+
const selectedQuestion = await chat.selectAndGetQuestionInOptionsMenu(questionNumber.toString());
95+
expect(selectedQuestion).toEqual(await chat.getLastQuestionInChat())
96+
});
97+
}
8698

8799
});

e2e/tests/codeGraph.spec.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,29 @@ test.describe("Code graph tests", () => {
149149
const finalAnalysis = await codeGraph.getCanvasAnalysis();
150150
const finalNodeCount = finalAnalysis.green.length + finalAnalysis.yellow.length + finalAnalysis.red.length;
151151
expect(initialNodeCount).toBe(finalNodeCount);
152-
153152
});
154153

154+
for (let index = 0; index < 3; index++) {
155+
const checkboxIndex = index + 1;
156+
test(`Verify selecting different graphs displays nodes in canvas - Iteration ${index + 1}`, async () => {
157+
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
158+
await codeGraph.selectGraph(checkboxIndex.toString());
159+
const result = await codeGraph.getCanvasAnalysis();
160+
const nodesLength = result.green.length + result.yellow.length + result.red.length;
161+
expect(nodesLength).toBeGreaterThan(1);
162+
});
163+
}
164+
165+
colors.forEach((color) => {
166+
test(`Validate canvas node dragging for color: ${color}`, async () => {
167+
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
168+
await codeGraph.selectGraph(GRAPH_ID);
169+
const initialAnalysis = await codeGraph.getCanvasAnalysis();
170+
await codeGraph.changeNodePosition(initialAnalysis[color][0].x, initialAnalysis[color][0].y);
171+
const finalAnalysis = await codeGraph.getCanvasAnalysis();
172+
expect(finalAnalysis[color][0].x).not.toBe(initialAnalysis.green[0].x);
173+
expect(finalAnalysis[color][0].y).not.toBe(initialAnalysis.green[0].y);
174+
});
175+
})
176+
155177
});

e2e/tests/navBar.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ test.describe(' Navbar tests', () => {
3838
await navBar.clickCreateNewProjectBtn();
3939
expect(await navBar.isCreateNewProjectDialog()).toBe(true)
4040
})
41+
42+
test("Validate Tip popup visibility and closure functionality", async () => {
43+
const navBar = await browser.createNewPage(CodeGraph, urls.baseUrl);
44+
await navBar.clickonTipBtn();
45+
expect(await navBar.isTipMenuVisible()).toBe(true);
46+
await navBar.clickonTipMenuCloseBtn();
47+
expect(await navBar.isTipMenuVisible()).toBe(false);
48+
});
4149
});

0 commit comments

Comments
 (0)