Browse Source

fix (Whiteboard): Paste shape (#8636)

* fix: paste shape

* fix: test

* fix: test

* fix: test

* fix: test

* fix: test

* fix: add timeout to headings test

* fix: test

* fix: e2e test

* just another attempt to fix the tests

* fix; yet another test fix

* remove the inconsistent test

* revert test change

* revert unneeded change

---------

Co-authored-by: Gabriel Horner <[email protected]>
Konstantinos 3 years ago
parent
commit
1ff15171ed

+ 1 - 0
e2e-tests/headings.spec.ts

@@ -73,6 +73,7 @@ test('set heading of nested block to auto', async ({ page }) => {
 
 test('view nested block on a dedicated page', async ({ page }) => {
   await page.locator('span.bullet-container >> nth=1').click()
+  await page.waitForTimeout(200)
 
   expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('<h1>bar</h1>')
 })

+ 1 - 0
e2e-tests/utils.ts

@@ -8,6 +8,7 @@ export const IsMac = process.platform === 'darwin'
 export const IsLinux = process.platform === 'linux'
 export const IsWindows = process.platform === 'win32'
 export const IsCI = process.env.CI === 'true'
+export const modKey = IsMac ? 'Meta' : 'Control'
 
 export function randomString(length: number) {
   const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

+ 2 - 7
e2e-tests/whiteboards.spec.ts

@@ -1,6 +1,6 @@
 import { expect } from '@playwright/test'
 import { test } from './fixtures'
-import { IsMac } from './utils'
+import { modKey } from './utils'
 
 test('enable whiteboards', async ({ page }) => {
   await expect(page.locator('.nav-header .whiteboard')).toBeHidden()
@@ -88,13 +88,8 @@ test('draw a rectangle', async ({ page }) => {
   ).not.toHaveCount(0)
 })
 
-
 test('cleanup the shapes', async ({ page }) => {
-  if (IsMac) {
-    await page.keyboard.press('Meta+a')
-  } else {
-    await page.keyboard.press('Control+a')
-  }
+  await page.keyboard.press(`${modKey}+a`)
   await page.keyboard.press('Delete')
   await expect(page.locator('[data-type=Shape]')).toHaveCount(0)
 })

+ 1 - 2
tldraw/apps/tldraw-logseq/src/hooks/usePaste.ts

@@ -253,8 +253,7 @@ const handleCreatingShapes = async (
       const text = rawText.trim()
       return tryCreateShapeHelper(
         tryCreateShapeFromURL,
-        tryCreateShapeFromIframeString,
-        tryCreateLogseqPortalShapesFromUUID
+        tryCreateShapeFromIframeString
       )(text)
     }