-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2360 - "Select" tool - added select and erase tools - implemented DrawingEntitiesManager and RenderersManager which controls entities parameters changes and render - added rootDir to tsconfig of core package
- Loading branch information
1 parent
e26a020
commit 19b56df
Showing
77 changed files
with
1,844 additions
and
818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { test } from '@playwright/test'; | ||
import { | ||
addMonomerToCanvas, | ||
selectEraseTool, | ||
selectSingleBondTool, | ||
takeEditorScreenshot, | ||
} from '@utils'; | ||
import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; | ||
import { bondTwoMonomers } from '@utils/macromolecules/polymerBond'; | ||
/* eslint-disable no-magic-numbers */ | ||
|
||
test.describe('Erase Tool', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(''); | ||
await turnOnMacromoleculesEditor(page); | ||
}); | ||
test.skip('Delete monomer bonded with another monomers', async ({ page }) => { | ||
/* | ||
Test case: #2370 - "Erase" tool for macromolecules editor | ||
Description: Erase Tool | ||
*/ | ||
|
||
// Create 4 peptides on canvas | ||
const MONOMER_NAME = 'Tza___3-thiazolylalanine'; | ||
const MONOMER_ALIAS = 'Tza'; | ||
await addMonomerToCanvas(page, MONOMER_NAME, 300, 300); | ||
await addMonomerToCanvas(page, MONOMER_NAME, 400, 400); | ||
await addMonomerToCanvas(page, MONOMER_NAME, 500, 500); | ||
await addMonomerToCanvas(page, MONOMER_NAME, 500, 200); | ||
|
||
// Get 4 peptides locators | ||
const peptides = await page.getByText(MONOMER_ALIAS).locator('..'); | ||
const peptide1 = peptides.nth(0); | ||
const peptide2 = peptides.nth(1); | ||
const peptide3 = peptides.nth(2); | ||
const peptide4 = peptides.nth(3); | ||
|
||
// Select bond tool | ||
await selectSingleBondTool(page); | ||
|
||
// Create bonds between peptides | ||
await bondTwoMonomers(page, peptide1, peptide2); | ||
await bondTwoMonomers(page, peptide3, peptide2); | ||
await bondTwoMonomers(page, peptide3, peptide4); | ||
|
||
await takeEditorScreenshot(page); | ||
|
||
await selectEraseTool(page); | ||
|
||
// Delete peptide linked with two other peptides by bonds | ||
await peptide3.click(); | ||
|
||
await takeEditorScreenshot(page); | ||
}); | ||
}); |
Binary file added
BIN
+8.95 KB
...ts/Erase-Tool-Delete-monomer-bonded-with-another-monomers-1-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.59 KB
...ts/Erase-Tool-Delete-monomer-bonded-with-another-monomers-2-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ests/tests/Macromolecule-editor/Rectangle-Selection-Tool/rectangle-selection-tool.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { test } from '@playwright/test'; | ||
import { | ||
addMonomerToCanvas, | ||
selectEraseTool, | ||
selectRectangleArea, | ||
selectRectangleSelectionTool, | ||
selectSingleBondTool, | ||
} from '@utils'; | ||
import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; | ||
import { bondTwoMonomers } from '@utils/macromolecules/polymerBond'; | ||
/* eslint-disable no-magic-numbers */ | ||
|
||
test.describe('Rectangle Selection Tool', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(''); | ||
await turnOnMacromoleculesEditor(page); | ||
}); | ||
test.skip('Select monomer and bonds and then erase', async ({ page }) => { | ||
/* | ||
Test case: #2360 - "Select" tool for Macromolecules editor | ||
Description: Rectangle Selection Tool | ||
*/ | ||
|
||
// Create 4 peptides on canvas | ||
const MONOMER_NAME = 'Tza___3-thiazolylalanine'; | ||
const MONOMER_ALIAS = 'Tza'; | ||
await addMonomerToCanvas(page, MONOMER_NAME, 300, 300); | ||
await addMonomerToCanvas(page, MONOMER_NAME, 400, 400); | ||
await addMonomerToCanvas(page, MONOMER_NAME, 500, 500); | ||
await addMonomerToCanvas(page, MONOMER_NAME, 500, 200); | ||
|
||
// Get 4 peptides locators | ||
const peptides = await page.getByText(MONOMER_ALIAS).locator('..'); | ||
const peptide1 = peptides.nth(0); | ||
const peptide2 = peptides.nth(1); | ||
const peptide3 = peptides.nth(2); | ||
const peptide4 = peptides.nth(3); | ||
|
||
// Select bond tool | ||
await selectSingleBondTool(page); | ||
|
||
// Create bonds between peptides | ||
await bondTwoMonomers(page, peptide1, peptide2); | ||
await bondTwoMonomers(page, peptide3, peptide2); | ||
await bondTwoMonomers(page, peptide3, peptide4); | ||
|
||
await page.screenshot({ | ||
path: 'tests/Macromolecule-editor/screenshots/rectangle-selection-tool.png', | ||
}); | ||
|
||
await selectRectangleSelectionTool(page); | ||
|
||
// Coordinates for rectangle selection | ||
const startX = 100; | ||
const startY = 100; | ||
const endX = 500; | ||
const endY = 500; | ||
|
||
await selectRectangleArea(page, startX, startY, endX, endY); | ||
|
||
await page.screenshot({ | ||
path: 'tests/Macromolecule-editor/screenshots/rectangle-selection-tool2.png', | ||
}); | ||
|
||
// Erase selected elements | ||
await selectEraseTool(page); | ||
|
||
await page.screenshot({ | ||
path: 'tests/Macromolecule-editor/screenshots/rectangle-selection-tool3.png', | ||
}); | ||
}); | ||
}); |
Binary file modified
BIN
-4.13 KB
(92%)
...ests/tests/Macromolecule-editor/screenshots/add-custom-preset-add-to-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.85 KB
(92%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/add-custom-preset-add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.27 KB
(93%)
...utotests/tests/Macromolecule-editor/screenshots/add-custom-preset-duplicate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 KB
(92%)
...totests/tests/Macromolecule-editor/screenshots/add-default-preset-to-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.99 KB
(91%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/chem-add-to-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.01 KB
(97%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/chem-library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.97 KB
(91%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/default-presets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.49 KB
(94%)
...her-autotests/tests/Macromolecule-editor/screenshots/peptides-add-to-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.66 KB
(92%)
...er-autotests/tests/Macromolecule-editor/screenshots/polymer-bond-tool-chem1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.93 KB
(91%)
...er-autotests/tests/Macromolecule-editor/screenshots/polymer-bond-tool-chem2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+258 Bytes
(100%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/polymer-bond-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+281 Bytes
(100%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/polymer-bond-tool2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.27 KB
(97%)
ketcher-autotests/tests/Macromolecule-editor/screenshots/polymer-bond-tool3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.3 KB
...r-autotests/tests/Macromolecule-editor/screenshots/rectangle-selection-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.1 KB
...-autotests/tests/Macromolecule-editor/screenshots/rectangle-selection-tool2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.6 KB
...-autotests/tests/Macromolecule-editor/screenshots/rectangle-selection-tool3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, Page } from '@playwright/test'; | ||
import { POLYMER_TOGGLER } from '@constants/testIdConstants'; | ||
|
||
export async function turnOnMacromoleculesEditor(page: Page) { | ||
await expect(page.getByTestId(POLYMER_TOGGLER)).toBeVisible(); | ||
await page.getByTestId(POLYMER_TOGGLER).click(); | ||
} |
12 changes: 12 additions & 0 deletions
12
ketcher-autotests/tests/utils/macromolecules/polymerBond.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Locator, Page } from '@playwright/test'; | ||
|
||
export async function bondTwoMonomers( | ||
page: Page, | ||
firstMonomerElement: Locator, | ||
secondMonomerElement: Locator, | ||
) { | ||
await firstMonomerElement.hover(); | ||
await page.mouse.down(); | ||
await secondMonomerElement.hover(); | ||
await page.mouse.up(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/ketcher-core/__tests__/application/editor/tools/SelectRectangleTool.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { CoreEditor } from 'application/editor'; | ||
import { PeptideRenderer } from 'application/render/renderers/PeptideRenderer'; | ||
import { | ||
getFinishedPolymerBond, | ||
peptideMonomerItem, | ||
polymerEditorTheme, | ||
} from '../../../mock-data'; | ||
import { createPolymerEditorCanvas } from '../../../helpers/dom'; | ||
import { SelectRectangle } from 'application/editor/tools/SelectRectangle'; | ||
|
||
jest.mock('d3', () => { | ||
return { | ||
brush() { | ||
return { | ||
on() {}, | ||
}; | ||
}, | ||
select() { | ||
return { | ||
call() { | ||
return this; | ||
}, | ||
insert() { | ||
return this; | ||
}, | ||
select() { | ||
return this; | ||
}, | ||
attr() { | ||
return this; | ||
}, | ||
style() { | ||
return this; | ||
}, | ||
}; | ||
}, | ||
}; | ||
}); | ||
|
||
describe('Select Rectangle Tool', () => { | ||
it('should select drawing entity on mousedown', () => { | ||
const polymerBond = getFinishedPolymerBond(0, 0, 10, 10); | ||
const event = { | ||
target: { | ||
__data__: polymerBond.renderer, | ||
}, | ||
}; | ||
const selectRectangleTool = new SelectRectangle( | ||
new CoreEditor({ | ||
theme: polymerEditorTheme, | ||
canvas: createPolymerEditorCanvas(), | ||
}), | ||
); | ||
|
||
expect(polymerBond.selected).toBeFalsy(); | ||
selectRectangleTool.mousedown(event); | ||
expect(polymerBond.selected).toBeTruthy(); | ||
}); | ||
|
||
it('should initiate the render of peptide mousedown', () => { | ||
const canvas: SVGSVGElement = createPolymerEditorCanvas(); | ||
const editor: CoreEditor = new CoreEditor({ | ||
canvas, | ||
theme: polymerEditorTheme, | ||
}); | ||
const onShow = jest.fn(); | ||
jest.spyOn(PeptideRenderer.prototype, 'show').mockImplementation(onShow); | ||
editor.events.selectMonomer.dispatch(peptideMonomerItem); | ||
canvas.dispatchEvent(new Event('mouseover', { bubbles: true })); | ||
expect(onShow).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.