From fabfdafdd7fd548b5eb515686d0aa8246c822424 Mon Sep 17 00:00:00 2001 From: Nikita Chistousov Date: Thu, 8 Aug 2024 15:39:13 +0200 Subject: [PATCH 1/2] =?UTF-8?q?#5184=20=E2=80=93=20Fix=20unresolved=20mono?= =?UTF-8?q?mers=20bond=20establishing=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ketcher-core/src/application/editor/tools/Bond.ts | 9 +++++++++ .../src/domain/entities/UnresolvedMonomer.ts | 9 +++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/ketcher-core/src/application/editor/tools/Bond.ts b/packages/ketcher-core/src/application/editor/tools/Bond.ts index 93a7982115..1db7f7684e 100644 --- a/packages/ketcher-core/src/application/editor/tools/Bond.ts +++ b/packages/ketcher-core/src/application/editor/tools/Bond.ts @@ -28,6 +28,7 @@ import { Coordinates } from '../shared/coordinates'; import { AttachmentPointName } from 'domain/types'; import { AttachmentPoint } from 'domain/AttachmentPoint'; import { Command } from 'domain/entities/Command'; +import { UnresolvedMonomer } from 'domain/entities'; class PolymerBond implements BaseTool { private bondRenderer?: PolymerBondRenderer; @@ -493,6 +494,14 @@ class PolymerBond implements BaseTool { return true; } + // Modal: Any or both monomers are unresolved + if ( + firstMonomer instanceof UnresolvedMonomer || + secondMonomer instanceof UnresolvedMonomer + ) { + return true; + } + // Modal: One monomer is Peptide and another is RNA monomer const rnaMonomerClasses = [Sugar, RNABase, Phosphate]; const firstMonomerIsRNA = rnaMonomerClasses.find( diff --git a/packages/ketcher-core/src/domain/entities/UnresolvedMonomer.ts b/packages/ketcher-core/src/domain/entities/UnresolvedMonomer.ts index b6b6611f11..c3314fc02f 100644 --- a/packages/ketcher-core/src/domain/entities/UnresolvedMonomer.ts +++ b/packages/ketcher-core/src/domain/entities/UnresolvedMonomer.ts @@ -2,14 +2,15 @@ import { BaseMonomer } from './BaseMonomer'; import { ChemSubChain } from 'domain/entities/monomer-chains/ChemSubChain'; import { PeptideSubChain } from 'domain/entities/monomer-chains/PeptideSubChain'; import { SubChainNode } from 'domain/entities/monomer-chains/types'; +import { Peptide } from 'domain/entities/Peptide'; export class UnresolvedMonomer extends BaseMonomer { - public getValidSourcePoint(_monomer?: BaseMonomer) { - return undefined; + public getValidSourcePoint(monomer?: BaseMonomer) { + return Peptide.prototype.getValidSourcePoint.call(this, monomer); } - public getValidTargetPoint(_monomer: BaseMonomer) { - return undefined; + public getValidTargetPoint(monomer: BaseMonomer) { + return Peptide.prototype.getValidTargetPoint.call(this, monomer); } public get SubChainConstructor() { From 12990977730d2474c137740b9f6c6b5fed7a6849 Mon Sep 17 00:00:00 2001 From: Nikita Chistousov Date: Fri, 9 Aug 2024 14:29:20 +0200 Subject: [PATCH 2/2] =?UTF-8?q?#5184=20=E2=80=93=20Remove=20UI=20test=20ex?= =?UTF-8?q?pectation=20to=20fail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../import-saving-idt.spec.ts | 72 +++++++++---------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts index aa35f35df8..afc05bc86e 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts @@ -844,50 +844,42 @@ test.describe('Import-Saving .idt Files', () => { await takeEditorScreenshot(page); }); - test( - 'Delete bond between unresolved and known monomers connected through R2/R1 and Undo', - { tag: ['@IncorrectResultBecauseOfBug'] }, - async ({ page }) => { - /* - Test case: Import/Saving files/4431 - Description: Bond deleted and after pressing Undo appears. - Test working not a proper way because we have a bug https://github.com/epam/ketcher/issues/5184 - */ - test.fail(); - const x = 650; - const y = 400; - const firstMonomer = await page.getByText('iMe-dC').locator('..'); - const secondMonomer = await page.getByText('1Nal').locator('..').first(); - const bondLine = page.locator('g[pointer-events="stroke"]').first(); + test('Delete bond between unresolved and known monomers connected through R2/R1 and Undo', async ({ + page, + }) => { + const x = 650; + const y = 400; + const firstMonomer = await page.getByText('iMe-dC').locator('..'); + const secondMonomer = await page.getByText('1Nal').locator('..').first(); + const bondLine = page.locator('g[pointer-events="stroke"]').first(); - await pasteFromClipboardAndAddToMacromoleculesCanvas( - page, - 'IDT', - `/iMe-dC/`, - ); - await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); - await page.mouse.click(x, y); - await bondTwoMonomersPointToPoint( - page, - firstMonomer, - secondMonomer, - 'R2', - 'R1', - ); + await pasteFromClipboardAndAddToMacromoleculesCanvas( + page, + 'IDT', + `/iMe-dC/`, + ); + await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); + await page.mouse.click(x, y); + await bondTwoMonomersPointToPoint( + page, + firstMonomer, + secondMonomer, + 'R2', + 'R1', + ); - const bondExists = await bondLine.isVisible(); + const bondExists = await bondLine.isVisible(); - if (!bondExists) { - throw new Error('Bond line is not present, likely due to a known bug.'); - } + if (!bondExists) { + throw new Error('Bond line is not present, likely due to a known bug.'); + } - await selectEraseTool(page); - await bondLine.click(); - await takeEditorScreenshot(page); - await selectTopPanelButton(TopPanelButton.Undo, page); - await takeEditorScreenshot(page); - }, - ); + await selectEraseTool(page); + await bondLine.click(); + await takeEditorScreenshot(page); + await selectTopPanelButton(TopPanelButton.Undo, page); + await takeEditorScreenshot(page); + }); test('Delete bond between unresolved and known monomers connected through R3/R4 and Undo', async ({ page,