1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 03:11:44 +02:00

fix hovering-toolbar playwright integration test (#5284)

This commit is contained in:
Sergei Dedkov
2023-02-08 11:13:09 +06:00
committed by GitHub
parent 9de2e2c316
commit fc84fdbd99
3 changed files with 11 additions and 13 deletions

View File

@@ -78,6 +78,9 @@ const config: PlaywrightTestConfig = {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry', trace: 'on-first-retry',
/* Name of attribute for selecting elements by page.getByTestId */
testIdAttribute: 'data-test-id',
}, },
/* Configure projects for major browsers */ /* Configure projects for major browsers */

View File

@@ -7,24 +7,18 @@ test.describe('hovering toolbar example', () => {
test('hovering toolbar appears', async ({ page }) => { test('hovering toolbar appears', async ({ page }) => {
await page.pause() await page.pause()
await expect(page.locator('div').nth(12)).toHaveCSS('opacity', '0') await expect(page.getByTestId('menu')).toHaveCSS('opacity', '0')
await page await page
.locator('span[data-slate-string="true"]') .locator('span[data-slate-string="true"]')
.nth(0) .nth(0)
.selectText() .selectText()
expect( expect(await page.getByTestId('menu').count()).toBe(1)
await page
.locator('div')
.nth(12)
.count()
).toBe(1)
await expect(page.locator('div').nth(12)).toHaveCSS('opacity', '1') await expect(page.getByTestId('menu')).toHaveCSS('opacity', '1')
expect( expect(
await page await page
.locator('div') .getByTestId('menu')
.nth(12)
.locator('span.material-icons') .locator('span.material-icons')
.count() .count()
).toBe(3) ).toBe(3)
@@ -35,7 +29,7 @@ test.describe('hovering toolbar example', () => {
.locator('span[data-slate-string="true"]') .locator('span[data-slate-string="true"]')
.nth(0) .nth(0)
.selectText() .selectText()
await expect(page.locator('div').nth(12)).toHaveCSS('opacity', '1') await expect(page.getByTestId('menu')).toHaveCSS('opacity', '1')
await page await page
.locator('span[data-slate-string="true"]') .locator('span[data-slate-string="true"]')
.nth(0) .nth(0)
@@ -43,7 +37,7 @@ test.describe('hovering toolbar example', () => {
await page await page
.locator('div') .locator('div')
.nth(0) .nth(0)
.click({ force: true }) .click({ force: true, position: { x: 0, y: 0 } })
await expect(page.locator('div').nth(12)).toHaveCSS('opacity', '0') await expect(page.getByTestId('menu')).toHaveCSS('opacity', '0')
}) })
}) })

View File

@@ -149,6 +149,7 @@ export const Menu = React.forwardRef(
) => ( ) => (
<div <div
{...props} {...props}
data-test-id="menu"
ref={ref} ref={ref}
className={cx( className={cx(
className, className,