-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa7d150
commit 08ead3c
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...r-Interface/Preview-For-Abbreviated-Structures/preview-for-abbreviated-structures.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,81 @@ | ||
import { test } from '@playwright/test'; | ||
import { | ||
takeEditorScreenshot, | ||
selectRingButton, | ||
clickInTheMiddleOfTheScreen, | ||
RingButton, | ||
selectTemplate, | ||
selectFunctionalGroups, | ||
FunctionalGroups, | ||
delay, | ||
moveMouseToTheMiddleOfTheScreen, | ||
} from '@utils'; | ||
import { getRightAtomByAttributes } from '@utils/canvas/atoms'; | ||
|
||
/* Show abbreviated structure preview when hovering over atoms or bonds | ||
* with the template tool selected | ||
* related to GitHub issue: https://github.com/epam/ketcher/issues/2939 | ||
*/ | ||
test.describe('Preview for abbreviated structures: functional groups', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(''); | ||
|
||
// place a benzene ring in the middle of the screen | ||
// and select a functional group from structure library | ||
await selectRingButton(RingButton.Benzene, page); | ||
await clickInTheMiddleOfTheScreen(page); | ||
await selectTemplate(page); | ||
await page.getByRole('tab', { name: 'Functional Groups' }).click(); | ||
await selectFunctionalGroups(FunctionalGroups.Boc, page); | ||
}); | ||
|
||
test('Should show a preview of a functional group when hovering over atom', async ({ | ||
page, | ||
}) => { | ||
const point = await getRightAtomByAttributes(page, { label: 'C' }); | ||
await page.mouse.move(point.x, point.y); | ||
// delay is required because preview is shown with delay | ||
await delay(1); | ||
|
||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Should hide preview of a functional group when hovering over atom and then moving the mouse away', async ({ | ||
page, | ||
}) => { | ||
const point = await getRightAtomByAttributes(page, { label: 'C' }); | ||
await page.mouse.move(point.x, point.y); | ||
// delay is required because preview is shown with delay | ||
await delay(1); | ||
await moveMouseToTheMiddleOfTheScreen(page); | ||
|
||
await delay(1); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Should hide preview of a functional group when hovering over atom', async ({ | ||
page, | ||
}) => { | ||
const point = await getRightAtomByAttributes(page, { label: 'C' }); | ||
await page.mouse.move(point.x, point.y); | ||
// delay is required because preview is shown with delay | ||
await delay(1); | ||
await moveMouseToTheMiddleOfTheScreen(page); | ||
|
||
await delay(1); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Should remove preview and add the functional group to atom in contracted state when clicked', async ({ | ||
page, | ||
}) => { | ||
const point = await getRightAtomByAttributes(page, { label: 'C' }); | ||
await page.mouse.move(point.x, point.y); | ||
// delay is required because preview is shown with delay | ||
await delay(1); | ||
await page.mouse.click(point.x, point.y); | ||
await moveMouseToTheMiddleOfTheScreen(page); | ||
|
||
await takeEditorScreenshot(page); | ||
}); | ||
}); |