소스 검색

test(e2e): text normalization

Junyi Du 3 년 전
부모
커밋
6fe10a587e
2개의 변경된 파일47개의 추가작업 그리고 0개의 파일을 삭제
  1. 42 0
      e2e-tests/basic.with-diacritics.spec.ts
  2. 5 0
      e2e-tests/utils.ts

+ 42 - 0
e2e-tests/basic.with-diacritics.spec.ts

@@ -0,0 +1,42 @@
+import { expect } from '@playwright/test'
+import { test } from './fixtures'
+import { IsMac, createRandomPage, newBlock, randomString, lastInnerBlock, activateNewPage} from './utils'
+
+
+test('create page and blocks (diacritics)', async ({ page }) => {
+  let hotkeyOpenLink = 'Control+o'
+  let hotkeyBack = 'Control+['
+  if (IsMac) {
+    hotkeyOpenLink = 'Meta+o'
+    hotkeyBack = 'Meta+['
+  }
+
+  // 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)
+
+  // build target Page with diacritics
+  await activateNewPage(page)
+  await page.type(':nth-match(textarea, 1)', 'Diacritic title test content')
+  await page.keyboard.press(hotkeyBack)
+
+  // visit target Page with diacritics (looks same but not same in Unicode)
+  await newBlock(page)
+  await page.type(':nth-match(textarea, 1)', '[[Einführung in die Allgemeine Sprachwissenschaft' + rand + ']] diacritic-block-2')
+  await page.keyboard.press(hotkeyOpenLink)
+  await lastInnerBlock(page)
+  expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('Diacritic title test content')
+  await page.keyboard.press(hotkeyBack)
+
+  // check if diacritics are indexed
+  await page.click('#search-button')
+  await page.waitForSelector('[placeholder="Search or create page"]')
+  await page.fill('[placeholder="Search or create page"]', 'Einführung in die Allgemeine Sprachwissenschaft' + rand)
+
+  await page.waitForTimeout(500)
+  const results = await page.$$('#ui__ac-inner .block')
+  expect(results.length).toEqual(3) // 2 blocks + 1 page
+})

+ 5 - 0
e2e-tests/utils.ts

@@ -100,3 +100,8 @@ export async function escapeToBlockEditor(page: Page): Promise<void> {
     await page.press('.CodeMirror textarea', 'Escape')
     await page.waitForTimeout(500)
 }
+
+export async function activateNewPage(page: Page) {
+    await page.click('.ls-block >> nth=0')
+    await page.waitForTimeout(500)
+}