Skip to content

Commit

Permalink
Autotests: #5558 - Add ambiguous monomers to the library and allow th…
Browse files Browse the repository at this point in the history
…eir addition to the canvas - Case 8
  • Loading branch information
AlexeyGirin committed Sep 25, 2024
1 parent 9e7a464 commit 56cf615
Show file tree
Hide file tree
Showing 24 changed files with 229 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { test } from '@playwright/test';
import {
waitForPageInit,
Bases,
Peptides,
selectMonomer,
takeEditorScreenshot,
clickOnTheCanvas,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import { goToRNATab, MonomerLocationTabs } from '@utils/macromolecules/library';

interface IAmbiguousMonomerName {
testDescription: string;
AmbiguousMonomerName: Peptides | Bases;
MonomerLocationTab: MonomerLocationTabs;
// Set shouldFail to true if you expect test to fail because of existed bug and put issues link to issueNumber
shouldFail?: boolean;
// issueNumber is mandatory if shouldFail === true
issueNumber?: string;
// set pageReloadNeeded to true if you need to restart ketcher before test (f.ex. to restart font renderer)
pageReloadNeeded?: boolean;
}

test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
});

const AmbiguousMonomers: IAmbiguousMonomerName[] = [
{
testDescription: "1. 'X' ambiguous peptide",
AmbiguousMonomerName: Peptides.X,
MonomerLocationTab: MonomerLocationTabs.PEPTIDES,
},
{
testDescription: "2. 'B' ambiguous peptide",
AmbiguousMonomerName: Peptides.B,
MonomerLocationTab: MonomerLocationTabs.PEPTIDES,
},
{
testDescription: "3. 'J' ambiguous peptide",
AmbiguousMonomerName: Peptides.J,
MonomerLocationTab: MonomerLocationTabs.PEPTIDES,
},
{
testDescription: "4. 'Z' ambiguous peptide",
AmbiguousMonomerName: Peptides.Z,
MonomerLocationTab: MonomerLocationTabs.PEPTIDES,
},
{
testDescription: "5. 'N' ambiguous DNA base",
AmbiguousMonomerName: Bases.DNA_N,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "6. 'B' ambiguous DNA base",
AmbiguousMonomerName: Bases.DNA_B,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "7. 'H' ambiguous DNA base",
AmbiguousMonomerName: Bases.DNA_H,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "8. 'K' ambiguous DNA base",
AmbiguousMonomerName: Bases.DNA_K,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "9. 'W' ambiguous DNA base",
AmbiguousMonomerName: Bases.DNA_W,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "10. 'Y' ambiguous DNA base",
AmbiguousMonomerName: Bases.DNA_Y,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "11. 'N' ambiguous RNA base",
AmbiguousMonomerName: Bases.RNA_N,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "12. 'B' ambiguous RNA base",
AmbiguousMonomerName: Bases.RNA_B,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "13. 'H' ambiguous RNA base",
AmbiguousMonomerName: Bases.RNA_H,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "14. 'K' ambiguous RNA base",
AmbiguousMonomerName: Bases.RNA_K,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "15. 'W' ambiguous RNA base",
AmbiguousMonomerName: Bases.RNA_W,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "16. 'Y' ambiguous RNA base",
AmbiguousMonomerName: Bases.RNA_Y,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "17. 'M' ambiguous base",
AmbiguousMonomerName: Bases.M,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "18. 'R' ambiguous base",
AmbiguousMonomerName: Bases.R,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "19. 'S' ambiguous base",
AmbiguousMonomerName: Bases.S,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
{
testDescription: "20. 'V' ambiguous base",
AmbiguousMonomerName: Bases.V,
MonomerLocationTab: MonomerLocationTabs.BASES,
},
];

test.describe('Put ambiguous monomer on the canvas from library:', () => {
for (const AmbiguousMonomer of AmbiguousMonomers) {
test(`${AmbiguousMonomer.testDescription}`, async ({ page }) => {
/*
Test task: https://github.com/epam/ketcher/issues/5558
8. Verify the addition of ambuguous monomers to the canvas
Case:
1. Find monomer at the library and click on it
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);

// Test should be skipped if related bug exists
test.fixme(
AmbiguousMonomer.shouldFail === true,
`That test fails because of ${AmbiguousMonomer.issueNumber} issue.`,
);
});
}
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ import {
pressNewPresetButton,
toggleBasesAccordion,
toggleNucleotidesAccordion,
togglePhosphatesAccordion,
toggleRnaBuilderAccordion,
toggleSugarsAccordion,
} from '@utils/macromolecules/rnaBuilder';
import { Chems } from '@utils/selectors/macromoleculeEditor';
import {
goToCHEMTab,
goToMonomerLocationTab,
goToPeptidesTab,
goToRNATab,
MonomerLocationTabs,
} from '@utils/macromolecules/library';

async function drawThreeMonomers(page: Page) {
Expand Down Expand Up @@ -1385,16 +1386,6 @@ test.describe('RNA Library', () => {
await page.getByTestId('cancel-btn').click();
});

enum MonomerLocationTabs {
PEPTIDES = 'Peptides',
PRESETS = 'Presets',
SUGARS = 'Sugars',
BASES = 'Bases',
PHOSPHATES = 'Phosphates',
NUCLEOTIDES = 'Nucleotides',
CHEM = 'CHEM',
}

interface ISearchString {
testDescription: string;
SearchString: string;
Expand All @@ -1408,42 +1399,6 @@ test.describe('RNA Library', () => {
pageReloadNeeded?: boolean;
}

async function goToMonomerLocationTab(
page: Page,
monomerLocation: MonomerLocationTabs,
) {
switch (monomerLocation) {
case 'Peptides':
await goToPeptidesTab(page);
break;
case 'Presets':
await goToRNATab(page);
// Presets tab openned by default
break;
case 'Sugars':
await goToRNATab(page);
await toggleSugarsAccordion(page);
break;
case 'Bases':
await goToRNATab(page);
await toggleBasesAccordion(page);
break;
case 'Phosphates':
await goToRNATab(page);
await togglePhosphatesAccordion(page);
break;
case 'Nucleotides':
await toggleNucleotidesAccordion(page);
break;
case 'CHEM':
await goToCHEMTab(page);
break;
default:
await goToRNATab(page);
break;
}
}

async function searchMonomerByName(page: Page, monomerName: string) {
const rnaLibrarySearch = page.getByTestId('monomer-library-input');
await rnaLibrarySearch.fill(monomerName);
Expand Down Expand Up @@ -1678,7 +1633,7 @@ test.describe('RNA Library', () => {
}) => {
/*
Test task: https://github.com/epam/ketcher/issues/5558
Verify ambiguous monomer search functionality in the library
7. Verify ambiguous monomer search functionality in the library
Case:
1. Fill Search field with value
2. Switch to monomer's tab to see it
Expand Down
52 changes: 52 additions & 0 deletions ketcher-autotests/tests/utils/macromolecules/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {
PEPTIDES_TAB,
RNA_TAB,
} from '@constants/testIdConstants';
import {
toggleSugarsAccordion,
toggleBasesAccordion,
togglePhosphatesAccordion,
toggleNucleotidesAccordion,
} from './rnaBuilder';

export async function goToRNATab(page: Page) {
await page.getByTestId(FAVORITES_TAB).click();
Expand All @@ -17,3 +23,49 @@ export async function goToCHEMTab(page: Page) {
export async function goToPeptidesTab(page: Page) {
await page.getByTestId(PEPTIDES_TAB).click();
}

export enum MonomerLocationTabs {
PEPTIDES = 'Peptides',
PRESETS = 'Presets',
SUGARS = 'Sugars',
BASES = 'Bases',
PHOSPHATES = 'Phosphates',
NUCLEOTIDES = 'Nucleotides',
CHEM = 'CHEM',
}

export async function goToMonomerLocationTab(
page: Page,
monomerLocation: MonomerLocationTabs,
) {
switch (monomerLocation) {
case 'Peptides':
await goToPeptidesTab(page);
break;
case 'Presets':
await goToRNATab(page);
// Presets tab openned by default
break;
case 'Sugars':
await goToRNATab(page);
await toggleSugarsAccordion(page);
break;
case 'Bases':
await goToRNATab(page);
await toggleBasesAccordion(page);
break;
case 'Phosphates':
await goToRNATab(page);
await togglePhosphatesAccordion(page);
break;
case 'Nucleotides':
await toggleNucleotidesAccordion(page);
break;
case 'CHEM':
await goToCHEMTab(page);
break;
default:
await goToRNATab(page);
break;
}
}
18 changes: 18 additions & 0 deletions ketcher-autotests/tests/utils/selectors/templateModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ export enum Peptides {
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 Sugars {
Expand All @@ -119,8 +122,23 @@ export enum Bases {
NBebnzylAdenine = 'baA___N-benzyl-adenine',
TClampOMe = 'clA___T-clamp OMe',
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 async function selectBase(baseName: Bases, page: Page) {
Expand Down

0 comments on commit 56cf615

Please sign in to comment.