fix(test): refine e2e test

This commit is contained in:
Andelf
2022-11-29 13:03:41 +08:00
parent 7b7c766260
commit c1bec2fc44
9 changed files with 40 additions and 25 deletions

View File

@@ -189,4 +189,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: e2e-test-report
path: artifacts.zip
path: e2e-dump/*

View File

@@ -11,5 +11,5 @@ test('should not have any automatically detectable accessibility issues', async
.setLegacyMode()
.analyze()
expect(accessibilityScanResults.violations).toEqual([]);
expect(accessibilityScanResults.violations).toEqual([]);
})

View File

@@ -246,4 +246,4 @@ test('Scheduled date picker should point to the already specified Date #6985', a
// Close date picker
await page.click('a.opacity-80')
await page.waitForTimeout(500)
})
})

View File

@@ -118,6 +118,12 @@ base.beforeEach(async () => {
await page.keyboard.press('Escape')
await page.keyboard.press('Escape')
const locator = page.locator('.notification-close-button').first()
while (await locator.isVisible()) {
await locator.click()
expect(locator.isVisible()).resolves.toBe(false)
}
const rightSidebar = page.locator('.cp__right-sidebar-inner')
if (await rightSidebar.isVisible()) {
await page.click('button.toggle-right-sidebar', {delay: 100})
@@ -129,6 +135,8 @@ base.afterAll(async () => {
// if (electronApp) {
// await electronApp.close()
//}
// use .dump as extension to avoid unfolded when zip by github
await context.tracing.stop({ path: 'e2e-dump/trace.zip.dump' });
})
// hijack electron app into the test context

View File

@@ -10,7 +10,7 @@ test("Logseq URLs (same graph)", async ({ page, block }) => {
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.click('.ui__dropdown-trigger .toolbar-dots-btn')
await page.locator("text=Copy page URL").click()
await createRandomPage(page)
await block.mustFill("") // to enter editing mode

View File

@@ -8,7 +8,7 @@ import { IsMac, createRandomPage, newBlock, newInnerBlock, randomString, lastBlo
* Consider diacritics
***/
test('Search page and blocks (diacritics)', async ({ page }) => {
test('Search page and blocks (diacritics)', async ({ page, block }) => {
let hotkeyOpenLink = 'Control+o'
let hotkeyBack = 'Control+['
if (IsMac) {
@@ -21,28 +21,35 @@ import { IsMac, createRandomPage, newBlock, newInnerBlock, randomString, lastBlo
// diacritic opening test
await createRandomPage(page)
await page.fill('textarea >> nth=0', '[[Einführung in die Allgemeine Sprachwissenschaft' + rand + ']] diacritic-block-1')
await block.mustType('[[Einführung in die Allgemeine Sprachwissenschaft' + rand + ']] diacritic-block-1', { delay: 10 })
await page.keyboard.press(hotkeyOpenLink)
// build target Page with diacritics
await lastBlock(page)
await page.type('textarea >> nth=0', 'Diacritic title test content')
const pageTitle = page.locator('.page-title').first()
expect(await pageTitle.innerText()).toEqual('Einführung in die Allgemeine Sprachwissenschaft' + rand)
await page.keyboard.press('Enter')
await page.fill('textarea >> nth=0', '[[Einführung in die Allgemeine Sprachwissenschaft' + rand + ']] diacritic-block-2')
await page.waitForTimeout(500)
// build target Page with diacritics
await block.activeEditing(0)
await block.mustType('Diacritic title test content', { delay: 10 })
await block.enterNext()
await block.mustType('[[Einführung in die Allgemeine Sprachwissenschaft' + rand + ']] diacritic-block-2', { delay: 10 })
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.type('[placeholder="Search or create page"]', 'Einführung in die Allgemeine Sprachwissenschaft' + rand, { delay: 10 })
await page.waitForTimeout(2000) // wait longer for search contents to render
const results = await page.$$('#ui__ac-inner>div')
expect(results.length).toBeGreaterThan(3) // 2 blocks + 1 page + 2 page content
await page.keyboard.press("Escape")
await page.waitForTimeout(1000) // wait for modal disappear
await page.keyboard.press("Escape")
// 2 blocks + 1 page + 1 page content
const searchResults = page.locator('#ui__ac-inner>div')
await expect(searchResults).toHaveCount(4)
await page.keyboard.press("Escape") // escape search box typing
await page.waitForTimeout(500)
await page.keyboard.press("Escape") // escape modal
})
async function alias_test(page: Page, page_name: string, search_kws: string[]) {

View File

@@ -12,7 +12,7 @@ test('favorite item and recent item test', async ({ page }) => {
const fav_page_name = await createRandomPage(page)
let favs = await page.$$('.favorite-item a')
let previous_fav_count = favs.length
await page.click('.ui__dropdown-trigger')
await page.click('.ui__dropdown-trigger .toolbar-dots-btn')
await page.locator("text=Add to Favorites").click()
// click from another page
const another_page_name = await createRandomPage(page)
@@ -24,7 +24,7 @@ test('favorite item and recent item test', async ({ page }) => {
expect(await page.innerText(':nth-match(.recent-item a, 2)')).toBe(another_page_name)
// remove fav
await page.click('.ui__dropdown-trigger')
await page.click('.ui__dropdown-trigger .toolbar-dots-btn')
await page.locator("text=Unfavorite page").click()
await expect(page.locator('.favorite-item a')).toHaveCount(previous_fav_count)

View File

@@ -4,9 +4,9 @@
"private": true,
"main": "static/electron.js",
"devDependencies": {
"@axe-core/playwright": "^4.4.4",
"@axe-core/playwright": "=4.4.4",
"@capacitor/cli": "^4.0.0",
"@playwright/test": "^1.24.2",
"@playwright/test": "=1.25.2",
"@tailwindcss/aspect-ratio": "0.4.2",
"@tailwindcss/forms": "0.5.3",
"@tailwindcss/line-clamp": "0.4.2",
@@ -20,7 +20,7 @@
"gulp-clean-css": "^4.3.0",
"ip": "1.1.8",
"npm-run-all": "^4.1.5",
"playwright": "^1.24.2",
"playwright": "=1.25.2",
"postcss": "8.4.17",
"postcss-cli": "10.0.0",
"postcss-import": "15.0.0",

View File

@@ -15,7 +15,7 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@jridgewell/trace-mapping" "^0.3.9"
"@axe-core/playwright@^4.4.4":
"@axe-core/playwright@=4.4.4":
version "4.4.4"
resolved "https://registry.yarnpkg.com/@axe-core/playwright/-/playwright-4.4.4.tgz#3786c5f6bba38d1991b608584b00ae2744544573"
integrity sha512-VA7MR1WCqW5tFcUGCXDaaqV9pJUCdOGIR4DiZJrOxGjeRYxz3VwyMc1MDg/yiJ5fQA/QYMx+w0mvqYEr3CPx7w==
@@ -713,7 +713,7 @@
eventemitter3 "^3.1.0"
url "^0.11.0"
"@playwright/test@^1.24.2":
"@playwright/test@=1.25.2":
version "1.25.2"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.25.2.tgz#e726cf4844f096315c3954fdb3abf295cede43ba"
integrity sha512-6qPznIR4Fw02OMbqXUPMG6bFFg1hDVNEdihKy0t9K0dmRbus1DyP5Q5XFQhGwEHQkLG5hrSfBuu9CW/foqhQHQ==
@@ -5414,7 +5414,7 @@ playwright-core@1.25.2:
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.25.2.tgz#ea4baa398a4d45fcdfe48799482b599e3d0f033f"
integrity sha512-0yTbUE9lIddkEpLHL3u8PoCL+pWiZtj5A/j3U7YoNjcmKKDGBnCrgHJMzwd2J5vy6l28q4ki3JIuz7McLHhl1A==
"playwright@>= 1.0.0", playwright@^1.24.2:
playwright@=1.25.2, "playwright@>= 1.0.0":
version "1.25.2"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.25.2.tgz#0fc67e4385a52a51371ff9114bf68e3ad50a7f41"
integrity sha512-RwMB5SFRV/8wSfK+tK8ycpqdzORvoqUNz9DUeRfSgZFrZej5uuBl9wFjWcc+OkXFEtaPmx1acAVGG7hA4IJ1kg==