Skip to content

Commit

Permalink
#6266 - Autotests: Replace direct monomer addressing with selectMonom…
Browse files Browse the repository at this point in the history
…er helper function (#6327)

* refactor: renamed values in the Sugars enum

* refactor: improve monomer selection and favorites management, update constants usage

What was done:
- Enhanced `selectMonomer` to support selecting various monomers across different tabs, including the Favorites tab. Added `selectMonomers`.
- Added `addMonomerToFavorites`, `addMonomersToFavorites`, `removeMonomerFromFavorites`, and `removeMonomersFromFavorites` for better management of favorites. Updated usage to leverage these functions directly.
- Moved monomer test IDs to the `monomer` constants file for centralized management and easier reuse.
- Removed unused selectors to clean up the codebase.

* feat: add new base '2imen2' to Bases enum and update test selectors for consistency

---------

Co-authored-by: Svetlana Demid <[email protected]>
  • Loading branch information
split-ends and Svetlana Demid authored Jan 21, 2025
1 parent 3513a0d commit 02647ce
Show file tree
Hide file tree
Showing 35 changed files with 924 additions and 988 deletions.
124 changes: 124 additions & 0 deletions ketcher-autotests/constants/monomers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
export enum Bases {
A = 'A___Adenine',
_2imen2 = '2imen2___N2-[(Imidazo-2-yl)ethylamino]adenine',
_5meC = '5meC___5-methylcytosine',
baA = 'baA___N6-benzyladenine',
c7A = 'c7A___7-Deazaadenine',
clA = 'clA___T-clamp OMe',
dabA = 'dabA___7-deaza-8-aza-7-bromo-2-amino-Adenine',
oC64m5 = 'oC64m5___4-Hexan-6-ol-5-methylcytosine',
nC6n2G = 'nC6n2G___6-Aminohexyl-2-aminoguanine',
nC6n5C = 'nC6n5C___Amino-Modier C6 dC',
nC6n8A = 'nC6n8A___6-Aminohexyl-8-aminoadenine',
meA = 'meA___N6-methyladenine',
DNA_N = '_A___Adenine_C___Cytosine_G___Guanine_T___Thymine',
DNA_B = '_C___Cytosine_G___Guanine_T___Thymine',
DNA_D = '_A___Adenine_G___Guanine_T___Thymine',
DNA_H = '_A___Adenine_C___Cytosine_T___Thymine',
DNA_K = '_G___Guanine_T___Thymine',
DNA_W = '_A___Adenine_T___Thymine',
DNA_Y = '_C___Cytosine_T___Thymine',
RNA_N = '_A___Adenine_C___Cytosine_G___Guanine_U___Uracil',
RNA_B = '_C___Cytosine_G___Guanine_U___Uracil',
RNA_D = '_A___Adenine_G___Guanine_U___Uracil',
RNA_H = '_A___Adenine_C___Cytosine_U___Uracil',
RNA_K = '_G___Guanine_U___Uracil',
RNA_W = '_A___Adenine_U___Uracil',
RNA_Y = '_C___Cytosine_U___Uracil',
M = '_A___Adenine_C___Cytosine',
R = '_A___Adenine_G___Guanine',
S = '_C___Cytosine_G___Guanine',
V = '_A___Adenine_C___Cytosine_G___Guanine',
}

export enum Chem {
_4aPEGMal = '4aPEGMal___4-Arm PEG-Maleimide',
_4FB = '4FB___4-Formylbenzamide',
A6OH = 'A6OH___6-amino-hexanol',
Az = 'Az___4-azidobutyric acid',
B7 = 'B7___Biotin',
DOTA = 'DOTA___Tetraxetan',
EG = 'EG___Ethylene Glycol',
fisL = 'flsL___Lactone fluorescein',
fisQ = 'flsQ___P-quinoid fluorescein',
hxy = 'hxy___5-hexyn-1-ol',
Mal = 'Mal___Maleimide',
MCC = 'MCC___4-(N-maleimidomethyl)cyclohexane-1-carboxylate',
PEG_2 = 'PEG-2___Diethylene Glycol',
PEG_4 = 'PEG-4___Tetraethylene glycol',
PEG_6 = 'PEG-6___Hexaethylene glycol',
sDBL = 'sDBL___Symmetric Doubler',
SMCC = 'SMCC___SMCC',
SMPEG2 = 'SMPEG2___SM(PEG)2',
SS3 = 'SS3___Dipropanol-disulfide',
Test_6_Ch = 'Test-6-Ch___Test-6-AP-Chem',
}

export enum Nucleotides {
_2_damdA = '2-damdA___2,6-Diaminopurine',
_5hMedC = '5hMedC___Hydroxymethyl dC',
Super_G = 'Super G___8-aza-7-deazaguanosine',
AmMC6T = 'AmMC6T___Amino Modifier C6 dT',
Super_T = 'Super T___5-hydroxybutynl-2’-deoxyuridine',
_5Br_dU = '5Br-dU___5-Bromo-deoxyuridine',
_5NitInd = '5NitInd___5-Nitroindole',
}

export enum Peptides {
A = 'A___Alanine',
Ala_al = 'Ala-al___(2S)-2-aminopropanal',
_1Nal = '1Nal___3-(1-naphthyl)-alanine',
_NHBn = '-NHBn___C-Terminal benzylamino',
bAla = 'bAla___beta-Alanine',
Boc_ = 'Boc-___N-Terminal tert-butyloxycarbonyl',
Cys_Bn = 'Cys_Bn___S-benzylcysteine',
dA = 'dA___D-Alanine',
D_2Nal = 'D-2Nal___D-3-(2-naphthyl)-alanine',
D_OAla = 'D-OAla___D-Lactic acid',
Edc = 'Edc___S-ethylthiocysteine',
meD = 'meD___N-Methyl-Aspartic acid',
meM = 'meM___N-Methyl-Methionine',
Test_6_P = 'Test-6-P___Test-6-AP-Peptide',
Tza = 'Tza___3-(4-Thiazolyl)-alanine',
Phe4Me = 'Phe4Me___p-Methylphenylalanine',
Hcy = 'Hcy___homocysteine',
X = '_A___Alanine_C___Cysteine_D___Aspartic acid_E___Glutamic acid_F___Phenylalanine_G___Glycine_H___' +
'Histidine_I___Isoleucine_K___Lysine_L___Leucine_M___Methionine_N___Asparagine_O___Pyrrolysine_P__' +
'_Proline_Q___Glutamine_R___Arginine_S___Serine_T___Threonine_U___Selenocysteine_V___Valine_W___Tryptophan_Y___Tyrosine',
B = '_D___Aspartic acid_N___Asparagine',
J = '_L___Leucine_I___Isoleucine',
Z = '_E___Glutamic acid_Q___Glutamine',
}

export enum Phosphates {
Test_6_Ph = 'Test-6-Ph___Test-6-AP-Phosphate',
P = 'P___Phosphate',
sP_ = 'sP-___Dihydrogen phosphorothioate',
bP = 'bP___Boranophosphate',
moen = 'moen___2-Methoxyethylamino',
ibun = 'ibun___Isobutylamino',
}

export enum Presets {
A = 'A_A_R_P',
C = 'C_C_R_P',
G = 'G_G_R_P',
T = 'T_T_R_P',
dR_U_P = 'dR(U)P_U_dR_P',
MOE_A_P = 'MOE(A)P_A_MOE_P',
MOE_5meC_P = 'MOE(5meC)P_5meC_MOE_P',
MOE_G_P = 'MOE(G)P_G_MOE_P',
MOE_T_P = 'MOE(T)P_T_MOE_P',
}

export enum Sugars {
R = 'R___Ribose',
_3A6 = "3A6___6-amino-hexanol (3' end)",
_3SS6 = "3SS6___Thiol Modifier 6 S-S (3' end)",
_5cGT = "5cGT___2-(methylamino)acetamidate (5' end)",
_5formD = '5formD___5-Formyl-2-deoxyribose',
_12ddR = "12ddR___1',2'-dideoxyribose",
_25d3r = '25d3r___3-Deoxyribose (2,5 connectivity)',
_25R = '25R___Ribose (2,5 connectivity)',
_25mo3r = '25mo3r___3-O-Methylribose (2,5 connectivity)',
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Bases, Peptides } from '@constants/monomers';
import { test } from '@playwright/test';
import {
waitForPageInit,
Bases,
Peptides,
clickOnTheCanvas,
selectMonomer,
takeEditorScreenshot,
clickOnTheCanvas,
waitForPageInit,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import { goToRNATab, MonomerLocationTabs } from '@utils/macromolecules/library';
import { MonomerLocationTabs } from '@utils/macromolecules/library';

interface IAmbiguousMonomerName {
testDescription: string;
Expand Down Expand Up @@ -141,7 +140,6 @@ test.describe('Put ambiguous monomer on the canvas from library:', () => {
2. Click at the center of canvas
3. Take screenshot of the canvas to make sure selected monomer appeared on the canvas
*/
await goToRNATab(page);
await selectMonomer(page, AmbiguousMonomer.AmbiguousMonomerName);
await clickOnTheCanvas(page, 0, 0);
await takeEditorScreenshot(page);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Chem } from '@constants/monomers';
import { test } from '@playwright/test';
import {
clickInTheMiddleOfTheScreen,
openFileAndAddToCanvasMacro,
pressButton,
selectMacroBond,
selectMonomer,
takeEditorScreenshot,
waitForPageInit,
} from '@utils';
Expand All @@ -22,11 +24,7 @@ test('Select chem and drag it to canvas', async ({ page }) => {

// Click on POLYMER_TOGGLER
await turnOnMacromoleculesEditor(page);
await page.getByText('CHEM').click();

// Click on <div> "sDBL___Symmetric Doubler"
await page.click('[data-testid="sDBL___Symmetric Doubler"]');

await selectMonomer(page, Chem.sDBL);
// Click on <svg> #polymer-editor-canvas
await clickInTheMiddleOfTheScreen(page);
await hideMonomerPreview(page);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Peptides } from '@constants/monomers';
import { test, expect } from '@playwright/test';
import {
addSingleMonomerToCanvas,
Expand All @@ -18,7 +19,6 @@ import {
pressRedoButton,
pressUndoButton,
} from '@utils/macromolecules/topToolBar';
import { Peptides } from '@utils/selectors/macromoleculeEditor';
/* eslint-disable no-magic-numbers */

test.describe('Clear Canvas Tool', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Bases, Chem, Peptides } from '@constants/monomers';
import { test, expect } from '@playwright/test';
import {
addSingleMonomerToCanvas,
Expand All @@ -13,11 +14,9 @@ import {
selectSnakeLayoutModeTool,
takeEditorScreenshot,
waitForPageInit,
Peptides as Peptides2,
selectMonomer,
clickOnTheCanvas,
selectRectangleSelectionTool,
Bases,
selectAllStructuresOnCanvas,
clickOnCanvas,
selectMacroBond,
Expand All @@ -30,10 +29,8 @@ import {
turnOnMacromoleculesEditor,
zoomWithMouseWheel,
} from '@utils/macromolecules';
import { goToRNATab } from '@utils/macromolecules/library';
import { bondTwoMonomers } from '@utils/macromolecules/polymerBond';
import { pressUndoButton } from '@utils/macromolecules/topToolBar';
import { Peptides } from '@utils/selectors/macromoleculeEditor';
import {
FileType,
verifyFileExport,
Expand Down Expand Up @@ -146,8 +143,7 @@ test.describe('Erase Tool', () => {
Test case: Erase Tool
Description: CHEM is deleted.
*/
await page.getByTestId('CHEM-TAB').click();
await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click();
await selectMonomer(page, Chem.Test_6_Ch);
await clickInTheMiddleOfTheScreen(page);
await moveMouseAway(page);
await takeEditorScreenshot(page);
Expand Down Expand Up @@ -439,8 +435,7 @@ test.describe('Erase Tool', () => {
4. Press Delete tool
5. Take screenshot to make sure canvas is empty
*/
await goToRNATab(page);
await selectMonomer(page, Peptides2.X);
await selectMonomer(page, Peptides.X);
await clickOnTheCanvas(page, 0, 0);

await selectRectangleSelectionTool(page);
Expand All @@ -466,7 +461,6 @@ test.describe('Erase Tool', () => {
4. Press Delete tool
5. Take screenshot to make sure canvas is empty
*/
await goToRNATab(page);
await selectMonomer(page, Bases.DNA_N);
await clickOnTheCanvas(page, 0, 0);

Expand All @@ -493,8 +487,7 @@ test.describe('Erase Tool', () => {
4. Press Del key
5. Take screenshot to make sure canvas is empty
*/
await goToRNATab(page);
await selectMonomer(page, Peptides2.Z);
await selectMonomer(page, Peptides.Z);
await clickOnTheCanvas(page, 0, 0);

await selectRectangleSelectionTool(page);
Expand All @@ -520,7 +513,6 @@ test.describe('Erase Tool', () => {
4. Press Del key
5. Take screenshot to make sure canvas is empty
*/
await goToRNATab(page);
await selectMonomer(page, Bases.RNA_N);
await clickOnTheCanvas(page, 0, 0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import { test } from '@playwright/test';
import {
addMonomerToFavorites,
clickInTheMiddleOfTheScreen,
selectMonomer,
takeEditorScreenshot,
waitForPageInit,
} from '@utils';
import {
ALANINE,
getFavoriteButtonSelector,
} from '@utils/selectors/macromoleculeEditor';
import {
hideMonomerPreview,
turnOnMacromoleculesEditor,
} from '@utils/macromolecules';
import { Peptides } from '@constants/monomers';

test('Add molecule to favorites, switch to Favorites tab and drag it to the canvas', async ({
page,
}) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);

await page.click(getFavoriteButtonSelector(ALANINE));
await page.getByText('Favorites').click();
await page.click(ALANINE);
await addMonomerToFavorites(page, Peptides.A);
await selectMonomer(page, Peptides.A, true);
await clickInTheMiddleOfTheScreen(page);
await hideMonomerPreview(page);

Expand Down
Loading

0 comments on commit 02647ce

Please sign in to comment.