Skip to content

Commit

Permalink
#4977 - System doesn't show side chain bonds if chain loaded directly…
Browse files Browse the repository at this point in the history
… to Snake-mode canvas (#5015)

- added snake layout operation after opening file if snake mode turned on
  • Loading branch information
rrodionov91 authored Jul 6, 2024
1 parent 9d23ee8 commit a23d3bb
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
openFileAndAddToCanvasMacro,
moveMouseAway,
scrollDown,
scrollUp,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import { bondTwoMonomers } from '@utils/macromolecules/polymerBond';
Expand Down Expand Up @@ -601,14 +602,15 @@ test.describe('Snake Bond Tool', () => {
*/
const x = 500;
const y = 300;
const x1 = 100;
const y1 = 100;
const x1 = 300;
const y1 = 300;
await selectSnakeLayoutModeTool(page);
await openFileAndAddToCanvasMacro(`KET/two-peptides-connected.ket`, page);
await takeEditorScreenshot(page);
await page.getByText('meE').locator('..').first().hover();
await dragMouseTo(x, y, page);
await page.mouse.click(x1, y1);
await moveMouseAway(page);
await takeEditorScreenshot(page);
});

Expand Down Expand Up @@ -680,8 +682,9 @@ test.describe('Snake Bond Tool', () => {
`KET/peptides-flex-chain.ket`,
page,
);
scrollUp(page, 200);
await takeEditorScreenshot(page);
await page.getByText('DHis1B').locator('..').first().hover();
await page.getByText('meS').locator('..').first().hover();
await dragMouseTo(x, y, page);
await page.mouse.click(x2, y2);
await takeEditorScreenshot(page);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ test.describe('Zoom Tool', () => {
Test case: Zoom Tool
Description: After zoom in on created long snake chain of peptides you can use scroll with Shift
*/
const wheelDelta = 200;
const wheelYDelta = -400;
const wheelXDelta = -400;
await selectSnakeLayoutModeTool(page);
await openFileAndAddToCanvasMacro(
'KET/peptides-connected-with-bonds.ket',
Expand All @@ -199,8 +200,9 @@ test.describe('Zoom Tool', () => {
});
}
await page.keyboard.down('Shift');
await page.mouse.wheel(0, wheelDelta);
await page.mouse.wheel(wheelXDelta, 0);
await page.keyboard.up('Shift');
await page.mouse.wheel(0, wheelYDelta);
await takeEditorScreenshot(page);
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ketcher-autotests/tests/utils/macromolecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export async function scrollDown(page: Page, scrollDelta: number) {
await page.mouse.wheel(0, scrollDelta);
}

export async function scrollUp(page: Page, scrollDelta: number) {
await moveMouseToTheMiddleOfTheScreen(page);
await page.mouse.wheel(0, -scrollDelta);
}

export async function chooseFileFormat(
page: Page,
fileFomat:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
EditorHistory,
SequenceMode,
macromoleculesFilesInputFormats,
ModeTypes,
SnakeMode,
} from 'ketcher-core';
import { IndigoProvider } from 'ketcher-react';
import { RequiredModalProps } from '../modalContainer';
Expand Down Expand Up @@ -137,14 +139,23 @@ const addToCanvas = ({
);
const editorHistory = new EditorHistory(editor);
const isSequenceMode = editor.mode instanceof SequenceMode;
const isSnakeMode = editor.mode instanceof SnakeMode;

editor.renderersContainer.update(modelChanges);
editorHistory.update(modelChanges);

if (isSequenceMode) {
modelChanges.setUndoOperationReverse();
editor.events.selectMode.dispatch({
mode: 'sequence-layout-mode',
mode: ModeTypes.sequence,
mergeWithLatestHistoryCommand: true,
});
}

if (isSnakeMode) {
modelChanges.setUndoOperationReverse();
editor.events.selectMode.dispatch({
mode: ModeTypes.snake,
mergeWithLatestHistoryCommand: true,
});
}
Expand Down

0 comments on commit a23d3bb

Please sign in to comment.