瀏覽代碼

test(e2e): page alias with diacritics tests

Junyi Du 3 年之前
父節點
當前提交
6c686c4ead
共有 2 個文件被更改,包括 40 次插入14 次删除
  1. 2 1
      e2e-tests/basic.with-diacritics.spec.ts
  2. 38 13
      e2e-tests/page-refs.spec.ts

+ 2 - 1
e2e-tests/basic.with-diacritics.spec.ts

@@ -10,10 +10,11 @@ test('create page and blocks (diacritics)', async ({ page }) => {
     hotkeyOpenLink = 'Meta+o'
     hotkeyBack = 'Meta+['
   }
+  
+  const rand = randomString(20)
 
   // diacritic opening test
   await createRandomPage(page)
-  const rand = randomString(20)
 
   await page.fill(':nth-match(textarea, 1)', '[[Einführung in die Allgemeine Sprachwissenschaft' + rand + ']] diacritic-block-1')
   await page.keyboard.press(hotkeyOpenLink)

+ 38 - 13
e2e-tests/page-alias.spec.ts → e2e-tests/page-refs.spec.ts

@@ -1,9 +1,8 @@
 import { expect } from '@playwright/test'
 import { test } from './fixtures'
-import { IsMac, createRandomPage, newBlock, newInnerBlock, lastBlock, lastInnerBlock } from './utils'
+import { IsMac, createRandomPage, newBlock, newInnerBlock, randomString, lastInnerBlock } from './utils'
 
-
-test('page alias', async ({ page }) => {
+async function alias_test (page, page_name: string){
   let hotkeyOpenLink = 'Control+o'
   let hotkeyBack = 'Control+['
   if (IsMac) {
@@ -11,29 +10,36 @@ test('page alias', async ({ page }) => {
     hotkeyBack = 'Meta+['
   }
 
+  const rand = randomString(10)
+  let target_name = page_name + ' target ' + rand
+  let alias_name = page_name + ' alias ' + rand
+  let alias_test_content_1 = randomString(20)
+  let alias_test_content_2 = randomString(20)
+  let alias_test_content_3 = randomString(20)
+
   // shortcut opening test
   await createRandomPage(page)
 
-  await page.fill(':nth-match(textarea, 1)', '[[page alias test target page]]')
+  await page.fill(':nth-match(textarea, 1)', '[[' + target_name + ']]')
   await page.keyboard.press(hotkeyOpenLink)
 
   // build target Page with alias
-  await page.type(':nth-match(textarea, 1)', 'alias:: [[page alias test alias page]]')
+  await page.type(':nth-match(textarea, 1)', 'alias:: [[' + alias_name + ']]')
   await page.press(':nth-match(textarea, 1)', 'Enter') // double Enter for exit property editing
   await page.press(':nth-match(textarea, 1)', 'Enter')
-  await page.type(':nth-match(textarea, 1)', 'page alias test content')
+  await page.type(':nth-match(textarea, 1)', alias_test_content_1)
   await page.keyboard.press(hotkeyBack)
 
   // create alias ref in origin Page
   await newBlock(page)
-  await page.type(':nth-match(textarea, 1)', '[[page alias test alias page]]')
+  await page.type(':nth-match(textarea, 1)', '[[' + alias_name + ']]')
   await page.keyboard.press(hotkeyOpenLink)
 
   // shortcut opening test
   await lastInnerBlock(page)
-  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('page alias test content')
+  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(alias_test_content_1)
   await newInnerBlock(page)
-  await page.type(':nth-match(textarea, 1)', 'yet another page alias test content')
+  await page.type(':nth-match(textarea, 1)', alias_test_content_2)
   await page.keyboard.press(hotkeyBack)
 
   // pressing enter opening test
@@ -43,16 +49,35 @@ test('page alias', async ({ page }) => {
   await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
   await page.press(':nth-match(textarea, 1)', 'Enter')
   await lastInnerBlock(page)
-  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('yet another page alias test content')
+  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(alias_test_content_2)
   await newInnerBlock(page)
-  await page.type(':nth-match(textarea, 1)', 'still another page alias test content')
+  await page.type(':nth-match(textarea, 1)', alias_test_content_3)
   await page.keyboard.press(hotkeyBack)
 
   // clicking opening test
   await page.click('.page-blocks-inner .ls-block .page-ref >> nth=-1')
   await lastInnerBlock(page)
-  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('still another page alias test content')
+  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(alias_test_content_3)
 
   // TODO: test alias from graph clicking
-  // TODO: test alias from search clicking
+
+  // test alias from search clicking
+  await page.click('#search-button')
+  await page.waitForSelector('[placeholder="Search or create page"]')
+  await page.fill('[placeholder="Search or create page"]', alias_name)
+
+  await page.waitForTimeout(500)
+  const results = await page.$$('#ui__ac-inner .block')
+  page.pause()
+  expect(results.length).toEqual(3) // 2 blocks + 1 page
+  await page.keyboard.press("Escape")
+}
+
+test('page alias', async ({ page }) => {
+  await alias_test(page, "p")
+})
+
+
+test('page diacritic alias', async ({ page }) => {
+  await alias_test(page, "ü")
 })