fix: page search e2e tests

This commit is contained in:
Tienson Qin
2023-11-07 19:42:52 +08:00
parent 59c9c244c6
commit f68beb4d16
3 changed files with 8 additions and 15 deletions

View File

@@ -149,30 +149,18 @@ async function alias_test(block: Block, page: Page, page_name: string, search_kw
let kw_name = kw + ' alias ' + rand
const results = await searchPage(page, kw_name)
await expect(results.length).toEqual(5) // page + block + alias property + page content
// test search results
expect(await results[0].innerText()).toContain(alias_name)
expect(await results[1].innerText()).toContain("[[" + alias_name + "]]")
expect(await results[2].innerText()).toContain("[[" + alias_name + "]]")
// test search entering (page)
page.keyboard.press("Enter")
await page.waitForNavigation()
await page.waitForSelector('.ls-block span.inline')
expect(await page.locator('.ls-block span.inline >> nth=2').innerHTML()).toBe(alias_test_content_3)
// test search clicking (block)
await searchPage(page, kw_name)
page.click(":nth-match(.search-result, 3)")
await page.waitForNavigation()
await page.waitForSelector('.selected a.page-ref')
expect(await page.locator('.selected a.page-ref').innerHTML()).toBe(alias_name)
await page.keyboard.press(hotkeyBack)
}
// TODO: search clicking (alias property)
}
test('page diacritic alias', async ({ block, page }) => {

View File

@@ -103,9 +103,9 @@
:else
(->>
[["Pages" :pages (visible-items :pages)]
["Commands" :commands (visible-items :commands)]
(when-not (or page-exists? (= :blocks filter-group))
["Create" :create (create-items input)])
["Commands" :commands (visible-items :commands)]
["Current page" :current-page (visible-items :current-page)]
["Blocks" :blocks (visible-items :blocks)]
["Files" :files (visible-items :files)]

View File

@@ -14,6 +14,11 @@
[]
(state/block-content-max-length (state/get-current-repo)))
(defn- sanitize
[content]
(some-> content
(util/search-normalize (state/enable-search-remove-accents?))))
(defn block->index
"Convert a block to the index for searching"
[{:block/keys [uuid page content] :as block}]
@@ -22,7 +27,7 @@
{:id (:db/id block)
:uuid (str uuid)
:page page
:content content})))
:content (sanitize content)})))
(defn page->index
"Convert a page name to the index for searching (page content level)
@@ -35,7 +40,7 @@
{:id (:db/id page)
:uuid (str uuid)
;; Add page name to the index
:content (str "$pfts_f6ld>$ " original-name " $<pfts_f6ld$ " content)}))))
:content (sanitize (str "$pfts_f6ld>$ " original-name " $<pfts_f6ld$ " content))}))))
(defn build-blocks-indice
;; TODO: Remove repo effects fns further up the call stack. db fns need standardization on taking connection