diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1414209f0f..bdb6870b19 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/apps/electron/package.json b/apps/electron/package.json index b5b6fc6080..e58dc3a4e7 100644 --- a/apps/electron/package.json +++ b/apps/electron/package.json @@ -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", diff --git a/apps/electron/tests/basic.spec.ts b/apps/electron/tests/basic.spec.ts index 1062d2dba0..5e42b583e7 100644 --- a/apps/electron/tests/basic.spec.ts +++ b/apps/electron/tests/basic.spec.ts @@ -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 () => { diff --git a/package.json b/package.json index aa5a1825bb..fc22fefed9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/fixtures/tsconfig.json b/tests/fixtures/tsconfig.json index 7513033f03..bb542f3839 100644 --- a/tests/fixtures/tsconfig.json +++ b/tests/fixtures/tsconfig.json @@ -1,4 +1,4 @@ { "extends": "../../tsconfig.json", - "include": ["./src"] + "include": ["."] } diff --git a/tests/kit/package.json b/tests/kit/package.json new file mode 100644 index 0000000000..a454e2ad8c --- /dev/null +++ b/tests/kit/package.json @@ -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": "*" + } +} diff --git a/tests/libs/playwright.ts b/tests/kit/playwright.ts similarity index 100% rename from tests/libs/playwright.ts rename to tests/kit/playwright.ts diff --git a/tests/kit/tsconfig.json b/tests/kit/tsconfig.json new file mode 100644 index 0000000000..1fcfc7ee75 --- /dev/null +++ b/tests/kit/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./*.ts"] +} diff --git a/tests/parallels/affine/affine-built-in-workspace.spec.ts b/tests/parallels/affine/affine-built-in-workspace.spec.ts index e57de61e5c..393e493fef 100644 --- a/tests/parallels/affine/affine-built-in-workspace.spec.ts +++ b/tests/parallels/affine/affine-built-in-workspace.spec.ts @@ -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, diff --git a/tests/parallels/affine/affine-lost-auth.spec.ts b/tests/parallels/affine/affine-lost-auth.spec.ts index bad62c9729..5eff02f451 100644 --- a/tests/parallels/affine/affine-lost-auth.spec.ts +++ b/tests/parallels/affine/affine-lost-auth.spec.ts @@ -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'; diff --git a/tests/parallels/affine/affine-public-single-page.spec.ts b/tests/parallels/affine/affine-public-single-page.spec.ts index 12f2786ae1..94bf451608 100644 --- a/tests/parallels/affine/affine-public-single-page.spec.ts +++ b/tests/parallels/affine/affine-public-single-page.spec.ts @@ -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'; diff --git a/tests/parallels/affine/affine-public-workspace.spec.ts b/tests/parallels/affine/affine-public-workspace.spec.ts index 2126f97d23..96ffb6a302 100644 --- a/tests/parallels/affine/affine-public-workspace.spec.ts +++ b/tests/parallels/affine/affine-public-workspace.spec.ts @@ -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, diff --git a/tests/parallels/affine/affine-workspace.spec.ts b/tests/parallels/affine/affine-workspace.spec.ts index 9d4f6b08c7..044e384acf 100644 --- a/tests/parallels/affine/affine-workspace.spec.ts +++ b/tests/parallels/affine/affine-workspace.spec.ts @@ -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, diff --git a/tests/parallels/change-page-mode.spec.ts b/tests/parallels/change-page-mode.spec.ts index c00cd27d9e..78bc448243 100644 --- a/tests/parallels/change-page-mode.spec.ts +++ b/tests/parallels/change-page-mode.spec.ts @@ -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); diff --git a/tests/parallels/contact-us.spec.ts b/tests/parallels/contact-us.spec.ts index 7b98e44ab5..c523b98258 100644 --- a/tests/parallels/contact-us.spec.ts +++ b/tests/parallels/contact-us.spec.ts @@ -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); diff --git a/tests/parallels/debug-init-page.spec.ts b/tests/parallels/debug-init-page.spec.ts index d2cf632ae1..72736df47d 100644 --- a/tests/parallels/debug-init-page.spec.ts +++ b/tests/parallels/debug-init-page.spec.ts @@ -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'); diff --git a/tests/parallels/debug-page-broadcast.spec.ts b/tests/parallels/debug-page-broadcast.spec.ts index da1c2da780..bc8b909bed 100644 --- a/tests/parallels/debug-page-broadcast.spec.ts +++ b/tests/parallels/debug-page-broadcast.spec.ts @@ -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, diff --git a/tests/parallels/exception-page.spec.ts b/tests/parallels/exception-page.spec.ts index 81088c5231..76dcdeb70a 100644 --- a/tests/parallels/exception-page.spec.ts +++ b/tests/parallels/exception-page.spec.ts @@ -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]'); diff --git a/tests/parallels/invite-code-page.spec.ts b/tests/parallels/invite-code-page.spec.ts index d627f4df7b..17817ad170 100644 --- a/tests/parallels/invite-code-page.spec.ts +++ b/tests/parallels/invite-code-page.spec.ts @@ -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); diff --git a/tests/parallels/layout.spec.ts b/tests/parallels/layout.spec.ts index f65144a427..ca6419fe6b 100644 --- a/tests/parallels/layout.spec.ts +++ b/tests/parallels/layout.spec.ts @@ -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); diff --git a/tests/parallels/local-first-avatar.spec.ts b/tests/parallels/local-first-avatar.spec.ts index d1c0bb862b..11158f1aa8 100644 --- a/tests/parallels/local-first-avatar.spec.ts +++ b/tests/parallels/local-first-avatar.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-delete-page.spec.ts b/tests/parallels/local-first-delete-page.spec.ts index 32f30eae29..b3d7217821 100644 --- a/tests/parallels/local-first-delete-page.spec.ts +++ b/tests/parallels/local-first-delete-page.spec.ts @@ -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 ({ diff --git a/tests/parallels/local-first-delete-workspace.spec.ts b/tests/parallels/local-first-delete-workspace.spec.ts index 0b9a2525a3..9018682576 100644 --- a/tests/parallels/local-first-delete-workspace.spec.ts +++ b/tests/parallels/local-first-delete-workspace.spec.ts @@ -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'; diff --git a/tests/parallels/local-first-export-page.spec.ts b/tests/parallels/local-first-export-page.spec.ts index c4e1276860..9c48b4d46e 100644 --- a/tests/parallels/local-first-export-page.spec.ts +++ b/tests/parallels/local-first-export-page.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-favorite-page.spec.ts b/tests/parallels/local-first-favorite-page.spec.ts index 4f20c6250a..a19a085d6b 100644 --- a/tests/parallels/local-first-favorite-page.spec.ts +++ b/tests/parallels/local-first-favorite-page.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-favorites-items.spec.ts b/tests/parallels/local-first-favorites-items.spec.ts index 9721eb1466..e6c88c6941 100644 --- a/tests/parallels/local-first-favorites-items.spec.ts +++ b/tests/parallels/local-first-favorites-items.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-new-page.spec.ts b/tests/parallels/local-first-new-page.spec.ts index 8533966919..d7be89fa17 100644 --- a/tests/parallels/local-first-new-page.spec.ts +++ b/tests/parallels/local-first-new-page.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-openpage-newtab.spec.ts b/tests/parallels/local-first-openpage-newtab.spec.ts index 03a4c88b1d..65b78e253b 100644 --- a/tests/parallels/local-first-openpage-newtab.spec.ts +++ b/tests/parallels/local-first-openpage-newtab.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-restore-page.spec.ts b/tests/parallels/local-first-restore-page.spec.ts index 744a83a0a5..1536854936 100644 --- a/tests/parallels/local-first-restore-page.spec.ts +++ b/tests/parallels/local-first-restore-page.spec.ts @@ -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 ({ diff --git a/tests/parallels/local-first-setting-page.spec.ts b/tests/parallels/local-first-setting-page.spec.ts index d7b6d275f4..eec736b07d 100644 --- a/tests/parallels/local-first-setting-page.spec.ts +++ b/tests/parallels/local-first-setting-page.spec.ts @@ -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'; diff --git a/tests/parallels/local-first-show-delete-modal.spec.ts b/tests/parallels/local-first-show-delete-modal.spec.ts index f924ac84cc..542e080483 100644 --- a/tests/parallels/local-first-show-delete-modal.spec.ts +++ b/tests/parallels/local-first-show-delete-modal.spec.ts @@ -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 }) => { diff --git a/tests/parallels/local-first-trash-page.spec.ts b/tests/parallels/local-first-trash-page.spec.ts index a75c69c285..93fe66ccd0 100644 --- a/tests/parallels/local-first-trash-page.spec.ts +++ b/tests/parallels/local-first-trash-page.spec.ts @@ -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 ({ diff --git a/tests/parallels/local-first-workspace-list.spec.ts b/tests/parallels/local-first-workspace-list.spec.ts index 34c5b36d86..1b6c21bdfe 100644 --- a/tests/parallels/local-first-workspace-list.spec.ts +++ b/tests/parallels/local-first-workspace-list.spec.ts @@ -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'; diff --git a/tests/parallels/local-first-workspace.spec.ts b/tests/parallels/local-first-workspace.spec.ts index de08f12596..3b87014a4c 100644 --- a/tests/parallels/local-first-workspace.spec.ts +++ b/tests/parallels/local-first-workspace.spec.ts @@ -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'; diff --git a/tests/parallels/open-affine.spec.ts b/tests/parallels/open-affine.spec.ts index 36fac0587e..11bb1bd451 100644 --- a/tests/parallels/open-affine.spec.ts +++ b/tests/parallels/open-affine.spec.ts @@ -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 }) => { diff --git a/tests/parallels/pin-board.spec.ts b/tests/parallels/pin-board.spec.ts index dded1d3ffb..2f82399e1d 100644 --- a/tests/parallels/pin-board.spec.ts +++ b/tests/parallels/pin-board.spec.ts @@ -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) { diff --git a/tests/parallels/quick-search.spec.ts b/tests/parallels/quick-search.spec.ts index 31f5108de8..60aef23f5c 100644 --- a/tests/parallels/quick-search.spec.ts +++ b/tests/parallels/quick-search.spec.ts @@ -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 })); diff --git a/tests/parallels/router.spec.ts b/tests/parallels/router.spec.ts index 1cd5c3d625..f9c195d164 100644 --- a/tests/parallels/router.spec.ts +++ b/tests/parallels/router.spec.ts @@ -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 }) => { diff --git a/tests/parallels/shortcuts.spec.ts b/tests/parallels/shortcuts.spec.ts index 5f3fbb3588..b9ef1d0fe9 100644 --- a/tests/parallels/shortcuts.spec.ts +++ b/tests/parallels/shortcuts.spec.ts @@ -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); diff --git a/tests/parallels/storybook/button.spec.ts b/tests/parallels/storybook/button.spec.ts index b023275ef0..4583ad4867 100644 --- a/tests/parallels/storybook/button.spec.ts +++ b/tests/parallels/storybook/button.spec.ts @@ -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`); } diff --git a/tests/parallels/subpage.spec.ts b/tests/parallels/subpage.spec.ts index e5a8d08e1b..003f95efdb 100644 --- a/tests/parallels/subpage.spec.ts +++ b/tests/parallels/subpage.spec.ts @@ -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); diff --git a/tests/parallels/theme.spec.ts b/tests/parallels/theme.spec.ts index ae29cc8b3e..a4029837cb 100644 --- a/tests/parallels/theme.spec.ts +++ b/tests/parallels/theme.spec.ts @@ -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 diff --git a/tsconfig.json b/tsconfig.json index 1ed804ae4a..a880406304 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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" }, diff --git a/yarn.lock b/yarn.lock index 43475c1326..0d73573d0f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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