Skip to content

Commit

Permalink
Autotests: #5832 - autotests expand macromolecules in micro mode 2 (#…
Browse files Browse the repository at this point in the history
…5913)

* First banch

* For Roman

* For roman 2

* - added clickOnAtomById helper

* Zoom coordinates recalculation added

* Verify that deleting an expanded monomer in a chain structure using the Erase tool cause Edit Abbreviations dialog to appear

* fix

* Verify that after using the Erase tool to delete an expanded monomer in both chain and ring structures, the Undo and Redo functionality works correctly, restoring or re-removing the expanded monomer and its bonds

* Move collapsed monomer on Micro and Undo

* Move expanded monomer on Micro and Undo

* Verify switching back from micro mode to macro mode with expanded and collapsed monomers

* Small fix

* first draft

* Verify saving collapsed monomers in Daylight SMARTS

* Saving collapsed monomer to SMARTS

* Last fix

* last fix

* lf 2

* lf3

* Micro molecules fix

* lf4

* Verify that expanding multiple monomers works in a left-to-right order within a chain fix

* Verify that expanding multiple monomers works in a top-to-bottom order within a chain fix

* Verify that expanding monomers with big mircomolecule ring structures in the middle behaves correctly without breaking the chain fix

* Verify that deleting an expanded monomer in a chain structure using the Erase tool cause Edit Abbreviations dialog to appear fix

* last fix

* lf2

* Move collapsed monomer on Micro and Undo fix

* Last fix

* last last fix

* One more try

* One more fix

* macro-micro-switcher.spec.ts:3232 update

* macro-micro-switcher.spec.ts:3093 update

* all the rest

* final

* Horizontal split

* one more fix

* On more try

* one more try

* and one more

* 260

* last one

* lf 2

---------

Co-authored-by: Roman Rodionov <roman_rodionov@epam.com>
  • Loading branch information
AlexeyGirin and rrodionov91 authored Nov 11, 2024
1 parent 94e560b commit 168e713
Show file tree
Hide file tree
Showing 354 changed files with 6,586 additions and 332 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from '@playwright/test';
import { expect, Page, test } from '@playwright/test';
import {
takeEditorScreenshot,
clickInTheMiddleOfTheScreen,
Expand All @@ -10,7 +10,10 @@ import {
saveToFile,
receiveFileComparisonData,
openFileAndAddToCanvasAsNewProject,
waitForRender,
} from '@utils';
import { pageReload } from '@utils/common/helpers';
import { FileType, verifyFile2 } from '@utils/files/receiveFileComparisonData';

test.describe('Loading SMARTS files', () => {
test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -436,3 +439,176 @@ test.describe('Loading SMARTS files', () => {
await takeEditorScreenshot(page);
});
});

interface IMonomer {
monomerDescription: string;
KETFile: string;
SMARTSFile_Expected: string;
monomerLocatorText: string;
// Set shouldFail to true if you expect test to fail because of existed bug and put issues link to issueNumber
shouldFail?: boolean;
// issueNumber is mandatory if shouldFail === true
issueNumber?: string;
// set pageReloadNeeded to true if you need to restart ketcher before test (f.ex. to restart font renderer)
pageReloadNeeded?: boolean;
}

const allTypesExpandableOfMonomers: IMonomer[] = [
{
monomerDescription: '1. Petide D (from library)',
KETFile:
'KET/Micro-Macro-Switcher/Basic-Monomers/Positive/1. Petide D (from library).ket',
SMARTSFile_Expected:
'SMARTS/Micro-Macro-Switcher/Basic-Monomers/Positive/1. Petide D (from library)-expected.smarts',
monomerLocatorText: 'D',
pageReloadNeeded: true,
},
{
monomerDescription: '2. Sugar UNA (from library)',
KETFile:
'KET/Micro-Macro-Switcher/Basic-Monomers/Positive/2. Sugar UNA (from library).ket',
SMARTSFile_Expected:
'SMARTS/Micro-Macro-Switcher/Basic-Monomers/Positive/2. Sugar UNA (from library)-expected.smarts',
monomerLocatorText: 'UNA',
},
{
monomerDescription: '3. Base hU (from library)',
KETFile:
'KET/Micro-Macro-Switcher/Basic-Monomers/Positive/3. Base hU (from library).ket',
SMARTSFile_Expected:
'SMARTS/Micro-Macro-Switcher/Basic-Monomers/Positive/3. Base hU (from library)-expected.smarts',
monomerLocatorText: 'hU',
},
{
monomerDescription: '4. Phosphate bnn (from library)',
KETFile:
'KET/Micro-Macro-Switcher/Basic-Monomers/Positive/4. Phosphate bnn (from library).ket',
SMARTSFile_Expected:
'SMARTS/Micro-Macro-Switcher/Basic-Monomers/Positive/4. Phosphate bnn (from library)-expected.smarts',
monomerLocatorText: 'bnn',
},
{
monomerDescription: '5. Unsplit nucleotide 5hMedC (from library)',
KETFile:
'KET/Micro-Macro-Switcher/Basic-Monomers/Positive/5. Unsplit nucleotide 5hMedC (from library).ket',
SMARTSFile_Expected:
'SMARTS/Micro-Macro-Switcher/Basic-Monomers/Positive/5. Unsplit nucleotide 5hMedC (from library)-expected.smarts',
monomerLocatorText: '5hMedC',
},
{
monomerDescription: '6. CHEM 4aPEGMal (from library)',
KETFile:
'KET/Micro-Macro-Switcher/Basic-Monomers/Positive/6. CHEM 4aPEGMal (from library).ket',
SMARTSFile_Expected:
'SMARTS/Micro-Macro-Switcher/Basic-Monomers/Positive/6. CHEM 4aPEGMal (from library)-expected.smarts',
monomerLocatorText: '4aPEGMal',
},
];

test.describe('Saving collapsed monomer to SMARTS: ', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

for (const monomer of allTypesExpandableOfMonomers) {
test(`${monomer.monomerDescription}`, async ({ page }) => {
/*
* Test task: https://github.com/epam/ketcher/issues/5832
* Description: Verify saving collapsed monomers in Daylight SMARTS
*
* Case: 1. Load monomer chain on Molecules canvas
* 2. Take screenshot to witness initial state
* 3. For each monomer do the following:
* 3.1 Save monomer to Daylight SMARTS
* 3.2 Validate saved file using template
* 3.3 Load saved file back to canvas
* 3.4 Take screenshot to witness result on the canvas
*/
if (monomer.pageReloadNeeded) {
await pageReload(page);
}
await openFileAndAddToCanvasAsNewProject(monomer.KETFile, page);
await takeEditorScreenshot(page);

await verifyFile2(
page,
`tests/test-data/${monomer.SMARTSFile_Expected}`,
FileType.SMARTS,
);

await openFileAndAddToCanvasAsNewProject(
monomer.SMARTSFile_Expected,
page,
);
await takeEditorScreenshot(page);

// Test should be skipped if related bug exists
test.fixme(
monomer.shouldFail === true,
`That test results are wrong because of ${monomer.issueNumber} issue(s).`,
);
});
}
});

async function callContexMenu(page: Page, locatorText: string) {
const canvasLocator = page.getByTestId('ketcher-canvas');
await canvasLocator.getByText(locatorText, { exact: true }).click({
button: 'right',
});
}

async function expandMonomer(page: Page, locatorText: string) {
await callContexMenu(page, locatorText);
await waitForRender(page, async () => {
await page.getByText('Expand monomer').click();
});
}

test.describe('Saving expanded monomer to SMARTS: ', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

for (const monomer of allTypesExpandableOfMonomers) {
test(`${monomer.monomerDescription}`, async ({ page }) => {
/*
* Test task: https://github.com/epam/ketcher/issues/5832
* Description: Verify saving expanded monomers in Daylight SMARTS
*
* Case: 1. Load monomer chain on Molecules canvas
* 2. Expand monomer on the canvas
* 2. Take screenshot to witness initial state
* 3. For each monomer do the following:
* 3.1 Save monomer to Daylight SMARTS
* 3.2 Validate saved file using template
* 3.3 Load saved file back to canvas
* 3.4 Take screenshot to witness result on the canvas
*/
if (monomer.pageReloadNeeded) {
await pageReload(page);
}
await openFileAndAddToCanvasAsNewProject(monomer.KETFile, page);
await expandMonomer(page, monomer.monomerLocatorText);
await takeEditorScreenshot(page);

await verifyFile2(
page,
`tests/test-data/${monomer.SMARTSFile_Expected}`,
FileType.SMARTS,
);

await openFileAndAddToCanvasAsNewProject(
monomer.SMARTSFile_Expected,
page,
);
await takeEditorScreenshot(page);

// Test should be skipped if related bug exists
test.fixme(
monomer.shouldFail === true,
`That test results are wrong because of ${monomer.issueNumber} issue(s).`,
);
});
}
});
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.
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 @@ -4,8 +4,6 @@ import {
selectNestedTool,
openFileAndAddToCanvas,
takeEditorScreenshot,
selectTopPanelButton,
TopPanelButton,
clickOnTheCanvas,
applyAutoMapMode,
selectLeftPanelButton,
Expand All @@ -15,6 +13,7 @@ import {
clickOnAtom,
waitForSpinnerFinishedWork,
} from '@utils';
import { pressUndoButton } from '@utils/macromolecules/topToolBar';

test.describe('Verifying buttons on reaction am tool dropdown', () => {
test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -81,7 +80,7 @@ test.describe('Verifying buttons on reaction am tool dropdown', () => {
const atomNumber2 = 2;
await openFileAndAddToCanvas('Rxn-V2000/reaction-3.rxn', page);
await applyAutoMapMode(page, mode);
await selectTopPanelButton(TopPanelButton.Undo, page);
await pressUndoButton(page);
await takeEditorScreenshot(page);
await selectLeftPanelButton(LeftPanelButton.ReactionMappingTool, page);
await clickOnAtom(page, 'C', atomNumber1);
Expand All @@ -98,9 +97,9 @@ test.describe('Verifying buttons on reaction am tool dropdown', () => {
await selectLeftPanelButton(LeftPanelButton.RectangleSelection, page);
await takeEditorScreenshot(page);
await applyAutoMapMode(page, 'Discard');
await selectTopPanelButton(TopPanelButton.Undo, page);
await pressUndoButton(page);
await applyAutoMapMode(page, 'Keep');
await selectTopPanelButton(TopPanelButton.Undo, page);
await pressUndoButton(page);
await applyAutoMapMode(page, 'Alter', false);
});
test('After the manual mapping with incorrect ordering', async ({
Expand Down
Loading

0 comments on commit 168e713

Please sign in to comment.