Skip to content

Commit 123cda5

Browse files
committed
fix #289 test & locators
1 parent 8b5f9fe commit 123cda5

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

e2e/logic/POM/codeGraph.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ export default class CodeGraph extends BasePage {
3838
return this.page.locator("//button[@role='combobox']")
3939
}
4040

41-
private get selectGraphInComboBox(): (graph: string) => Locator {
41+
private get selectGraphInComboBoxByName(): (graph: string) => Locator {
4242
return (graph: string) => this.page.locator(`//div[@role='presentation']//div//span[contains(text(), '${graph}')]`);
4343
}
4444

45+
private get selectGraphInComboBoxById(): (graph: string) => Locator {
46+
return (graph: string) => this.page.locator(`//div[@role='presentation']//div[${graph}]`);
47+
}
48+
4549
private get lastElementInChat(): Locator {
4650
return this.page.locator("//main[@data-name='main-chat']/*[last()]/span");
4751
}
@@ -307,10 +311,15 @@ export default class CodeGraph extends BasePage {
307311
}
308312

309313
/* CodeGraph functionality */
310-
async selectGraph(graph: string): Promise<void> {
314+
async selectGraph(graph: string | number): Promise<void> {
311315
await this.comboBoxbtn.click();
312-
await this.selectGraphInComboBox(graph).waitFor({ state : 'visible'})
313-
await this.selectGraphInComboBox(graph).click();
316+
if(typeof graph === 'number'){
317+
await this.selectGraphInComboBoxById(graph.toString()).waitFor({ state : 'visible'})
318+
await this.selectGraphInComboBoxById(graph.toString()).click();
319+
} else {
320+
await this.selectGraphInComboBoxByName(graph).waitFor({ state : 'visible'})
321+
await this.selectGraphInComboBoxByName(graph).click();
322+
}
314323
}
315324

316325
async createProject(url : string): Promise<void> {

e2e/tests/codeGraph.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ test.describe("Code graph tests", () => {
164164
expect(initialNodeCount).toBe(finalNodeCount);
165165
});
166166

167-
for (let index = 0; index < 3; index++) {
167+
for (let index = 0; index < 2; index++) {
168168
const checkboxIndex = index + 1;
169169
test(`Verify selecting different graphs displays nodes in canvas - Iteration ${index + 1}`, async () => {
170170
const codeGraph = await browser.createNewPage(CodeGraph, urls.baseUrl);
171-
await codeGraph.selectGraph(checkboxIndex.toString());
171+
await codeGraph.selectGraph(checkboxIndex);
172172
const result = await codeGraph.getCanvasAnalysis();
173173
const nodesLength = result.green.length + result.yellow.length + result.red.length;
174174
expect(nodesLength).toBeGreaterThan(1);

0 commit comments

Comments
 (0)