Explorar o código

test(e2e): pass test on windows

Andelf %!s(int64=3) %!d(string=hai) anos
pai
achega
18caeec139
Modificáronse 3 ficheiros con 79 adicións e 79 borrados
  1. 39 35
      e2e-tests/editor.spec.ts
  2. 1 3
      e2e-tests/hotkey.spec.ts
  3. 39 41
      e2e-tests/logseq-url.spec.ts

+ 39 - 35
e2e-tests/editor.spec.ts

@@ -143,41 +143,41 @@ test(
   })
 
 test('copy & paste block ref and replace its content', async ({ page, block }) => {
-    await createRandomPage(page)
+  await createRandomPage(page)
 
-    await block.mustFill('Some random text')
-    // FIXME: copy instantly will make content disappear
-    await page.waitForTimeout(1000)
-    if (IsMac) {
-        await page.keyboard.press('Meta+c')
-    } else {
-        await page.keyboard.press('Control+c')
-    }
+  await block.mustFill('Some random text')
+  // FIXME: copy instantly will make content disappear
+  await page.waitForTimeout(1000)
+  if (IsMac) {
+    await page.keyboard.press('Meta+c')
+  } else {
+    await page.keyboard.press('Control+c')
+  }
 
-    await page.press('textarea >> nth=0', 'Enter')
-    if (IsMac) {
-        await page.keyboard.press('Meta+v')
-    } else {
-        await page.keyboard.press('Control+v')
-    }
-    await page.keyboard.press('Enter')
+  await page.press('textarea >> nth=0', 'Enter')
+  if (IsMac) {
+    await page.keyboard.press('Meta+v')
+  } else {
+    await page.keyboard.press('Control+v')
+  }
+  await page.keyboard.press('Enter')
 
-    const blockRef = page.locator('.block-ref >> text="Some random text"');
+  const blockRef = page.locator('.block-ref >> text="Some random text"');
 
-    // Check if the newly created block-ref has the same referenced content
-    await expect(blockRef).toHaveCount(1);
+  // Check if the newly created block-ref has the same referenced content
+  await expect(blockRef).toHaveCount(1);
 
-    // Move cursor into the block ref
-    for (let i = 0; i < 4; i++) {
-        await page.press('textarea >> nth=0', 'ArrowLeft')
-}
+  // Move cursor into the block ref
+  for (let i = 0; i < 4; i++) {
+    await page.press('textarea >> nth=0', 'ArrowLeft')
+  }
 
-    // Trigger replace-block-reference-with-content-at-point
-    if (IsMac) {
-        await page.keyboard.press('Meta+Shift+r')
-    } else {
-        await page.keyboard.press('Control+Shift+v')
-    }
+  // Trigger replace-block-reference-with-content-at-point
+  if (IsMac) {
+    await page.keyboard.press('Meta+Shift+r')
+  } else {
+    await page.keyboard.press('Control+Shift+v')
+  }
 })
 
 test('copy and paste block after editing new block #5962', async ({ page, block }) => {
@@ -204,9 +204,9 @@ test('copy and paste block after editing new block #5962', async ({ page, block
 
   // Quickly paste the copied block
   if (IsMac) {
-      await page.keyboard.press('Meta+v')
+    await page.keyboard.press('Meta+v')
   } else {
-      await page.keyboard.press('Control+v')
+    await page.keyboard.press('Control+v')
   }
 
   await expect(page.locator('text="Typed block"')).toHaveCount(1);
@@ -216,11 +216,14 @@ test('undo and redo after starting an action should not destroy text #6267', asy
   await createRandomPage(page)
 
   // Get one piece of undo state onto the stack
-  await block.mustFill('text1 ')
-  await page.waitForTimeout(550) // Wait for 500ms autosave period to expire
+  await block.mustType('text1 ')
+  await page.waitForTimeout(500) // Wait for 500ms autosave period to expire
 
   // Then type more, start an action prompt, and undo
-  await page.keyboard.type('text2 [[')
+  await page.keyboard.type('text2 ', { delay: 50 })
+  for (const char of '[[') {
+    await page.keyboard.type(char, { delay: 50 })
+  }
   await expect(page.locator(`[data-modal-name="page-search"]`)).toBeVisible()
   if (IsMac) {
     await page.keyboard.press('Meta+z')
@@ -458,7 +461,8 @@ test('pressing backspace and remaining inside of brackets should NOT close autoc
     await page.keyboard.press('Backspace')
     await page.waitForTimeout(100)
     await autocompleteMenu.expectVisible(modalName)
-  }})
+  }
+})
 test('press escape when autocomplete menu is open, should close autocomplete menu only #6270', async ({ page, block }) => {
   for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['/', 'commands']]) {
     await createRandomPage(page)

+ 1 - 3
e2e-tests/hotkey.spec.ts

@@ -5,10 +5,8 @@ import { createRandomPage, newBlock, lastBlock, IsMac, IsLinux } from './utils'
 test('open search dialog', async ({ page }) => {
   if (IsMac) {
     await page.keyboard.press('Meta+k')
-  } else if (IsLinux) {
-    await page.keyboard.press('Control+k')
   } else {
-    expect(false, "TODO: test on Windows and other platforms").toBeTruthy()
+    await page.keyboard.press('Control+k')
   }
 
   await page.waitForSelector('[placeholder="Search or create page"]')

+ 39 - 41
e2e-tests/logseq-url.spec.ts

@@ -2,46 +2,44 @@ import { expect } from '@playwright/test'
 import { test } from './fixtures'
 import { createRandomPage, lastBlock, IsMac, IsLinux } from './utils'
 
-test(
-  "Logseq URLs (same graph)",
-  async ({ page, block }) => {
-    let paste_key = IsMac ? 'Meta+v' : 'Control+v'
-    // create a page with identify block
-    let identify_text = "URL redirect target"
-    let page_title = await createRandomPage(page)
-    await block.mustFill(identify_text)
+test("Logseq URLs (same graph)", async ({ page, block }) => {
+  let paste_key = IsMac ? 'Meta+v' : 'Control+v'
+  // create a page with identify block
+  let identify_text = "URL redirect target"
+  let page_title = await createRandomPage(page)
+  await block.mustFill(identify_text)
 
-    // paste current page's URL to another page, then redirect throught the URL
-    await page.click('.ui__dropdown-trigger')
-    await page.locator("text=Copy page URL").click()
-    await createRandomPage(page)
-    await block.mustFill("") // to enter editing mode
-    await page.keyboard.press(paste_key)
-    let cursor_locator = page.locator('textarea >> nth=0')
-    expect(await cursor_locator.inputValue()).toContain("page=" + page_title)
-    await cursor_locator.press("Enter")
-    if (!IsLinux) { // FIXME: support Logseq URL on Linux (XDG)
-        page.locator('a.external-link >> nth=0').click()
-        await page.waitForNavigation()
-        await page.waitForTimeout(500)
-        cursor_locator = await lastBlock(page)
-        expect(await cursor_locator.inputValue()).toBe(identify_text)
-    }
+  // paste current page's URL to another page, then redirect throught the URL
+  await page.click('.ui__dropdown-trigger')
+  await page.locator("text=Copy page URL").click()
+  await createRandomPage(page)
+  await block.mustFill("") // to enter editing mode
+  await page.keyboard.press(paste_key)
+  let cursor_locator = page.locator('textarea >> nth=0')
+  expect(await cursor_locator.inputValue()).toContain("page=" + page_title)
+  await cursor_locator.press("Enter")
+  if (IsMac) { // FIXME: support Logseq URL on Linux (XDG)
+    page.locator('a.external-link >> nth=0').click()
+    await page.waitForNavigation()
+    await page.waitForTimeout(500)
+    cursor_locator = await lastBlock(page)
+    expect(await cursor_locator.inputValue()).toBe(identify_text)
+  }
 
-    // paste the identify block's URL to another page, then redirect throught the URL
-    await page.click('span.bullet >> nth=0', { button: "right" })
-    await page.locator("text=Copy block URL").click()
-    await createRandomPage(page)
-    await block.mustFill("") // to enter editing mode
-    await page.keyboard.press(paste_key)
-    cursor_locator = page.locator('textarea >> nth=0')
-    expect(await cursor_locator.inputValue()).toContain("block-id=")
-    await cursor_locator.press("Enter")
-    if (!IsLinux) { // FIXME: support Logseq URL on Linux (XDG)
-        page.locator('a.external-link >> nth=0').click()
-        await page.waitForNavigation()
-        await page.waitForTimeout(500)
-        cursor_locator = await lastBlock(page)
-        expect(await cursor_locator.inputValue()).toBe(identify_text)
-    }
-})
+  // paste the identify block's URL to another page, then redirect throught the URL
+  await page.click('span.bullet >> nth=0', { button: "right" })
+  await page.locator("text=Copy block URL").click()
+  await createRandomPage(page)
+  await block.mustFill("") // to enter editing mode
+  await page.keyboard.press(paste_key)
+  cursor_locator = page.locator('textarea >> nth=0')
+  expect(await cursor_locator.inputValue()).toContain("block-id=")
+  await cursor_locator.press("Enter")
+  if (IsMac) { // FIXME: support Logseq URL on Linux (XDG)
+    page.locator('a.external-link >> nth=0').click()
+    await page.waitForNavigation()
+    await page.waitForTimeout(500)
+    cursor_locator = await lastBlock(page)
+    expect(await cursor_locator.inputValue()).toBe(identify_text)
+  }
+})