From 80f084a84ee1ea2ea9a95233e86a6213ae870ce1 Mon Sep 17 00:00:00 2001 From: Roman Rodionov Date: Fri, 11 Oct 2024 16:20:20 +0200 Subject: [PATCH] #5205 - Edit Connection points dialog can cause invalid connection between monomers (#5717) - fixed unstable test --- ketcher-autotests/tests/utils/clicks/index.ts | 4 ++++ .../ketcher-core/src/application/editor/Editor.ts | 9 +-------- .../modal/monomerConnection/MonomerConnections.tsx | 11 +++++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ketcher-autotests/tests/utils/clicks/index.ts b/ketcher-autotests/tests/utils/clicks/index.ts index 36d0e01565..ec59a6887b 100644 --- a/ketcher-autotests/tests/utils/clicks/index.ts +++ b/ketcher-autotests/tests/utils/clicks/index.ts @@ -194,6 +194,10 @@ export async function openDropdown(page: Page, dropdownElementId: DropdownIds) { const button = page.getByTestId(dropdownElementId); await button.isVisible(); await button.click({ delay: 200, clickCount: 2 }); + const dropdown = await page.locator('.default-multitool-dropdown'); + if (!(await dropdown.isVisible({ timeout: 200 }))) { + await button.click(); + } } export async function selectDropdownTool( diff --git a/packages/ketcher-core/src/application/editor/Editor.ts b/packages/ketcher-core/src/application/editor/Editor.ts index 627fbd8408..b84c073bb0 100644 --- a/packages/ketcher-core/src/application/editor/Editor.ts +++ b/packages/ketcher-core/src/application/editor/Editor.ts @@ -326,14 +326,7 @@ export class CoreEditor { initialFirstMonomerAttachmentPoint?: AttachmentPointName; initialSecondMonomerAttachmentPoint?: AttachmentPointName; }) { - if ( - payload.isReconnection && - payload.polymerBond && - (payload.firstSelectedAttachmentPoint !== - payload.initialFirstMonomerAttachmentPoint || - payload.secondSelectedAttachmentPoint !== - payload.initialSecondMonomerAttachmentPoint) - ) { + if (payload.isReconnection && payload.polymerBond) { const command = new Command(); const history = new EditorHistory(this); diff --git a/packages/ketcher-macromolecules/src/components/modal/monomerConnection/MonomerConnections.tsx b/packages/ketcher-macromolecules/src/components/modal/monomerConnection/MonomerConnections.tsx index 14992aa2f0..896dfb131a 100644 --- a/packages/ketcher-macromolecules/src/components/modal/monomerConnection/MonomerConnections.tsx +++ b/packages/ketcher-macromolecules/src/components/modal/monomerConnection/MonomerConnections.tsx @@ -118,6 +118,17 @@ const MonomerConnection = ({ throw new Error('Attachment points cannot be falsy'); } + if ( + firstSelectedAttachmentPoint === + initialFirstMonomerAttachmentPointRef.current && + secondSelectedAttachmentPoint === + initialSecondMonomerAttachmentPointRef.current + ) { + cancelBondCreationAndClose(); + + return; + } + editor.events.createBondViaModal.dispatch({ firstMonomer, secondMonomer,