test: move playwright test suite to top level (#2113)

This commit is contained in:
Himself65
2023-04-24 22:12:48 -05:00
committed by GitHub
parent 5c673a8ffc
commit 7e61708850
44 changed files with 111 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["./src"]
"include": ["."]
}

16
tests/kit/package.json Normal file
View File

@@ -0,0 +1,16 @@
{
"name": "@affine-test/kit",
"private": true,
"version": "0.5.4-canary.9",
"exports": {
"./playwright": "./playwright.ts"
},
"devDependencies": {
"@playwright/test": "^1.32.3",
"playwright": "^1.32.3"
},
"peerDependencies": {
"@playwright/test": "*",
"playwright": "*"
}
}

4
tests/kit/tsconfig.json Normal file
View File

@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["./*.ts"]
}

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../../libs/load-page';
import { waitMarkdownImported } from '../../libs/page-logic';
import { test } from '../../libs/playwright';
import {
clickNewPageButton,
clickSideBarCurrentWorkspaceBanner,

View File

@@ -1,6 +1,7 @@
import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '../../libs/load-page';
import { waitMarkdownImported } from '../../libs/page-logic';
import { test } from '../../libs/playwright';
import { clickSideBarAllPageButton } from '../../libs/sidebar';
import { createFakeUser, loginUser } from '../../libs/utils';
import { enableAffineCloudWorkspace } from '../../libs/workspace';

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../../libs/load-page';
import { waitMarkdownImported } from '../../libs/page-logic';
import { test } from '../../libs/playwright';
import { clickNewPageButton } from '../../libs/sidebar';
import { createFakeUser, loginUser } from '../../libs/utils';
import { createWorkspace } from '../../libs/workspace';

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../../libs/load-page';
import { waitMarkdownImported } from '../../libs/page-logic';
import { test } from '../../libs/playwright';
import { clickPublishPanel } from '../../libs/setting';
import {
clickSideBarAllPageButton,

View File

@@ -7,7 +7,8 @@ import { waitMarkdownImported } from '../../libs/page-logic';
const userA = require('../../fixtures/userA.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const userB = require('../../fixtures/userB.json');
import { test } from '../../libs/playwright';
import { test } from '@affine-test/kit/playwright';
import {
clickNewPageButton,
clickSideBarCurrentWorkspaceBanner,

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { clickPageMoreActions, waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test('Switch to edgeless by switch edgeless item', async ({ page }) => {
await openHomePage(page);

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test('Click right-bottom corner contact icon', async ({ page }) => {
await openHomePage(page);

View File

@@ -1,7 +1,6 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { test } from '../libs/playwright';
test('should have page0', async ({ page }) => {
await page.goto('http://localhost:8080/_debug/init-page?type=importMarkdown');
await page.waitForSelector('v-line');

View File

@@ -1,7 +1,6 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { test } from '../libs/playwright';
test('should broadcast a message to all debug pages', async ({
page,
context,

View File

@@ -1,7 +1,6 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { test } from '../libs/playwright';
test('visit 404 page', async ({ page }) => {
await page.goto('http://localhost:8080/404');
const notFoundTip = page.locator('[data-testid=notFound]');

View File

@@ -1,7 +1,6 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { test } from '../libs/playwright';
test('the link has expired', async ({ page }) => {
await page.goto('http://localhost:8080//invite/abc');
await page.waitForTimeout(1000);

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test('Collapse Sidebar', async ({ page }) => {
await openHomePage(page);

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { newPage, waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('should create a page with a local first avatar', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -6,7 +7,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('New a page , then delete it in all pages, permanently delete it', async ({

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarSettingButton } from '../libs/sidebar';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -7,7 +8,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.skip('New a page ,then open it and export html', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -7,7 +8,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('New a page and open it ,then favorite it', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -7,7 +8,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('Show favorite items in sidebar', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -6,7 +7,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('click btn new page', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -6,7 +7,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('click btn bew page and open in tab', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -6,7 +7,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('New a page , then delete it in all pages, restore it', async ({

View File

@@ -1,10 +1,10 @@
import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarSettingButton } from '../libs/sidebar';
import { testResultDir } from '../libs/utils';

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -7,7 +8,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('New a page ,then open it and show delete modal', async ({ page }) => {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
@@ -6,7 +7,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test('New a page , then delete it in all pages, finally find it in trash', async ({

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarAllPageButton } from '../libs/sidebar';
import { createWorkspace, openWorkspaceListModal } from '../libs/workspace';

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarCurrentWorkspaceBanner } from '../libs/sidebar';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { createWorkspace } from '../libs/workspace';
test('Open last workspace when back to affine', async ({ page }) => {

View File

@@ -1,9 +1,9 @@
import { test } from '@affine-test/kit/playwright';
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { initHomePageWithPinboard } from '../libs/load-page';
import { createPinboardPage } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { getMetas } from '../libs/utils';
async function openPinboardPageOperationMenu(page: Page, id: string) {

View File

@@ -1,3 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import { expect, type Page } from '@playwright/test';
import { withCtrlOrMeta } from '../libs/keyboard';
@@ -7,7 +8,6 @@ import {
newPage,
waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
const openQuickSearchByShortcut = async (page: Page) =>
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage, webUrl } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarAllPageButton } from '../libs/sidebar';
test('goto not found page', async ({ page }) => {

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test('Open shortcuts modal', async ({ page }) => {
await openHomePage(page);

View File

@@ -1,8 +1,7 @@
import { test } from '@affine-test/kit/playwright';
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { test } from '../../libs/playwright';
async function openStorybook(page: Page, storyName?: string) {
return page.goto(`http://localhost:6006`);
}

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test('Create subpage', async ({ page }) => {
await openHomePage(page);

View File

@@ -1,10 +1,10 @@
import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { testResultDir } from '../libs/utils';
// default could be anything according to the system