diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts index 1d7d29a55d..214ec90097 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-len */ /* eslint-disable no-magic-numbers */ /* Tests below moved here from macro-micro-switcher since they are designed to be executed in isolated environment @@ -47,6 +48,9 @@ import { screenshotBetweenUndoRedoInMacro, copyAndPaste, copyToClipboardByKeyboard, + takePageScreenshot, + selectFlexLayoutModeTool, + selectSequenceLayoutModeTool, } from '@utils'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; @@ -57,7 +61,10 @@ import { verifyFileExport, } from '@utils/files/receiveFileComparisonData'; import { goToFavoritesTab } from '@utils/macromolecules/library'; -import { pressUndoButton } from '@utils/macromolecules/topToolBar'; +import { + pressRedoButton, + pressUndoButton, +} from '@utils/macromolecules/topToolBar'; async function addToFavoritesMonomers(page: Page) { await addMonomersToFavorites(page, [ @@ -727,4 +734,105 @@ test.describe('Macro-Micro-Switcher2', () => { ); await takeEditorScreenshot(page); }); + + test('Verify that flex mode is opened by default when a user enters macromolecules mode for the first time and there is a drawing on the canvas', async ({ + page, + }) => { + /* + Test case: https://github.com/epam/ketcher/issues/6029 + Description: Flex mode is opened by default when a user enters macromolecules mode for the first time and there is a drawing on the canvas + Case: + 1. Open KET file with drawing in Micro mode + 2. Switch to Macromolecules mode + 3. Verify that Flex mode is opened + */ + await openFileAndAddToCanvasAsNewProject( + 'KET/benzene-ring-with-two-atoms.ket', + page, + ); + await turnOnMacromoleculesEditor(page, false, false); + await takePageScreenshot(page); + }); + + test('Verify that flex mode is not opened by default if the user previously entered macromolecules mode change macro mode to (Snake, Sequence) and re-entering it from Micro mode', async ({ + page, + }) => { + /* + Test case: https://github.com/epam/ketcher/issues/6029 + Description: Flex mode is not opened by default if the user previously entered macromolecules mode change + macro mode to (Snake, Sequence) and re-entering it from Micro mode + Case: + 1. Switch to Macromolecules mode + 2. Change macro mode to Snake + 3. Switch to Micro mode + 4. Switch to Macromolecules mode + */ + await turnOnMacromoleculesEditor(page, false, false); + await selectSnakeLayoutModeTool(page); + await takePageScreenshot(page); + await turnOnMicromoleculesEditor(page); + await turnOnMacromoleculesEditor(page, false, false); + await takePageScreenshot(page); + }); + + test('Verify that flex mode is not triggered if the canvas is empty when the user enters macromolecules mode for the first time (Sequence mode by default)', async ({ + page, + }) => { + /* + Test case: https://github.com/epam/ketcher/issues/6029 + Description: Flex mode is not triggered if the canvas is empty when the user enters + macromolecules mode for the first time (Sequence mode by default) + Case: + 1. Switch to Macromolecules mode + 2. Verify that Sequence mode is opened + */ + await turnOnMacromoleculesEditor(page, false, false); + await takePageScreenshot(page); + }); + + test('Verify the behavior when the user manually switches to sequence mode after flex mode and then switches to micro and back to macro (Sequence should be by default)', async ({ + page, + }) => { + /* + Test case: https://github.com/epam/ketcher/issues/6029 + Description: Behavior when the user manually switches to sequence mode after flex mode and + then switches to micro and back to macro (Sequence should be by default) + Case: + 1. Switch to Macromolecules mode + 2. Change macro mode to Flex + 3. Change macro mode to Sequence + 4. Switch to Micro mode + 5. Switch to Macromolecules mode + */ + await turnOnMacromoleculesEditor(page, false, false); + await selectFlexLayoutModeTool(page); + await selectSequenceLayoutModeTool(page); + await turnOnMicromoleculesEditor(page); + await turnOnMacromoleculesEditor(page, false, false); + await takePageScreenshot(page); + }); + + test('Verify undo/redo functionality when entering macromolecules mode for the first time and modifying a drawing in flex mode (undo/redo not changes layout modes)', async ({ + page, + }) => { + /* + Test case: https://github.com/epam/ketcher/issues/6029 + Description: Undo/redo functionality when entering macromolecules mode for the first time and + modifying a drawing in flex mode (undo/redo not changes layout modes) + Case: + 1. Switch to Macromolecules mode + 2. Modify drawing in Flex mode + 3. Undo/redo + */ + await openFileAndAddToCanvasAsNewProject( + 'KET/benzene-ring-with-two-atoms.ket', + page, + ); + await turnOnMacromoleculesEditor(page, false, false); + await selectClearCanvasTool(page); + await pressUndoButton(page); + await takePageScreenshot(page); + await pressRedoButton(page); + await takePageScreenshot(page); + }); }); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-17135-rst-time-and-there-is-a-drawing-on-the-canvas-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-17135-rst-time-and-there-is-a-drawing-on-the-canvas-1-chromium-linux.png new file mode 100644 index 0000000000..f837e17d93 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-17135-rst-time-and-there-is-a-drawing-on-the-canvas-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-948f6-for-the-first-time-Sequence-mode-by-default-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-948f6-for-the-first-time-Sequence-mode-by-default-1-chromium-linux.png new file mode 100644 index 0000000000..90e25481a1 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-948f6-for-the-first-time-Sequence-mode-by-default-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-a16cc--Sequence-and-re-entering-it-from-Micro-mode-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-a16cc--Sequence-and-re-entering-it-from-Micro-mode-2-chromium-linux.png new file mode 100644 index 0000000000..b26367b50f Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-a16cc--Sequence-and-re-entering-it-from-Micro-mode-2-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-c9482--Sequence-and-re-entering-it-from-Micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-c9482--Sequence-and-re-entering-it-from-Micro-mode-1-chromium-linux.png new file mode 100644 index 0000000000..fe71e46028 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-that-flex-mode-is-c9482--Sequence-and-re-entering-it-from-Micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-the-behavior-when-7613d-back-to-macro-Sequence-should-be-by-default-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-the-behavior-when-7613d-back-to-macro-Sequence-should-be-by-default-1-chromium-linux.png new file mode 100644 index 0000000000..d3c51de21d Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-the-behavior-when-7613d-back-to-macro-Sequence-should-be-by-default-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-undo-redo-functio-7a5fa-lex-mode-undo-redo-not-changes-layout-modes-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-undo-redo-functio-7a5fa-lex-mode-undo-redo-not-changes-layout-modes-1-chromium-linux.png new file mode 100644 index 0000000000..63a29fd403 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-undo-redo-functio-7a5fa-lex-mode-undo-redo-not-changes-layout-modes-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-undo-redo-functio-fc366-lex-mode-undo-redo-not-changes-layout-modes-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-undo-redo-functio-fc366-lex-mode-undo-redo-not-changes-layout-modes-2-chromium-linux.png new file mode 100644 index 0000000000..4711a8bb9b Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Verify-undo-redo-functio-fc366-lex-mode-undo-redo-not-changes-layout-modes-2-chromium-linux.png differ diff --git a/ketcher-autotests/tests/utils/macromolecules/index.ts b/ketcher-autotests/tests/utils/macromolecules/index.ts index 1876db0007..eb8f7fe778 100644 --- a/ketcher-autotests/tests/utils/macromolecules/index.ts +++ b/ketcher-autotests/tests/utils/macromolecules/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-magic-numbers */ import { expect, Page } from '@playwright/test'; import { MACROMOLECULES_MODE, @@ -16,16 +17,28 @@ import { } from '@utils'; import { goToPeptidesTab } from './library'; -export async function turnOnMacromoleculesEditor(page: Page) { +export async function turnOnMacromoleculesEditor( + page: Page, + enableFlexMode = true, + goToPeptides = true, +) { await expect(page.getByTestId(POLYMER_TOGGLER)).toBeVisible(); await page.getByTestId(POLYMER_TOGGLER).click(); await expect(page.getByTestId(MACROMOLECULES_MODE)).toBeVisible(); await page.getByTestId(MACROMOLECULES_MODE).click(); await expect(page.getByTestId(LAYOUT_TOGGLER)).toBeVisible(); - await selectFlexLayoutModeTool(page); - await goToPeptidesTab(page); + + if (enableFlexMode) { + await selectFlexLayoutModeTool(page); + } + + if (goToPeptides) { + await goToPeptidesTab(page); + } + await page.evaluate(() => { // Temporary solution to disable autozoom for the polymer editor in e2e tests + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore window._ketcher_isAutozoomDisabled = true; });