Skip to content

Commit

Permalink
#3869 enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlaStarla committed Jan 30, 2024
1 parent 6a1a825 commit 187aedb
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,73 +275,89 @@ test.describe('Snake Bond Tool', () => {
await page.getByText('RNA').click();
await selectSnakeBondTool(page);

await addRnaPresetOnCanvas(page, 'A_A_R_P', 300, 300);
await addRnaPresetOnCanvas(page, 'C_C_R_P', 400, 600);
await addRnaPresetOnCanvas(page, 'G_G_R_P', 600, 400);
const { phosphate } = await addRnaPresetOnCanvas(
page,
'A_A_R_P',
300,
300,
0,
0,
);
const { sugar: sugar1, phosphate: phosphate1 } = await addRnaPresetOnCanvas(
page,
'C_C_R_P',
400,
600,
1,
1,
);
const { sugar: sugar2 } = await addRnaPresetOnCanvas(
page,
'G_G_R_P',
600,
400,
2,
2,
);

await selectSingleBondTool(page);

const phosphate1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(0);

const phosphate2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(1);

const sugar1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(1);
const sugar2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(2);

await bondTwoMonomers(page, phosphate1, sugar1);
await bondTwoMonomers(page, phosphate2, sugar2);
await bondTwoMonomers(page, phosphate, sugar1);
await bondTwoMonomers(page, phosphate1, sugar2);

await takeEditorScreenshot(page);
});

test('Check snake mode arrange for RNA chain', async ({ page }) => {
await page.getByText('RNA').click();

await addRnaPresetOnCanvas(page, 'A_A_R_P', 300, 300);
await addRnaPresetOnCanvas(page, 'C_C_R_P', 400, 600);
await addRnaPresetOnCanvas(page, 'G_G_R_P', 600, 400);
await addRnaPresetOnCanvas(page, 'T_T_R_P', 800, 200);
await addRnaPresetOnCanvas(page, 'T_T_R_P', 100, 100);
const { phosphate } = await addRnaPresetOnCanvas(
page,
'A_A_R_P',
300,
300,
0,
0,
);
const { sugar: sugar1, phosphate: phosphate1 } = await addRnaPresetOnCanvas(
page,
'C_C_R_P',
400,
600,
1,
1,
);
const { sugar: sugar2, phosphate: phosphate2 } = await addRnaPresetOnCanvas(
page,
'G_G_R_P',
600,
400,
2,
2,
);
const { sugar: sugar3, phosphate: phosphate3 } = await addRnaPresetOnCanvas(
page,
'T_T_R_P',
800,
200,
3,
3,
);
const { sugar: sugar4 } = await addRnaPresetOnCanvas(
page,
'T_T_R_P',
100,
100,
4,
4,
);

await selectSingleBondTool(page);

const phosphate1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(0);
const phosphate2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(1);
const phosphate3 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(2);
const phosphate4 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(3);
const sugar1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(1);
const sugar2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(2);
const sugar3 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(3);
const sugar4 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(4);

await bondTwoMonomers(page, phosphate1, sugar1);
await bondTwoMonomers(page, phosphate2, sugar2);
await bondTwoMonomers(page, phosphate3, sugar3);
await bondTwoMonomers(page, phosphate4, sugar4);
await bondTwoMonomers(page, phosphate, sugar1);
await bondTwoMonomers(page, phosphate1, sugar2);
await bondTwoMonomers(page, phosphate2, sugar3);
await bondTwoMonomers(page, phosphate3, sugar4);

await selectSnakeBondTool(page);
await takeEditorScreenshot(page);
Expand Down Expand Up @@ -411,35 +427,36 @@ test.describe('Snake Bond Tool', () => {
await page.getByText('RNA').click();
await selectSnakeBondTool(page);

await addRnaPresetOnCanvas(page, 'A_A_R_P', 200, 200);
await addRnaPresetOnCanvas(page, 'C_C_R_P', 300, 500);
await addRnaPresetOnCanvas(page, 'G_G_R_P', 400, 300);
const { phosphate } = await addRnaPresetOnCanvas(
page,
'A_A_R_P',
200,
200,
0,
0,
);
const { sugar: sugar1, phosphate: phosphate1 } = await addRnaPresetOnCanvas(
page,
'C_C_R_P',
300,
500,
1,
1,
);
const { sugar: sugar2, phosphate: phosphate2 } = await addRnaPresetOnCanvas(
page,
'G_G_R_P',
400,
300,
2,
2,
);

await selectSingleBondTool(page);

const phosphate1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(0);
const phosphate2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(1);
const phosphate3 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(2);

const sugar1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(1);
const sugar2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(2);

await bondTwoMonomers(page, phosphate1, sugar1);
await bondTwoMonomers(page, phosphate2, sugar2);
await bondTwoMonomers(page, phosphate3, peptide1);

await page.locator('button[title=R1]').nth(1).click();
await page.locator('button[title=Connect]').click();
await bondTwoMonomers(page, phosphate, sugar1);
await bondTwoMonomers(page, phosphate1, sugar2);
await bondTwoMonomers(page, phosphate2, peptide1, undefined, 'R1');
await bondTwoMonomers(page, peptide1, peptide2);
await bondTwoMonomers(page, peptide2, peptide3);

Expand All @@ -460,8 +477,22 @@ test.describe('Snake Bond Tool', () => {
await page.getByText('RNA').click();
await selectSnakeBondTool(page);

await addRnaPresetOnCanvas(page, 'A_A_R_P', 200, 200);
await addRnaPresetOnCanvas(page, 'G_G_R_P', 700, 300);
const { phosphate } = await addRnaPresetOnCanvas(
page,
'A_A_R_P',
200,
200,
0,
0,
);
const { sugar } = await addRnaPresetOnCanvas(
page,
'G_G_R_P',
700,
300,
1,
1,
);

await page.getByTestId('summary-Sugars').click();
const sugarOfNucleoside = await addMonomerToCanvas(
Expand All @@ -484,15 +515,6 @@ test.describe('Snake Bond Tool', () => {

await selectSingleBondTool(page);
await bondTwoMonomers(page, sugarOfNucleoside, baseOfNucleoside);

const phosphate = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(0);

const sugar = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(1);

await bondTwoMonomers(page, phosphate, sugarOfNucleoside);
await bondTwoMonomers(page, sugarOfNucleoside, sugar);

Expand All @@ -507,12 +529,31 @@ test.describe('Snake Bond Tool', () => {

test('Create snake bond for chain with side chains', async ({ page }) => {
await page.getByText('RNA').click();

await addRnaPresetOnCanvas(page, 'A_A_R_P', 200, 200);
await addRnaPresetOnCanvas(page, 'G_G_R_P', 500, 300);
await addRnaPresetOnCanvas(page, 'T_T_R_P', 700, 300);
await addRnaPresetOnCanvas(page, 'U_U_R_P', 900, 300);

const { phosphate } = await addRnaPresetOnCanvas(
page,
'A_A_R_P',
200,
200,
0,
0,
);
const { sugar: sugar1, phosphate: phosphate1 } = await addRnaPresetOnCanvas(
page,
'G_G_R_P',
500,
300,
1,
1,
);
const { sugar: sugar2, phosphate: phosphate2 } = await addRnaPresetOnCanvas(
page,
'T_T_R_P',
700,
300,
2,
2,
);
await addRnaPresetOnCanvas(page, 'U_U_R_P', 900, 300, 3, 3);
await page.getByTestId('summary-Sugars').click();
const sugarOfNucleoside = await addMonomerToCanvas(
page,
Expand Down Expand Up @@ -601,40 +642,17 @@ test.describe('Snake Bond Tool', () => {

await selectSingleBondTool(page);
await bondTwoMonomers(page, sugarOfNucleoside, baseOfNucleoside);
await bondTwoMonomers(page, baseOfNucleoside, monomer1);
await page.locator('button[title=R2]').nth(0).click();
await page.locator('button[title=R1]').nth(1).click();
await page.locator('button[title=Connect]').click();
await bondTwoMonomers(page, baseOfNucleoside, monomer1, 'R2', 'R1');

await bondTwoMonomers(page, monomer1, monomer2);
await bondTwoMonomers(page, monomer2, monomer3);
await bondTwoMonomers(page, monomer3, monomer4);
await bondTwoMonomers(page, monomer2, monomer5);
await page.locator('button[title=R1]').nth(1).click();
await page.locator('button[title=Connect]').click();

const phosphate = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(0);

const sugar = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(1);
const sugar1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(2);
const phosphate1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(1);
const phosphate2 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(2);
await bondTwoMonomers(page, monomer2, monomer5, undefined, 'R1');

await bondTwoMonomers(page, phosphate, sugarOfNucleoside);
await bondTwoMonomers(page, sugarOfNucleoside, sugar);
await bondTwoMonomers(page, phosphate1, sugar1);
await bondTwoMonomers(page, phosphate2, monomer6);
await page.locator('button[title=R1]').nth(1).click();
await page.locator('button[title=Connect]').click();
await bondTwoMonomers(page, sugarOfNucleoside, sugar1);
await bondTwoMonomers(page, phosphate1, sugar2);
await bondTwoMonomers(page, phosphate2, monomer6, undefined, 'R1');
await bondTwoMonomers(page, monomer6, monomer7);
await bondTwoMonomers(page, monomer7, monomer8);

Expand Down
10 changes: 10 additions & 0 deletions ketcher-autotests/tests/utils/canvas/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,20 @@ export async function addRnaPresetOnCanvas(
presetId: string,
positionX: number,
positionY: number,
sugarIndex: number,
phosphateIndex: number,
) {
await page.getByTestId(presetId).click();
await page.mouse.click(positionX, positionY);
await hideMonomerPreview(page);
const sugar = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='R']]`)
.nth(sugarIndex);
const phosphate = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(phosphateIndex);

return { sugar, phosphate };
}

export async function addChemOnCanvas(page: Page, chemId: string) {
Expand Down
12 changes: 12 additions & 0 deletions ketcher-autotests/tests/utils/macromolecules/polymerBond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ export async function bondTwoMonomers(
page: Page,
firstMonomerElement: Locator,
secondMonomerElement: Locator,
connectTitle1?: string,
connectTitle2?: string,
) {
await firstMonomerElement.hover();
await page.mouse.down();
await secondMonomerElement.hover();
await page.mouse.up();
await hideMonomerPreview(page);
const dialog = await page.getByRole('dialog');
if (await dialog.isVisible()) {
if (connectTitle1) {
await page.locator(`button[title='${connectTitle1}']`).nth(0).click();
}
if (connectTitle2) {
await page.locator(`button[title='${connectTitle2}']`).nth(1).click();
}
await page.locator('button[title=Connect]').click();
}
}
Loading

0 comments on commit 187aedb

Please sign in to comment.