mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
add tests
This commit is contained in:
@@ -495,7 +495,7 @@ test('press escape when link/image dialog is open, should restore focus to input
|
||||
|
||||
// Press enter to open the link dialog
|
||||
await page.keyboard.press('Enter')
|
||||
await expect(page.locator(`[data-modal-name="input"]`)).toBeVisible()
|
||||
await expect(page.locaitor(`[data-modal-name="input"]`)).toBeVisible()
|
||||
|
||||
// Press escape; should close link dialog and restore focus to the block textarea
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
15
e2e-tests/paste.spec.ts
Normal file
15
e2e-tests/paste.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { expect } from '@playwright/test'
|
||||
import { test } from './fixtures'
|
||||
import { createRandomPage, enterNextBlock, lastBlock, modKey } from './utils'
|
||||
import { dispatch_kb_events } from './util/keyboard-events'
|
||||
import * as kb_events from './util/keyboard-events'
|
||||
|
||||
test('property text deleted on Ctrl+C when its value mixes [[link]] and other text #9100', async ({ page, block }) => {
|
||||
await createRandomPage(page)
|
||||
|
||||
await block.mustType('category:: [[A]] and [[B]] test')
|
||||
|
||||
await page.keyboard.press(modKey + '+c', { delay: 10 })
|
||||
|
||||
await expect(page.locator('textarea >> nth=0')).toHaveValue('category:: [[A]] and [[B]] test')
|
||||
})
|
||||
@@ -97,11 +97,11 @@
|
||||
|
||||
(defn- markdown-blocks?
|
||||
[text]
|
||||
(util/safe-re-find #"(?m)^\s*(?:[-+*]|#+)\s+" text))
|
||||
(boolean (util/safe-re-find #"(?m)^\s*(?:[-+*]|#+)\s+" text)))
|
||||
|
||||
(defn- org-blocks?
|
||||
[text]
|
||||
(util/safe-re-find #"(?m)^\s*\*+\s+" text))
|
||||
(boolean (util/safe-re-find #"(?m)^\s*\*+\s+" text)))
|
||||
|
||||
(defn- paste-copied-blocks-or-text
|
||||
;; todo: logseq/whiteboard-shapes is now text/html
|
||||
@@ -218,8 +218,6 @@
|
||||
(let [clipboard-data (gobj/get e "clipboardData")
|
||||
html (.getData clipboard-data "text/html")
|
||||
text (.getData clipboard-data "text")]
|
||||
(prn {:html html
|
||||
:text text})
|
||||
(cond
|
||||
(and (string/blank? text) (string/blank? html))
|
||||
(paste-file-if-exists id e)
|
||||
|
||||
@@ -173,3 +173,25 @@
|
||||
:files files}})]
|
||||
(is (= files (js->clj @pasted-file)))
|
||||
(reset)))))
|
||||
|
||||
(deftest-async editor-on-paste-prefer-text-blocks-to-html
|
||||
(let [actual-blocks (atom nil)
|
||||
;; Simplified version of block attributes that are copied
|
||||
expected-blocks [{:block/content "Test node"}
|
||||
{:block/content "Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"}]
|
||||
html "<b>bold text</b>"
|
||||
text "- Test node\n\t- Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"]
|
||||
(test-helper/with-reset
|
||||
reset
|
||||
[state/get-input (constantly #js {:value "block"})
|
||||
;; paste-copied-blocks-or-text mocks below
|
||||
util/stop (constantly nil)
|
||||
html-parser/convert (constantly "**bold text**")
|
||||
paste-handler/get-copied-blocks (constantly (p/resolved nil))
|
||||
state/get-edit-block (constantly {})
|
||||
editor-handler/paste-blocks (fn [blocks _] (reset! actual-blocks blocks))]
|
||||
(p/let [_ ((paste-handler/editor-on-paste! nil)
|
||||
#js {:clipboardData #js {:getData (fn [kind]
|
||||
(if (= kind "text/html") html text))}})]
|
||||
(is (= expected-blocks (map #(select-keys % [:block/content]) @actual-blocks)))
|
||||
(reset)))))
|
||||
|
||||
Reference in New Issue
Block a user