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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 111 additions and 52 deletions

View File

@ -83,6 +83,7 @@ jobs:
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
API_SERVER_PROFILE: local
ENABLE_DEBUG_PAGE: true
ENABLE_LEGACY_PROVIDER: true
COVERAGE: true
- name: Upload artifact
@ -92,6 +93,32 @@ jobs:
path: ./apps/web/.next
if-no-files-found: error
- name: Build @affine/web for desktop
run: yarn build
env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
API_SERVER_PROFILE: affine
ENABLE_DEBUG_PAGE: true
ENABLE_LEGACY_PROVIDER: false
COVERAGE: true
- name: Export static resources
run: yarn export
working-directory: apps/web
- name: Upload static resources artifact
uses: actions/upload-artifact@v3
with:
name: next-js-static
path: ./apps/web/out
if-no-files-found: error
server-test:
name: Server Test
runs-on: ubuntu-latest
@ -257,18 +284,11 @@ jobs:
name: affine-ubuntu
path: ./apps/electron/dist
- name: Download artifact
- name: Download static resource artifact
uses: actions/download-artifact@v3
with:
name: next-js
path: ./apps/web/.next
- name: Generate static files
run: yarn export
working-directory: ./apps/web
- name: Move static files to electron
run: mv ./apps/web/out ./apps/electron/resources/web-static
name: next-js-static
path: ./apps/electron/resources/web-static
- name: Run desktop tests
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test

View File

@ -24,6 +24,7 @@
},
"main": "./dist/layers/main/index.js",
"devDependencies": {
"@affine-test/kit": "workspace:*",
"@electron-forge/cli": "^6.1.1",
"@electron-forge/core": "^6.1.1",
"@electron-forge/core-utils": "^6.1.1",

View File

@ -1,6 +1,7 @@
import { resolve } from 'node:path';
import { expect, test } from '@playwright/test';
import { test } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { _electron as electron } from 'playwright';
test('new page', async () => {

View File

@ -7,7 +7,8 @@
"workspaces": [
"apps/*",
"packages/*",
"tests/fixtures"
"tests/fixtures",
"tests/kit"
],
"scripts": {
"dev": "dev-web",
@ -37,6 +38,7 @@
"*.{ts,tsx,mjs,js,jsx}": "eslint --cache --fix"
},
"devDependencies": {
"@affine-test/kit": "workspace:*",
"@affine/cli": "workspace:*",
"@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1",

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

View File

@ -29,6 +29,7 @@
"@affine/utils": ["./packages/utils"],
"@affine/workspace/*": ["./packages/workspace/src/*"],
"@affine/graphql": ["./packages/graphql/src"],
"@affine-test/kit/*": ["./tests/kit/*"],
"@affine-test/fixtures/*": ["./tests/fixtures/*"],
"@toeverything/y-indexeddb": ["./packages/y-indexeddb/src"],
"@toeverything/hooks/*": ["./packages/hooks/src/*"]
@ -71,6 +72,9 @@
{
"path": "./tests/fixtures"
},
{
"path": "./tests/kit"
},
{
"path": "./tsconfig.node.json"
},

View File

@ -18,6 +18,18 @@ __metadata:
languageName: unknown
linkType: soft
"@affine-test/kit@workspace:*, @affine-test/kit@workspace:tests/kit":
version: 0.0.0-use.local
resolution: "@affine-test/kit@workspace:tests/kit"
dependencies:
"@playwright/test": ^1.32.3
playwright: ^1.32.3
peerDependencies:
"@playwright/test": "*"
playwright: "*"
languageName: unknown
linkType: soft
"@affine/cli@workspace:*, @affine/cli@workspace:packages/cli":
version: 0.0.0-use.local
resolution: "@affine/cli@workspace:packages/cli"
@ -112,6 +124,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/electron@workspace:apps/electron"
dependencies:
"@affine-test/kit": "workspace:*"
"@electron-forge/cli": ^6.1.1
"@electron-forge/core": ^6.1.1
"@electron-forge/core-utils": ^6.1.1
@ -9652,6 +9665,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "AFFiNE@workspace:."
dependencies:
"@affine-test/kit": "workspace:*"
"@affine/cli": "workspace:*"
"@commitlint/cli": ^17.6.1
"@commitlint/config-conventional": ^17.6.1