Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5973 autotests replace mouseclick operations with clickoncanvas function #6006

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ketcher-autotests/tests/API/api-set-get-molecule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
openFileAndAddToCanvasAsNewProject,
drawBenzeneRing,
waitForLoad,
clickOnCanvas,
} from '@utils';
import { getAtomByIndex } from '@utils/canvas/atoms';
import {
Expand Down Expand Up @@ -364,7 +365,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {

// eslint-disable-next-line no-magic-numbers
const point = await getAtomByIndex(page, { label: 'C' }, 3);
await page.mouse.click(point.x, point.y, { button: 'right' });
await clickOnCanvas(page, point.x, point.y, { button: 'right' });
await page.getByText('Contract Abbreviation').click();
await takeEditorScreenshot(page);
});
Expand Down Expand Up @@ -411,7 +412,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {

// eslint-disable-next-line no-magic-numbers
const point = await getAtomByIndex(page, { label: 'C' }, 3);
await page.mouse.click(point.x, point.y, { button: 'right' });
await clickOnCanvas(page, point.x, point.y, { button: 'right' });
await page.getByText('Contract Abbreviation').click();
await takeEditorScreenshot(page);
});
Expand Down Expand Up @@ -497,7 +498,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {

// eslint-disable-next-line no-magic-numbers
const point = await getAtomByIndex(page, { label: 'C' }, 3);
await page.mouse.click(point.x, point.y, { button: 'right' });
await clickOnCanvas(page, point.x, point.y, { button: 'right' });
await page.getByText('Contract Abbreviation').click();
await takeEditorScreenshot(page);
});
Expand Down Expand Up @@ -544,7 +545,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {

// eslint-disable-next-line no-magic-numbers
const point = await getAtomByIndex(page, { label: 'C' }, 3);
await page.mouse.click(point.x, point.y, { button: 'right' });
await clickOnCanvas(page, point.x, point.y, { button: 'right' });
await page.getByText('Contract Abbreviation').click();
await takeEditorScreenshot(page);
});
Expand Down Expand Up @@ -627,7 +628,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {

// eslint-disable-next-line no-magic-numbers
const point = await getAtomByIndex(page, { label: 'C' }, 3);
await page.mouse.click(point.x, point.y, { button: 'right' });
await clickOnCanvas(page, point.x, point.y, { button: 'right' });
await page.getByText('Contract Abbreviation').click();
await takeEditorScreenshot(page);
});
Expand Down Expand Up @@ -671,7 +672,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {

// eslint-disable-next-line no-magic-numbers
const point = await getAtomByIndex(page, { label: 'C' }, 3);
await page.mouse.click(point.x, point.y, { button: 'right' });
await clickOnCanvas(page, point.x, point.y, { button: 'right' });
await page.getByText('Contract Abbreviation').click();
await takeEditorScreenshot(page);
});
Expand Down
5 changes: 3 additions & 2 deletions ketcher-autotests/tests/API/view-only-mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
dragMouseTo,
selectAllStructuresOnCanvas,
pasteFromClipboardByKeyboard,
clickOnCanvas,
} from '@utils';
import { closeErrorAndInfoModals } from '@utils/common/helpers';
import {
Expand Down Expand Up @@ -194,7 +195,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {
await page.getByTitle('Copy as MOL (Ctrl+M)').click();
await disableViewOnlyModeBySetOptions(page);
await pasteFromClipboardByKeyboard(page);
await page.mouse.click(200, 200);
await clickOnCanvas(page, 200, 200);
await takeEditorScreenshot(page);
});

Expand All @@ -213,7 +214,7 @@ test.describe('Tests for API setMolecule/getMolecule', () => {
await page.getByTitle('Copy as KET (Ctrl+Shift+K)').click();
await disableViewOnlyModeBySetOptions(page);
await pasteFromClipboardByKeyboard(page);
await page.mouse.click(200, 200);
await clickOnCanvas(page, 200, 200);
await takeEditorScreenshot(page);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
receiveFileComparisonData,
saveToFile,
moveOnAtom,
clickOnCanvas,
} from '@utils';
import { getKet } from '@utils/formats';

Expand Down Expand Up @@ -197,7 +198,7 @@ test.describe('load as fragment (Add to Canvas) srtuctures from files with diffe

async function addSecondHydrogen() {
await selectAtomInToolbar(AtomButton.Hydrogen, page);
await page.mouse.click(x + shiftForSecondHydrogen, y, {
await clickOnCanvas(page, x + shiftForSecondHydrogen, y, {
button: 'left',
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
setBondLengthOptionUnit,
setBondLengthValue,
openSettings,
clickOnCanvas,
} from '@utils';
import { getRxn } from '@utils/formats';
import { drawReactionWithTwoBenzeneRings } from '@utils/canvas/drawStructures';
Expand Down Expand Up @@ -104,7 +105,7 @@ test.describe('Tests for Open and Save RXN file operations', () => {
await page.getByRole('button', { name: 'Cancel' }).click();
await selectNestedTool(page, RgroupTool.R_GROUP_FRAGMENT);
const { x, y } = await getCoordinatesTopAtomOfBenzeneRing(page);
await page.mouse.click(x, y);
await clickOnCanvas(page, x, y);
await page.getByRole('button', { name: 'R22' }).click();
await page.getByRole('button', { name: 'Apply' }).click();
await selectTopPanelButton(TopPanelButton.Save, page);
Expand Down Expand Up @@ -161,7 +162,7 @@ test.describe('Tests for Open and Save RXN file operations', () => {

await pressButton(page, 'Cancel');
await selectLeftPanelButton(LeftPanelButton.ReactionPlusTool, page);
await page.mouse.click(xCoordinatesWithShiftHalf, yCoordinatesWithShift);
await clickOnCanvas(page, xCoordinatesWithShiftHalf, yCoordinatesWithShift);
const ySecondChain = yCoordinatesWithShift + yDelta50;
await selectLeftPanelButton(LeftPanelButton.Chain, page);
await page.mouse.move(x, ySecondChain);
Expand All @@ -170,7 +171,7 @@ test.describe('Tests for Open and Save RXN file operations', () => {

await pressButton(page, 'Cancel');
await selectLeftPanelButton(LeftPanelButton.Erase, page);
await page.mouse.click(xCoordinatesWithShiftHalf, yCoordinatesWithShift);
await clickOnCanvas(page, xCoordinatesWithShiftHalf, yCoordinatesWithShift);
await selectNestedTool(page, ArrowTool.ARROW_FILLED_BOW);
const yArrowStart = y + yDelta20;
const yArrowEnd = yArrowStart + yDelta20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
waitForSpinnerFinishedWork,
waitForPageInit,
openFileAndAddToCanvasAsNewProject,
clickOnCanvas,
} from '@utils';
import { getCml, getMolfile, getRxn, getSmiles } from '@utils/formats';
import {
Expand Down Expand Up @@ -164,7 +165,7 @@ test.describe('Aromatize/Dearomatize Tool', () => {
page,
);
await copyAndPaste(page);
await page.mouse.click(CANVAS_CLICK_X, CANVAS_CLICK_Y);
await clickOnCanvas(page, CANVAS_CLICK_X, CANVAS_CLICK_Y);
await waitForSpinnerFinishedWork(page, async () => {
await selectTopPanelButton(TopPanelButton.Aromatize, page);
});
Expand All @@ -184,7 +185,7 @@ test.describe('Aromatize/Dearomatize Tool', () => {
page,
);
await cutAndPaste(page);
await page.mouse.click(CANVAS_CLICK_X, CANVAS_CLICK_Y);
await clickOnCanvas(page, CANVAS_CLICK_X, CANVAS_CLICK_Y);
await waitForSpinnerFinishedWork(page, async () => {
await selectTopPanelButton(TopPanelButton.Aromatize, page);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
clickOnBond,
openFileAndAddToCanvasAsNewProject,
selectAllStructuresOnCanvas,
clickOnCanvas,
} from '@utils';
import { getAtomByIndex } from '@utils/canvas/atoms';
import { getBondByIndex } from '@utils/canvas/bonds';
Expand Down Expand Up @@ -122,9 +123,7 @@ test.describe('Indigo Tools - Calculate CIP Tool', () => {
);
await selectTopPanelButton(TopPanelButton.Calculate, page);
await copyAndPaste(page);
await waitForRender(page, async () => {
await page.mouse.click(x, y);
});
await clickOnCanvas(page, x, y);
await takeEditorScreenshot(page);
});

Expand All @@ -144,7 +143,7 @@ test.describe('Indigo Tools - Calculate CIP Tool', () => {
);
await selectTopPanelButton(TopPanelButton.Calculate, page);
await cutAndPaste(page);
await page.mouse.click(x, y);
await clickOnCanvas(page, x, y);
await takeEditorScreenshot(page);
});

Expand Down Expand Up @@ -368,7 +367,7 @@ test.describe('Indigo Tools - Calculate CIP Tool', () => {
await selectTopPanelButton(TopPanelButton.Calculate, page);
await selectLeftPanelButton(LeftPanelButton.Erase, page);
const point = await getAtomByIndex(page, { label: 'N' }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);

await takeEditorScreenshot(page);

Expand Down Expand Up @@ -425,7 +424,7 @@ test.describe('Indigo Tools - Calculate CIP Tool', () => {
});
await selectNestedTool(page, BondTool.UP);
const point = await getBondByIndex(page, { type: BondType.SINGLE }, 5);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await takeEditorScreenshot(page);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
AtomButton,
waitForPageInit,
waitForSpinnerFinishedWork,
clickOnCanvas,
} from '@utils';
import { getAtomByIndex } from '@utils/canvas/atoms';
import { getBondByIndex } from '@utils/canvas/bonds';
Expand Down Expand Up @@ -127,11 +128,11 @@ test.describe('Calculated Values Tools', () => {

point = await getBondByIndex(page, { type: BondType.SINGLE }, 3);
await page.keyboard.down('Shift');
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
point = await getBondByIndex(page, { type: BondType.SINGLE }, 4);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
point = await getBondByIndex(page, { type: BondType.SINGLE }, 5);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await page.keyboard.up('Shift');

await waitForSpinnerFinishedWork(page, async () => {
Expand Down Expand Up @@ -494,7 +495,7 @@ test.describe('Calculated Values Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V3000/a-query-non-hsub.mol', page);
const point = await getBondByIndex(page, { type: BondType.SINGLE }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await selectTopPanelButton(TopPanelButton.Calculated, page);
await takeEditorScreenshot(page);
});
Expand All @@ -512,7 +513,7 @@ test.describe('Calculated Values Tools', () => {
page,
);
const point = await getBondByIndex(page, { type: BondType.SINGLE }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await selectTopPanelButton(TopPanelButton.Calculated, page);
await takeEditorScreenshot(page);
});
Expand All @@ -527,7 +528,7 @@ test.describe('Calculated Values Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V3000/a-query-ring-bonds.mol', page);
const point = await getBondByIndex(page, { type: BondType.SINGLE }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await selectTopPanelButton(TopPanelButton.Calculated, page);
await takeEditorScreenshot(page);
});
Expand All @@ -542,7 +543,7 @@ test.describe('Calculated Values Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V3000/a-query-aq.mol', page);
const point = await getBondByIndex(page, { type: BondType.SINGLE }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await selectTopPanelButton(TopPanelButton.Calculated, page);
await takeEditorScreenshot(page);
});
Expand All @@ -557,7 +558,7 @@ test.describe('Calculated Values Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V3000/a-query-atom-list.mol', page);
const point = await getAtomByIndex(page, { label: 'C' }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await selectTopPanelButton(TopPanelButton.Calculated, page);
await takeEditorScreenshot(page);
});
Expand All @@ -572,7 +573,7 @@ test.describe('Calculated Values Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V3000/a-query-not-list.mol', page);
const point = await getAtomByIndex(page, { label: 'C' }, 0);
await page.mouse.click(point.x, point.y);
await clickOnCanvas(page, point.x, point.y);
await selectTopPanelButton(TopPanelButton.Calculated, page);
await takeEditorScreenshot(page);
});
Expand Down
3 changes: 2 additions & 1 deletion ketcher-autotests/tests/Indigo-Tools/Layout/layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
takeTopToolbarScreenshot,
selectPartOfMolecules,
selectPartOfChain,
clickOnCanvas,
} from '@utils';

async function openFileWithShift(filename: string, page: Page) {
Expand All @@ -28,7 +29,7 @@ async function openFileWithShift(filename: string, page: Page) {
});
const { x, y } = await getCoordinatesOfTheMiddleOfTheScreen(page);
const shift = 150;
await page.mouse.click(x + shift, y + shift);
await clickOnCanvas(page, x + shift, y + shift);
}

test.describe('Indigo Tools - Layout', () => {
Expand Down
Loading
Loading