Skip to content

Commit

Permalink
Backmerge: #5184 – Fix unresolved monomers bond establishing issue (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
svvald authored and Guch1g0v committed Oct 17, 2024
1 parent 474bd23 commit 3f2d3d5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -847,50 +847,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,
Expand Down
9 changes: 9 additions & 0 deletions packages/ketcher-core/src/application/editor/tools/Bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 3f2d3d5

Please sign in to comment.