Skip to content

Commit

Permalink
Autotests: #3168 - Open and Save files (Mol-files) (#3206)
Browse files Browse the repository at this point in the history
* #3168 – Autotests - Open and Save Mol-files

* #3168 - add testes

* #3168 - fix test

* #3168 - start fix comments to mr

* #3168 - fix comments to mr

* #3168 - add a loop

* #3168 - rename files

* #3168 - add loop and rename files

* #3168 - small fix

* #3168 - small fix

* #3168 - replace fixme to skip

* #3168 - the last fix without comment

* #3168 - fix comment

* #3168 - small fix

* #3168 -  small fix

* #3168 - add waitForPageInit

---------

Co-authored-by: Olga Mazurina <olga_mazurina@epam.com>
  • Loading branch information
OlgaMazurina and Olga Mazurina authored Sep 19, 2023
1 parent b88b806 commit 3e846bf
Show file tree
Hide file tree
Showing 75 changed files with 7,980 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-magic-numbers */
import { MolfileFormat } from '@app/../packages/ketcher-core/dist';
import { expect, test } from '@playwright/test';
import {
takeEditorScreenshot,
Expand Down Expand Up @@ -547,3 +548,250 @@ test('Open V3000 file with R-Groups with Fragments', async ({ page }) => {
await openFileAndAddToCanvas('RGroup-With-Fragments.mol', page);
await takeEditorScreenshot(page);
});

test.describe('Open and Save file', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
});

test.describe('Open file', () => {
/*
* Test case: EPMLSOPKET-1852, 1856, 1874, 1890, 1895, 1979, 8914, 12966, 4731, 5259, 1875, 1876, 12963
* Description: The structure is correctly rendered on the canvas
*/
const files = [
{
testName: 'Open/Save structure with bond properties',
path: 'Molfiles-V2000/all-bond-properties.mol',
},
{
testName: 'Open/Save Alias and Pseudoatoms',
path: 'Molfiles-V2000/alias-and-pseudoatoms.mol',
},
{
testName: 'Open/Save V3000 mol file contains Rgroup',
path: 'Molfiles-V3000/rgroup-V3000.mol',
},
{
testName: 'Open/Save V3000 mol file contains more than 900 symbols',
path: 'Molfiles-V3000/more-900-atoms.mol',
},
{
testName: 'Open/Save V3000 mol file contains Sgroup',
path: 'Molfiles-V3000/multi-V3000.mol',
},
{
testName: 'Save structure as *.mol V3000',
path: 'Molfiles-V3000/multi-V3000.mol',
},
{
testName: 'MDL Molfile v2000: Correct padding for M ALS',
path: 'Molfiles-V2000/molfile-with-als.mol',
},
{
testName: 'Open structure with R-Group from v3000 mol file',
path: 'Molfiles-V3000/rgroup-V3000.mol',
},
{
testName: 'Don`t creates invalid molfiles with "NaN"',
path: 'Molfiles-V2000/benzoic-acid-with-na.mol',
},
{
testName: 'Functional group name layout close to attachment point',
path: 'Molfiles-V2000/display-abbrev-groups-example.mol',
},
{
testName: 'Open/Save file with S-Groups',
path: 'Molfiles-V2000/sgroup-different.mol',
},
{
testName: 'Open/Save V3000 mol file contains Sgroup - 2',
path: 'Molfiles-V3000/sgroup-different-V3000.mol',
},
{
testName: 'Open/Save v3000 mol file with assigned Alias',
path: 'Molfiles-V3000/chain-with-alias.mol',
},
];

for (const file of files) {
test(`${file.testName}`, async ({ page }) => {
await openFileAndAddToCanvas(file.path, page);
await takeEditorScreenshot(page);
});
}
});

test.describe('Save file', () => {
/*
* Test case: EPMLSOPKET-1856, 1874, 1890, 1895, 1875, 1876, 12963
* Description: The saved structure is correctly rendered on the canvas
*/
const files = [
{
testName: 'Open/Save Alias and Pseudoatoms',
pathToOpen: 'Molfiles-V2000/alias-and-pseudoatoms.mol',
pathToExpected: 'Molfiles-V2000/alias-and-pseudoatoms-expected.mol',
format: 'v2000',
},
{
testName: 'Open/Save V3000 mol file contains Rgroup',
pathToOpen: 'Molfiles-V3000/rgroup-V3000.mol',
pathToExpected: 'Molfiles-V3000/rgroup-V3000-expected.mol',
format: 'v3000',
},
{
testName: 'Open/Save V3000 mol file contains more than 900 symbols',
pathToOpen: 'Molfiles-V3000/more-900-atoms.mol',
pathToExpected: 'Molfiles-V3000/more-900-atoms-expected.mol',
format: 'v3000',
},
{
testName: 'Open/Save V3000 mol file contains Sgroup',
pathToOpen: 'Molfiles-V3000/multi-V3000.mol',
pathToExpected: 'Molfiles-V3000/multi-V3000-expected.mol',
format: 'v3000',
},
{
testName: 'Open/Save V3000 mol file contains Sgroup - 2',
pathToOpen: 'Molfiles-V3000/sgroup-different-V3000.mol',
pathToExpected: 'Molfiles-V2000/sgroup-different-V2000-expected.mol',
format: 'v2000',
},
{
testName: 'Open/Save v3000 mol file with assigned Alias',
pathToOpen: 'Molfiles-V3000/chain-with-alias.mol',
pathToExpected: 'Molfiles-V3000/chain-with-alias-expected.mol',
format: 'v3000',
},
];

for (const file of files) {
test(`${file.testName}`, async ({ page }) => {
await openFileAndAddToCanvas(file.pathToOpen, page);

const expectedFile = await getMolfile(
page,
file.format as MolfileFormat,
);
await saveToFile(file.pathToExpected, expectedFile);

const METADATA_STRING_INDEX = [1];
const { fileExpected: molFileExpected, file: molFile } =
await receiveFileComparisonData({
page,
expectedFileName: `tests/test-data/${file.pathToExpected}`,
fileFormat: file.format as MolfileFormat,
metaDataIndexes: METADATA_STRING_INDEX,
});

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

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,
);

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);
});

for (let i = 1; i < 9; i++) {
test(`Open/Save files for ferrocen-like structures 1/2 - open ferrocene_radical0${i}.mol`, async ({
page,
}) => {
/**
* Test case: EPMLSOPKET-1893(1)
* Description: Structures are rendered correctly
*/

await openFileAndAddToCanvas(
`Molfiles-V2000/ferrocene-radical0${i}.mol`,
page,
);
await takeEditorScreenshot(page);
await page.keyboard.press('Control+a');
await page.keyboard.press('Delete');
});
}

test('Open/Save files for ferrocen-like structures 2/2 - save', async ({
page,
}) => {
/**
* Test case: EPMLSOPKET-1893(2)
* Description: Structures are rendered correctly.
* */

for (let i = 1; i < 9; i++) {
await openFileAndAddToCanvas(
`Molfiles-V2000/ferrocene-radical0${i}.mol`,
page,
);
}

const expectedFile = await getMolfile(page, 'v2000');
await saveToFile(
'Molfiles-V2000/ferrocene-radical-8-expected.mol',
expectedFile,
);

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

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

test('MDL Molfile v2000: Correct padding for M ALS 2/2 - check padding', async ({
page,
}) => {
/**
* Test case: EPMLSOPKET-8914(2)
* Description: Files opens.
* Alias is located on the atom to which we assigned it
* */

await openFileAndAddToCanvas('Molfiles-V2000/molfile-with-als.mol', page);
const expectedFile = await getMolfile(page, 'v2000');
const isCorrectPadding = expectedFile.includes('N ');

expect(isCorrectPadding).toEqual(true);
});
});
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.
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.
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,20 @@

Ketcher 9152313 72D 1 1.00000 0.00000 0

7 6 0 0 0 0 0 0 0 0999 V2000
12.4769 -8.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.3429 -8.5500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.2090 -8.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.0750 -8.5500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.9410 -8.0500 0.0000 G 0 0 0 0 0 0 0 0 0 0 0 0
16.8070 -8.5500 0.0000 GH 0 0 0 0 0 0 0 0 0 0 0 0
17.6731 -8.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0
2 3 1 0 0 0
3 4 1 0 0 0
4 5 1 0 0 0
5 6 1 0 0 0
6 7 1 0 0 0
A 2
alias123
M END
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Ketcher 8242313 02D 1 1.00000 0.00000 0

7 6 0 0 0 0 0 0 0 0999 V2000
6.4000 -7.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.2660 -7.5500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.1321 -7.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.9981 -7.5500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
9.8641 -7.0500 0.0000 G 0 0 0 0 0 0 0 0 0 0 0 0
10.7301 -7.5500 0.0000 GH 0 0 0 0 0 0 0 0 0 0 0 0
11.5962 -7.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0
2 3 1 0 0 0
3 4 1 0 0 0
4 5 1 0 0 0
5 6 1 0 0 0
6 7 1 0 0 0
A 2
alias123
M END
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Ketcher 8242310232D 1 1.00000 0.00000 0

8 7 0 0 0 0 0 0 0 0999 V2000
9.3500 -7.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.2160 -7.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.0821 -7.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.9481 -7.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.8141 -7.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.6801 -7.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.5462 -7.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
15.4122 -7.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 0 0 0
2 3 1 0 0 0
3 4 2 0 0 0
4 5 1 0 0 0
5 6 1 0 0 0
6 7 2 0 0 0
7 8 1 0 0 0
M END
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Ketcher 9142313362D 1 1.00000 0.00000 0
Ketcher 9152313 62D 1 1.00000 0.00000 0

10 9 0 0 1 0 0 0 0 0999 V2000
12.0438 -8.0500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Ketcher 8252314252D 1 1.00000 0.00000 0

10 9 0 0 0 0 0 0 0 0999 V2000
20.4648 -10.6547 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.3304 -12.1530 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
21.3313 -11.1553 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
20.4635 -12.6534 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.5945 -11.1572 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
19.6003 -12.1573 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
22.1976 -10.6559 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
23.0633 -11.1564 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
22.1982 -9.6559 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
24.2388 -9.9451 0.0000 Na 0 0 0 0 0 0 0 0 0 0 0 0
3 1 1 0 0 0
4 2 1 0 0 0
1 5 2 0 0 0
2 3 2 0 0 0
5 6 1 0 0 0
6 4 2 0 0 0
3 7 1 0 0 0
7 8 1 0 0 0
7 9 2 0 0 0
M CHG 2 8 -1 10 1
M END
Loading

0 comments on commit 3e846bf

Please sign in to comment.