2022-02-17 13:54:28 +00:00
|
|
|
import { expect } from '@playwright/test'
|
|
|
|
import { test } from './fixtures'
|
2022-08-08 05:14:08 +00:00
|
|
|
import { createPage, createRandomPage, openLeftSidebar, randomString, searchAndJumpToPage } from './utils'
|
2022-02-17 13:54:28 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* Test side bar features
|
|
|
|
***/
|
|
|
|
|
|
|
|
test('favorite item and recent item test', async ({ page }) => {
|
2022-03-31 14:52:42 +00:00
|
|
|
await openLeftSidebar(page)
|
2022-02-17 13:54:28 +00:00
|
|
|
// add page to fav
|
|
|
|
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')
|
2022-04-22 09:29:38 +00:00
|
|
|
await page.locator("text=Add to Favorites").click()
|
2022-02-17 13:54:28 +00:00
|
|
|
// click from another page
|
|
|
|
const another_page_name = await createRandomPage(page)
|
2022-05-31 08:41:17 +00:00
|
|
|
expect(await page.innerText(':nth-match(.favorite-item a, 1)')).toBe(fav_page_name)
|
2022-02-17 13:54:28 +00:00
|
|
|
await page.click(":nth-match(.favorite-item, 1)")
|
|
|
|
expect(await page.innerText('.page-title .title')).toBe(fav_page_name)
|
|
|
|
|
2022-05-31 08:41:17 +00:00
|
|
|
expect(await page.innerText(':nth-match(.recent-item a, 1)')).toBe(fav_page_name)
|
|
|
|
expect(await page.innerText(':nth-match(.recent-item a, 2)')).toBe(another_page_name)
|
2022-02-17 13:54:28 +00:00
|
|
|
|
|
|
|
// remove fav
|
|
|
|
await page.click('.ui__dropdown-trigger')
|
2022-04-22 09:29:38 +00:00
|
|
|
await page.locator("text=Unfavorite page").click()
|
2022-04-26 06:49:22 +00:00
|
|
|
await expect(page.locator('.favorite-item a')).toHaveCount(previous_fav_count)
|
2022-02-17 13:54:28 +00:00
|
|
|
|
|
|
|
// click from fav page
|
2022-04-26 06:49:22 +00:00
|
|
|
await page.click(':nth-match(.recent-item a, 2)')
|
|
|
|
await expect(page.locator('.page-title .title')).toHaveText(another_page_name)
|
2022-02-21 00:34:56 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
test('recent is updated #4320', async ({ page }) => {
|
|
|
|
const page1 = await createRandomPage(page)
|
2022-03-31 14:52:42 +00:00
|
|
|
await page.fill('textarea >> nth=0', 'Random Thought')
|
2022-02-21 00:34:56 +00:00
|
|
|
|
|
|
|
const page2 = await createRandomPage(page)
|
2022-03-31 14:52:42 +00:00
|
|
|
await page.fill('textarea >> nth=0', 'Another Random Thought')
|
2022-02-21 00:34:56 +00:00
|
|
|
|
|
|
|
const firstRecent = page.locator('.nav-content-item.recent li >> nth=0')
|
|
|
|
expect(await firstRecent.textContent()).toContain(page2)
|
|
|
|
|
|
|
|
const secondRecent = page.locator('.nav-content-item.recent li >> nth=1')
|
|
|
|
expect(await secondRecent.textContent()).toContain(page1)
|
|
|
|
|
|
|
|
// then jump back
|
|
|
|
await searchAndJumpToPage(page, page1)
|
|
|
|
expect(await firstRecent.textContent()).toContain(page1)
|
|
|
|
expect(await secondRecent.textContent()).toContain(page2)
|
|
|
|
})
|
2022-08-08 05:14:08 +00:00
|
|
|
|
|
|
|
test('recent file name is displayed correctly #6297', async ({ page }) => {
|
|
|
|
const pageName = randomString(5) + "_@#$%^&*()_" + randomString(5)
|
|
|
|
await createPage(page, pageName)
|
|
|
|
await page.fill('textarea >> nth=0', 'Random Content')
|
|
|
|
|
|
|
|
const firstRecent = page.locator('.nav-content-item.recent li >> nth=0')
|
|
|
|
expect(await firstRecent.textContent()).toContain(pageName)
|
|
|
|
})
|