mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
Merge branch 'master' into feat/slash-command-for-code-block
This commit is contained in:
@@ -14,7 +14,9 @@ import {
|
||||
* For more information, see: https://codemirror.net/doc/manual.html
|
||||
*/
|
||||
|
||||
test('switch code editing mode', async ({ page }) => {
|
||||
// TODO: Fix test that started intermittently failing some time around
|
||||
// https://github.com/logseq/logseq/pull/9540
|
||||
test.skip('switch code editing mode', async ({ page }) => {
|
||||
await createRandomPage(page)
|
||||
|
||||
// NOTE: ` will trigger auto-pairing in Logseq
|
||||
|
||||
@@ -27,12 +27,13 @@ const consoleLogWatcher = (msg: ConsoleMessage) => {
|
||||
|
||||
// List of error messages to ignore
|
||||
const ignoreErrors = [
|
||||
/net::ERR_CONNECTION_REFUSED/,
|
||||
/net/,
|
||||
/^Error with Permissions-Policy header:/
|
||||
];
|
||||
|
||||
// If the text matches any of the ignoreErrors, return early
|
||||
if (ignoreErrors.some(error => text.match(error))) {
|
||||
console.log(`WARN:: ${text}\n`)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ test('undo/redo of a renamed page should be preserved', async ({ page, block })
|
||||
await page.waitForTimeout(500) // Wait for 500ms autosave period to expire
|
||||
|
||||
await renamePage(page, randomString(10))
|
||||
await page.click('.ui__confirm-modal button')
|
||||
|
||||
await page.keyboard.press(modKey + '+z')
|
||||
await page.waitForTimeout(100)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { expect } from '@playwright/test'
|
||||
import { test } from './fixtures'
|
||||
import { createRandomPage, enterNextBlock, lastBlock, modKey, IsLinux } from './utils'
|
||||
import { createRandomPage, enterNextBlock, lastBlock, modKey, IsLinux, closeSearchBox } from './utils'
|
||||
|
||||
test('open search dialog', async ({ page }) => {
|
||||
await page.waitForTimeout(200)
|
||||
await closeSearchBox(page)
|
||||
await page.keyboard.press(modKey + '+k')
|
||||
|
||||
await page.waitForSelector('[placeholder="Search or create page"]')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect, Page } from '@playwright/test'
|
||||
import { test } from './fixtures'
|
||||
import { createPage, randomLowerString, randomString, renamePage } from './utils'
|
||||
import { closeSearchBox, createPage, randomLowerString, randomString, renamePage, searchPage } from './utils'
|
||||
|
||||
/***
|
||||
* Test rename feature
|
||||
@@ -15,6 +15,7 @@ async function page_rename_test(page: Page, original_page_name: string, new_page
|
||||
|
||||
// Rename page in UI
|
||||
await renamePage(page, new_name)
|
||||
await page.click('.ui__confirm-modal button')
|
||||
|
||||
expect(await page.innerText('.page-title .title')).toBe(new_name)
|
||||
|
||||
@@ -45,6 +46,7 @@ async function homepage_rename_test(page: Page, original_page_name: string, new_
|
||||
expect(await page.locator('.home-nav span.flex-1').innerText()).toBe(original_name);
|
||||
|
||||
await renamePage(page, new_name)
|
||||
await page.click('.ui__confirm-modal button')
|
||||
|
||||
expect(await page.locator('.home-nav span.flex-1').innerText()).toBe(new_name);
|
||||
|
||||
@@ -64,6 +66,16 @@ test('page rename test', async ({ page }) => {
|
||||
await page_rename_test(page, "abcd", "a.b.c.d")
|
||||
await page_rename_test(page, "abcd", "a/b/c/d")
|
||||
|
||||
// The page name in page search are not updated after changing the capitalization of the page name #9577
|
||||
// https://github.com/logseq/logseq/issues/9577
|
||||
// Expect the page name to be updated in the search results
|
||||
await page_rename_test(page, "DcBA_", "dCBA_")
|
||||
const results = await searchPage(page, "DcBA_")
|
||||
// search result 0 is the new page & 1 is the new whiteboard
|
||||
const thirdResultRow = await results[2].innerText()
|
||||
expect(thirdResultRow).toContain("dCBA_");
|
||||
expect(thirdResultRow).not.toContain("DcBA_");
|
||||
await closeSearchBox(page)
|
||||
})
|
||||
|
||||
// TODO introduce more samples when #4722 is fixed
|
||||
|
||||
@@ -11,5 +11,4 @@ export async function renamePage(page: Page, new_name: string) {
|
||||
await page.fill('input[type="text"]', '')
|
||||
await page.type('.title input', new_name)
|
||||
await page.keyboard.press('Enter')
|
||||
await page.click('.ui__confirm-modal button')
|
||||
}
|
||||
|
||||
@@ -1,63 +1,66 @@
|
||||
import { Page, Locator, ElementHandle } from '@playwright/test'
|
||||
import { randomString } from './basic'
|
||||
|
||||
export async function closeSearchBox(page: Page): Promise<void> {
|
||||
await page.keyboard.press("Escape") // escape (potential) search box typing
|
||||
await page.waitForTimeout(500)
|
||||
await page.keyboard.press("Escape") // escape modal
|
||||
}
|
||||
|
||||
export async function createRandomPage(page: Page) {
|
||||
const randomTitle = randomString(20)
|
||||
|
||||
await closeSearchBox(page)
|
||||
// Click #search-button
|
||||
await page.click('#search-button')
|
||||
// Fill [placeholder="Search or create page"]
|
||||
await page.fill('[placeholder="Search or create page"]', randomTitle)
|
||||
// Click text=/.*New page: "new page".*/
|
||||
await page.click('text=/.*New page: ".*/')
|
||||
await page.click('text=/.*New page:".*/')
|
||||
// Wait for h1 to be from our new page
|
||||
await page.waitForSelector(`h1 >> text="${randomTitle}"`, { state: 'visible' })
|
||||
// wait for textarea of first block
|
||||
await page.waitForSelector('textarea >> nth=0', { state: 'visible' })
|
||||
|
||||
|
||||
return randomTitle;
|
||||
}
|
||||
|
||||
export async function createPage(page: Page, page_name: string) {// Click #search-button
|
||||
}
|
||||
|
||||
export async function createPage(page: Page, page_name: string) {// Click #search-button
|
||||
await closeSearchBox(page)
|
||||
await page.click('#search-button')
|
||||
// Fill [placeholder="Search or create page"]
|
||||
await page.fill('[placeholder="Search or create page"]', page_name)
|
||||
// Click text=/.*New page: "new page".*/
|
||||
await page.click('text=/.*New page: ".*/')
|
||||
await page.click('text=/.*New page:".*/')
|
||||
// wait for textarea of first block
|
||||
await page.waitForSelector('textarea >> nth=0', { state: 'visible' })
|
||||
|
||||
|
||||
return page_name;
|
||||
}
|
||||
|
||||
export async function searchAndJumpToPage(page: Page, pageTitle: string) {
|
||||
|
||||
export async function searchAndJumpToPage(page: Page, pageTitle: string) {
|
||||
await closeSearchBox(page)
|
||||
await page.click('#search-button')
|
||||
await page.type('[placeholder="Search or create page"]', pageTitle)
|
||||
await page.waitForSelector(`[data-page-ref="${pageTitle}"]`, { state: 'visible' })
|
||||
page.click(`[data-page-ref="${pageTitle}"]`)
|
||||
await page.waitForNavigation()
|
||||
return pageTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* type a search query into the search box
|
||||
* stop at the point where search box shows up
|
||||
*
|
||||
* @param page the pw page object
|
||||
* @param query the search query to type into the search box
|
||||
* @returns the HTML element for the search results ui
|
||||
*/
|
||||
export async function searchPage(page: Page, query: string): Promise<ElementHandle<SVGElement | HTMLElement>[]>{
|
||||
}
|
||||
|
||||
/**
|
||||
* type a search query into the search box
|
||||
* stop at the point where search box shows up
|
||||
*
|
||||
* @param page the pw page object
|
||||
* @param query the search query to type into the search box
|
||||
* @returns the HTML element for the search results ui
|
||||
*/
|
||||
export async function searchPage(page: Page, query: string): Promise<ElementHandle<SVGElement | HTMLElement>[]>{
|
||||
await closeSearchBox(page)
|
||||
await page.click('#search-button')
|
||||
await page.waitForSelector('[placeholder="Search or create page"]')
|
||||
await page.type('[placeholder="Search or create page"]', query, { delay: 10 })
|
||||
await page.waitForTimeout(2000) // wait longer for search contents to render
|
||||
|
||||
|
||||
return page.$$('#ui__ac-inner>div');
|
||||
}
|
||||
|
||||
export async function closeSearchBox(page: Page): Promise<void> {
|
||||
await page.keyboard.press("Escape") // escape (potential) search box typing
|
||||
await page.waitForTimeout(500)
|
||||
await page.keyboard.press("Escape") // escape modal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect } from '@playwright/test'
|
||||
import { test } from './fixtures'
|
||||
import { modKey } from './utils'
|
||||
import { modKey, renamePage } from './utils'
|
||||
|
||||
test('enable whiteboards', async ({ page }) => {
|
||||
if (await page.$('.nav-header .whiteboard') === null) {
|
||||
@@ -293,7 +293,7 @@ test('create a block', async ({ page }) => {
|
||||
|
||||
test('expand the block', async ({ page }) => {
|
||||
await page.keyboard.press('Escape')
|
||||
await page.click('.logseq-tldraw .tl-context-bar .tie-object-expanded ')
|
||||
await page.keyboard.press(modKey + '+ArrowDown')
|
||||
await page.waitForTimeout(100)
|
||||
|
||||
await expect(page.locator('.logseq-tldraw .tl-logseq-portal-container .tl-logseq-portal-header')).toHaveCount(1)
|
||||
@@ -437,3 +437,65 @@ test('go to another board and check reference', async ({ page }) => {
|
||||
const pageRefCount$ = page.locator('.whiteboard-page-refs-count')
|
||||
await expect(pageRefCount$.locator('.open-page-ref-link')).toContainText('1')
|
||||
})
|
||||
|
||||
test('Create an embedded whiteboard', async ({ page }) => {
|
||||
const canvas = await page.waitForSelector('.logseq-tldraw')
|
||||
await canvas.dblclick({
|
||||
position: {
|
||||
x: 150,
|
||||
y: 150,
|
||||
},
|
||||
})
|
||||
|
||||
const quickAdd$ = page.locator('.tl-quick-search')
|
||||
await expect(quickAdd$).toBeVisible()
|
||||
|
||||
await page.fill('.tl-quick-search input', 'My embedded whiteboard')
|
||||
await quickAdd$
|
||||
.locator('div[data-index="2"] .tl-quick-search-option')
|
||||
.first()
|
||||
.click()
|
||||
|
||||
await expect(quickAdd$).toBeHidden()
|
||||
await expect(page.locator('.tl-logseq-portal-header a')).toContainText('My embedded whiteboard')
|
||||
})
|
||||
|
||||
test('New whiteboard should have the correct name', async ({ page }) => {
|
||||
page.locator('.tl-logseq-portal-header a').click()
|
||||
|
||||
await expect(page.locator('.whiteboard-page-title')).toContainText('My embedded whiteboard')
|
||||
})
|
||||
|
||||
test('Create an embedded page', async ({ page }) => {
|
||||
const canvas = await page.waitForSelector('.logseq-tldraw')
|
||||
await canvas.dblclick({
|
||||
position: {
|
||||
x: 150,
|
||||
y: 150,
|
||||
},
|
||||
})
|
||||
|
||||
const quickAdd$ = page.locator('.tl-quick-search')
|
||||
await expect(quickAdd$).toBeVisible()
|
||||
|
||||
await page.fill('.tl-quick-search input', 'My page')
|
||||
await quickAdd$
|
||||
.locator('div[data-index="1"] .tl-quick-search-option')
|
||||
.first()
|
||||
.click()
|
||||
|
||||
await expect(quickAdd$).toBeHidden()
|
||||
await expect(page.locator('.tl-logseq-portal-header a')).toContainText('My page')
|
||||
})
|
||||
|
||||
test('New page should have the correct name', async ({ page }) => {
|
||||
page.locator('.tl-logseq-portal-header a').click()
|
||||
|
||||
await expect(page.locator('.ls-page-title')).toContainText('My page')
|
||||
})
|
||||
|
||||
test('Renaming a page to an existing whiteboard name should be prohibited', async ({ page }) => {
|
||||
await renamePage(page, "My embedded whiteboard")
|
||||
|
||||
await expect(page.locator('.page-title input')).toHaveValue('My page')
|
||||
})
|
||||
Reference in New Issue
Block a user