Skip to content

Commit

Permalink
Autotests: #6275 - All inproper library tabs switching (Favorites, Pe…
Browse files Browse the repository at this point in the history
…ptides, RNA, CHEM) … (#6329)

* All inproper library tabs switching (Favorites, Peptides, RNA, CHEM) have been replaced with the proper helper functions.

* * 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]>

* #6246 - Import indigo with EXPORT_ES6 & USE_ES6_IMPORT_META options (#6330)

- fixed build for esm base64 ketcher-standalone

* Imports fixes.

* Changes in index.ts and polymerBond.ts files.

---------

Co-authored-by: Svetlana Demid <[email protected]>
Co-authored-by: Svetlana Demid <[email protected]>
Co-authored-by: Roman Rodionov <[email protected]>
  • Loading branch information
4 people authored Jan 24, 2025
1 parent 07e5002 commit f951fba
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test';
import { waitForPageInit } from '@utils/common';
import { takeMonomerLibraryScreenshot } from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import { goToCHEMTab } from '@utils/macromolecules/library';

test.describe('Open Ketcher', () => {
test.beforeEach(async ({ page }) => {
Expand All @@ -22,7 +23,7 @@ test.describe('Open Ketcher', () => {
Test case: #2496 - chem monomer library
Description: Open Chem tab in library
*/
await page.getByText('CHEM').click();
await goToCHEMTab(page);
await expect(page.getByText('A6OH')).toBeVisible();
await takeMonomerLibraryScreenshot(page);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
FileType,
verifyFileExport,
} from '@utils/files/receiveFileComparisonData';
import { goToFavoritesTab } from '@utils/macromolecules/library';
import { pressUndoButton } from '@utils/macromolecules/topToolBar';

async function addToFavoritesMonomers(page: Page) {
Expand Down Expand Up @@ -96,7 +97,7 @@ test.describe('Macro-Micro-Switcher2', () => {
await page.getByText('Hide').click();
await turnOnMicromoleculesEditor(page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('FAVORITES-TAB').click();
await goToFavoritesTab(page);
await takeMonomerLibraryScreenshot(page);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
} from '@utils';
import { toggleRnaBuilderAccordion } from '@utils/macromolecules/rnaBuilder';
import { Presets } from '@constants/monomers';
import { goToRNATab } from '@utils/macromolecules/library';

test.describe('Macromolecules default presets', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
await toggleRnaBuilderAccordion(page);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Presets } from '@constants/monomers';
import { test, expect } from '@playwright/test';
import { takeMonomerLibraryScreenshot, waitForPageInit } from '@utils';
import { goToFavoritesTab, goToRNATab } from '@utils/macromolecules/library';
import { gotoRNA } from '@utils/macromolecules/rnaBuilder';

test.describe('Macromolecules add RNA presets to Favorites', () => {
Expand All @@ -15,12 +16,12 @@ test.describe('Macromolecules add RNA presets to Favorites', () => {
});

test('Should add RNA presets to Favorites', async ({ page }) => {
await page.getByTestId('FAVORITES-TAB').click();
await goToFavoritesTab(page);
await expect(page.getByTestId(Presets.A)).not.toBeVisible();

await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
await page.locator('div[class="star "]').first().click();
await page.getByTestId('FAVORITES-TAB').click();
await goToFavoritesTab(page);
await expect(page.getByTestId(Presets.A)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
enterSequence,
turnOnMacromoleculesEditor,
} from '@utils/macromolecules';
import { goToRNATab } from '@utils/macromolecules/library';
import { expandCollapseRnaBuilder } from '@utils/macromolecules/rnaBuilder';
import {
clickOnSequenceSymbol,
Expand Down Expand Up @@ -441,7 +442,7 @@ test.describe('Sequence edit mode', () => {
Test case: #4928
Description: System show full set of IDT aliases at preview tooltip.
*/
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
await expandCollapseRnaBuilder(page);
await page.getByTestId(Presets.dR_U_P).hover();
await takePageScreenshot(page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
turnOnMacromoleculesEditor,
turnOnMicromoleculesEditor,
} from '@utils/macromolecules';
import { goToPeptidesTab, goToRNATab } from '@utils/macromolecules/library';
import { bondTwoMonomers } from '@utils/macromolecules/polymerBond';
/* eslint-disable no-magic-numbers */

Expand Down Expand Up @@ -216,7 +217,7 @@ test.describe('Snake Bond Tool', () => {
});

test('Create snake bond between RNA nucleotides', async () => {
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
await selectSnakeLayoutModeTool(page);

const { phosphate } = await addRnaPresetOnCanvas(
Expand Down Expand Up @@ -254,7 +255,7 @@ test.describe('Snake Bond Tool', () => {

test('Check snake mode arrange for RNA chain', async () => {
await selectFlexLayoutModeTool(page);
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);

const { phosphate } = await addRnaPresetOnCanvas(
page,
Expand Down Expand Up @@ -367,7 +368,7 @@ test.describe('Snake Bond Tool', () => {
);

await selectFlexLayoutModeTool(page);
await page.getByTestId('PEPTIDES-TAB').click();
await goToPeptidesTab(page);
await addBondedMonomersToCanvas(
page,
Peptides.bAla,
Expand All @@ -378,7 +379,7 @@ test.describe('Snake Bond Tool', () => {
50,
4,
);
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);

const { phosphate } = await addRnaPresetOnCanvas(
page,
Expand Down Expand Up @@ -421,7 +422,7 @@ test.describe('Snake Bond Tool', () => {
});

test('Create snake bond for chain with nucleoside', async () => {
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
await selectSnakeLayoutModeTool(page);

const { phosphate } = await addRnaPresetOnCanvas(
Expand Down Expand Up @@ -476,7 +477,7 @@ test.describe('Snake Bond Tool', () => {

test('Create snake bond for chain with side chains', async () => {
await pageReload(page);
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
const { phosphate } = await addRnaPresetOnCanvas(
page,
Presets.C,
Expand Down Expand Up @@ -521,7 +522,7 @@ test.describe('Snake Bond Tool', () => {
0,
);

await page.getByTestId('PEPTIDES-TAB').click();
await goToPeptidesTab(page);
const [peptide] = await addBondedMonomersToCanvas(
page,
Peptides.A,
Expand Down Expand Up @@ -582,7 +583,7 @@ test.describe('Snake Bond Tool', () => {

test('Create snake mode for single monomer and nucleoside', async () => {
await addSingleMonomerToCanvas(page, Peptides.bAla, 'bAla', 300, 300, 0);
await page.getByTestId('RNA-TAB').click();
await goToRNATab(page);
await page.getByTestId('summary-Sugars').click();
const sugarOfNucleoside = await addSingleMonomerToCanvas(
page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const fileTypeHandlers: { [key in FileType]: FileTypeHandler } = {
[FileType.SDF]: getSdf,
};


async function getFileContent(
page: Page,
fileType: FileType,
Expand Down
3 changes: 3 additions & 0 deletions ketcher-autotests/tests/utils/macromolecules/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export type Tabs =
| typeof RNA_TAB
| typeof CHEM_TAB;

export const goToFavoritesTab = async (page: Page) =>
goToTab(page, FAVORITES_TAB);

export const goToRNATab = async (page: Page) => goToTab(page, RNA_TAB);

export const goToCHEMTab = async (page: Page) => goToTab(page, CHEM_TAB);
Expand Down

0 comments on commit f951fba

Please sign in to comment.