Skip to content

Commit

Permalink
Autotests: #5960 autotests display molecules in macro mode basic stru…
Browse files Browse the repository at this point in the history
…ctures with atoms and bonds (#5983)

* Verify that bond lines between atoms do not overlap in any angle in macro mode

* screen

* Verify that connections between monomers and molecules are maintained correctly in both micro and macro modes

* Verify that switching between micro and macro modes displays molecules without structural changes

* Verify that deleting a bond in macro mode removes the bond while maintaining the integrity of the surrounding structure

* Verify that the structure in macro mode can be saved as a .ket file, and all elements including bonds and atoms are correctly restored when re-loaded

* Peptides - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode

* Bases - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode

* CHEMS - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode

* Nucleotide - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode - Part 1

* Nucleotide - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode - Part 2

* Phosphates - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode
and
HELM results correction

* Sugar - Verify that connection points between monomers and molecules can be created by drawing bonds in macro mode

* phosphate fix

* Nucleotide fix

* Peptide fix

* phosphate fix

* Sugar fix

* CHEMs fix

* Bases fix

* Some fixes
  • Loading branch information
AlexeyGirin authored Nov 19, 2024
1 parent 0c9dc01 commit f873318
Show file tree
Hide file tree
Showing 143 changed files with 16,261 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ test.beforeAll(async ({ browser }) => {
});

test.afterEach(async () => {
await page.keyboard.press('Escape');
await page.keyboard.press('Escape');
// await page.keyboard.press('Control+0');
await selectClearCanvasTool(page);
// await page.keyboard.press('Control+0');
});

test.afterAll(async ({ browser }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,77 +347,72 @@ const correctHELMStrings: IHELMString[] = [
helmDescription: '48. RNA(RA) with single inline Extended SMILES (A)',
HELMString:
'RNA1{R([C1(C2=C(N=CN=1)N%91C=N2)N.[*:1]%91 |$;;;;;;;;;;_R1$|])}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
pageReloadNeeded: true,
differentHELMExport:
'RNA1{R([C1(N)=NC=NC2N([*:1])C=NC1=2 |$;;;;;;;_R1;;;$|])}$$$$V2.0',
},
{
helmDescription: '49. RNA(RAP) with single inline Extended SMILES (A)',
HELMString:
'RNA1{R([C1(C2=C(N=CN=1)N%91C=N2)N.[*:1]%91 |$;;;;;;;;;;_R1$|])P}$$$$V2.0',
shouldFail: true,
issueNumber:
'https://github.com/epam/Indigo/issues/2339, https://github.com/epam/Indigo/issues/2337',
differentHELMExport:
'RNA1{R([C1(N)=NC=NC2N([*:1])C=NC1=2 |$;;;;;;;_R1;;;$|])P}$$$$V2.0',
},
{
helmDescription: '50. RNA(RP) with single inline Extended SMILES (P)',
HELMString: 'RNA1{R[P%91(O)(O)=O.[*:1]%91 |$;;;;_R1$|]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport: 'RNA1{R[P([*:1])(=O)(O)O |$;_R1;;;$|]}$$$$V2.0',
},
{
helmDescription: '51. RNA(RP) with single inline Extended SMILES (R)',
HELMString:
'RNA1{[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]P}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport:
'RNA1{[O1C(CO[*:1])C(O[*:2])C(O)C1[*:3] |$;;;;_R1;;;_R2;;;;_R3$|]P}$$$$V2.0',
},
{
helmDescription: '52. RNA(RAP) with single inline Extended SMILES (P)',
HELMString: 'RNA1{R(A)[P%91(O)(O)=O.[*:1]%91 |$;;;;_R1$|]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport: 'RNA1{R(A)[P([*:1])(=O)(O)O |$;_R1;;;$|]}$$$$V2.0',
pageReloadNeeded: true,
},
{
helmDescription:
'53. RNA(RAP) with all monomer inline Extended SMILES (RAP)',
HELMString:
'RNA1{[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|](A)P}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2339',
differentHELMExport:
'RNA1{[O1C(CO[*:1])C(O[*:2])C(O)C1[*:3] |$;;;;_R1;;;_R2;;;;_R3$|](A)P}$$$$V2.0',
pageReloadNeeded: true,
},
{
helmDescription:
'54. Single peptide with inline SMILES (L) without attachment points',
HELMString: 'PEPTIDE1{[C([C@@H](C(O)=O)N[H])C(C)C]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport: 'PEPTIDE1{[C(C(C)C)C(N[H])C(=O)O]}$$$$V2.0',
pageReloadNeeded: true,
},
{
helmDescription: '55. Single peptide with inline Extended SMILES (L)',
HELMString:
'PEPTIDE1{[C([C@@H](C%91=O)N%92)C(C)C.[*:2]%91.[*:1]%92 |$;;;;;;;;_R2;_R1$|]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport:
'PEPTIDE1{[C(C(C)C)C(N[*:1])C([*:2])=O |$;;;;;;_R1;;_R2;$|]}$$$$V2.0',
pageReloadNeeded: true,
},
{
helmDescription:
'56. Single CHEM with inline SMILES (A6OH) without attachment points',
HELMString: 'CHEM1{[N([H])CCCCCCO[H]]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport: 'CHEM1{[N(CCCCCCO[H])[H]]}$$$$V2.0',
pageReloadNeeded: true,
},
{
helmDescription: '57. Single CHEM with inline Extended SMILES (A6OH)',
HELMString:
'CHEM1{[N%91CCCCCCO%92.[*:2]%91.[*:1]%92 |$;;;;;;;;_R2;_R1$|]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport:
'CHEM1{[N([*:2])CCCCCCO[*:1] |$;_R2;;;;;;;;_R1$|]}$$$$V2.0',
pageReloadNeeded: true,
},
{
Expand All @@ -427,20 +422,23 @@ const correctHELMStrings: IHELMString[] = [
'[C%91([C@H](CS%92)N%93)=O.[*:2]%91.[*:1]%93.[*:3]%92 |$;;;;;;_R2;_R1;_R3$|].' +
'[C%91([C@H](CC(O%92)=O)N%93)=O.[*:1]%93.[*:2]%91.[*:3]%92 |$;;;;;;;;_R1;_R2;_R3$|].' +
'[C([C@@H](C%91=O)N%92)C(C)C.[*:2]%91.[*:1]%92 |$;;;;;;;;_R2;_R1$|]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2337',
differentHELMExport:
'PEPTIDE1{[N([*:1])C(C)C([*:2])=O |$;_R1;;;;_R2;$|].' +
'[C([*:2])(=O)C(N[*:1])CS[*:3] |$;_R2;;;;_R1;;;_R3$|].' +
'[C([*:2])(=O)C(N[*:1])CC(=O)O[*:3] |$;_R2;;;;_R1;;;;;_R3$|].' +
'[C(C(C)C)C(N[*:1])C([*:2])=O |$;;;;;;_R1;;_R2;$|]}$$$$V2.0',
pageReloadNeeded: true,
},
{
helmDescription:
'59. List of RNAs of inline Extended Smiles (R(A)P, R(C)P, R(G)P)',
HELMString:
// eslint-disable-next-line max-len
'RNA1{[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]([C1(C2=C(N=CN=1)N%91C=N2)N.[*:1]%91 |$;;;;;;;;;;_R1$|])[P%91(O)(O)=O.[*:1]%91 |$;;;;_R1$|]' +
'RNA1{[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]([C1(C2=C(N=CN=1)N%91C=N2)N.[*:1]%91 |$;;;;;;;;;;_R1$|])[P%91%92(=O)O.[*:2]%91.[*:1]%92 |$;;;_R2;_R1$|].' +
// eslint-disable-next-line max-len
'.[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]([C1(N)=NC(=O)N%91C=C1.[*:1]%91 |$;;;;;;;;_R1$|])[P%91(O)(O)=O.[*:1]%91 |$;;;;_R1$|].' +
'[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]([C1(N)=NC(=O)N%91C=C1.[*:1]%91 |$;;;;;;;;_R1$|])[P%91%92(=O)O.[*:2]%91.[*:1]%92 |$;;;_R2;_R1$|].' +
// eslint-disable-next-line max-len
'[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]([C1(C2=C(N=C(N)N1)N%91C=N2)=O.[*:1]%91 |$;;;;;;;;;;;_R1$|])[P%91(O)(O)=O.[*:1]%91 |$;;;;_R1$|]}$$$$V2.0',
'[O1[C@@H]%91[C@H](O)[C@H](O%92)[C@H]1CO%93.[*:3]%91.[*:1]%93.[*:2]%92 |$;;;;;;;;;_R3;_R1;_R2$|]([C1(C2=C(N=C(N)N1)N%91C=N2)=O.[*:1]%91 |$;;;;;;;;;;;_R1$|])[P%91%92(=O)O.[*:2]%91.[*:1]%92 |$;;;_R2;_R1$|]}$$$$V2.0',
shouldFail: true,
issueNumber: 'https://github.com/epam/Indigo/issues/2339',
},
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 @@ -23,8 +23,10 @@ import {
openFileAndAddToCanvasAsNewProjectMacro,
Sugars,
selectAllStructuresOnCanvas,
openFileAndAddToCanvasAsNewProject,
} from '@utils';
import { pageReload } from '@utils/common/helpers';
import { FileType, verifyFile2 } from '@utils/files/receiveFileComparisonData';
import {
turnOnMacromoleculesEditor,
zoomWithMouseWheel,
Expand Down Expand Up @@ -892,3 +894,31 @@ test.describe('Sugar monomers on the canvas, their connection points and preview
// await takeEditorScreenshot(page);
// });
// }

test(`Verify that the structure in macro mode can be saved as a .ket file, and all elements including bonds and atoms are correctly restored when re-loaded`, async () => {
/*
* Test task: https://github.com/epam/ketcher/issues/5960
* Description: Verify that the structure in macro mode can be saved as a .ket file, and all elements including bonds and atoms are correctly restored when re-loaded
* Case: 1. Load monomer on Macrolecules mode
* 2. Take screenshot to witness original state
* 3. Save canvas to KET
* 4. Verify that export result equal to template
* 5. Load saved KET to the canvas
* 6. Take screenshot to witness saved state
* (screenshots have to be equal)
*/

const KETFile =
'KET/Micro-Macro-Switcher/Complicated structures on the canvas.ket';
const KETFileExpected =
'tests/test-data/KET/Micro-Macro-Switcher/Complicated structures on the canvas-expected.ket';

await openFileAndAddToCanvasAsNewProject(KETFile, page);
await takeEditorScreenshot(page);
await verifyFile2(page, KETFileExpected, FileType.KET);
await openFileAndAddToCanvasAsNewProject(
KETFileExpected.replace('tests/test-data/', ''),
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/* eslint-disable no-self-compare */
/* eslint-disable max-len */
/* eslint-disable no-magic-numbers */
import {
chooseTab,
Tabs,
turnOnMacromoleculesEditor,
turnOnMicromoleculesEditor,
} from '@utils/macromolecules';
import { Page, test } from '@playwright/test';
import {
takeEditorScreenshot,
openFileAndAddToCanvasAsNewProject,
selectClearCanvasTool,
waitForPageInit,
selectEraseTool,
} from '@utils';
import { clickOnMicroBondByIndex } from '@utils/macromolecules/polymerBond';

let page: Page;

async function configureInitialState(page: Page) {
await chooseTab(page, Tabs.Rna);
}

test.beforeAll(async ({ browser }) => {
const context = await browser.newContext();
page = await context.newPage();

await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
await configureInitialState(page);
});

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

test.afterAll(async ({ browser }) => {
await Promise.all(browser.contexts().map((context) => context.close()));
});

test(`Verify that bond lines between atoms do not overlap in any angle in macro mode`, async () => {
/*
* Test task: https://github.com/epam/ketcher/issues/5960
* Description: Verify that bond lines between atoms do not overlap in any angle in macro mode
*
* Case: 1. Load ket file with structures
* 2. Take screenshot to witness canvas was rendered correct
*/
await openFileAndAddToCanvasAsNewProject(
'KET/Micro-Macro-Switcher/Micro bonds on macro canvas.ket',
page,
);
await takeEditorScreenshot(page);

// Test should be skipped if related bug exists
test.fixme(
true === true,
`That test results are wrong because of https://github.com/epam/ketcher/issues/5961 issue(s).`,
);
});

test(`Verify that connections between monomers and molecules are maintained correctly in both micro and macro modes`, async () => {
/*
* Test task: https://github.com/epam/ketcher/issues/5960
* Description: Verify that connections between monomers and molecules are maintained correctly in both micro and macro modes
*
* Case: 1. Load ket file with structures
* 2. Take screenshot to witness canvas was rendered correct at macro
* 3. Switch to Micromolecules mode
* 4. Take screenshot to witness canvas was rendered correct at micro
*/
await openFileAndAddToCanvasAsNewProject(
'KET/Micro-Macro-Switcher/All type of monomers connected to micro.ket',
page,
);
await takeEditorScreenshot(page);

await turnOnMicromoleculesEditor(page);
await takeEditorScreenshot(page);

await turnOnMacromoleculesEditor(page);
});

test(`Verify that switching between micro and macro modes displays molecules without structural changes`, async () => {
/*
* Test task: https://github.com/epam/ketcher/issues/5960
* Description: Verify that switching between micro and macro modes displays molecules without structural changes
*
* Case: 1. Load ket file with structures at Macro
* 2. Take screenshot to witness canvas was rendered correct at macro
* 3. Switch to Micromolecules mode
* 4. Take screenshot to witness canvas was rendered correct at micro
* Canvases should be equal
*/
await turnOnMicromoleculesEditor(page);
await openFileAndAddToCanvasAsNewProject(
'KET/Micro-Macro-Switcher/Complicated structures on the canvas.ket',
page,
);
await takeEditorScreenshot(page);

await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});

test(`Verify that deleting a bond in macro mode removes the bond while maintaining the integrity of the surrounding structure`, async () => {
/*
* Test task: https://github.com/epam/ketcher/issues/5960
* Description: Verify that deleting a bond in macro mode removes the bond while maintaining the integrity of the surrounding structure
*
* Case: 1. Load ket file with structures at Macro
* 2. Take screenshot to witness initial state
* 3. Delete all bonds at the center of every molecule
* 4. Take screenshot to witness final state
*/
await openFileAndAddToCanvasAsNewProject(
'KET/Micro-Macro-Switcher/All Bonds on Macro.ket',
page,
);
await takeEditorScreenshot(page);

await selectEraseTool(page);
// removing single bond
await clickOnMicroBondByIndex(page, 39);
// removing double bond
await clickOnMicroBondByIndex(page, 45);
// removing single up bond
await clickOnMicroBondByIndex(page, 51);
// removing single down bond
await clickOnMicroBondByIndex(page, 51);

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.
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 f873318

Please sign in to comment.