forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context-menu.spec.ts
60 lines (39 loc) · 1.86 KB
/
context-menu.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { expect } from '@playwright/test'
import { test } from './fixtures'
import { createRandomPage } from './utils'
test('open context menu', async ({ page }) => {
await createRandomPage(page)
await page.locator('span.bullet-container >> nth=0').click({button: "right"})
await expect(page.locator('#custom-context-menu')).toBeVisible()
})
test('close context menu on esc', async ({ page }) => {
await createRandomPage(page)
await page.locator('span.bullet-container >> nth=0').click({button: "right"})
await page.keyboard.press('Escape')
await expect(page.locator('#custom-context-menu')).toHaveCount(0)
})
test('close context menu by left clicking on empty space', async ({ page }) => {
await createRandomPage(page)
await page.locator('span.bullet-container >> nth=0').click({button: "right"})
await page.mouse.click(0, 200, {button: "left"})
await expect(page.locator('#custom-context-menu')).toHaveCount(0)
})
test('close context menu by clicking on a menu item', async ({ page }) => {
await createRandomPage(page)
await page.locator('span.bullet-container >> nth=0').click({button: "right"})
await page.locator('#custom-context-menu .menu-link >> nth=1').click()
await expect(page.locator('#custom-context-menu')).toHaveCount(0)
})
test('close context menu by clicking on a block', async ({ page, block }) => {
await createRandomPage(page)
await block.mustType('fist Block')
await block.enterNext()
await page.locator('span.bullet-container >> nth=-1').click({button: "right"})
const elementHandle = page.locator('.block-content >> nth=0');
const box = await elementHandle.boundingBox();
expect(box).toBeTruthy()
if (box) {
await page.mouse.click(box.x + box.width - 5, box.y + box.height / 2);
}
await expect(page.locator('#custom-context-menu')).toHaveCount(0)
})