|
@@ -1,6 +1,11 @@
|
|
|
import { expect } from '@playwright/test'
|
|
|
import { test } from './fixtures'
|
|
|
-import { createRandomPage, escapeToCodeEditor, escapeToBlockEditor } from './utils'
|
|
|
+import {
|
|
|
+ createRandomPage,
|
|
|
+ escapeToCodeEditor,
|
|
|
+ escapeToBlockEditor,
|
|
|
+ repeatKeyPress,
|
|
|
+} from './utils'
|
|
|
|
|
|
/**
|
|
|
* NOTE: CodeMirror is a complex library that requires a lot of setup to work.
|
|
@@ -239,3 +244,38 @@ test('multi properties with code', async ({ page }) => {
|
|
|
'```'
|
|
|
)
|
|
|
})
|
|
|
+
|
|
|
+test('Select codeblock language', async ({ page }) => {
|
|
|
+ await createRandomPage(page)
|
|
|
+
|
|
|
+ await page.type('textarea >> nth=0', '/code block', { delay: 100 })
|
|
|
+ await page.press('textarea >> nth=0', 'Enter', { delay: 100 })
|
|
|
+
|
|
|
+ // Select Clojure from the dropdown menu
|
|
|
+ await repeatKeyPress(page, 'ArrowDown', 6)
|
|
|
+ await page.press('textarea >> nth=0', 'Enter', { delay: 100 })
|
|
|
+
|
|
|
+ await page.fill('.CodeMirror textarea', '(println "Hello, Logseq!")')
|
|
|
+ await page.press('.CodeMirror textarea', 'Escape', { delay: 100 })
|
|
|
+ expect(await page.inputValue('.block-editor textarea')).toBe(
|
|
|
+ '```clojure\n(println "Hello, Logseq!")\n```'
|
|
|
+ )
|
|
|
+})
|
|
|
+
|
|
|
+test('Select codeblock language while surrounded by text', async ({ page }) => {
|
|
|
+ await createRandomPage(page)
|
|
|
+
|
|
|
+ await page.fill('textarea >> nth=0', 'abc abc')
|
|
|
+ await repeatKeyPress(page, 'ArrowLeft', 3)
|
|
|
+ await page.type('textarea >> nth=0', '/code', { delay: 100 })
|
|
|
+ await page.press('textarea >> nth=0', 'Enter', { delay: 100 })
|
|
|
+
|
|
|
+ // Select Clojure from the dropdown menu
|
|
|
+ await repeatKeyPress(page, 'ArrowDown', 6)
|
|
|
+ await page.press('textarea >> nth=0', 'Enter', { delay: 100 })
|
|
|
+
|
|
|
+ await page.press('.CodeMirror textarea', 'Escape', { delay: 100 })
|
|
|
+ expect(await page.inputValue('.block-editor textarea')).toBe(
|
|
|
+ 'abc \n```clojure\n```\nabc'
|
|
|
+ )
|
|
|
+})
|