mirror of https://github.com/logseq/logseq
Merge branch 'master' into feat/integrated-title-bar
commit
ce11a51657
|
@ -152,6 +152,7 @@ test(
|
|||
// This test requires dev mode
|
||||
test.skip(process.env.RELEASE === 'true', 'not available for release version')
|
||||
|
||||
// @ts-ignore
|
||||
for (let [idx, events] of [
|
||||
kb_events.win10_pinyin_left_full_square_bracket,
|
||||
kb_events.macos_pinyin_left_full_square_bracket
|
||||
|
@ -168,7 +169,7 @@ test(
|
|||
expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(check_text + '[[]]')
|
||||
};
|
||||
|
||||
// dont trigger RIME #3440
|
||||
// @ts-ignore dont trigger RIME #3440
|
||||
for (let [idx, events] of [
|
||||
kb_events.macos_pinyin_selecting_candidate_double_left_square_bracket,
|
||||
kb_events.win10_RIME_selecting_candidate_double_left_square_bracket
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
import { test } from './fixtures'
|
||||
import { expect } from '@playwright/test'
|
||||
|
||||
test('block related apis',
|
||||
async ({ page }) => {
|
||||
const callAPI = callPageAPI.bind(null, page)
|
||||
|
||||
const bPageName = 'block-test-page'
|
||||
await callAPI('create_page', bPageName, null, { createFirstBlock: false })
|
||||
|
||||
await page.waitForSelector(`span[data-ref="${bPageName}"]`)
|
||||
|
||||
let p = await callAPI('get_current_page')
|
||||
const bp = await callAPI('append_block_in_page', bPageName, 'tests')
|
||||
|
||||
expect(p.name).toBe(bPageName)
|
||||
|
||||
p = await callAPI('get_page', bPageName)
|
||||
|
||||
expect(p.name).toBe(bPageName)
|
||||
|
||||
await callAPI('edit_block', bp.uuid)
|
||||
|
||||
const b = (await callAPI('get_current_block'))
|
||||
expect(Object.keys(b)).toContain('uuid')
|
||||
|
||||
await page.waitForSelector('.block-editor > textarea')
|
||||
await page.locator('.block-editor > textarea').fill('')
|
||||
const content = 'test api'
|
||||
await page.type('.block-editor > textarea', content)
|
||||
|
||||
const editingContent = await callAPI('get_editing_block_content')
|
||||
expect(editingContent).toBe(content)
|
||||
|
||||
// create
|
||||
let b1 = await callAPI('insert_block', b.uuid, content)
|
||||
b1 = await callAPI('get_block', b1.uuid)
|
||||
|
||||
expect(b1.parent.id).toBe(b.id)
|
||||
|
||||
// update
|
||||
const content1 = content + '+ update!'
|
||||
await callAPI('update_block', b1.uuid, content1)
|
||||
await page.waitForTimeout(1000)
|
||||
b1 = await callAPI('get_block', b1.uuid)
|
||||
|
||||
expect(b1.content).toBe(content1)
|
||||
|
||||
// remove
|
||||
await callAPI('remove_block', b1.uuid)
|
||||
b1 = await callAPI('get_block', b1.uuid)
|
||||
|
||||
expect(b1).toBeNull()
|
||||
|
||||
// traverse
|
||||
b1 = await callAPI('insert_block', b.uuid, content1, { sibling: true })
|
||||
const nb = await callAPI('get_next_sibling_block', b.uuid)
|
||||
const pb = await callAPI('get_previous_sibling_block', b1.uuid)
|
||||
|
||||
expect(nb.uuid).toBe(b1.uuid)
|
||||
expect(pb.uuid).toBe(b.uuid)
|
||||
|
||||
// move
|
||||
await callAPI('move_block', b.uuid, b1.uuid)
|
||||
const mb = await callAPI('get_next_sibling_block', b1.uuid)
|
||||
|
||||
expect(mb.uuid).toBe(b.uuid)
|
||||
|
||||
// properties
|
||||
await callAPI('upsert_block_property', b1.uuid, 'a', 1)
|
||||
let prop1 = await callAPI('get_block_property', b1.uuid, 'a')
|
||||
|
||||
expect(prop1).toBe(1)
|
||||
|
||||
await callAPI('upsert_block_property', b1.uuid, 'a', 2)
|
||||
prop1 = await callAPI('get_block_property', b1.uuid, 'a')
|
||||
|
||||
expect(prop1).toBe(2)
|
||||
|
||||
await callAPI('remove_block_property', b1.uuid, 'a')
|
||||
prop1 = await callAPI('get_block_property', b1.uuid, 'a')
|
||||
|
||||
expect(prop1).toBeNull()
|
||||
|
||||
await callAPI('upsert_block_property', b1.uuid, 'a', 1)
|
||||
await callAPI('upsert_block_property', b1.uuid, 'b', 1)
|
||||
|
||||
prop1 = await callAPI('get_block_properties', b1.uuid)
|
||||
|
||||
expect(prop1).toEqual({ a: 1, b: 1 })
|
||||
|
||||
// await page.pause()
|
||||
})
|
||||
|
||||
/**
|
||||
* @param page
|
||||
* @param method
|
||||
* @param args
|
||||
*/
|
||||
export async function callPageAPI(page, method, ...args) {
|
||||
return await page.evaluate(([method, args]) => {
|
||||
// @ts-ignore
|
||||
return window.logseq.api[method]?.(...args)
|
||||
}, [method, args])
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import { expect } from '@playwright/test'
|
||||
import { test } from './fixtures'
|
||||
import { callPageAPI } from './logseq-api.spec'
|
||||
|
||||
test.skip('enabled plugin system default', async ({ page }) => {
|
||||
const callAPI = callPageAPI.bind(null, page)
|
||||
|
@ -59,14 +60,3 @@ test.skip('play a plugin<logseq-journals-calendar> from the Marketplace', async
|
|||
await expect(page.locator('body[data-page="page"]')).toBeVisible()
|
||||
})
|
||||
|
||||
/**
|
||||
* @param page
|
||||
* @param method
|
||||
* @param args
|
||||
*/
|
||||
async function callPageAPI(page, method, ...args) {
|
||||
return await page.evaluate(([method, args]) => {
|
||||
// @ts-ignore
|
||||
return window.logseq.api[method]?.(...args)
|
||||
}, [method, args])
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Page, Locator } from 'playwright'
|
|||
import { expect, ConsoleMessage } from '@playwright/test'
|
||||
import * as pathlib from 'path'
|
||||
import { modKey } from './util/basic'
|
||||
import { Block } from './types'
|
||||
|
||||
// TODO: The file should be a facade of utils in the /util folder
|
||||
// No more additional functions should be added to this file
|
||||
|
|
|
@ -700,7 +700,7 @@
|
|||
(fn [block-uuid]
|
||||
(when-let [block (db-model/query-block-by-uuid (sdk-utils/uuid-or-throw-error block-uuid))]
|
||||
(when-let [right-sibling (outliner/get-right-sibling (:db/id block))]
|
||||
(let [block (db/pull (:id right-sibling))]
|
||||
(let [block (db/pull (:db/id right-sibling))]
|
||||
(bean/->js (sdk-utils/normalize-keyword-for-json block)))))))
|
||||
|
||||
(def ^:export set_block_collapsed
|
||||
|
|
Loading…
Reference in New Issue