Skip to content

Commit

Permalink
#5077 - fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-sloboda committed Sep 2, 2024
1 parent 4b3f08c commit 9662526
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const formatsForSave = [
},
];

const OFFSET_FROM_ARROW = 30;

test.describe('Plus and Arrows tools ', () => {
const modifier = getControlModifier();
const CANVAS_CLICK_X = 300;
Expand Down Expand Up @@ -369,8 +371,8 @@ test.describe('Plus and Arrows tools ', () => {
});

test('Select the reaction arrow and move it', async ({ page }) => {
await page.mouse.move(point.x + 60, point.y);
await dragMouseTo(point.x + 60, point.y - 40, page);
await page.mouse.move(point.x + OFFSET_FROM_ARROW, point.y);
await dragMouseTo(point.x + OFFSET_FROM_ARROW, point.y - 40, page);
});

test('Select the reaction arrow with any reaction component(s) and move them', async ({
Expand All @@ -392,7 +394,7 @@ test.describe('Plus and Arrows tools ', () => {
page,
}) => {
await waitForRender(page, async () => {
await page.mouse.click(point.x + 60, point.y);
await page.mouse.click(point.x + OFFSET_FROM_ARROW, point.y);
});
await cutToClipboardByKeyboard(page);
await pasteFromClipboardByKeyboard(page, { delay: INPUT_DELAY });
Expand All @@ -415,7 +417,7 @@ test.describe('Plus and Arrows tools ', () => {
page,
}) => {
await waitForRender(page, async () => {
await page.mouse.click(point.x + 60, point.y);
await page.mouse.click(point.x + OFFSET_FROM_ARROW, point.y);
});

await copyToClipboardByKeyboard(page);
Expand All @@ -429,7 +431,7 @@ test.describe('Plus and Arrows tools ', () => {
page,
}) => {
await selectLeftPanelButton(LeftPanelButton.Erase, page);
await clickOnTheCanvas(page, -60, 0);
await clickOnTheCanvas(page, -OFFSET_FROM_ARROW, 0);
await takeEditorScreenshot(page);
await selectTopPanelButton(TopPanelButton.Undo, page);
await takeEditorScreenshot(page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export enum MultitailArrowRefName {

export interface MultitailArrowReferencePosition {
name: MultitailArrowRefName;
offset: Vec2;
isLine: boolean;
tailId: number | null;
}
Expand Down Expand Up @@ -355,12 +354,14 @@ export class ReMultitailArrow extends ReObject {
return distance < acc.distance
? {
distance,
ref: {
name: refName,
offset: new Vec2(0, 0),
isLine,
tailId,
},
ref:
refName !== MultitailArrowRefName.SPINE
? {
name: refName,
isLine,
tailId,
}
: null,
}
: acc;
},
Expand Down
10 changes: 4 additions & 6 deletions packages/ketcher-react/src/script/editor/tool/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ class SelectTool implements Tool {
return true;
}

if (ci.map === MULTITAIL_ARROW_KEY) {
if (ci.map === MULTITAIL_ARROW_KEY && ci.ref) {
this.dragCtx = this.multitailArrowMoveTool.mousedown(
event,
ci as MultitailArrowClosestItem,
);
} else if (ci.map === 'rxnArrows') {
} else if (ci.map === 'rxnArrows' && ci.ref) {
this.dragCtx = this.reactionArrowMoveTool.mousedown(
event,
ci as ReactionArrowClosestItem,
Expand Down Expand Up @@ -377,18 +377,15 @@ class SelectTool implements Tool {
);
}
if (this.dragCtx.action) {
this.editor.update(true);
this.editor.update(this.dragCtx.action);
this.editor.update(true);
}
this.dragCtx = null;
return;
}

if (this.dragCtx?.item) {
if (!isMergingToMacroMolecule(this.editor, this.dragCtx)) {
dropAndMerge(editor, this.dragCtx.mergeItems, this.dragCtx.action);
}
delete this.dragCtx;
} else if (this.#lassoHelper.running()) {
// TODO it catches more events than needed, to be re-factored
this.selectElementsOnCanvas(newSelected, editor, event);
Expand All @@ -399,6 +396,7 @@ class SelectTool implements Tool {
)
editor.selection(null);
}
this.dragCtx = null;
editor.event.message.dispatch({
info: false,
});
Expand Down

0 comments on commit 9662526

Please sign in to comment.