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, 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() {