瀏覽代碼

fix(test): random fail while typing

Andelf 3 年之前
父節點
當前提交
93faf552ac
共有 2 個文件被更改,包括 23 次插入56 次删除
  1. 22 55
      e2e-tests/basic.spec.ts
  2. 1 1
      e2e-tests/fixtures.ts

+ 22 - 55
e2e-tests/basic.spec.ts

@@ -4,71 +4,38 @@ import path from 'path'
 import { test } from './fixtures'
 import { randomString, createRandomPage } from './utils'
 
-test('toggle sidebar', async ({ page }) => {
-  let sidebar = page.locator('#left-sidebar')
-
-  // Left sidebar is toggled by `is-open` class
-  if (/is-open/.test(await sidebar.getAttribute('class'))) {
-    await page.click('#left-menu.button')
-    await expect(sidebar).not.toHaveClass(/is-open/)
-  } else {
-    await page.click('#left-menu.button')
-    await page.waitForTimeout(10)
-    await expect(sidebar).toHaveClass(/is-open/)
-    await page.click('#left-menu.button')
-    await page.waitForTimeout(10)
-    await expect(sidebar).not.toHaveClass(/is-open/)
-  }
-
-  await page.click('#left-menu.button')
-
-  await page.waitForTimeout(10)
-  await expect(sidebar).toHaveClass(/is-open/)
-  await page.waitForSelector('#left-sidebar .left-sidebar-inner', { state: 'visible' })
-  await page.waitForSelector('#left-sidebar a:has-text("New page")', { state: 'visible' })
-})
-
-test('search', async ({ page }) => {
-  await page.click('#search-button')
-  await page.waitForSelector('[placeholder="Search or create page"]')
-  await page.fill('[placeholder="Search or create page"]', 'welcome')
-
-  await page.waitForTimeout(500)
-  const results = await page.$$('#ui__ac-inner .block')
-  expect(results.length).toBeGreaterThanOrEqual(1)
-})
 
 test('create page and blocks, save to disk', async ({ page, block, graphDir }) => {
   const pageTitle = await createRandomPage(page)
 
   // do editing
-  await block.mustFill('this is my first bullet')
+  await page.keyboard.type('first bullet')
   await block.enterNext()
 
   await block.waitForBlocks(2)
 
-  await block.mustFill('this is my second bullet')
+  await page.keyboard.type('second bullet')
   await block.clickNext()
 
-  await block.mustFill('this is my third bullet')
-  await block.indent()
+  await page.keyboard.type('third bullet')
+  expect(await block.indent()).toBe(true)
   await block.enterNext()
 
-  await page.keyboard.type('continue editing test')
+  await page.keyboard.type('continue editing')
   await page.keyboard.press('Shift+Enter')
-  await page.keyboard.type('continue')
+  await page.keyboard.type('second line')
 
   await block.enterNext()
   expect(await block.unindent()).toBe(true)
   expect(await block.unindent()).toBe(false)
-  await block.mustFill('test ok')
+  await page.keyboard.type('test ok')
   await page.keyboard.press('Escape')
 
   await block.waitForBlocks(5)
 
   // active edit, and create next block
   await block.clickNext()
-  await page.fill('textarea >> nth=0', 'test')
+  await page.keyboard.type('test')
   for (let i = 0; i < 5; i++) {
     await page.keyboard.press('Backspace', { delay: 100 })
   }
@@ -82,11 +49,11 @@ test('create page and blocks, save to disk', async ({ page, block, graphDir }) =
     'utf8'
   )
   expect(contentOnDisk.trim()).toEqual(`
-- this is my first bullet
-- this is my second bullet
-	- this is my third bullet
-	- continue editing test
-	  continue
+- first bullet
+- second bullet
+	- third bullet
+	- continue editing
+	  second line
 - test ok`.trim())
 })
 
@@ -194,8 +161,8 @@ test('auto completion square brackets', async ({ page, block }) => {
   // In this test, `type` is unsed instead of `fill`, to allow for auto-completion.
 
   // [[]]
-  await block.mustType('This is a [', { toBe: 'This is a []'})
-  await block.mustType('[', { toBe: 'This is a [[]]'})
+  await block.mustType('This is a [', { toBe: 'This is a []' })
+  await block.mustType('[', { toBe: 'This is a [[]]' })
 
   // wait for search popup
   await page.waitForSelector('text="Search for a page"')
@@ -227,27 +194,27 @@ test('auto completion and auto pair', async ({ page, block }) => {
   await block.enterNext()
 
   // {{
-  await block.mustType('type {{', { toBe: 'type {{}}'})
+  await block.mustType('type {{', { toBe: 'type {{}}' })
 
   // ((
   await block.clickNext()
 
-  await block.mustType('type (', { toBe: 'type ()'})
-  await block.mustType('(', { toBe: 'type (())'})
+  await block.mustType('type (', { toBe: 'type ()' })
+  await block.mustType('(', { toBe: 'type (())' })
 
   // [[  #3251
   await block.clickNext()
 
-  await block.mustType('type [', { toBe: 'type []'})
-  await block.mustType('[', { toBe: 'type [[]]'})
+  await block.mustType('type [', { toBe: 'type []' })
+  await block.mustType('[', { toBe: 'type [[]]' })
 
   await block.escapeEditing() // escape any popup from `[[]]`
 
   // ``
   await block.clickNext()
 
-  await block.mustType('type `', { toBe: 'type ``'})
-  await block.mustType('code here', { toBe: 'type `code here`'})
+  await block.mustType('type `', { toBe: 'type ``' })
+  await block.mustType('code here', { toBe: 'type `code here`' })
 })
 
 test('invalid page props #3944', async ({ page, block }) => {

+ 1 - 1
e2e-tests/fixtures.ts

@@ -153,7 +153,7 @@ export const test = base.extend<LogseqFixtures>({
         });
         let blockCount = await page.locator('.page-blocks-inner .ls-block').count()
         // the next element after all blocks.
-        await page.click('.add-button-link-wrap', { delay: 50 })
+        await page.click('.add-button-link-wrap', { delay: 100 })
         await page.waitForSelector(`.ls-block >> nth=${blockCount} >> textarea`, { state: 'visible', timeout: 1000 })
         return page.locator('textarea >> nth=0')
       },