Skip to content

Commit

Permalink
Autotests: #2884 create autotests for mapping/unmapping and reaction …
Browse files Browse the repository at this point in the history
…tools (#2917)

* - Added test for mapping/unmapping tool

* - code refactoring;
- added expected snapshot;
- renamed 4 test files

* - updated tests for 'mapping-tool';
- updated expected snapshots;
- added 1 test file;
- added 1 AtomLabelType;
- updated tests for 'qreaction-tools'

* - added assertions

* - code refactoring

* - code rfactoring

* - changed 'selectNestedTool' to 'selectDropdownTool';
- added 'urszula-gawlowska' to 'auto_assign'

* - deleted ignore eslint for whole file;
- added expected snapshots;
- added function 'takeMultitoolDropdownScreenshot'

* - added 'Reaction-tool' to const regularTests

---------

Co-authored-by: Mikhail Zhirnov <[email protected]>
  • Loading branch information
AleksandraSmolianinova and Zhirnoff authored Sep 25, 2023
1 parent 4d84438 commit b8ab285
Show file tree
Hide file tree
Showing 26 changed files with 514 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/auto_assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ reviewGroups:
- MartaWilliams
- y-holik
- AnastasiyaPiatrovaKlu
- ViktoriaTkacheva
- ViktoriaTkacheva
- urszula-gawlowska
1 change: 1 addition & 0 deletions ketcher-autotests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const regularTests = [
'Indigo-Tools/**',
'R-group-tool/**',
'Reactions/**',
'Reaction-tool/**',
'Reagents/**',
'Settings/**',
'Structure-Creating-&-Editing/**',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { test, expect } from '@playwright/test';
import {
takeEditorScreenshot,
LeftPanelButton,
clickInTheMiddleOfTheScreen,
selectLeftPanelButton,
openFileAndAddToCanvas,
selectRingButton,
RingButton,
getCoordinatesTopAtomOfBenzeneRing,
selectTopPanelButton,
TopPanelButton,
dragMouseTo,
waitForPageInit,
mapTwoAtoms,
clickOnAtom,
receiveFileComparisonData,
saveToFile,
selectDropdownTool,
} from '@utils';
import { getAtomByIndex } from '@utils/canvas/atoms';
import { getRxn } from '@utils/formats';

test.describe('Mapping Tools', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
await takeEditorScreenshot(page);
});

test('Click atoms to map atoms in a reaction', async ({ page }) => {
/* Test case: EPMLSOPKET-1799, EPMLSOPKET-8909
Description: Click atoms to map atoms in a reaction
*/
await openFileAndAddToCanvas('Rxn-V2000/reaction-3.rxn', page);
await selectDropdownTool(page, 'reaction-map', 'reaction-map');
await mapTwoAtoms(
page,
{ label: 'C', number: 0 },
{ label: 'C', number: 10 },
);
});

test.describe('Mapping Tools', () => {
test.beforeEach(async ({ page }) => {
await openFileAndAddToCanvas('Rxn-V2000/mapped-atoms.rxn', page);
});

test('Click the single mapped atom to delete mapping', async ({ page }) => {
// EPMLSOPKET-1827
const anyAtom = 0;
await selectDropdownTool(page, 'reaction-map', 'reaction-unmap');
await clickOnAtom(page, 'Br', anyAtom);
});

test('Map ordering', async ({ page }) => {
await selectDropdownTool(page, 'reaction-map', 'reaction-map');
await page.getByText('ALK').click();
await page.getByText('ABH').click();
await page.getByText('CHC').click();
await page.getByText('ARY').click();
});
});

test('No Unmapping after the arrow deleting', async ({ page }) => {
// EPMLSOPKET-1828
await openFileAndAddToCanvas('Rxn-V2000/mapped-rection-benz.rxn', page);
await selectLeftPanelButton(LeftPanelButton.Erase, page);
await clickInTheMiddleOfTheScreen(page);
});

test('Click atoms to map atoms of reactants or products', async ({
page,
}) => {
await openFileAndAddToCanvas('Rxn-V2000/reaction-3.rxn', page);
await selectDropdownTool(page, 'reaction-map', 'reaction-map');
const point = await getAtomByIndex(page, { label: 'C' }, 0);
await page.mouse.click(point.x, point.y);
const { x, y } = await getCoordinatesTopAtomOfBenzeneRing(page);
await dragMouseTo(x, y, page);
});

test('Undo working in atom mapping, able to remove mapping', async ({
page,
}) => {
// EPMLSOPKET-12961
// Undo not working properly https://github.com/epam/ketcher/issues/2174
await selectRingButton(RingButton.Benzene, page);
await clickInTheMiddleOfTheScreen(page);
await selectDropdownTool(page, 'reaction-map', 'reaction-map');
const { x, y } = await getCoordinatesTopAtomOfBenzeneRing(page);
await page.mouse.click(x, y);
await takeEditorScreenshot(page);

await selectTopPanelButton(TopPanelButton.Undo, page);
});

test.describe('Mapping reactions', () => {
test.beforeEach(async ({ page }) => {
await openFileAndAddToCanvas('Rxn-V2000/mapped-reaction.rxn', page);
await clickInTheMiddleOfTheScreen(page);
});

test('Remove the reaction components', async ({ page }) => {
// EPMLSOPKET-1831
await selectDropdownTool(page, 'reaction-map', 'reaction-map');
await page.getByText('CEL').click();
await page.keyboard.press('Delete');
await takeEditorScreenshot(page);

await selectTopPanelButton(TopPanelButton.Undo, page);
});

test('Unmap the mapped reaction', async ({ page }) => {
// EPMLSOPKET-1830
await selectDropdownTool(page, 'reaction-map', 'reaction-unmap');
await page.getByText('CEL').click();
});
});
});

test.describe('Mapping reactions', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

test('Save as *.rxn file', async ({ page }) => {
/*
Test case: EPMLSOPKET-1830
Description: Structure with attachment points saved as .rxn file
*/
await openFileAndAddToCanvas('Rxn-V2000/mapped-reaction.rxn', page);
const expectedFile = await getRxn(page);
await saveToFile('Rxn-V2000/mapped-reaction-expected.rxn', expectedFile);

// eslint-disable-next-line no-magic-numbers
const METADATA_STRING_INDEX = [2, 7, 25, 40, 66];
const { fileExpected: rxnFileExpected, file: rxnFile } =
await receiveFileComparisonData({
page,
metaDataIndexes: METADATA_STRING_INDEX,
expectedFileName:
'tests/test-data/Rxn-V2000/mapped-reaction-expected.rxn',
});
expect(rxnFile).toEqual(rxnFileExpected);
});
});
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
@@ -0,0 +1,41 @@
import { test } from '@playwright/test';
import {
LeftPanelButton,
selectLeftPanelButton,
waitForPageInit,
openDropdown,
takeMultitoolDropdownScreenshot,
takeLeftToolbarScreenshot,
} from '@utils';

test.describe('Reaction Tools', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
await takeLeftToolbarScreenshot(page);
});

test('Icons for Plus Tool', async ({ page }) => {
await selectLeftPanelButton(LeftPanelButton.ReactionPlusTool, page);
});
});

test.describe('Reaction Tools', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

test.afterEach(async ({ page }) => {
await takeMultitoolDropdownScreenshot(page);
});

test('Icons for Reaction Mapping tools', async ({ page }) => {
await openDropdown(page, 'reaction-map');
});

test('Icons for Arrow Tools', async ({ page }) => {
await openDropdown(page, 'reaction-arrow-open-angle');
});
});
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.
71 changes: 71 additions & 0 deletions ketcher-autotests/tests/test-data/Rxn-V2000/mapped-atoms.rxn
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
$RXN

-INDIGO- 0710231101

2 2
$MOL

-INDIGO-07102311012D

6 6 0 0 0 0 0 0 0 0999 V2000
6.8954 -4.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.7614 -5.3250 0.0000 ABH 0 0 0 0 0 0 0 0 0 0 0 0
7.7614 -6.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.8954 -6.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.0294 -6.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.0294 -5.3250 0.0000 ALK 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 2 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
5 6 1 0 0 0 0
6 1 2 0 0 0 0
M END
$MOL

-INDIGO-07102311012D

5 4 0 0 0 0 0 0 0 0999 V2000
11.1455 -5.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.0115 -6.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.8776 -5.8250 0.0000 CHC 0 0 0 0 0 0 0 0 0 0 0 0
13.7436 -6.3250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.6096 -5.8250 0.0000 Br 0 0 0 0 0 0 0 0 0 1 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
M END
$MOL

-INDIGO-07102311012D

10 10 0 0 0 0 0 0 0 0999 V2000
20.0705 -4.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.9365 -5.3750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.9365 -6.3750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.0705 -6.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.2045 -6.3750 0.0000 CEL 0 0 0 0 0 0 0 0 0 1 0 0
19.2045 -5.3750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.8025 -4.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
22.6687 -5.3750 0.0000 ARY 0 0 0 0 0 0 0 0 0 0 0 0
23.5347 -4.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.8025 -3.8750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 2 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
5 6 1 0 0 0 0
6 1 2 0 0 0 0
2 7 1 0 0 0 0
7 8 1 0 0 0 0
8 9 1 0 0 0 0
7 10 1 0 0 0 0
M END
$MOL

-INDIGO-07102311012D

1 0 0 0 0 0 0 0 0 0999 V2000
26.5706 -6.1250 0.0000 Br 0 0 0 0 0 0 0 0 0 0 0 0
M END
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
$RXN

-INDIGO- 0914231944

2 2
$MOL

-INDIGO-09142319442D

6 6 0 0 0 0 0 0 0 0999 V2000
5.6648 -7.7497 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.5314 -8.2500 0.0000 C 0 0 0 0 0 0 0 0 0 13 0 0
5.6648 -9.7509 0.0000 C 0 0 0 0 0 0 0 0 0 4 0 0
4.7983 -9.2506 0.0000 C 0 0 0 0 0 0 0 0 0 5 0 0
4.7983 -8.2500 0.0000 C 0 0 0 0 0 0 0 0 0 6 0 0
6.5314 -9.2256 0.0000 C 0 0 0 0 0 0 0 0 0 14 0 0
1 2 1 0 0 0 0
3 4 2 0 0 0 0
4 5 1 0 0 0 0
5 1 2 0 0 0 0
2 6 2 0 0 0 0
6 3 1 0 0 0 0
M END
$MOL

-INDIGO-09142319442D

5 4 0 0 0 0 0 0 0 0999 V2000
9.9175 -8.7502 0.0000 C 0 0 0 0 0 0 0 0 0 7 0 0
10.7840 -9.2506 0.0000 C 0 0 0 0 0 0 0 0 0 8 0 0
12.5171 -9.2506 0.0000 C 0 0 0 0 0 0 0 0 0 10 0 0
13.3836 -8.7502 0.0000 Br 0 0 0 0 0 0 0 0 0 11 0 0
11.6506 -8.7502 0.0000 C 0 0 0 0 0 0 0 0 0 9 0 0
1 2 1 0 0 0 0
3 4 1 0 0 0 0
5 3 1 0 0 0 0
2 5 1 0 0 0 0
M END
$MOL

-INDIGO-09142319442D

10 10 0 0 0 0 0 0 0 0999 V2000
18.8478 -7.7997 0.0000 C 0 0 0 0 0 0 0 0 0 15 0 0
19.7143 -8.2999 0.0000 C 0 0 0 0 0 0 0 0 0 13 0 0
19.7143 -9.3006 0.0000 CEL 0 0 0 0 0 0 0 0 0 16 0 0
18.8478 -9.8009 0.0000 C 0 0 0 0 0 0 0 0 0 4 0 0
17.9812 -9.3006 0.0000 C 0 0 0 0 0 0 0 0 0 5 0 0
17.9812 -8.2999 0.0000 C 0 0 0 0 0 0 0 0 0 6 0 0
20.5809 -7.7997 0.0000 C 0 0 0 0 0 0 0 0 0 7 0 0
21.4475 -8.2999 0.0000 C 0 0 0 0 0 0 0 0 0 9 0 0
22.3140 -7.7997 0.0000 C 0 0 0 0 0 0 0 0 0 10 0 0
20.5809 -6.7991 0.0000 C 0 0 0 0 0 0 0 0 0 8 0 0
1 2 1 0 0 0 0
2 3 2 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
5 6 1 0 0 0 0
6 1 2 0 0 0 0
2 7 1 0 0 0 0
7 8 1 0 0 0 0
8 9 1 0 0 0 0
7 10 1 0 0 0 0
M END
$MOL

-INDIGO-09142319442D

1 0 0 0 0 0 0 0 0 0999 V2000
25.3517 -9.0504 0.0000 Br 0 0 0 0 0 0 0 0 0 11 0 0
M END
Loading

0 comments on commit b8ab285

Please sign in to comment.