Skip to content

Commit

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

Co-authored-by: Urszula Gawlowska <[email protected]>
  • Loading branch information
Zhirnoff and Urszula Gawlowska authored Feb 5, 2024
1 parent c981241 commit 34555ea
Show file tree
Hide file tree
Showing 41 changed files with 853 additions and 5 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,37 @@
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)
*/
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,87 @@
import { Page, test } from '@playwright/test';
import {
BondTypeName,
checkSmartsValue,
checkSmartsWarnings,
clickInTheMiddleOfTheScreen,
doubleClickOnAtom,
pressButton,
selectBond,
setReactionFlagExactChange,
setReactionFlagInversion,
takeEditorScreenshot,
waitForAtomPropsModal,
waitForPageInit,
} from '@utils';

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, 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, 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, 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 34555ea

Please sign in to comment.