Skip to content

Commit d9609cd

Browse files
committed
fix pom
1 parent 00627b7 commit d9609cd

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

e2e/logic/POM/codeGraph.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,9 @@ export default class CodeGraph extends BasePage {
479479
}
480480

481481
async clickOnRemoveNodeViaElementMenu(): Promise<void> {
482-
const button = this.elementMenuButton("Remove");
483-
const isVisible = await waitForElementToBeVisible(button);
484-
if (!isVisible) throw new Error("'Remove' button is not visible!");
485-
await button.click();
482+
await interactWhenVisible(
483+
this.elementMenuButton("Remove"), (el) => el.click(), 'Remove button'
484+
);
486485
}
487486

488487
async nodeClick(x: number, y: number): Promise<void> {
@@ -546,10 +545,9 @@ export default class CodeGraph extends BasePage {
546545
}
547546

548547
async clickOnViewNode(): Promise<void> {
549-
const button = this.elementMenuButton("View Node");
550-
const isButtonVisible = await waitForElementToBeVisible(button);
551-
if (!isButtonVisible) throw new Error("'View Node' button is not visible!");
552-
await button.click();
548+
await interactWhenVisible(
549+
this.elementMenuButton("View Node"), (el) => el.click(), 'View Node button'
550+
);
553551
}
554552

555553
async getNodeDetailsHeader(): Promise<string> {
@@ -582,10 +580,9 @@ export default class CodeGraph extends BasePage {
582580
}
583581

584582
async clickOnCopyToClipboard(): Promise<string> {
585-
const button = this.elementMenuButton("Copy src to clipboard");
586-
const isVisible = await waitForElementToBeVisible(button);
587-
if (!isVisible) throw new Error("View Node button is not visible!");
588-
await button.click();
583+
await interactWhenVisible(
584+
this.elementMenuButton("Copy src to clipboard"), (el) => el.click(), 'Copy src to clipboard button'
585+
);
589586
return await this.page.evaluate(() => navigator.clipboard.readText());
590587
}
591588

@@ -594,14 +591,12 @@ export default class CodeGraph extends BasePage {
594591
}
595592

596593
async getNodeDetailsPanelElements(): Promise<string[]> {
597-
const button = this.elementMenuButton("View Node");
598-
const isVisible = await waitForElementToBeVisible(button);
599-
if (!isVisible) throw new Error("View Node button is not visible!");
600-
await button.click();
601-
602-
const isPanelVisible = await waitForElementToBeVisible(this.nodedetailsPanelElements.first());
603-
if (!isPanelVisible) throw new Error("Node details panel did not appear!");
604-
594+
await interactWhenVisible(
595+
this.elementMenuButton("View Node"), (el) => el.click(), 'View Node button'
596+
);
597+
await interactWhenVisible(
598+
this.nodedetailsPanelElements.first(), async () => {}, 'Node details panel'
599+
);
605600
const elements = await this.nodedetailsPanelElements.all();
606601
return Promise.all(elements.map(element => element.innerHTML()));
607602
}
@@ -689,11 +684,21 @@ export default class CodeGraph extends BasePage {
689684
}
690685

691686
async rightClickAtCanvasCenter(): Promise<void> {
687+
await this.waitForCanvasAnimationToEnd();
692688
const boundingBox = await this.canvasElement.boundingBox();
693689
if (!boundingBox) throw new Error('Canvas bounding box not found');
694690
const centerX = boundingBox.x + boundingBox.width / 2;
695691
const centerY = boundingBox.y + boundingBox.height / 2;
696-
await this.page.mouse.click(centerX, centerY, { button: 'right' });
692+
for (let attempt = 1; attempt <= 3; attempt++) {
693+
await this.page.mouse.move(centerX, centerY);
694+
await this.page.waitForTimeout(500);
695+
await this.page.mouse.click(centerX, centerY, { button: 'right' });
696+
if (await this.elementMenu.isVisible()) {
697+
return;
698+
}
699+
await this.page.waitForTimeout(1000);
700+
}
701+
throw new Error('Element menu not visible after right-clicking at canvas center');
697702
}
698703

699704
async hoverAtCanvasCenter(): Promise<void> {

0 commit comments

Comments
 (0)