Skip to content

Commit

Permalink
fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Gautier committed Dec 12, 2022
1 parent cfd40ae commit b50ca9f
Showing 1 changed file with 94 additions and 28 deletions.
122 changes: 94 additions & 28 deletions test/e2e/specs/editor/blocks/paragraph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -207,8 +211,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -219,8 +227,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -231,8 +243,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand Down Expand Up @@ -309,8 +325,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -321,8 +341,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -333,8 +357,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -345,8 +373,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}
} );

Expand Down Expand Up @@ -387,8 +419,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -399,8 +435,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -411,8 +451,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( firstBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
firstBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -423,8 +467,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -435,8 +483,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}

{
Expand All @@ -447,8 +499,12 @@ test.describe( 'Paragraph', () => {
);
await expect( draggingUtils.dropZone ).toBeVisible();
await expect
.poll( () => draggingUtils.dropZone.boundingBox() )
.toEqual( secondBlockBox );
.poll( () =>
draggingUtils.confirmValidDropZonePosition(
secondBlockBox
)
)
.toBeTruthy();
}
} );
} );
Expand Down Expand Up @@ -508,4 +564,14 @@ class DraggingUtils {
await this.page.mouse.move( 0, 0 );
await this.page.mouse.down();
}

async confirmValidDropZonePosition( element ) {
// Check that both x and y axis of the dropzone
// have a less than 1 difference with a given target element
const box = await this.dropZone.boundingBox();
return (
Math.abs( element.x - box.x ) < 1 &&
Math.abs( element.y - box.y ) < 1
);
}
}

0 comments on commit b50ca9f

Please sign in to comment.