mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-22 09:13:18 +03:00
refactor: test directory structure (#1677)
This commit is contained in:
parent
56acb2bdeb
commit
9eec8d0f1e
@ -75,7 +75,7 @@ const nextConfig = {
|
||||
'@affine/templates',
|
||||
],
|
||||
publicRuntimeConfig: {
|
||||
PROJECT_NAME: process.env.npm_package_name,
|
||||
PROJECT_NAME: process.env.npm_package_name ?? 'AFFiNE',
|
||||
BUILD_DATE: new Date().toISOString(),
|
||||
gitVersion: getGitVersion(),
|
||||
hash: getCommitHash(),
|
||||
|
1
packages/env/src/index.ts
vendored
1
packages/env/src/index.ts
vendored
@ -110,6 +110,7 @@ export const publicRuntimeConfigSchema = z.object({
|
||||
enableIndexedDBProvider: z.boolean(),
|
||||
enableBroadCastChannelProvider: z.boolean(),
|
||||
prefetchWorkspace: z.boolean(),
|
||||
enableDebugPage: z.boolean(),
|
||||
// expose internal api to globalThis, **development only**
|
||||
exposeInternal: z.boolean(),
|
||||
enableSubpage: z.boolean(),
|
||||
|
@ -16,7 +16,7 @@ import type {
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
const config: PlaywrightTestConfig = {
|
||||
testDir: './tests',
|
||||
testDir: './tests/parallels',
|
||||
fullyParallel: true,
|
||||
timeout: process.env.CI ? 50_000 : 30_000,
|
||||
use: {
|
||||
|
@ -9,6 +9,7 @@ export default function getConfig() {
|
||||
serverAPI: 'http://localhost:3000/api',
|
||||
enableBroadCastChannelProvider: true,
|
||||
enableIndexedDBProvider: true,
|
||||
enableDebugPage: true,
|
||||
prefetchWorkspace: false,
|
||||
exposeInternal: true,
|
||||
enableSubpage: true,
|
||||
|
@ -1,13 +1,6 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { test } from '@playwright/test';
|
||||
|
||||
interface IType {
|
||||
page: Page;
|
||||
}
|
||||
export function loadPage() {
|
||||
test.beforeEach(async ({ page }: IType) => {
|
||||
await page.goto('http://localhost:8080');
|
||||
// waiting for page loading end
|
||||
await page.waitForSelector('#__next');
|
||||
});
|
||||
export async function openHomePage(page: Page) {
|
||||
await page.goto('http://localhost:8080');
|
||||
await page.waitForSelector('#__next');
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { clickPageMoreActions } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { clickPageMoreActions } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Change page mode(Page or Edgeless)', () => {
|
||||
test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
const btn = await page.getByTestId('switch-edgeless-mode-button');
|
||||
await btn.click();
|
||||
|
||||
@ -15,6 +15,7 @@ test.describe('Change page mode(Page or Edgeless)', () => {
|
||||
});
|
||||
|
||||
test('Convert to edgeless by editor header items', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await clickPageMoreActions(page);
|
||||
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
|
||||
await menusEdgelessItem.click({ delay: 100 });
|
@ -1,12 +1,11 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Open contact us', () => {
|
||||
test('Click right-bottom corner contact icon', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await page.locator('[data-testid=help-island]').click();
|
||||
const rightBottomContactUs = page.locator(
|
||||
'[data-testid=right-bottom-contact-us-icon]'
|
@ -1,6 +1,6 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { test } from './libs/playwright';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Debug page broadcast', () => {
|
||||
test('should broadcast a message to all debug pages', async ({
|
@ -1,11 +1,7 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
loadPage();
|
||||
|
||||
// ps aux | grep 8080
|
||||
test.describe('exception page', () => {
|
||||
test('visit 404 page', async ({ page }) => {
|
||||
await page.goto('http://localhost:8080/404');
|
@ -1,11 +1,7 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
loadPage();
|
||||
|
||||
// ps aux | grep 8080
|
||||
test.describe('invite code page', () => {
|
||||
test('the link has expired', async ({ page }) => {
|
||||
await page.goto('http://localhost:8080//invite/abc');
|
@ -1,18 +1,18 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Layout ui', () => {
|
||||
test('Collapse Sidebar', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await page.getByTestId('sliderBar-arrowButton-collapse').click();
|
||||
const sliderBarArea = page.getByTestId('sliderBar');
|
||||
await expect(sliderBarArea).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('Expand Sidebar', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await page.getByTestId('sliderBar-arrowButton-collapse').click();
|
||||
const sliderBarArea = page.getByTestId('sliderBar');
|
||||
await expect(sliderBarArea).not.toBeVisible();
|
@ -1,14 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first create page', () => {
|
||||
test('should create a page with a local first avatar', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await page.getByTestId('workspace-name').click();
|
||||
await page.getByTestId('new-workspace').click({ delay: 50 });
|
@ -1,16 +1,15 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first delete page', () => {
|
||||
test('New a page , then delete it in all pages, permanently delete it', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');
|
@ -1,16 +1,15 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
import { clickSideBarSettingButton } from './libs/sidebar';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
import { clickSideBarSettingButton } from '../libs/sidebar';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first delete workspace', () => {
|
||||
test('New a workspace , then delete it in all workspaces, permanently delete it', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openHomePage(page);
|
||||
await clickSideBarSettingButton(page);
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
const workspaceNameDom = await page.getByTestId('workspace-name');
|
@ -1,17 +1,17 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import {
|
||||
clickPageMoreActions,
|
||||
getBlockSuiteEditorTitle,
|
||||
newPage,
|
||||
} from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
} from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first export page', () => {
|
||||
test.skip('New a page ,then open it and export html', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await page
|
@ -1,17 +1,17 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import {
|
||||
clickPageMoreActions,
|
||||
getBlockSuiteEditorTitle,
|
||||
newPage,
|
||||
} from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
} from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first favorite and cancel favorite page', () => {
|
||||
test('New a page and open it ,then favorite it', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
||||
@ -28,6 +28,7 @@ test.describe('Local first favorite and cancel favorite page', () => {
|
||||
await assertCurrentWorkspaceFlavour('local', page);
|
||||
});
|
||||
test('Cancel favorite', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
@ -1,17 +1,17 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import {
|
||||
clickPageMoreActions,
|
||||
getBlockSuiteEditorTitle,
|
||||
newPage,
|
||||
} from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
} from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first favorite items ui', () => {
|
||||
test('Show favorite items in sidebar', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
||||
@ -35,6 +35,7 @@ test.describe('Local first favorite items ui', () => {
|
||||
});
|
||||
|
||||
test('Show favorite items in favorite list', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
@ -1,13 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('local first new page', () => {
|
||||
test('click btn new page', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
const originPageId = page.url().split('/').reverse()[0];
|
||||
await newPage(page);
|
||||
const newPageId = page.url().split('/').reverse()[0];
|
||||
@ -16,6 +16,7 @@ test.describe('local first new page', () => {
|
||||
});
|
||||
|
||||
test('click btn bew page and find it in all pages', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page');
|
@ -1,13 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('local first new page', () => {
|
||||
test('click btn bew page and open in tab', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page');
|
@ -1,15 +1,15 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first delete page', () => {
|
||||
test('New a page , then delete it in all pages, restore it', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');
|
||||
@ -33,7 +33,8 @@ test.describe('Local first delete page', () => {
|
||||
await page.getByRole('button', { name: 'Delete' }).click();
|
||||
|
||||
await page.getByRole('link', { name: 'Trash' }).click();
|
||||
const trashPage = await page.url();
|
||||
await page.waitForTimeout(50);
|
||||
const trashPage = page.url();
|
||||
// restore it
|
||||
await page
|
||||
.getByTestId('more-actions-' + newPageId)
|
@ -1,17 +1,17 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import {
|
||||
clickPageMoreActions,
|
||||
getBlockSuiteEditorTitle,
|
||||
newPage,
|
||||
} from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
} from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first delete page', () => {
|
||||
test('New a page ,then open it and show delete modal', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
|
||||
@ -33,6 +33,7 @@ test.describe('Local first delete page', () => {
|
||||
test('New a page ,then go to all pages and show delete modal', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
|
@ -1,15 +1,15 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first trash page', () => {
|
||||
test('New a page , then delete it in all pages, finally find it in trash', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
|
@ -1,13 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
import { clickSideBarAllPageButton } from './libs/sidebar';
|
||||
import { createWorkspace } from './libs/workspace';
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
import { clickSideBarAllPageButton } from '../libs/sidebar';
|
||||
import { createWorkspace } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first workspace list', () => {
|
||||
test('just one item in the workspace list at first', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
const workspaceName = page.getByTestId('workspace-name');
|
||||
await workspaceName.click();
|
||||
expect(
|
||||
@ -19,6 +19,7 @@ test.describe('Local first workspace list', () => {
|
||||
});
|
||||
|
||||
test('create one workspace in the workspace list', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
const newWorkspaceNameStr = 'New Workspace';
|
||||
await createWorkspace({ name: newWorkspaceNameStr }, page);
|
||||
|
||||
@ -46,6 +47,7 @@ test.describe('Local first workspace list', () => {
|
||||
});
|
||||
|
||||
test('create multi workspace in the workspace list', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await createWorkspace({ name: 'New Workspace 2' }, page);
|
||||
await createWorkspace({ name: 'New Workspace 3' }, page);
|
||||
|
@ -1,14 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
import { clickSideBarCurrentWorkspaceBanner } from './libs/sidebar';
|
||||
import { assertCurrentWorkspaceFlavour } from './libs/workspace';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
import { clickSideBarCurrentWorkspaceBanner } from '../libs/sidebar';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test.describe('Local first default workspace', () => {
|
||||
test('preset workspace name', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
const workspaceName = page.getByTestId('workspace-name');
|
||||
expect(await workspaceName.textContent()).toBe('Demo Workspace');
|
||||
await assertCurrentWorkspaceFlavour('local', page);
|
||||
@ -23,6 +22,7 @@ test.describe('Local first default workspace', () => {
|
||||
});
|
||||
test.describe('Language switch', () => {
|
||||
test('Open language switch menu', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await clickSideBarCurrentWorkspaceBanner(page);
|
||||
const languageMenuButton = page.getByTestId('language-menu-button');
|
||||
await expect(languageMenuButton).toBeVisible();
|
@ -1,13 +1,12 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
import { createWorkspace } from './libs/workspace';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
import { createWorkspace } from '../libs/workspace';
|
||||
|
||||
test.describe('Open AFFiNE', () => {
|
||||
test('Open last workspace when back to affine', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await createWorkspace({ name: 'New Workspace 2' }, page);
|
||||
// FIXME: can not get when the new workspace is surely created, hack a timeout to wait
|
||||
// waiting for page loading end
|
@ -1,10 +1,9 @@
|
||||
import { expect, type Page } from '@playwright/test';
|
||||
|
||||
import { withCtrlOrMeta } from './libs/keyboard';
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { newPage } from './libs/page-logic';
|
||||
import { test } from './libs/playwright';
|
||||
loadPage();
|
||||
import { withCtrlOrMeta } from '../libs/keyboard';
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { newPage } from '../libs/page-logic';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
const openQuickSearchByShortcut = async (page: Page) =>
|
||||
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));
|
||||
@ -32,6 +31,7 @@ async function titleIsFocused(page: Page) {
|
||||
|
||||
test.describe('Open quick search', () => {
|
||||
test('Click slider bar button', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
const quickSearchButton = page.locator(
|
||||
'[data-testid=slider-bar-quick-search-button]'
|
||||
@ -42,6 +42,7 @@ test.describe('Open quick search', () => {
|
||||
});
|
||||
|
||||
test('Click arrowDown icon after title', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
const quickSearchButton = page.locator(
|
||||
'[data-testid=slider-bar-quick-search-button]'
|
||||
@ -52,6 +53,7 @@ test.describe('Open quick search', () => {
|
||||
});
|
||||
|
||||
test('Press the shortcut key cmd+k', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
const quickSearch = page.locator('[data-testid=quickSearch]');
|
||||
@ -61,6 +63,7 @@ test.describe('Open quick search', () => {
|
||||
|
||||
test.describe('Add new page in quick search', () => {
|
||||
test('Create a new page without keyword', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
|
||||
@ -70,6 +73,7 @@ test.describe('Add new page in quick search', () => {
|
||||
});
|
||||
|
||||
test('Create a new page with keyword', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
await page.keyboard.insertText('test123456');
|
||||
@ -82,6 +86,7 @@ test.describe('Add new page in quick search', () => {
|
||||
|
||||
test.describe('Search and select', () => {
|
||||
test('Enter a keyword to search for', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
await page.keyboard.insertText('test123456');
|
||||
@ -89,6 +94,7 @@ test.describe('Search and select', () => {
|
||||
expect(actual).toBe('test123456');
|
||||
});
|
||||
test('Create a new page and search this page', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
await page.keyboard.insertText('test123456');
|
||||
@ -119,6 +125,7 @@ test.describe('Disable search on 404 page', () => {
|
||||
});
|
||||
test.describe('Open quick search on the published page', () => {
|
||||
test('Open quick search on local page', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
const publishedSearchResults = page.locator('[publishedSearchResults]');
|
||||
@ -128,6 +135,7 @@ test.describe('Open quick search on the published page', () => {
|
||||
|
||||
test.describe('Focus event for quick search', () => {
|
||||
test('Autofocus input after opening quick search', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
const locator = page.locator('[cmdk-input]');
|
||||
@ -135,6 +143,7 @@ test.describe('Focus event for quick search', () => {
|
||||
await expect(locator).toBeFocused();
|
||||
});
|
||||
test('Autofocus input after select', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
await page.keyboard.press('ArrowUp');
|
||||
@ -143,6 +152,7 @@ test.describe('Focus event for quick search', () => {
|
||||
await expect(locator).toBeFocused();
|
||||
});
|
||||
test('Focus title after creating a new page', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await newPage(page);
|
||||
await openQuickSearchByShortcut(page);
|
||||
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
|
||||
@ -154,6 +164,7 @@ test.describe('Novice guidance for quick search', () => {
|
||||
test('When opening the website for the first time, the first folding sidebar will appear novice guide', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openHomePage(page);
|
||||
const quickSearchTips = page.locator('[data-testid=quick-search-tips]');
|
||||
await expect(quickSearchTips).not.toBeVisible();
|
||||
await page.getByTestId('sliderBar-arrowButton-collapse').click();
|
@ -1,12 +1,11 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Shortcuts Modal', () => {
|
||||
test('Open shortcuts modal', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await page.locator('[data-testid=help-island]').click();
|
||||
|
||||
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');
|
@ -1,12 +1,11 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('subpage', () => {
|
||||
test('Create subpage', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await page.getByTestId('sliderBar-arrowButton-collapse').click();
|
||||
const sliderBarArea = page.getByTestId('sliderBar');
|
||||
await expect(sliderBarArea).not.toBeVisible();
|
@ -1,9 +1,7 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { loadPage } from './libs/load-page';
|
||||
import { test } from './libs/playwright';
|
||||
|
||||
loadPage();
|
||||
import { openHomePage } from '../libs/load-page';
|
||||
import { test } from '../libs/playwright';
|
||||
|
||||
test.describe('Change Theme', () => {
|
||||
// default could be anything according to the system
|
||||
@ -12,9 +10,7 @@ test.describe('Change Theme', () => {
|
||||
colorScheme: 'light',
|
||||
});
|
||||
const page = await context.newPage();
|
||||
await page.goto('http://localhost:8080');
|
||||
// waiting for page loading end
|
||||
await page.waitForSelector('#__next');
|
||||
await openHomePage(page);
|
||||
await page.waitForSelector('html');
|
||||
const root = page.locator('html');
|
||||
const themeMode = await root.evaluate(element =>
|
21
tests/unit/compare-config.spec.ts
Normal file
21
tests/unit/compare-config.spec.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { expect, test } from 'vitest';
|
||||
|
||||
test('compare config', async () => {
|
||||
const { default: nextConfigMock } = await import(
|
||||
'../../scripts/vitest/next-config-mock'
|
||||
);
|
||||
const mockConfig = nextConfigMock().publicRuntimeConfig;
|
||||
const { default: nextConfig } = await import(
|
||||
'../../apps/web/next.config.mjs'
|
||||
);
|
||||
const config = nextConfig.publicRuntimeConfig;
|
||||
|
||||
Object.keys(config).forEach(key => {
|
||||
expect(key in mockConfig, `${key} should be in the mockConfig`).toBe(true);
|
||||
expect(typeof config[key], `${key}`).toBe(typeof mockConfig[key]);
|
||||
});
|
||||
Object.keys(mockConfig).forEach(key => {
|
||||
expect(key in config, `${key} should be in the config`).toBe(true);
|
||||
expect(typeof config[key], `${key}`).toBe(typeof mockConfig[key]);
|
||||
});
|
||||
});
|
@ -15,8 +15,11 @@ export default defineConfig({
|
||||
test: {
|
||||
include: [
|
||||
'packages/**/*.spec.ts',
|
||||
'packages/**/*.spec.tsx',
|
||||
'apps/web/**/*.spec.ts',
|
||||
'apps/web/**/*.spec.tsx',
|
||||
'tests/unit/**/*.spec.ts',
|
||||
'tests/unit/**/*.spec.tsx',
|
||||
],
|
||||
testTimeout: 5000,
|
||||
coverage: {
|
||||
|
Loading…
Reference in New Issue
Block a user