Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backmerge: #5184 – Fix unresolved monomers bond establishing issue #5258

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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
Loading