Skip to content

Commit 8e5dc72

Browse files
committed
fix test errors
1 parent 95518d4 commit 8e5dc72

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

e2e/logic/POM/codeGraph.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ export default class CodeGraph extends BasePage {
152152
return this.page.locator("//main[@data-name='main-chat']/*[last()-1]/p");
153153
}
154154

155+
private get responseLoadingImg(): Locator {
156+
return this.page.locator("//img[@alt='Waiting for response']");
157+
}
158+
155159
/* Canvas Locators*/
156160

157161
private get canvasElement(): Locator {
@@ -277,7 +281,8 @@ export default class CodeGraph extends BasePage {
277281
}
278282

279283
async getTextInLastChatElement(): Promise<string>{
280-
await delay(2500);
284+
await this.page.waitForSelector('img[alt="Waiting for response"]', { state: 'hidden' });
285+
await delay(2000);
281286
return (await this.lastElementInChat.textContent())!;
282287
}
283288

@@ -349,6 +354,7 @@ export default class CodeGraph extends BasePage {
349354
await this.selectGraphInComboBoxByName(graph).waitFor({ state : 'visible'})
350355
await this.selectGraphInComboBoxByName(graph).click();
351356
}
357+
await delay(2000); // graph animation delay
352358
}
353359

354360
async createProject(url : string): Promise<void> {
@@ -417,7 +423,7 @@ export default class CodeGraph extends BasePage {
417423

418424
async nodeClick(x: number, y: number): Promise<void> {
419425
await this.canvasElement.hover({ position: { x, y } });
420-
await this.canvasElement.click({ position: { x, y } });
426+
await this.canvasElement.click({ position: { x, y }, button: 'right' });
421427
}
422428

423429
async selectCodeGraphCheckbox(checkbox: string): Promise<void> {

e2e/tests/canvas.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ test.describe("Canvas tests", () => {
4343
test(`Verify center graph button centers nodes in canvas`, async () => {
4444
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
4545
await codeGraph.selectGraph(GRAPH_ID);
46+
await codeGraph.clickCenter();
4647
const initialGraph = await codeGraph.getCanvasScaling();
47-
4848
await codeGraph.clickZoomOut();
4949
await codeGraph.clickZoomOut();
5050
await codeGraph.clickCenter();
5151
const updatedGraph = await codeGraph.getCanvasScaling();
5252
expect(Math.abs(initialGraph.scaleX - updatedGraph.scaleX)).toBeLessThanOrEqual(0.1);
5353
expect(Math.abs(initialGraph.scaleY - updatedGraph.scaleY)).toBeLessThanOrEqual(0.1);
54-
5554
})
5655

5756
nodes.slice(0,2).forEach((node) => {

e2e/tests/chat.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,22 @@ test.describe("Chat tests", () => {
110110
const result = await chat.getTextInLastChatElement();
111111
const number = result.match(/\d+/g)?.[0]!;
112112
responses.push(number);
113+
113114
}
114115
const identicalResponses = responses.every((value) => value === responses[0]);
115116
expect(identicalResponses).toBe(true);
116117
});
117118

118119
test(`Validate UI response matches API response for a given question in chat`, async () => {
120+
const api = new ApiCalls();
121+
const apiResponse = await api.askQuestion(PROJECT_NAME, Node_Question);
119122
const chat = await browser.createNewPage(CodeGraph, urls.baseUrl);
120123
await chat.selectGraph(GRAPH_ID);
121124

122125
await chat.sendMessage(Node_Question);
123126
const uiResponse = await chat.getTextInLastChatElement();
124127
const number = uiResponse.match(/\d+/g)?.[0]!;
125128

126-
const api = new ApiCalls();
127-
const apiResponse = await api.askQuestion(PROJECT_NAME, Node_Question);
128129
expect(number).toEqual(apiResponse.result.response.match(/\d+/g)?.[0]);
129130
});
130131
});

0 commit comments

Comments
 (0)