Skip to content

Commit 27ac9a0

Browse files
committed
Fixed e2e tests
1 parent c478ac8 commit 27ac9a0

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

packages/core/src/extensions/FormattingToolbar/FormattingToolbar.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { NodeSelection, TextSelection } from "prosemirror-state";
2+
13
import {
24
createExtension,
35
createStore,
46
} from "../../editor/BlockNoteExtension.js";
5-
import { TextSelection } from "prosemirror-state";
67

78
export const FormattingToolbarExtension = createExtension(({ editor }) => {
89
const store = createStore(false);
@@ -15,6 +16,15 @@ export const FormattingToolbarExtension = createExtension(({ editor }) => {
1516
return false;
1617
}
1718

19+
// Don't show if a block with inline content is selected.
20+
if (
21+
tr.selection instanceof NodeSelection &&
22+
(tr.selection.node.type.spec.content === "inline*" ||
23+
tr.selection.node.firstChild?.type.spec.content === "inline*")
24+
) {
25+
return false;
26+
}
27+
1828
// Don't show if the selection is a text selection but contains no text.
1929
if (
2030
tr.selection instanceof TextSelection &&

tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"scripts": {
66
"build": "tsc",
77
"lint": "eslint src --max-warnings 0",
8-
"playwright": "playwright test",
8+
"playwright": "playwright test dragdrop --headed",
99
"test": "vitest --run",
10-
"test:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd)/..:/work/ -w /work/tests -it mcr.microsoft.com/playwright:v1.51.1-noble npx playwright test -u",
10+
"test:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd)/..:/work/ -w /work/tests -it mcr.microsoft.com/playwright:v1.51.1-noble npx playwright test dragdrop -u",
1111
"test-ct": "playwright test -c playwright-ct.config.ts --headed",
1212
"test-ct:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd)/..:/work/ -w /work/tests -it mcr.microsoft.com/playwright:v1.51.1-noble npx playwright test -c playwright-ct.config.ts -u",
1313
"clean": "rimraf dist"

tests/src/end-to-end/dragdrop/dragdrop.test.ts-snapshots/dragdropnested-chromium-linux.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"type": "blockContainer",
99
"attrs": {
10-
"id": "1"
10+
"id": "2"
1111
},
1212
"content": [
1313
{
@@ -54,7 +54,7 @@
5454
{
5555
"type": "blockContainer",
5656
"attrs": {
57-
"id": "3"
57+
"id": "5"
5858
},
5959
"content": [
6060
{
@@ -77,7 +77,7 @@
7777
{
7878
"type": "blockContainer",
7979
"attrs": {
80-
"id": "2"
80+
"id": "4"
8181
},
8282
"content": [
8383
{
@@ -109,7 +109,7 @@
109109
{
110110
"type": "blockContainer",
111111
"attrs": {
112-
"id": "4"
112+
"id": "6"
113113
},
114114
"content": [
115115
{
@@ -133,7 +133,7 @@
133133
{
134134
"type": "blockContainer",
135135
"attrs": {
136-
"id": "5"
136+
"id": "7"
137137
},
138138
"content": [
139139
{

tests/src/end-to-end/dragdrop/dragdrop.test.ts-snapshots/dragdropnested-webkit-linux.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"type": "blockContainer",
99
"attrs": {
10-
"id": "1"
10+
"id": "2"
1111
},
1212
"content": [
1313
{
@@ -54,7 +54,7 @@
5454
{
5555
"type": "blockContainer",
5656
"attrs": {
57-
"id": "3"
57+
"id": "5"
5858
},
5959
"content": [
6060
{
@@ -77,7 +77,7 @@
7777
{
7878
"type": "blockContainer",
7979
"attrs": {
80-
"id": "2"
80+
"id": "4"
8181
},
8282
"content": [
8383
{
@@ -109,7 +109,7 @@
109109
{
110110
"type": "blockContainer",
111111
"attrs": {
112-
"id": "4"
112+
"id": "6"
113113
},
114114
"content": [
115115
{
@@ -133,7 +133,7 @@
133133
{
134134
"type": "blockContainer",
135135
"attrs": {
136-
"id": "5"
136+
"id": "7"
137137
},
138138
"content": [
139139
{

tests/src/utils/mouse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ export async function dragAndDropBlock(
3939
dropAbove: boolean,
4040
) {
4141
await moveMouseOverElement(page, dragTarget);
42+
await page.waitForTimeout(100);
4243

4344
await page.waitForSelector(DRAG_HANDLE_SELECTOR);
4445
const dragHandle = await page.locator(DRAG_HANDLE_SELECTOR);
4546
const dragHandleCenterCoords = await getElementCenterCoords(page, dragHandle);
4647
await page.mouse.move(dragHandleCenterCoords.x, dragHandleCenterCoords.y, {
4748
steps: 5,
4849
});
50+
await page.waitForTimeout(100);
4951
await page.mouse.down();
52+
await page.waitForTimeout(100);
5053

5154
const dropTargetCoords = dropAbove
5255
? await getElementLeftCoords(page, dropTarget)

0 commit comments

Comments
 (0)