|
@@ -5,36 +5,10 @@ import { createRandomPage, enterNextBlock } from './utils'
|
|
|
/**
|
|
|
* Drag and Drop tests.
|
|
|
*
|
|
|
- * When we drag and drop a block, it should always be moved under the target element,
|
|
|
- * unless the targer is the first element of its container. In thas case, if we drop
|
|
|
- * it at the top half of the target, it should be moved on top of it.
|
|
|
+ * NOTE: x = 30 is an estimation of left position of the drop target.
|
|
|
*/
|
|
|
|
|
|
-test('drop "block b" to the upper left area of "block a", which is the first element of a container', async ({ page, block }) => {
|
|
|
- await createRandomPage(page)
|
|
|
-
|
|
|
- await block.mustFill('block a')
|
|
|
- await block.enterNext()
|
|
|
-
|
|
|
- await block.mustFill('block b')
|
|
|
- await block.escapeEditing()
|
|
|
-
|
|
|
- const bullet = page.locator('span.bullet-container >> nth=-1')
|
|
|
- const where = page.locator('.ls-block >> nth=0')
|
|
|
- await bullet.dragTo(where, {
|
|
|
- targetPosition: {
|
|
|
- x: 0,
|
|
|
- y: 0
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- await page.keyboard.press('Escape')
|
|
|
-
|
|
|
- const pageElem = page.locator('.page-blocks-inner')
|
|
|
- await expect(pageElem).toHaveText('block b\nblock a', {useInnerText: true})
|
|
|
-})
|
|
|
-
|
|
|
-test('drop "block b" to the bottom left area of "block a", which is the first element of a container', async ({ page, block }) => {
|
|
|
+test('drop to left center', async ({ page }) => {
|
|
|
await createRandomPage(page)
|
|
|
|
|
|
await page.fill('textarea >> nth=0', 'block a')
|
|
@@ -47,31 +21,29 @@ test('drop "block b" to the bottom left area of "block a", which is the first el
|
|
|
const where = page.locator('.ls-block >> nth=0')
|
|
|
await bullet.dragTo(where, {
|
|
|
targetPosition: {
|
|
|
- x: 0,
|
|
|
- y: (await where.boundingBox())!.height * 0.75
|
|
|
+ x: 30,
|
|
|
+ y: (await where.boundingBox()).height * 0.5
|
|
|
}
|
|
|
})
|
|
|
|
|
|
await page.keyboard.press('Escape')
|
|
|
|
|
|
const pageElem = page.locator('.page-blocks-inner')
|
|
|
- await expect(pageElem).toHaveText('block a\nblock b', {useInnerText: true})
|
|
|
+ await expect(pageElem).toHaveText('block b\nblock a', {useInnerText: true})
|
|
|
})
|
|
|
|
|
|
-test('drop "block c" to the upper left area of "block b", which is the second element of a container', async ({ page, block }) => {
|
|
|
+
|
|
|
+test('drop to upper left', async ({ page, block }) => {
|
|
|
await createRandomPage(page)
|
|
|
|
|
|
await block.mustFill('block a')
|
|
|
await block.enterNext()
|
|
|
|
|
|
await block.mustFill('block b')
|
|
|
- await block.enterNext()
|
|
|
-
|
|
|
- await block.mustFill('block c')
|
|
|
await block.escapeEditing()
|
|
|
|
|
|
const bullet = page.locator('span.bullet-container >> nth=-1')
|
|
|
- const where = page.locator('.ls-block >> nth=1')
|
|
|
+ const where = page.locator('.ls-block >> nth=0')
|
|
|
await bullet.dragTo(where, {
|
|
|
targetPosition: {
|
|
|
x: 0,
|
|
@@ -82,32 +54,29 @@ test('drop "block c" to the upper left area of "block b", which is the second el
|
|
|
await page.keyboard.press('Escape')
|
|
|
|
|
|
const pageElem = page.locator('.page-blocks-inner')
|
|
|
- await expect(pageElem).toHaveText('block a\nblock b\nblock c', {useInnerText: true})
|
|
|
+ await expect(pageElem).toHaveText('block b\nblock a', {useInnerText: true})
|
|
|
})
|
|
|
|
|
|
-test('drop "block c" to the bottom left area of "block a", which is the first element of a container', async ({ page, block }) => {
|
|
|
+test('drop to bottom left', async ({ page }) => {
|
|
|
await createRandomPage(page)
|
|
|
|
|
|
- await block.mustFill('block a')
|
|
|
- await block.enterNext()
|
|
|
-
|
|
|
- await block.mustFill('block b')
|
|
|
- await block.enterNext()
|
|
|
+ await page.fill('textarea >> nth=0', 'block a')
|
|
|
+ await enterNextBlock(page)
|
|
|
|
|
|
- await block.mustFill('block c')
|
|
|
- await block.escapeEditing()
|
|
|
+ await page.fill('textarea >> nth=0', 'block b')
|
|
|
+ await page.press('textarea >> nth=0', 'Escape')
|
|
|
|
|
|
const bullet = page.locator('span.bullet-container >> nth=-1')
|
|
|
const where = page.locator('.ls-block >> nth=0')
|
|
|
await bullet.dragTo(where, {
|
|
|
targetPosition: {
|
|
|
- x: 0,
|
|
|
- y: 0
|
|
|
+ x: 30,
|
|
|
+ y: (await where.boundingBox()).height * 0.75
|
|
|
}
|
|
|
})
|
|
|
|
|
|
await page.keyboard.press('Escape')
|
|
|
|
|
|
const pageElem = page.locator('.page-blocks-inner')
|
|
|
- await expect(pageElem).toHaveText('block c\nblock a\nblock b', {useInnerText: true})
|
|
|
-})
|
|
|
+ await expect(pageElem).toHaveText('block a\nblock b', {useInnerText: true})
|
|
|
+})
|