diff --git a/ketcher-autotests/constants/monomers.ts b/ketcher-autotests/constants/monomers.ts new file mode 100644 index 0000000000..0e5c487ed5 --- /dev/null +++ b/ketcher-autotests/constants/monomers.ts @@ -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)', +} diff --git a/ketcher-autotests/tests/Macromolecule-editor/Ambiguous-Monomers/ambiguous-monomer-add-to-canvas.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Ambiguous-Monomers/ambiguous-monomer-add-to-canvas.spec.ts index b927368ca1..94abebb28f 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Ambiguous-Monomers/ambiguous-monomer-add-to-canvas.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Ambiguous-Monomers/ambiguous-monomer-add-to-canvas.spec.ts @@ -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; @@ -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); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-add-to-canvas.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-add-to-canvas.spec.ts index 1d92114f66..2c44d32b44 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-add-to-canvas.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Chem-monomers/chem-add-to-canvas.spec.ts @@ -1,9 +1,11 @@ +import { Chem } from '@constants/monomers'; import { test } from '@playwright/test'; import { clickInTheMiddleOfTheScreen, openFileAndAddToCanvasMacro, pressButton, selectMacroBond, + selectMonomer, takeEditorScreenshot, waitForPageInit, } from '@utils'; @@ -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
"sDBL___Symmetric Doubler" - await page.click('[data-testid="sDBL___Symmetric Doubler"]'); - + await selectMonomer(page, Chem.sDBL); // Click on #polymer-editor-canvas await clickInTheMiddleOfTheScreen(page); await hideMonomerPreview(page); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Clear-Tool/clear-tool.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Clear-Tool/clear-tool.spec.ts index cda89751ca..7e0f38e9da 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Clear-Tool/clear-tool.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Clear-Tool/clear-tool.spec.ts @@ -1,3 +1,4 @@ +import { Peptides } from '@constants/monomers'; import { test, expect } from '@playwright/test'; import { addSingleMonomerToCanvas, @@ -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', () => { diff --git a/ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts index 3377d82898..6ab89a0ea2 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts @@ -1,3 +1,4 @@ +import { Bases, Chem, Peptides } from '@constants/monomers'; import { test, expect } from '@playwright/test'; import { addSingleMonomerToCanvas, @@ -13,11 +14,9 @@ import { selectSnakeLayoutModeTool, takeEditorScreenshot, waitForPageInit, - Peptides as Peptides2, selectMonomer, clickOnTheCanvas, selectRectangleSelectionTool, - Bases, selectAllStructuresOnCanvas, clickOnCanvas, selectMacroBond, @@ -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, @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Favorites/favorites-add-to-canvas.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Favorites/favorites-add-to-canvas.spec.ts index 38f221d716..68c549f07d 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Favorites/favorites-add-to-canvas.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Favorites/favorites-add-to-canvas.spec.ts @@ -1,17 +1,16 @@ 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, @@ -19,9 +18,8 @@ test('Add molecule to favorites, switch to Favorites tab and drag it to the canv 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); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts index eab724b59b..4394c1f70d 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.spec.ts @@ -1,39 +1,47 @@ /* eslint-disable no-magic-numbers */ -import { test, expect, Page, chromium } from '@playwright/test'; import { - TopPanelButton, - openFileAndAddToCanvasMacro, - selectTopPanelButton, - takeEditorScreenshot, - waitForPageInit, - saveToFile, - openFile, - receiveFileComparisonData, + Chem, + Nucleotides, + Peptides, + Phosphates, + Presets, +} from '@constants/monomers'; +import { chromium, expect, Page, test } from '@playwright/test'; +import { chooseFileFormat, - readFileContents, - moveMouseAway, + clickInTheMiddleOfTheScreen, + clickOnCanvas, + copyToClipboardByKeyboard, getIdt, - selectSequenceLayoutModeTool, - selectSnakeLayoutModeTool, - waitForLoad, - pressButton, - selectMacromoleculesPanelButton, MacromoleculesTopPanelButton, - selectClearCanvasTool, - waitForRender, - takePolymerEditorScreenshot, - openStructurePasteFromClipboard, - clickInTheMiddleOfTheScreen, - selectEraseTool, + moveMouseAway, + openFile, openFileAndAddToCanvasAsNewProject, - resetZoomLevelToDefault, - waitForSpinnerFinishedWork, openFileAndAddToCanvasAsNewProjectMacro, - copyToClipboardByKeyboard, + openFileAndAddToCanvasMacro, + openStructurePasteFromClipboard, pasteFromClipboardByKeyboard, + pressButton, + readFileContents, + receiveFileComparisonData, + resetZoomLevelToDefault, + saveToFile, selectAllStructuresOnCanvas, + selectClearCanvasTool, + selectEraseTool, selectMacroBond, - clickOnCanvas, + selectMacromoleculesPanelButton, + selectMonomer, + selectSequenceLayoutModeTool, + selectSnakeLayoutModeTool, + selectTopPanelButton, + takeEditorScreenshot, + takePolymerEditorScreenshot, + TopPanelButton, + waitForLoad, + waitForPageInit, + waitForRender, + waitForSpinnerFinishedWork, } from '@utils'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { @@ -41,6 +49,10 @@ import { closeOpenStructure, pageReload, } from '@utils/common/helpers'; +import { + FileType, + verifyFileExport, +} from '@utils/files/receiveFileComparisonData'; import { chooseTab, enterSequence, @@ -49,22 +61,18 @@ import { turnOnMicromoleculesEditor, zoomWithMouseWheel, } from '@utils/macromolecules'; +import { goToPeptidesTab } from '@utils/macromolecules/library'; import { bondTwoMonomersPointToPoint } from '@utils/macromolecules/polymerBond'; import { toggleNucleotidesAccordion, togglePhosphatesAccordion, } from '@utils/macromolecules/rnaBuilder'; import { clickOnSequenceSymbol } from '@utils/macromolecules/sequence'; +import { pressUndoButton } from '@utils/macromolecules/topToolBar'; import { markResetToDefaultState, processResetToDefaultState, } from '@utils/testAnnotations/resetToDefaultState'; -import { pressUndoButton } from '@utils/macromolecules/topToolBar'; -import { - FileType, - verifyFileExport, -} from '@utils/files/receiveFileComparisonData'; -import { goToPeptidesTab } from '@utils/macromolecules/library'; let page: Page; @@ -196,7 +204,7 @@ test.describe('Import-Saving .idt Files', () => { Test case: Import/Saving files/#4495 Description: In case of peptide monomers are on canvas, error "Peptide monomers are not supported in IDT" appear. */ - await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); + await selectMonomer(page, Peptides._1Nal); await clickInTheMiddleOfTheScreen(page); await selectTopPanelButton(TopPanelButton.Save, page); await chooseFileFormat(page, 'IDT'); @@ -265,19 +273,19 @@ test.describe('Import-Saving .idt Files', () => { await chooseTab(page, Tabs.Rna); await togglePhosphatesAccordion(page); await waitForRender(page, async () => { - await page.getByTestId('P___Phosphate').hover(); + await page.getByTestId(Phosphates.P).hover(); }); await takePolymerEditorScreenshot(page); }); const rnaNucleotides = [ - `2-damdA___2,6-Diaminopurine`, - `5hMedC___Hydroxymethyl dC`, - `Super G___8-aza-7-deazaguanosine`, - `AmMC6T___Amino Modifier C6 dT`, - `Super T___5-hydroxybutynl-2’-deoxyuridine`, - `5Br-dU___5-Bromo-deoxyuridine`, - `5NitInd___5-Nitroindole`, + Nucleotides._2_damdA, + Nucleotides._5hMedC, + Nucleotides.Super_G, + Nucleotides.AmMC6T, + Nucleotides.Super_T, + Nucleotides._5Br_dU, + Nucleotides._5NitInd, ]; for (const monomer of rnaNucleotides) { @@ -298,11 +306,11 @@ test.describe('Import-Saving .idt Files', () => { } const rnaMonomers = [ - 'MOE(G)P_G_MOE_P', - 'MOE(A)P_A_MOE_P', - 'MOE(5meC)P_5meC_MOE_P', - 'MOE(T)P_T_MOE_P', - 'dR(U)P_U_dR_P', + Presets.MOE_A_P, + Presets.MOE_G_P, + Presets.MOE_5meC_P, + Presets.MOE_T_P, + Presets.dR_U_P, ]; for (const monomer of rnaMonomers) { @@ -804,10 +812,10 @@ test.describe('Import-Saving .idt Files', () => { await goToPeptidesTab(page); const x = 650; const y = 400; - const firstMonomer = await page.getByText('iMe-dC').locator('..'); - const secondMonomer = await page.getByText('1Nal').locator('..').first(); + const firstMonomer = page.getByText('iMe-dC').locator('..'); + const secondMonomer = page.getByText('1Nal').locator('..').first(); await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); + await selectMonomer(page, Peptides._1Nal); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -830,14 +838,10 @@ test.describe('Import-Saving .idt Files', () => { const x = 650; const y = 400; - const firstMonomer = await page.getByText('iMe-dC').locator('..'); - const secondMonomer = await page - .getByText('Test-6-Ch') - .locator('..') - .first(); + const firstMonomer = page.getByText('iMe-dC').locator('..'); + const secondMonomer = page.getByText('Test-6-Ch').locator('..').first(); await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await chooseTab(page, Tabs.Chem); - await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click(); + await selectMonomer(page, Chem.Test_6_Ch); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -854,12 +858,12 @@ test.describe('Import-Saving .idt Files', () => { test('Delete bond between unresolved and known monomers connected through R2/R1 and Undo', async () => { const x = 650; const y = 400; - const firstMonomer = await page.getByText('iMe-dC').locator('..'); - const secondMonomer = await page.getByText('1Nal').locator('..').first(); + const firstMonomer = page.getByText('iMe-dC').locator('..'); + const secondMonomer = page.getByText('1Nal').locator('..').first(); const bondLine = page.locator('g[pointer-events="stroke"]').first(); await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); + await selectMonomer(page, Peptides._1Nal); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -891,15 +895,11 @@ test.describe('Import-Saving .idt Files', () => { const x = 650; const y = 400; - const firstMonomer = await page.getByText('iMe-dC').locator('..'); - const secondMonomer = await page - .getByText('Test-6-Ch') - .locator('..') - .first(); + const firstMonomer = page.getByText('iMe-dC').locator('..'); + const secondMonomer = page.getByText('Test-6-Ch').locator('..').first(); const bondLine = page.locator('g[pointer-events="stroke"]').first(); await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await chooseTab(page, Tabs.Chem); - await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click(); + await selectMonomer(page, Chem.Test_6_Ch); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -941,7 +941,7 @@ test.describe('Import-Saving .idt Files', () => { const x = 650; const y = 400; await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); + await selectMonomer(page, Peptides._1Nal); await clickOnCanvas(page, x, y); await selectMacroBond(page, MacroBondTool.SINGLE); await page.getByText('1Nal').locator('..').first().click(); @@ -961,7 +961,7 @@ test.describe('Import-Saving .idt Files', () => { const x = 650; const y = 400; await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await page.getByTestId('1Nal___3-(1-naphthyl)-alanine').click(); + await selectMonomer(page, Peptides._1Nal); await clickOnCanvas(page, x, y); await selectSnakeLayoutModeTool(page); await selectMacroBond(page, MacroBondTool.SINGLE); @@ -982,8 +982,7 @@ test.describe('Import-Saving .idt Files', () => { const x = 650; const y = 400; await pasteFromClipboardAndAddToMacromoleculesCanvas('IDT', `/iMe-dC/`); - await chooseTab(page, Tabs.Chem); - await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click(); + await selectMonomer(page, Chem.Test_6_Ch); await clickOnCanvas(page, x, y); await selectMacroBond(page, MacroBondTool.SINGLE); await page.getByText('iMe-dC').locator('..').click(); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts index d45bad93e4..e90baea681 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts @@ -1,4 +1,5 @@ /* eslint-disable no-magic-numbers */ +import { Peptides, Sugars } from '@constants/monomers'; import { test, expect, Page } from '@playwright/test'; import { TopPanelButton, @@ -17,10 +18,10 @@ import { clickUndo, dragMouseTo, openFileAndAddToCanvasAsNewProjectMacro, - Sugars, selectAllStructuresOnCanvas, openFileAndAddToCanvasAsNewProject, selectZoomOutTool, + selectMonomer, } from '@utils'; import { pageReload } from '@utils/common/helpers'; import { @@ -31,7 +32,6 @@ import { turnOnMacromoleculesEditor, zoomWithMouseWheel, } from '@utils/macromolecules'; -import { Peptides } from '@utils/selectors/macromoleculeEditor'; import { markResetToDefaultState, processResetToDefaultState, @@ -132,8 +132,7 @@ test.describe('Import-Saving .ket Files', () => { */ // Reload needed as monomer IDs increment in prior tests, affecting data comparasion await pageReload(page); - - await page.getByTestId(Peptides.BetaAlanine).click(); + await selectMonomer(page, Peptides.bAla); await clickInTheMiddleOfTheScreen(page); await verifyFileExport(page, 'KET/monomer-expected.ket', FileType.KET); await selectClearCanvasTool(page); @@ -175,9 +174,7 @@ test.describe('Import-Saving .ket Files', () => { markResetToDefaultState('tabSelection'); test.slow(); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId('summary-Sugars').click(); - await page.getByTestId(Sugars.TwentyFiveR).click(); + await selectMonomer(page, Sugars._25R); await clickInTheMiddleOfTheScreen(page); await verifyFileExport(page, 'KET/25R-expected.ket', FileType.KET); }); @@ -189,8 +186,7 @@ test.describe('Import-Saving .ket Files', () => { */ // Reload needed as monomer IDs increment in prior tests, affecting data comparasion await pageReload(page); - - await page.getByTestId(Peptides.D2Nal).click(); + await selectMonomer(page, Peptides.D_2Nal); await clickInTheMiddleOfTheScreen(page); await verifyFileExport(page, 'KET/D-2Nal-expected.ket', FileType.KET); }); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts index 853e2c6962..826a88c433 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts @@ -1,107 +1,97 @@ /* eslint-disable max-len */ /* eslint-disable no-magic-numbers */ +import { Bases, Chem, Peptides, Phosphates, Sugars } from '@constants/monomers'; +import { FAVORITES_TAB } from '@constants/testIdConstants'; +import { Page, expect, test } from '@playwright/test'; import { - chooseTab, - enterSequence, - Tabs, - turnOnMacromoleculesEditor, - turnOnMicromoleculesEditor, -} from '@utils/macromolecules'; -import { Page, test, expect } from '@playwright/test'; -import { + AtomButton, FILE_TEST_DATA, + FunctionalGroups, + LeftPanelButton, + RingButton, + SaltsAndSolvents, + SequenceType, TopPanelButton, + addMonomersToFavorites, clickInTheMiddleOfTheScreen, + clickOnAtom, + clickOnCanvas, + clickOnFileFormatDropdown, + clickUndo, dragMouseTo, - openFileAndAddToCanvas, - openFileAndAddToCanvasMacro, - pressButton, - selectTopPanelButton, - takeEditorScreenshot, - takeMonomerLibraryScreenshot, - takePageScreenshot, - waitForLoad, - waitForRender, - moveMouseToTheMiddleOfTheScreen, - selectOptionInDropdown, - waitForSpinnerFinishedWork, - selectRing, - RingButton, - moveMouseAway, - selectAtomInToolbar, - AtomButton, - selectFunctionalGroups, - FunctionalGroups, - selectSaltsAndSolvents, - SaltsAndSolvents, drawBenzeneRing, - selectSnakeLayoutModeTool, - selectEraseTool, - clickUndo, - clickOnAtom, - saveToFile, - receiveFileComparisonData, + getCml, + getControlModifier, getMolfile, - selectSequenceLayoutModeTool, - switchSequenceEnteringButtonType, - SequenceType, - selectLeftPanelButton, - LeftPanelButton, - selectDropdownTool, - openFileAndAddToCanvasAsNewProject, getSdf, + moveMouseAway, + moveMouseToTheMiddleOfTheScreen, openFile, - getCml, - clickOnFileFormatDropdown, - takeTopToolbarScreenshot, - setAttachmentPoints, - selectClearCanvasTool, - Sugars, - Bases, - Phosphates, - getControlModifier, - readFileContents, + openFileAndAddToCanvas, + openFileAndAddToCanvasAsNewProject, + openFileAndAddToCanvasMacro, openPasteFromClipboard, - waitForPageInit, + pressButton, + readFileContents, + receiveFileComparisonData, + saveToFile, selectAllStructuresOnCanvas, - clickOnCanvas, + selectAromatizeTool, + selectAtomInToolbar, + selectCleanTool, + selectClearCanvasTool, + selectDearomatizeTool, + selectDropdownTool, + selectEraseTool, + selectFunctionalGroups, + selectLayoutTool, + selectLeftPanelButton, selectMacroBond, + selectMonomer, selectOpenTool, + selectOptionInDropdown, + selectRing, + selectSaltsAndSolvents, + selectSequenceLayoutModeTool, + selectSnakeLayoutModeTool, + selectTopPanelButton, selectZoomInTool, selectZoomOutTool, selectZoomReset, - selectAromatizeTool, - selectDearomatizeTool, - selectCleanTool, - selectLayoutTool, + setAttachmentPoints, + switchSequenceEnteringButtonType, + takeEditorScreenshot, + takeMonomerLibraryScreenshot, + takePageScreenshot, + takeTopToolbarScreenshot, + waitForLoad, + waitForPageInit, + waitForRender, + waitForSpinnerFinishedWork, } from '@utils'; import { addSuperatomAttachmentPoint, removeSuperatomAttachmentPoint, } from '@utils/canvas/atoms/superatomAttachmentPoints'; -import { bondTwoMonomersPointToPoint } from '@utils/macromolecules/polymerBond'; -import { clickOnSequenceSymbol } from '@utils/macromolecules/sequence'; -import { miewApplyButtonIsEnabled } from '@utils/common/loaders/waitForMiewApplyButtonIsEnabled'; -import { pageReload } from '@utils/common/helpers'; -import { Chems, Peptides } from '@utils/selectors/macromoleculeEditor'; -import { moveMonomerOnMicro } from '@utils/macromolecules/monomer'; -import { - goToCHEMTab, - goToFavoritesTab, - goToPeptidesTab, - goToRNATab, -} from '@utils/macromolecules/library'; -import { - toggleBasesAccordion, - togglePhosphatesAccordion, - toggleSugarsAccordion, -} from '@utils/macromolecules/rnaBuilder'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; -import { pressUndoButton } from '@utils/macromolecules/topToolBar'; +import { pageReload } from '@utils/common/helpers'; +import { miewApplyButtonIsEnabled } from '@utils/common/loaders/waitForMiewApplyButtonIsEnabled'; import { FileType, verifyFileExport, } from '@utils/files/receiveFileComparisonData'; +import { + Tabs, + chooseTab, + enterSequence, + turnOnMacromoleculesEditor, + turnOnMicromoleculesEditor, +} from '@utils/macromolecules'; +import { goToRNATab, goToTab } from '@utils/macromolecules/library'; +import { moveMonomerOnMicro } from '@utils/macromolecules/monomer'; +import { bondTwoMonomersPointToPoint } from '@utils/macromolecules/polymerBond'; +import { clickOnSequenceSymbol } from '@utils/macromolecules/sequence'; +import { pressUndoButton } from '@utils/macromolecules/topToolBar'; const topLeftCorner = { x: -325, @@ -138,19 +128,15 @@ async function pasteFromClipboard( } async function addToFavoritesMonomers(page: Page) { - await goToPeptidesTab(page); - await page.getByTestId(Peptides.BetaAlanine).getByText('★').click(); - await page.getByTestId(Peptides.Phe4Me).getByText('★').click(); - await page.getByTestId(Peptides.meM).getByText('★').click(); - await goToRNATab(page); - await toggleSugarsAccordion(page); - await page.getByTestId(Sugars.TwentyFiveR).getByText('★').click(); - await toggleBasesAccordion(page); - await page.getByTestId(Bases.baA).getByText('★').click(); - await togglePhosphatesAccordion(page); - await page.getByTestId(Phosphates.bP).getByText('★').click(); - await goToCHEMTab(page); - await page.getByTestId(Chems.Test_6_Ch).getByText('★').click(); + await addMonomersToFavorites(page, [ + Peptides.bAla, + Peptides.Phe4Me, + Peptides.meM, + Sugars._25R, + Bases.baA, + Phosphates.bP, + Chem.Test_6_Ch, + ]); } async function setAtomAndBondSettings(page: Page) { @@ -480,7 +466,7 @@ test.describe('Macro-Micro-Switcher', () => { await addToFavoritesMonomers(page); await turnOnMicromoleculesEditor(page); await turnOnMacromoleculesEditor(page); - await goToFavoritesTab(page); + await goToTab(page, FAVORITES_TAB); await takeMonomerLibraryScreenshot(page); }); @@ -528,8 +514,7 @@ test.describe('Macro-Micro-Switcher', () => { Description: Pressing Layout or Clean Up button not erase all macromolecules from canvas */ await turnOnMacromoleculesEditor(page); - await chooseTab(page, Tabs.Peptides); - await page.getByTestId('A___Alanine').click(); + await selectMonomer(page, Peptides.A); await clickInTheMiddleOfTheScreen(page); await turnOnMicromoleculesEditor(page); await waitForSpinnerFinishedWork( @@ -546,8 +531,7 @@ test.describe('Macro-Micro-Switcher', () => { Description: Remove abbreviation restricted for CHEMs in micro mode. */ await turnOnMacromoleculesEditor(page); - 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 turnOnMicromoleculesEditor(page); await page.getByText('Test-6-Ch').click({ button: 'right' }); @@ -568,8 +552,7 @@ test.describe('Macro-Micro-Switcher', () => { */ await turnOnMacromoleculesEditor(page); - await page.getByTestId('PEPTIDES-TAB').click(); - await page.getByTestId(Peptides.BetaAlanine).click(); + await selectMonomer(page, Peptides.bAla); await clickInTheMiddleOfTheScreen(page); await turnOnMicromoleculesEditor(page); await selectRing(RingButton.Benzene, page); @@ -595,7 +578,7 @@ test.describe('Macro-Micro-Switcher', () => { } }); await turnOnMacromoleculesEditor(page); - await page.getByTestId(Peptides.BetaAlanine).click(); + await selectMonomer(page, Peptides.bAla); await clickInTheMiddleOfTheScreen(page); await turnOnMicromoleculesEditor(page); await turnOnMacromoleculesEditor(page); @@ -1144,22 +1127,19 @@ test.describe('Macro-Micro-Switcher', () => { { description: 'Sugar', monomer: '25R', - monomerTestId: Sugars.TwentyFiveR, - summaryTestId: 'summary-Sugars', + monomerTestId: Sugars._25R, bondEndpoints: { first: 'R1', second: 'R2' }, }, { description: 'Base', monomer: 'meA', monomerTestId: Bases.meA, - summaryTestId: 'summary-Bases', bondEndpoints: { first: 'R1', second: 'R1' }, }, { description: 'Phosphate', monomer: 'sP-', monomerTestId: Phosphates.sP_, - summaryTestId: 'summary-Phosphates', bondEndpoints: { first: 'R1', second: 'R2' }, }, ]; @@ -1172,19 +1152,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText(data.monomer) - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText(data.monomer).locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId(data.summaryTestId).click(); - await page.getByTestId(data.monomerTestId).click(); + await selectMonomer(page, data.monomerTestId); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1208,18 +1183,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText('Test-6-Ch') - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText('Test-6-Ch').locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - 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 clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1237,22 +1208,19 @@ test.describe('Macro-Micro-Switcher', () => { { description: 'Sugar', monomer: '25R', - monomerTestId: Sugars.TwentyFiveR, - summaryTestId: 'summary-Sugars', + monomerTestId: Sugars._25R, bondEndpoints: { first: 'R1', second: 'R2' }, }, { description: 'Base', monomer: 'meA', monomerTestId: Bases.meA, - summaryTestId: 'summary-Bases', bondEndpoints: { first: 'R1', second: 'R1' }, }, { description: 'Phosphate', monomer: 'moen', - monomerTestId: 'moen___2-Methoxyethylamino', - summaryTestId: 'summary-Phosphates', + monomerTestId: Phosphates.moen, bondEndpoints: { first: 'R1', second: 'R2' }, }, ]; @@ -1265,20 +1233,15 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText(data.monomer) - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText(data.monomer).locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); await selectSnakeLayoutModeTool(page); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId(data.summaryTestId).click(); - await page.getByTestId(data.monomerTestId).click(); + await selectMonomer(page, data.monomerTestId); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1311,8 +1274,7 @@ test.describe('Macro-Micro-Switcher', () => { ); await turnOnMacromoleculesEditor(page); await selectSnakeLayoutModeTool(page); - 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 clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1330,22 +1292,19 @@ test.describe('Macro-Micro-Switcher', () => { { description: 'Sugar', monomer: '25R', - monomerTestId: Sugars.TwentyFiveR, - summaryTestId: 'summary-Sugars', + monomerTestId: Sugars._25R, bondEndpoints: { first: 'R1', second: 'R2' }, }, { description: 'Base', monomer: 'meA', monomerTestId: Bases.meA, - summaryTestId: 'summary-Bases', bondEndpoints: { first: 'R1', second: 'R1' }, }, { description: 'Phosphate', monomer: 'sP-', monomerTestId: Phosphates.sP_, - summaryTestId: 'summary-Phosphates', bondEndpoints: { first: 'R1', second: 'R2' }, }, ]; @@ -1358,19 +1317,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText(data.monomer) - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText(data.monomer).locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId(data.summaryTestId).click(); - await page.getByTestId(data.monomerTestId).click(); + await selectMonomer(page, data.monomerTestId); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1395,18 +1349,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText('Test-6-Ch') - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText('Test-6-Ch').locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - 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 clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1427,22 +1377,19 @@ test.describe('Macro-Micro-Switcher', () => { { description: 'Sugar', monomer: '25R', - monomerTestId: Sugars.TwentyFiveR, - summaryTestId: 'summary-Sugars', + monomerTestId: Sugars._25R, bondEndpoints: { first: 'R1', second: 'R2' }, }, { description: 'Base', monomer: 'meA', monomerTestId: Bases.meA, - summaryTestId: 'summary-Bases', bondEndpoints: { first: 'R1', second: 'R1' }, }, { description: 'Phosphate', monomer: 'sP-', monomerTestId: Phosphates.sP_, - summaryTestId: 'summary-Phosphates', bondEndpoints: { first: 'R1', second: 'R2' }, }, ]; @@ -1455,19 +1402,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText(data.monomer) - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText(data.monomer).locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId(data.summaryTestId).click(); - await page.getByTestId(data.monomerTestId).click(); + await selectMonomer(page, data.monomerTestId); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1493,18 +1435,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText('Test-6-Ch') - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText('Test-6-Ch').locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - await goToCHEMTab(page); - await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click(); + await selectMonomer(page, Chem.Test_6_Ch); await clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, @@ -1530,18 +1468,14 @@ test.describe('Macro-Micro-Switcher', () => { */ const x = 750; const y = 370; - const firstMonomer = await page.getByText('F1').locator('..'); - const secondMonomer = await page - .getByText('Test-6-Ch') - .locator('..') - .first(); + const firstMonomer = page.getByText('F1').locator('..'); + const secondMonomer = page.getByText('Test-6-Ch').locator('..').first(); await openFileAndAddToCanvas( 'KET/one-attachment-point-added-in-micro-mode.ket', page, ); await turnOnMacromoleculesEditor(page); - 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 clickOnCanvas(page, x, y); await bondTwoMonomersPointToPoint( page, diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts index d3b2f35107..78c3d305cd 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts @@ -25,8 +25,6 @@ import { selectDropdownTool, clickInTheMiddleOfTheScreen, selectClearCanvasTool, - Sugars, - Bases, selectMacroBond, moveMouseAway, selectRingButton, @@ -38,31 +36,26 @@ import { clickOnCanvas, pasteFromClipboardByKeyboard, copyToClipboardByIcon, + addMonomersToFavorites, } from '@utils'; -import { Peptides } from '@utils/selectors/macromoleculeEditor'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { closeErrorAndInfoModals } from '@utils/common/helpers'; +import { Bases, Chem, Peptides, Phosphates, Sugars } from '@constants/monomers'; import { FileType, verifyFileExport, } from '@utils/files/receiveFileComparisonData'; async function addToFavoritesMonomers(page: Page) { - await page.getByTestId(Peptides.BetaAlanine).getByText('★').click(); - await page - .getByTestId('Phe4Me___p-Methylphenylalanine') - .getByText('★') - .click(); - await page.getByTestId('meM___N-Methyl-Methionine').getByText('★').click(); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId('summary-Sugars').click(); - await page.getByTestId(Sugars.TwentyFiveR).getByText('★').click(); - await page.getByTestId('summary-Bases').click(); - await page.getByTestId(Bases.baA).getByText('★').click(); - await page.getByTestId('summary-Phosphates').click(); - await page.getByTestId('bP___Boranophosphate').getByText('★').click(); - await page.getByTestId('CHEM-TAB').click(); - await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').getByText('★').click(); + await addMonomersToFavorites(page, [ + Peptides.bAla, + Peptides.Phe4Me, + Peptides.meM, + Sugars._25R, + Bases.baA, + Phosphates.bP, + Chem.Test_6_Ch, + ]); } test.describe('Macro-Micro-Switcher2', () => { diff --git a/ketcher-autotests/tests/Macromolecule-editor/Modal-window/modal-window.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Modal-window/modal-window.spec.ts index f1a96b8b4b..819486c356 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Modal-window/modal-window.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Modal-window/modal-window.spec.ts @@ -1,3 +1,4 @@ +import { Chem } from '@constants/monomers'; import { Locator, test } from '@playwright/test'; import { addSingleMonomerToCanvas, @@ -7,6 +8,7 @@ import { } from '@utils'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; +import { goToCHEMTab } from '@utils/macromolecules/library'; import { bondTwoMonomers } from '@utils/macromolecules/polymerBond'; /* eslint-disable no-magic-numbers */ @@ -16,8 +18,8 @@ test.describe('Modal window', () => { test.beforeEach(async ({ page }) => { await waitForPageInit(page); await turnOnMacromoleculesEditor(page); - await page.getByText('CHEM').click(); - const MONOMER_NAME = 'Test-6-Ch___Test-6-AP-Chem'; + await goToCHEMTab(page); + const MONOMER_NAME = Chem.Test_6_Ch; const MONOMER_ALIAS = 'Test-6-Ch'; peptide1 = await addSingleMonomerToCanvas( diff --git a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts index affb05b42c..94f641ab54 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptide-monomer-library.spec.ts @@ -1,12 +1,19 @@ -import { test, expect } from '@playwright/test'; +import { Chem, Peptides, Presets } from '@constants/monomers'; +import { FAVORITES_TAB } from '@constants/testIdConstants'; +import { expect, test } from '@playwright/test'; import { + addMonomersToFavorites, + addMonomerToFavorites, addPeptideOnCanvas, clickInTheMiddleOfTheScreen, dragMouseTo, moveMouseToTheMiddleOfTheScreen, openFileAndAddToCanvasMacro, + removeMonomerFromFavorites, + removeMonomersFromFavorites, selectEraseTool, selectMacroBond, + selectMonomer, selectRectangleSelectionTool, takeEditorScreenshot, takeMonomerLibraryScreenshot, @@ -14,8 +21,7 @@ import { } from '@utils'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; -import { goToPeptidesTab, goToRNATab } from '@utils/macromolecules/library'; -import { Chems } from '@utils/selectors/macromoleculeEditor'; +import { goToPeptidesTab, goToTab } from '@utils/macromolecules/library'; test.describe('Peptide library testing', () => { test.beforeEach(async ({ page }) => { @@ -30,7 +36,7 @@ test.describe('Peptide library testing', () => { test('Structure displaying in library', async ({ page }) => { // structure preview, molecule hovered state check - await page.getByTestId('A___Alanine').hover(); + await page.getByTestId(Peptides.A).hover(); await page.waitForSelector('[data-testid="polymer-library-preview"]'); await takeMonomerLibraryScreenshot(page); }); @@ -44,10 +50,7 @@ test.describe('Peptide library testing', () => { test('add molecule in favourites', async ({ page }) => { // favourites check. there is a bug - favourite sign (star) is golden when hovered(should be dark grey) // https://github.com/epam/ketcher/issues/3477 - await page.waitForSelector('.star'); - await page.getByTestId('A___Alanine').getByText('★').click(); - await clickInTheMiddleOfTheScreen(page); - await page.getByTestId('A___Alanine').getByText('★').hover(); + await addMonomerToFavorites(page, Peptides.A); await takeMonomerLibraryScreenshot(page); }); @@ -69,18 +72,23 @@ test.describe('Peptide library testing', () => { Description: Monomers is getting removed from favourites when clicking star sign. The test is currently not functioning correctly as the bug has not been fixed https://github.com/epam/ketcher/issues/3963 */ - await page.getByTestId('dA___D-Alanine').getByText('★').click(); - await page.getByTestId('Edc___S-ethylthiocysteine').getByText('★').click(); - await goToRNATab(page); - await page.getByTestId('A_A_R_P').getByText('★').click(); - await page.getByTestId('CHEM-TAB').click(); - await page.getByTestId('A6OH___6-amino-hexanol').getByText('★').click(); - await page.getByTestId('FAVORITES-TAB').click(); + await addMonomersToFavorites(page, [ + Peptides.dA, + Peptides.Edc, + Presets.A, + Chem.A6OH, + ]); + + await goToTab(page, FAVORITES_TAB); await takeMonomerLibraryScreenshot(page); - await page.getByTestId('A6OH___6-amino-hexanol').getByText('★').click(); - await page.getByTestId('dA___D-Alanine').getByText('★').click(); - await page.getByTestId('Edc___S-ethylthiocysteine').getByText('★').click(); - await page.getByText('★').click(); + + await removeMonomersFromFavorites(page, [ + Peptides.dA, + Peptides.Edc, + Chem.A6OH, + ]); + + await removeMonomerFromFavorites(page, Presets.A); await takeMonomerLibraryScreenshot(page); }); @@ -91,13 +99,13 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: Peptide is getting removed from favourites when clicking star sign again in Peptide tab section. */ - await page.getByTestId('dA___D-Alanine').getByText('★').click(); - await page.getByTestId('Edc___S-ethylthiocysteine').getByText('★').click(); - await page.getByTestId('FAVORITES-TAB').click(); + + await addMonomersToFavorites(page, [Peptides.dA, Peptides.Edc]); + await goToTab(page, FAVORITES_TAB); await takeMonomerLibraryScreenshot(page); - await page.getByTestId('PEPTIDES-TAB').click(); - await page.getByTestId('Edc___S-ethylthiocysteine').getByText('★').click(); - await page.getByTestId('FAVORITES-TAB').click(); + + await removeMonomerFromFavorites(page, Peptides.Edc, false); + await goToTab(page, FAVORITES_TAB); await takeMonomerLibraryScreenshot(page); }); @@ -108,7 +116,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: Selected Peptide discards when mouse hovered on canvas and ESC button is clicked. */ - await page.getByTestId('dA___D-Alanine').click(); + await selectMonomer(page, Peptides.dA); await moveMouseToTheMiddleOfTheScreen(page); await takeEditorScreenshot(page); await page.keyboard.press('Escape'); @@ -122,7 +130,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: A tooltip appears when hovering over a Peptide on canvas while Erase tool is selected. */ - await page.getByTestId('dA___D-Alanine').click(); + await selectMonomer(page, Peptides.dA); await clickInTheMiddleOfTheScreen(page); await selectEraseTool(page); await page.getByText('dA').locator('..').first().hover(); @@ -136,7 +144,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: A tooltip appears when hovering over a Peptide on canvas while Bond tool is selected. */ - await page.getByTestId('Edc___S-ethylthiocysteine').click(); + await selectMonomer(page, Peptides.Edc); await clickInTheMiddleOfTheScreen(page); await selectMacroBond(page, MacroBondTool.SINGLE); await page.getByText('Edc').locator('..').first().hover(); @@ -150,7 +158,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: A tooltip appears when hovering over a Peptide on canvas while Selection tool is selected. */ - await page.getByTestId('Edc___S-ethylthiocysteine').click(); + await selectMonomer(page, Peptides.Edc); await clickInTheMiddleOfTheScreen(page); await selectRectangleSelectionTool(page); await page.getByText('Edc').locator('..').first().hover(); @@ -164,8 +172,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: Selected CHEM discards when mouse hovered on canvas and ESC button is clicked. */ - 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 moveMouseToTheMiddleOfTheScreen(page); await takeEditorScreenshot(page); await page.keyboard.press('Escape'); @@ -179,8 +186,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: A tooltip appears when hovering over a CHEM on canvas while Erase tool is selected. */ - 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 selectEraseTool(page); await page.getByText('Test-6-Ch').locator('..').first().hover(); @@ -194,10 +200,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: A tooltip appears when hovering over a CHEM on canvas while Bond tool is selected. */ - await page.getByTestId('CHEM-TAB').click(); - await page - .getByTestId('MCC___4-(N-maleimidomethyl)cyclohexane-1-carboxylate') - .click(); + await selectMonomer(page, Chem.MCC); await clickInTheMiddleOfTheScreen(page); await selectMacroBond(page, MacroBondTool.SINGLE); await page.getByText('MCC').locator('..').first().hover(); @@ -211,8 +214,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures Description: A tooltip appears when hovering over a CHEM on canvas while Selection tool is selected. */ - await page.getByTestId('CHEM-TAB').click(); - await page.getByTestId(Chems.SMPEG2).click(); + await selectMonomer(page, Chem.SMPEG2); await clickInTheMiddleOfTheScreen(page); await selectRectangleSelectionTool(page); await page.getByText('SMPEG2').locator('..').first().hover(); @@ -226,8 +228,7 @@ test.describe('Peptide library testing', () => { Test case: Actions with structures https://github.com/epam/ketcher/issues/3986 Description: Selected RNA discards when mouse hovered on canvas and ESC button is clicked. */ - await goToRNATab(page); - await page.getByTestId('C_C_R_P').click(); + await selectMonomer(page, Presets.C); await moveMouseToTheMiddleOfTheScreen(page); await takeEditorScreenshot(page); await page.keyboard.press('Escape'); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptides-add-to-canvas.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptides-add-to-canvas.spec.ts index 89b5a3ffd8..f380faf2c8 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptides-add-to-canvas.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Peptides/peptides-add-to-canvas.spec.ts @@ -3,15 +3,16 @@ import { clickInTheMiddleOfTheScreen, moveMouseToTheMiddleOfTheScreen, selectMacroBond, + selectMonomer, takeEditorScreenshot, waitForPageInit, } from '@utils'; -import { ALANINE } from '@utils/selectors/macromoleculeEditor'; import { hideMonomerPreview, turnOnMacromoleculesEditor, } from '@utils/macromolecules'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; +import { Peptides } from '@constants/monomers'; /* Test case: #3063 - Add e2e tests for Macromolecule editor @@ -24,7 +25,7 @@ test.describe('Peptide', () => { }); test('Select peptide and drag it to canvas', async ({ page }) => { - await page.click(ALANINE); + await selectMonomer(page, Peptides.A); await clickInTheMiddleOfTheScreen(page); await hideMonomerPreview(page); await takeEditorScreenshot(page); @@ -35,7 +36,7 @@ test.describe('Peptide', () => { Test case: #2869 - Preview of monomer structures on canvas Description: Add monomer preview on canvas */ - await page.click(ALANINE); + await selectMonomer(page, Peptides.A); await clickInTheMiddleOfTheScreen(page); await selectMacroBond(page, MacroBondTool.SINGLE); await moveMouseToTheMiddleOfTheScreen(page); diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-hover.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-hover.spec.ts index 06a0d3db13..dc644ed3c0 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-hover.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-hover.spec.ts @@ -1,3 +1,4 @@ +import { Peptides } from '@constants/monomers'; import { test } from '@playwright/test'; import { addSingleMonomerToCanvas, @@ -8,7 +9,6 @@ import { import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; import { bondTwoMonomers } from '@utils/macromolecules/polymerBond'; -import { Peptides } from '@utils/selectors/macromoleculeEditor'; test.describe('Check attachment point hover', () => { test.beforeEach(async ({ page }) => { diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-rotation.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-rotation.spec.ts index 18b0d7b9b7..0467517b7f 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-rotation.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/attachment-point-rotation.spec.ts @@ -1,3 +1,4 @@ +import { Peptides } from '@constants/monomers'; import { test } from '@playwright/test'; import { addSingleMonomerToCanvas, @@ -11,7 +12,6 @@ import { import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; import { bondTwoMonomers } from '@utils/macromolecules/polymerBond'; -import { Peptides } from '@utils/selectors/macromoleculeEditor'; /* eslint-disable no-magic-numbers */ test.describe('Check attachment point rotation', () => { diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts index 5e703cae2d..001ea186f0 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts @@ -1,4 +1,5 @@ /* eslint-disable no-magic-numbers */ +import { Peptides } from '@constants/monomers'; import { test } from '@playwright/test'; import { addSingleMonomerToCanvas, @@ -38,7 +39,7 @@ test.describe('Connection rules for molecules with monomers: ', () => { await turnOnMacromoleculesEditor(page); const firstAlanine = await addSingleMonomerToCanvas( page, - 'A___Alanine', + Peptides.A, 'A', 100, 200, @@ -46,7 +47,7 @@ test.describe('Connection rules for molecules with monomers: ', () => { ); const secondAlanine = await addSingleMonomerToCanvas( page, - 'A___Alanine', + Peptides.A, 'A', 300, 200, @@ -54,7 +55,7 @@ test.describe('Connection rules for molecules with monomers: ', () => { ); const thirdAlanine = await addSingleMonomerToCanvas( page, - 'A___Alanine', + Peptides.A, 'A', 500, 200, diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/polymer-bond-tool.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/polymer-bond-tool.spec.ts index 0ce9c20fd4..8105cfc4a7 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/polymer-bond-tool.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/polymer-bond-tool.spec.ts @@ -32,6 +32,7 @@ import { selectOptionInTypeDropdown2, clickOnCanvas, selectMacroBond, + selectMonomer, } from '@utils'; import { MacroBondTool } from '@utils/canvas/tools/selectNestedTool/types'; import { pageReload } from '@utils/common/helpers'; @@ -45,11 +46,11 @@ import { } from '@utils/macromolecules'; import { connectMonomersWithBonds } from '@utils/macromolecules/monomer'; import { bondTwoMonomers } from '@utils/macromolecules/polymerBond'; -import { Chems, Peptides } from '@utils/selectors/macromoleculeEditor'; import { pressRedoButton, pressUndoButton, } from '@utils/macromolecules/topToolBar'; +import { Chem, Peptides, Presets } from '@constants/monomers'; let page: Page; let sharedContext: BrowserContext; @@ -190,8 +191,7 @@ test('Create bond between two chems', async () => { Description: Polymer bond tool */ // Choose chems - await page.getByText('CHEM').click(); - await page.getByTestId(Chems.hxy).click(); + await selectMonomer(page, Chem.hxy); // Create 2 chems on canvas await clickOnCanvas(page, 300, 300); @@ -266,9 +266,9 @@ test('Check in full-screen mode it is possible to add a bond between a Peptide m const x = 800; const y = 350; await page.locator('.css-1kbfai8').click(); - await page.getByTestId(Peptides.BetaAlanine).click(); + await selectMonomer(page, Peptides.bAla); await clickInTheMiddleOfTheScreen(page); - await page.getByTestId(Peptides.Ethylthiocysteine).click(); + await selectMonomer(page, Peptides.Edc); await clickOnCanvas(page, x, y); await connectMonomersWithBonds(page, ['Bal', 'Edc']); await takeEditorScreenshot(page, { @@ -285,10 +285,9 @@ test('Check in full-screen mode it is possible to add a bond between a RNA monom const x = 800; const y = 350; await page.locator('.css-1kbfai8').click(); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId('MOE(A)P_A_MOE_P').click(); + await selectMonomer(page, Presets.MOE_A_P); await clickInTheMiddleOfTheScreen(page); - await page.getByTestId('dR(U)P_U_dR_P').click(); + await selectMonomer(page, Presets.dR_U_P); await clickOnCanvas(page, x, y); await connectMonomersWithBonds(page, ['P', 'dR']); await takeEditorScreenshot(page, { @@ -305,10 +304,9 @@ test('Check in full-screen mode it is possible to add a bond between a CHEM mono const x = 800; const y = 350; await page.locator('.css-1kbfai8').click(); - await page.getByTestId('CHEM-TAB').click(); - await page.getByTestId('A6OH___6-amino-hexanol').click(); + await selectMonomer(page, Chem.A6OH); await clickInTheMiddleOfTheScreen(page); - await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click(); + await selectMonomer(page, Chem.Test_6_Ch); await clickOnCanvas(page, x, y); await connectMonomersWithBonds(page, ['A6OH', 'Test-6-Ch']); await page @@ -631,8 +629,7 @@ test('Verify that changes made in the "Edit Connection Points" dialog are saved Description: Changes made in the "Edit Connection Points" dialog are saved when the structure is saved to a IDT file and can be loaded. */ const bondLine = await getConnectionLine(page, 1); - await page.getByTestId('RNA-TAB').click(); - await page.getByTestId('MOE(A)P_A_MOE_P').click(); + await selectMonomer(page, Presets.MOE_A_P); await clickInTheMiddleOfTheScreen(page); await openEditConnectionPointsMenu(page, bondLine); await page.getByRole('button', { name: 'R1' }).first().click(); diff --git a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/add-custom-preset.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/add-custom-preset.spec.ts index 8489dfb7a6..5ecc3e0568 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/add-custom-preset.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/RNA-Builder/add-custom-preset.spec.ts @@ -1,27 +1,20 @@ +import { Bases, Phosphates, Sugars } from '@constants/monomers'; +import { BUTTON__ADD_TO_PRESETS, RNA_TAB } from '@constants/testIdConstants'; import { Page, test } from '@playwright/test'; import { - RNA_TAB, - SUGAR, - BASE, - PHOSPHATE, - BUTTON__ADD_TO_PRESETS, -} from '@constants/testIdConstants'; -import { waitForPageInit } from '@utils/common'; -import { - Bases, moveMouseToTheMiddleOfTheScreen, - Sugars, + selectCustomPreset, + selectMonomers, takeEditorScreenshot, takeMonomerLibraryScreenshot, } from '@utils'; +import { waitForPageInit } from '@utils/common'; import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; +import { goToRNATab } from '@utils/macromolecules/library'; import { pressAddToPresetsButton, pressSaveButton, - selectBaseSlot, - selectSugarSlot, } from '@utils/macromolecules/rnaBuilder'; -import { goToRNATab } from '@utils/macromolecules/library'; /* Test case: #3063 - Add e2e tests for Macromolecule editor @@ -33,28 +26,6 @@ async function createRNA(page: Page) { await page.press('[placeholder="Name your structure"]', 'Enter'); } -async function selectRNAComponents( - page: Page, - { - sugar, - base, - phosphate, - }: { - sugar: string; - base: string; - phosphate: string; - }, -) { - await page.getByTestId(SUGAR).click(); - await page.getByTestId(sugar).click(); - - await page.getByTestId(BASE).click(); - await page.getByTestId(base).click(); - - await page.getByTestId(PHOSPHATE).click(); - await page.getByTestId(phosphate).click(); -} - async function expandRnaBuilder(page: Page) { await page .locator('div') @@ -71,11 +42,7 @@ test.describe('Macromolecules custom presets', () => { }); test('Add new preset and duplicate it', async ({ page }) => { - await selectRNAComponents(page, { - sugar: Sugars.TwentyFiveR, - base: Bases.baA, - phosphate: 'bP___Boranophosphate', - }); + await selectMonomers(page, [Sugars._25R, Bases.baA, Phosphates.bP]); await moveMouseToTheMiddleOfTheScreen(page); await page.getByTestId(BUTTON__ADD_TO_PRESETS).click(); @@ -83,12 +50,7 @@ test.describe('Macromolecules custom presets', () => { await page.getByTestId('duplicate-btn').click(); - await selectRNAComponents(page, { - sugar: "12ddR___1',2'-dideoxyribose", - base: 'A___Adenine', - phosphate: 'P___Phosphate', - }); - + await selectMonomers(page, [Sugars._12ddR, Bases.A, Phosphates.P]); await pressSaveButton(page); await takeMonomerLibraryScreenshot(page); @@ -116,24 +78,14 @@ test.describe('Macromolecules custom presets', () => { // Press Enter on input await page.press('[placeholder="Name your structure"]', 'Enter'); - // Click on
"Sugar Not selected" - await selectSugarSlot(page); - - // Click on
"25R ★" - await page.click(`[data-testid="${Sugars.TwentyFiveR}"]`); - - // Click on
"Base Not selected" - await selectBaseSlot(page); - - // Click on
"baA ★" - await page.click(`[data-testid="${Bases.baA}"]`); + await selectMonomers(page, [Sugars._25R, Bases.baA]); // Click on