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

Autotests: #3319 - Actions with structures #3331

Merged
merged 8 commits into from
Sep 19, 2023
2 changes: 1 addition & 1 deletion ketcher-autotests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "Nitvex",
"license": "ISC",
"devDependencies": {
"@playwright/test": "1.37.0",
"@playwright/test": "^1.37.0",
"eslint": "^8.44.0",
"lint-staged": "^13.1.2",
"prettier": "2.8.4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { expect, test } from '@playwright/test';
import { selectAction, selectTool, takeEditorScreenshot } from '@utils/canvas';
import {
selectAction,
selectTool,
takeEditorScreenshot,
takeLeftToolbarScreenshot,
} from '@utils/canvas';
import { getLeftAtomByAttributes } from '@utils/canvas/atoms';
import { getLeftBondByAttributes } from '@utils/canvas/bonds';
import { BondType } from '@utils/canvas/types';
Expand Down Expand Up @@ -145,3 +150,24 @@ test.describe('Erase Tool', () => {
expect(arrowOnCanvas).toEqual(reactionArrow);
});
});

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

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

test('Toolbar icon verification', async ({ page }) => {
/*
Test case: EPMLSOPKET-1362
Description: The appropriate icon presents at the Toolbar for Erase tool.
*/
await openFileAndAddToCanvas(
'Rxn-V2000/benzene-bromobutane-reaction.rxn',
page,
);
});
});
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,54 @@
import { test } from '@playwright/test';
import {
selectTopPanelButton,
openFileAndAddToCanvas,
TopPanelButton,
takeEditorScreenshot,
waitForPageInit,
} from '@utils';

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

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

test('Structures are displayed in the middle of the screen after clicks "Layout" button', async ({
page,
}) => {
/*
Test case: EPMLSOPKET-16884
Description: The structures are displayed orderly in the middle of the screen
*/
await openFileAndAddToCanvas('KET/calculated-values-chain.ket', page);
await selectTopPanelButton(TopPanelButton.Layout, page);
});

test('Molecular structures are displayed in the middle of the screen after clicks "Ctrl+L"', async ({
page,
}) => {
/*
Test case: EPMLSOPKET-16885
Description: The structures are displayed orderly in the middle of the screen
*/
await openFileAndAddToCanvas('KET/two-atoms-and-bond.ket', page);
await page.keyboard.press('Control+l');
});

test('The reaction is displayed in the middle of the screen after clicks "Layout" button', async ({
page,
}) => {
/*
Test case: EPMLSOPKET-16886
Description: The structures are displayed orderly in the middle of the screen
*/
await openFileAndAddToCanvas(
'KET/two-templates-rings-and-functional-groups.ket',
page,
);
await selectTopPanelButton(TopPanelButton.Layout, page);
});
});
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,56 @@
import { test } from '@playwright/test';
import {
selectTopPanelButton,
TopPanelButton,
takeEditorScreenshot,
waitForPageInit,
selectAtomInToolbar,
AtomButton,
} from '@utils';

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

test('Track 32 steps (Undo,Redo action)', async ({ page }) => {
/*
Test case: EPMLSOPKET-1989
Description: Add Nitrogen atom to canvas 35 times and then press Undo 32 times
*/

const atomType = AtomButton.Nitrogen;

const addAtom = async (x: number, y: number) => {
await selectAtomInToolbar(atomType, page);
await page.mouse.click(x, y);
};

const numberOfRows = 6;
const numberOfColumns = 8;
const step = 100;
const coordinates = [];

for (let row = 0; row < numberOfRows; row++) {
for (let column = 0; column < numberOfColumns; column++) {
coordinates.push({ x: column * step, y: row * step });
}
}

for (const { x, y } of coordinates) {
await addAtom(x, y);
}

const maxUndoHistorySize = 32;
for (let i = 0; i < maxUndoHistorySize; i++) {
await selectTopPanelButton(TopPanelButton.Undo, page);
}
await takeEditorScreenshot(page);

const maxRedoHistorySize = 32;
for (let i = 0; i < maxRedoHistorySize; i++) {
await selectTopPanelButton(TopPanelButton.Redo, page);
}
await takeEditorScreenshot(page);
});
});
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/KET/two-atoms-and-bond.ket
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"root": {
"nodes": [
{
"$ref": "mol0"
},
{
"$ref": "mol1"
},
{
"$ref": "mol2"
}
]
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "N",
"location": [
1.4500000000000002,
-2.0500000000000003,
0
]
}
]
},
"mol1": {
"type": "molecule",
"atoms": [
{
"label": "O",
"location": [
22,
-7.875,
0
]
}
]
},
"mol2": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
3.266987298107781,
-13.5,
0
]
},
{
"label": "C",
"location": [
4.13301270189222,
-13,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
0,
1
]
}
]
}
}
Loading
Loading