Skip to content

Commit

Permalink
Autotests: #6047 - autotests replace clean up operations with valid h…
Browse files Browse the repository at this point in the history
…elper functions (#6233)

* Added a helper function to select the Clean tool.

* The selection of the Clean tool has been replaced with an appropriate helper function.
  • Loading branch information
YatsekTest authored Jan 7, 2025
1 parent 256be60 commit e2f67e8
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
screenshotBetweenUndoRedo,
selectAllStructuresOnCanvas,
selectAromatizeTool,
selectCleanTool,
selectClearCanvasTool,
selectDearomatizeTool,
selectEraseTool,
Expand Down Expand Up @@ -1349,10 +1350,7 @@ test.describe('Image files', () => {
await dragMouseTo(x, y, page);
await clickOnCanvas(page, 100, 100);
await takeEditorScreenshot(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand Down
126 changes: 26 additions & 100 deletions ketcher-autotests/tests/Indigo-Tools/Clean-Tools/clean-tools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
selectPartOfChain,
selectPartOfMolecules,
saveToFile,
selectCleanTool,
} from '@utils';
import { getMolfile } from '@utils/formats/formats';
import { pressUndoButton } from '@utils/macromolecules/topToolBar';
Expand Down Expand Up @@ -58,10 +59,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -82,10 +80,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -107,10 +102,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand Down Expand Up @@ -138,10 +130,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V2000/layout-distorted.mol', page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -160,10 +149,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -176,10 +162,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V2000/clean-appoints.mol', page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -201,10 +184,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });

await pressUndoButton(page);
Expand All @@ -227,10 +207,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -252,10 +229,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -276,10 +250,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -292,10 +263,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
*/
await openFileAndAddToCanvas('KET/stereolabels.ket', page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });

await pressUndoButton(page);
Expand All @@ -317,10 +285,7 @@ test.describe('Indigo Tools - Clean Tools', () => {

await pressUndoButton(page);

await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand Down Expand Up @@ -362,10 +327,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfChain(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -379,10 +341,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfChain(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -399,10 +358,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -416,16 +372,10 @@ test.describe('Indigo Tools - Clean Tools', () => {
const y = 300;
const anyAtom = 0;
await openFileAndAddToCanvas('Molfiles-V2000/toluene.mol', page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await moveOnBond(page, BondType.SINGLE, 0);
await dragMouseTo(x, y, page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await selectAtomInToolbar(AtomButton.Oxygen, page);
await clickOnAtom(page, 'C', anyAtom);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
Expand All @@ -444,10 +394,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -462,10 +409,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
Undo/Redo actions are correct.
*/
await openFileAndAddToCanvas('Molfiles-V2000/big-rings.mol', page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await pressUndoButton(page);
await waitForSpinnerFinishedWork(
page,
Expand All @@ -488,10 +432,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await page.getByText(anyRGroupLabel).click();
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -502,10 +443,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
Position of the reaction does not change.
*/
await openFileAndAddToCanvas('Rxn-V2000/distorted-reaction.rxn', page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -520,10 +458,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -546,10 +481,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -562,10 +494,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
*/
await openFileAndAddToCanvas('Molfiles-V2000/distorted-Sgroups.mol', page);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand All @@ -584,10 +513,7 @@ test.describe('Indigo Tools - Clean Tools', () => {
page,
);
await selectPartOfMolecules(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
selectZoomReset,
selectAromatizeTool,
selectDearomatizeTool,
selectCleanTool,
} from '@utils';
import {
addSuperatomAttachmentPoint,
Expand Down Expand Up @@ -1901,10 +1902,7 @@ test.describe('Macro-Micro-Switcher', () => {
*/
await openFileAndAddToCanvas('KET/distorted-r1-attachment-point.ket', page);
await takeEditorScreenshot(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page, { maxDiffPixelRatio: 0.05 });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
screenshotBetweenUndoRedo,
selectAllStructuresOnCanvas,
selectAromatizeTool,
selectCleanTool,
selectClearCanvasTool,
selectDearomatizeTool,
selectDropdownTool,
Expand All @@ -41,7 +42,6 @@ import {
TopPanelButton,
waitForPageInit,
waitForRender,
waitForSpinnerFinishedWork,
} from '@utils';
import { closeErrorAndInfoModals } from '@utils/common/helpers';
import {
Expand Down Expand Up @@ -3739,10 +3739,7 @@ test.describe('Multi-Tailed Arrow Tool', () => {
await dragMouseTo(700, 340, page);
await clickOnCanvas(page, 200, 200);
await takeEditorScreenshot(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);
await takeEditorScreenshot(page);
await verifyFileExport(
page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import {
waitForPageInit,
waitForRender,
openDropdown,
waitForSpinnerFinishedWork,
selectRectangleArea,
copyToClipboardByKeyboard,
cutToClipboardByKeyboard,
pasteFromClipboardByKeyboard,
selectAllStructuresOnCanvas,
clickOnCanvas,
selectCleanTool,
} from '@utils';
import {
pressRedoButton,
Expand Down Expand Up @@ -461,10 +461,7 @@ test.describe('Plus and Arrows tools ', () => {
await selectTopPanelButton(TopPanelButton.Layout, page);
await takeEditorScreenshot(page);
await pressUndoButton(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(TopPanelButton.Clean, page),
);
await selectCleanTool(page);

test.fixme(
true,
Expand Down
Loading

0 comments on commit e2f67e8

Please sign in to comment.