test: cover share page e2e (#4126)

This commit is contained in:
Alex Yang
2023-09-02 00:57:04 -05:00
committed by GitHub
parent 8825678ca9
commit 4f97ea8a5d
27 changed files with 186 additions and 99 deletions

View File

@@ -2,8 +2,8 @@ import { test } from '@affine-test/kit/playwright';
import { withCtrlOrMeta } from '@affine-test/kit/utils/keyboard';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { expect, type Page } from '@playwright/test';
@@ -39,7 +39,7 @@ async function titleIsFocused(page: Page) {
test('Click slider bar button', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]'
);
@@ -51,7 +51,7 @@ test('Click slider bar button', async ({ page }) => {
test('Click arrowDown icon after title', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]'
);
@@ -63,7 +63,7 @@ test('Click arrowDown icon after title', async ({ page }) => {
test('Press the shortcut key cmd+k', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
const quickSearch = page.locator('[data-testid=quickSearch]');
await expect(quickSearch).toBeVisible();
@@ -72,7 +72,7 @@ test('Press the shortcut key cmd+k', async ({ page }) => {
test('Create a new page without keyword', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click();
@@ -83,7 +83,7 @@ test('Create a new page without keyword', async ({ page }) => {
test('Create a new page with keyword', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
@@ -95,7 +95,7 @@ test('Create a new page with keyword', async ({ page }) => {
test('Enter a keyword to search for', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
const actual = await page.locator('[cmdk-input]').inputValue();
@@ -105,7 +105,7 @@ test('Enter a keyword to search for', async ({ page }) => {
test('Create a new page and search this page', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
// input title and create new page
await page.keyboard.insertText('test123456');
@@ -147,7 +147,7 @@ test('Navigate to the 404 page and try to open quick search', async ({
test('Open quick search on local page', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
const publishedSearchResults = page.locator('[publishedSearchResults]');
await expect(publishedSearchResults).toBeVisible({ visible: false });
@@ -156,7 +156,7 @@ test('Open quick search on local page', async ({ page }) => {
test('Autofocus input after opening quick search', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
const locator = page.locator('[cmdk-input]');
await expect(locator).toBeVisible();
@@ -165,7 +165,7 @@ test('Autofocus input after opening quick search', async ({ page }) => {
test('Autofocus input after select', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
await page.keyboard.press('ArrowUp');
const locator = page.locator('[cmdk-input]');
@@ -175,7 +175,7 @@ test('Autofocus input after select', async ({ page }) => {
test('Focus title after creating a new page', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await newPage(page);
await clickNewPageButton(page);
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click();
@@ -198,7 +198,7 @@ test('assert the recent browse pages are on the recent list', async ({
await waitForEditorLoad(page);
// create first page
await newPage(page);
await clickNewPageButton(page);
{
const title = getBlockSuiteEditorTitle(page);
await title.type('sgtokidoki', {