mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
fix(e2e): plugin apis related tests
This commit is contained in:
@@ -4,7 +4,7 @@ import { callPageAPI } from './utils'
|
||||
import { Page } from 'playwright'
|
||||
|
||||
async function createDBGraph(page: Page) {
|
||||
await page.locator(`a.cp__repos-select-trigger`).click()
|
||||
await page.locator(`#left-sidebar .cp__graphs-selector > a`).click()
|
||||
await page.click('text="Create db graph"')
|
||||
await page.waitForSelector('.new-graph')
|
||||
const name = `e2e-db-${Date.now()}`
|
||||
@@ -89,8 +89,6 @@ test('(File graph): block related apis',
|
||||
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')
|
||||
|
||||
@@ -203,28 +201,3 @@ test('(DB graph): block related apis',
|
||||
|
||||
// await page.pause()
|
||||
})
|
||||
|
||||
/**
|
||||
* load local tests plugin
|
||||
*/
|
||||
export async function loadLocalE2eTestsPlugin(page) {
|
||||
const pid = 'a-logseq-plugin-for-e2e-tests'
|
||||
const hasLoaded = await page.evaluate(async ([pid]) => {
|
||||
// @ts-ignore
|
||||
const p = window.LSPluginCore.registeredPlugins.get(pid)
|
||||
// @ts-ignore
|
||||
await window.LSPluginCore.enable(pid)
|
||||
return p != null
|
||||
}, [pid])
|
||||
|
||||
if (hasLoaded) return true
|
||||
|
||||
await callPageAPI(page, 'set_state_from_store',
|
||||
'ui/developer-mode?', true)
|
||||
await page.keyboard.press('t+p')
|
||||
await page.locator('text=Load unpacked plugin')
|
||||
await callPageAPI(page, 'set_state_from_store',
|
||||
'plugin/selected-unpacked-pkg', `${__dirname}/plugin`)
|
||||
await page.keyboard.press('Escape')
|
||||
await page.keyboard.press('Escape')
|
||||
}
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
import { expect } from '@playwright/test'
|
||||
import { test } from './fixtures'
|
||||
import {loadLocalE2eTestsPlugin } from './logseq-api.spec'
|
||||
import { callPageAPI } from './utils'
|
||||
|
||||
/**
|
||||
* load local tests plugin
|
||||
*/
|
||||
export async function loadLocalE2eTestsPlugin(page) {
|
||||
const pid = 'a-logseq-plugin-for-e2e-tests'
|
||||
const hasLoaded = await page.evaluate(async ([pid]) => {
|
||||
// @ts-ignore
|
||||
const p = window.LSPluginCore.registeredPlugins.get(pid)
|
||||
// @ts-ignore
|
||||
await window.LSPluginCore.enable(pid)
|
||||
return p != null
|
||||
}, [pid])
|
||||
|
||||
if (hasLoaded) return true
|
||||
|
||||
await callPageAPI(page, 'set_state_from_store',
|
||||
'ui/developer-mode?', true)
|
||||
await page.keyboard.press('t+p')
|
||||
await page.locator('text=Load unpacked plugin')
|
||||
await callPageAPI(page, 'set_state_from_store',
|
||||
'plugin/selected-unpacked-pkg', `${__dirname}/plugin`)
|
||||
await page.keyboard.press('Escape')
|
||||
await page.keyboard.press('Escape')
|
||||
}
|
||||
|
||||
test.skip('enabled plugin system default', async ({ page }) => {
|
||||
const callAPI = callPageAPI.bind(null, page)
|
||||
|
||||
|
||||
@@ -140,12 +140,10 @@ export async function loadLocalGraph(page: Page, path: string): Promise<void> {
|
||||
await expect(sidebar).toHaveClass(/is-open/)
|
||||
}
|
||||
|
||||
await page.click('#left-sidebar .repo-switch');
|
||||
await page.click('#left-sidebar .cp__graphs-selector > a');
|
||||
await page.waitForSelector('.cp__repos-quick-actions >> text="Add new graph"',
|
||||
{ state: 'visible', timeout: 5000 })
|
||||
await page.click('text=Add new graph')
|
||||
|
||||
expect(page.locator('.repo-name')).toHaveText(pathlib.basename(path))
|
||||
}
|
||||
|
||||
setMockedOpenDirPath(page, ''); // reset it
|
||||
|
||||
@@ -411,7 +411,8 @@
|
||||
"Select a Graph")]
|
||||
[:div.cp__graphs-selector.flex.items-center.justify-between
|
||||
[:a.item.flex.items-center.gap-1.select-none
|
||||
{:on-click (fn [^js e]
|
||||
{:title current-repo
|
||||
:on-click (fn [^js e]
|
||||
(shui/popup-show! (.closest (.-target e) "a")
|
||||
(fn [{:keys [id]}] (repos-dropdown-content {:contentid id}))
|
||||
{:as-dropdown? true
|
||||
|
||||
Reference in New Issue
Block a user