Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into 3251-rna-preset-name-shoul…
Browse files Browse the repository at this point in the history
…d-be-autofilled-when-user-selects-rna-parts
  • Loading branch information
Gayane Chilingaryan committed Oct 13, 2023
2 parents 7875be1 + 0249a5a commit 0363366
Show file tree
Hide file tree
Showing 251 changed files with 4,356 additions and 955 deletions.
158 changes: 80 additions & 78 deletions ketcher-autotests/tests/API/api-set-get-molecule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { expect, test } from '@playwright/test';
import {
AtomButton,
delay,
readFileContents,
selectAtomInToolbar,
takeEditorScreenshot,
DELAY_IN_SECONDS,
FILE_TEST_DATA,
receiveFileComparisonData,
waitForSpinnerFinishedWork,
clickInTheMiddleOfTheScreen,
waitForPageInit,
saveToFile,
} from '@utils';
import { getAtomByIndex } from '@utils/canvas/atoms';
import {
Expand All @@ -21,14 +20,6 @@ import {
setMolecule,
} from '@utils/formats';

function filteredFile(file: string, filteredIndex: number): string {
return file
.split('\n')
.filter((_str, index) => index > filteredIndex)
.join('\n')
.replace(/\s+/g, '');
}

test.describe('Tests for API setMolecule/getMolecule', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
Expand Down Expand Up @@ -148,83 +139,94 @@ test.describe('Tests for API setMolecule/getMolecule', () => {
);
});

test.fixme(
'Set and Get Molecule using V3000 Molfile format',
async ({ page }) => {
/*
test('Set and Get Molecule using V3000 Molfile format', async ({ page }) => {
/*
Test case: EPMLSOPKET- 10095
Description: Molecule set and get using V3000 format
*/
const ignoredLineIndigo = 1;
const orEnantiomer = await readFileContents(
'tests/test-data/or-enantiomer.mol',
);
await waitForSpinnerFinishedWork(
const ignoredLineIndigo = 1;
const orEnantiomer = await readFileContents(
'tests/test-data/or-enantiomer.mol',
);
await waitForSpinnerFinishedWork(
page,
async () => await setMolecule(page, orEnantiomer),
);

const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
async () => await setMolecule(page, orEnantiomer),
);
expectedFileName: 'tests/test-data/test-data-for-enatiomer.mol',
metaDataIndexes: [ignoredLineIndigo],
fileFormat: 'v3000',
});
expect(molFile).toEqual(molFileExpected);
});

const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
expectedFileName: 'tests/test-data/test-data-for-enatiomer.mol',
metaDataIndexes: [ignoredLineIndigo],
fileFormat: 'v3000',
});
expect(molFile).toEqual(molFileExpected);
},
);

// TO DO: split by two tests; use saveToFile function; do not get molv2000 in one line
test.fixme(
'Set and Get Molecule containing chiral centers',
async ({ page }) => {
/*
test('Set and Get Molecule containing chiral centers V2000', async ({
page,
}) => {
/*
Test case: EPMLSOPKET- 10097
Description: Molecule set and get with chiral centers
Description: Molecule set and get with chiral centers V2000
*/
const indexOfLineWithIndigo = 2;
const indexOfLineWithKetcher = 2;

await waitForSpinnerFinishedWork(
await waitForSpinnerFinishedWork(
page,
async () =>
await setMolecule(page, 'CC(=O)O[C@@H](C)[C@H](O)Cn1cnc2c1ncnc2N'),
);

const molV2000File = await getMolfile(page, 'v2000');
await saveToFile(
'Molfiles-V2000/test-data-for-chiral-centersv2000-expected.mol',
molV2000File,
);
const METADATA_STRING_INDEX = [1];

const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
async () =>
await setMolecule(page, 'CC(=O)O[C@@H](C)[C@H](O)Cn1cnc2c1ncnc2N'),
);

await delay(DELAY_IN_SECONDS.THREE);

const molV2000FileExpected = await readFileContents(
'tests/test-data/Molfiles-V2000/test-data-for-chiral-centersv2000.mol',
);
const molV2000File = await getMolfile(page, 'v2000');
const filteredmolV2000FileExpected = filteredFile(
molV2000FileExpected,
indexOfLineWithKetcher,
);
const filteredmolV2000File = filteredFile(
molV2000File,
indexOfLineWithKetcher,
);

expect(filteredmolV2000File).toEqual(filteredmolV2000FileExpected);

const molV3000FileExpected = await readFileContents(
'tests/test-data/Molfiles-V3000/test-data-for-chiral-centersv3000.mol',
);
const molV3000File = await getMolfile(page, 'v3000');
const filteredmolV3000FileExpected = filteredFile(
molV3000FileExpected,
indexOfLineWithIndigo,
);
const filteredmolV3000File = filteredFile(
molV3000File,
indexOfLineWithIndigo,
);

expect(filteredmolV3000File).toEqual(filteredmolV3000FileExpected);
},
);
expectedFileName:
'tests/test-data/Molfiles-V2000/test-data-for-chiral-centersv2000-expected.mol',
fileFormat: 'v2000',
metaDataIndexes: METADATA_STRING_INDEX,
});

expect(molFile).toEqual(molFileExpected);
});

test('Set and Get Molecule containing chiral centers V3000', async ({
page,
}) => {
/*
Test case: EPMLSOPKET- 10097
Description: Molecule set and get with chiral centers V3000
*/

await waitForSpinnerFinishedWork(
page,
async () =>
await setMolecule(page, 'CC(=O)O[C@@H](C)[C@H](O)Cn1cnc2c1ncnc2N'),
);
const molV3000File = await getMolfile(page, 'v3000');
await saveToFile(
'Molfiles-V3000/test-data-for-chiral-centersv3000-expected.mol',
molV3000File,
);
const METADATA_STRING_INDEX = [1];

const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/Molfiles-V3000/test-data-for-chiral-centersv3000-expected.mol',
fileFormat: 'v3000',
metaDataIndexes: METADATA_STRING_INDEX,
});

expect(molFile).toEqual(molFileExpected);
});

test('Check DisableQueryElements parameter', 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.
Original file line number Diff line number Diff line change
Expand Up @@ -698,42 +698,41 @@ test.describe('Open and Save file', () => {
}
});

test.fixme(
'V3000 mol file contains different Bond properties',
async ({ page }) => {
/**
* Test case: EPMLSOPKET-1853
* Description: Structre is correctly generated from Molstring and vise versa molstring is correctly generated from structure.
* A file with V3000 format is resaved in V2000 format
*
* Now we can`t open the file - `Convert error! Cannot deserialize input JSON.`
* https://github.com/epam/ketcher/issues/2378
*/
test.skip('V3000 mol file contains different Bond properties', async ({
page,
}) => {
/**
* Test case: EPMLSOPKET-1853
* Description: Structre is correctly generated from Molstring and vise versa molstring is correctly generated from structure.
* A file with V3000 format is resaved in V2000 format
*
* Now we can`t open the file - `Convert error! Cannot deserialize input JSON.`
* https://github.com/epam/ketcher/issues/2378
*/

await openFileAndAddToCanvas(
'Molfiles-V3000/marvin-bond-properties-V3000(1).mol',
page,
);
await openFileAndAddToCanvas(
'Molfiles-V3000/marvin-bond-properties-V3000(1).mol',
page,
);

const expectedFile = await getMolfile(page, 'v2000');
await saveToFile(
'Molfiles-V2000/marvin-bond-properties-V3000-expected.mol',
expectedFile,
);
const expectedFile = await getMolfile(page, 'v2000');
await saveToFile(
'Molfiles-V2000/marvin-bond-properties-V3000-expected.mol',
expectedFile,
);

const METADATA_STRING_INDEX = [1];
const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/Molfiles-V2000/marvin-bond-properties-V3000-expected.mol',
fileFormat: 'v2000',
metaDataIndexes: METADATA_STRING_INDEX,
});

expect(molFile).toEqual(molFileExpected);
},
);
const METADATA_STRING_INDEX = [1];
const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/Molfiles-V2000/marvin-bond-properties-V3000-expected.mol',
fileFormat: 'v2000',
metaDataIndexes: METADATA_STRING_INDEX,
});

expect(molFile).toEqual(molFileExpected);
});

for (let i = 1; i < 9; i++) {
test(`Open/Save files for ferrocen-like structures 1/2 - open ferrocene_radical0${i}.mol`, async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ import {
waitForSpinnerFinishedWork,
} from '@utils';
import { drawReactionWithTwoBenzeneRings } from '@utils/canvas/drawStructures';
import {
getInChIKey,
getKet,
getMolfile,
getRxn,
getSdf,
getSmiles,
} from '@utils/formats';
import { getKet, getMolfile, getRxn, getSdf, getSmiles } from '@utils/formats';

const RING_OFFSET = 150;
const ARROW_OFFSET = 20;
Expand Down Expand Up @@ -246,44 +239,21 @@ test.describe('Save files', () => {
expect(molFile).toEqual(molFileExpected);
});

test.fixme(
'Support for exporting to "InChiKey" file format',
async ({ page }) => {
/**
* Test case: EPMLSOPKET-18030
* Description: Save file - InChiKey for Benzene ring on canvas
*/
// Can't select TestId because after press drop-down menu there is no InchIKey.
await selectRingButton(RingButton.Benzene, page);
await clickInTheMiddleOfTheScreen(page);
await selectTopPanelButton(TopPanelButton.Save, page);
await pressButton(page, 'MDL Molfile V2000');
await selectOptionByText(page, 'InChIKey');
const inChistring = await page
.getByTestId('preview-area-text')
.inputValue();
expect(inChistring).toEqual('UHOVQNZJYSORNB-UHFFFAOYSA-N');
},
);

test.fixme('Save "InChiKey" file format', async ({ page }) => {
test('Support for exporting to "InChiKey" file format', async ({ page }) => {
/**
* Test case: EPMLSOPKET-18031
* Test case: EPMLSOPKET-18030
* Description: Save file - InChiKey for Benzene ring on canvas
*/
// After 'getInChIKey' return JSON instead InChIKey
// Can't select TestId because after press drop-down menu there is no InchIKey.
await selectRingButton(RingButton.Benzene, page);
await clickInTheMiddleOfTheScreen(page);
const expectedFile = await getInChIKey(page);
await saveToFile('benzene-ring-expected.inchikey', expectedFile);

const { fileExpected: inchikeyFileExpected, file: inchikeyFile } =
await receiveFileComparisonData({
page,
expectedFileName: 'tests/test-data/benzene-ring-expected.inchikey',
});

expect(inchikeyFile).toEqual(inchikeyFileExpected);
await selectTopPanelButton(TopPanelButton.Save, page);
await pressButton(page, 'MDL Molfile V2000');
await selectOptionByText(page, 'InChIKey');
const inChistring = await page
.getByTestId('inChIKey-preview-area-text')
.inputValue();
expect(inChistring).toEqual('UHOVQNZJYSORNB-UHFFFAOYSA-N');
});

test('Support for exporting to "SDF V2000" file format', 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.
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,24 @@ test.describe('Indigo Tools - Clean Tools', () => {
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
});

test('Clean Up action on part of structure with different properties', async ({
page,
}) => {
/*
Test case: EPMLSOPKET-1826
Description: Clean action is correct for the selected part.
Non-selected part is invariable.
Test working incorrect because we have a bug https://github.com/epam/Indigo/issues/388
*/
await openFileAndAddToCanvas(
'Molfiles-V2000/clean-different-properties.mol',
page,
);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, 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

0 comments on commit 0363366

Please sign in to comment.