Skip to content

Commit

Permalink
Autotests: #3581 - add tests for missed test cases based on done tick…
Browse files Browse the repository at this point in the history
…ets for smarts (#3710)

* adding test for checking  pasting as SMARTS feature

* adding few tests for visual check

* adding screenshots for tests from visual-check spec

* adding tests for checking warnings - covering with test cases ticket number 3431

* adding tests to cover ticket 3459 and 3445

* removing unnecessary import

* adding tests to cover ticket 3397 and 3408

* removing unnecessary import

* adding tests to cover 3387, 3372, 3362 and 3340

* adding tests to cover ticket 3339

* adding tests to cover tickets 3338 and 3328

* adding tests to cover indigo issues 1358, 1332, 1321, 1316, 1281 and 1252

* - code refactoring

* - working on comments;
- added 2 expected snapshots

* - code refactoring

* - change name of function

* - code refactoring

---------

Co-authored-by: Urszula Gawlowska <urszula.gawlowska@epam.com>
Co-authored-by: Zhirnoff <mikhail_zhirnov@epam.com>
  • Loading branch information
3 people committed Feb 3, 2024
1 parent c981241 commit 978d8ed
Show file tree
Hide file tree
Showing 39 changed files with 847 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ test.describe('open files with different formats', () => {
});

/* two structures should be added on the canvas in the following test
(same as in EPMLSOPKET-1835), however in this test when second structure is added
the first one disappears. Couldn't reproduct manually.
*/
(same as in EPMLSOPKET-1835), however in this test when second structure is added
the first one disappears. Couldn't reproduct manually.
*/
test('Open file - Input .mol, InChi', async ({ page }) => {
/**
* Test case: EPMLSOPKET-1835
Expand Down Expand Up @@ -159,4 +159,15 @@ the first one disappears. Couldn't reproduct manually.
await pressButton(page, 'Open as New Project');
});
});

test('Open ket file with SMARTS attributes', async ({ page }) => {
/*
Test case: https://github.com/epam/ketcher/issues/3397
Description: ket file with SMARTS attributes should be open without error
*/
await openFileAndAddToCanvas(
'KET/benzene-with-smarts-attributes.ket',
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
Expand Up @@ -412,4 +412,32 @@ test.describe('Open/Save/Paste files', () => {
await getPreviewForSmiles(page, 'Daylight SMILES');
await page.getByText('Warnings').click();
});

test('Save *.ket file with atom list and atom properties', async ({
page,
}) => {
/**
* Test case: https://github.com/epam/ketcher/issues/3387
* Description: All the atom properties (general and query specific) for atom list should be saved in ket format
*/
await openFileAndAddToCanvas(
'KET/benzene-with-atom-list-and-all-atom-and-query-attributes.ket',
page,
);

const expectedFile = await getKet(page);
await saveToFile(
'KET/benzene-with-atom-list-and-all-atom-and-query-attributes-to-compare.ket',
expectedFile,
);

const { fileExpected: ketFileExpected, file: ketFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/KET/benzene-with-atom-list-and-all-atom-and-query-attributes-to-compare.ket',
});

expect(ketFile).toEqual(ketFileExpected);
});
});
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,38 @@
import { test } from '@playwright/test';
import {
takeEditorScreenshot,
clickInTheMiddleOfTheScreen,
waitForPageInit,
pasteFromClipboardAndAddToCanvas,
} from '@utils';

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

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

test('Loading SMARTS with custom query', async ({ page }) => {
/*
Test case: https://github.com/epam/Indigo/issues/1358
Description: [!#6,!#7,!#8] should be loaded as custom query without any error
*/
const smartsStringToPaste = '[!#6,!#7,!#8]';
await pasteFromClipboardAndAddToCanvas(page, smartsStringToPaste, false);
await clickInTheMiddleOfTheScreen(page);
});

test('Loading SMARTS with aromatic atom list', async ({ page }) => {
/*
Test case: https://github.com/epam/Indigo/issues/1332
Description: c1-[#6]=[#6]-[#6]=[#6]-[c,n]=1 should be loaded as benzene with aromatic atom list (carbon and nitrogen)
Screenshot for this test is incorrect since Indigo issue #1332 still occurs when test is running locally
*/
const smartsStringToPaste = 'c1-[#6]=[#6]-[#6]=[#6]-[c,n]=1';
await pasteFromClipboardAndAddToCanvas(page, smartsStringToPaste, false);
await clickInTheMiddleOfTheScreen(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.
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,33 @@ test.describe('Atom Properties', () => {
await doubleClickOnAtom(page, 'O', 0);
});

test('Dialog - Atom type - List', async ({ page }) => {
/*
Test case: https://github.com/epam/ketcher/issues/3340
Description: if 'Atom type' is set to 'List' then dialog should change:
- Label and Number should be hided
- new items "List" (input field) and "edit" icon should be added
- "Not list (checkbox)" should be added
*/
await openFileAndAddToCanvas('KET/benzene-ring-with-two-atoms.ket', page);
await doubleClickOnAtom(page, 'C', 0);
await page.locator('label').filter({ hasText: 'Atom Type' }).click();
await page.getByRole('option', { name: 'List', exact: true }).click();
});

test('Dialog - Atom type - Special', async ({ page }) => {
/*
Test case: https://github.com/epam/ketcher/issues/3340
Description: if 'Atom type' is set to 'Special' then dialog should change:
- Label and Number should be hidden
- new item "Special" (input field) and "edit" icon should be added
*/
await openFileAndAddToCanvas('KET/benzene-ring-with-two-atoms.ket', page);
await doubleClickOnAtom(page, 'C', 0);
await page.locator('label').filter({ hasText: 'Atom Type' }).click();
await page.getByRole('option', { name: 'Special', exact: true }).click();
});

test('Charge of the Atoms', async ({ page }) => {
/*
Test case: EPMLSOPKET-1606
Expand Down Expand Up @@ -423,6 +450,23 @@ test.describe('Atom Properties', () => {
await page.getByLabel('Charge').fill('A');
});

test('Type in the Charge field number bigger than maximum', async ({
page,
}) => {
/*
Test case: https://github.com/epam/ketcher/issues/3339
Description: The range for charge is from -999 to 999
The 'Charge' field is framed with the red frame.
The 'Error: Invalid charge value' tooltip appears when the cursor over the field.
The 'Apply' button becomes disabled.
*/
await openFileAndAddToCanvas('KET/benzene-ring-with-two-atoms.ket', page);

await doubleClickOnAtom(page, 'C', 0);
await page.getByTestId('charge-input').fill('9999');
await page.getByTestId('charge-input').hover();
});

test('Save structure with two Charge as *.mol file', async ({ page }) => {
/*
Test case: EPMLSOPKET-1606
Expand Down Expand Up @@ -532,6 +576,19 @@ test.describe('Atom Properties', () => {
await page.getByLabel('Isotope').fill('b');
});

test('Add incorrect negative Isotope in modal', async ({ page }) => {
/*
Test case: https://github.com/epam/ketcher/issues/3339
Description: The range for 'Isotope' field is from 0 to 999
Field highlight with red and tooltip appears: Invalid isotope value!
*/
await openFileAndAddToCanvas('KET/chain.ket', page);

await doubleClickOnAtom(page, 'C', 1);
await page.getByTestId('isotope-input').fill('-88');
await page.getByTestId('isotope-input').hover();
});

test('Save structure with Isotope information as *.mol file', async ({
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Page, test } from '@playwright/test';
import {
BondTypeName,
clickInTheMiddleOfTheScreen,
doubleClickOnAtom,
pressButton,
selectBond,
takeEditorScreenshot,
waitForAtomPropsModal,
waitForPageInit,
} from '@utils';
import {
checkSmartsValue,
checkSmartsWarnings,
setReactionFlagExactChange,
setReactionFlagInversion,
} from '../utils';

const defaultFileFormat = 'MDL Molfile V2000';
const expectedSmarts = '[#6](-[#6])(-[#6])-[#6]';

async function drawStructure(page: Page, numberOfClicks: number) {
await selectBond(BondTypeName.Single, page);
for (let i = 0; i < numberOfClicks; i++) {
await clickInTheMiddleOfTheScreen(page);
}
}

async function drawStructureAndDoubleClickOnAtom(
page: Page,
numberOfBondsAtStructure: number,
atomType: string,
numberOfAtom: number,
) {
await waitForPageInit(page);
await drawStructure(page, numberOfBondsAtStructure);
await page.keyboard.press('Escape');
await doubleClickOnAtom(page, atomType, numberOfAtom);
await waitForAtomPropsModal(page);
}

test.describe('Checking atom properties attributes in SMARTS format', () => {
test.beforeEach(async ({ page }) => {
const numberOfAtom = 0;
const numberOfBondsAtStructure = 3;
await drawStructureAndDoubleClickOnAtom(
page,
numberOfBondsAtStructure,
'C',
numberOfAtom,
);
await page.getByTestId('Reaction flags-section').click();
});

test('Setting reaction flag - Inverts', async ({ page }) => {
/**
* Test case: https://github.com/epam/ketcher/issues/3431
* Description: setting reaction flag - inverts should have no impact on SMARTS output but warning should be displayed
*/
await setReactionFlagInversion(page, 'Inverts');
await pressButton(page, 'Apply');
await takeEditorScreenshot(page);
await checkSmartsValue(page, defaultFileFormat, expectedSmarts);
await checkSmartsWarnings(page);
});

test('Setting reaction flag - Retains', async ({ page }) => {
/**
* Test case: https://github.com/epam/ketcher/issues/3431
* Description: setting reaction flag - retains should have no impact on SMARTS output but warning should be displayed
*/
await setReactionFlagInversion(page, 'Retains');
await pressButton(page, 'Apply');
await takeEditorScreenshot(page);
await checkSmartsValue(page, defaultFileFormat, expectedSmarts);
await checkSmartsWarnings(page);
});

test('Setting reaction flag - Exact change checked', async ({ page }) => {
/**
* Test case: https://github.com/epam/ketcher/issues/3431
* Description: checking exact change option at reaction flag section should have no impact on SMARTS output but warning should be displayed
*/
await setReactionFlagExactChange(page);
await pressButton(page, 'Apply');
await takeEditorScreenshot(page);
await checkSmartsValue(page, defaultFileFormat, expectedSmarts);
await checkSmartsWarnings(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.
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

0 comments on commit 978d8ed

Please sign in to comment.