diff --git a/packages/backend/server/package.json b/packages/backend/server/package.json index 6bdbb0a211398..4d17bc261b458 100644 --- a/packages/backend/server/package.json +++ b/packages/backend/server/package.json @@ -12,8 +12,10 @@ "start": "node --loader ts-node/esm/transpile-only.mjs ./src/index.ts", "dev": "nodemon ./src/index.ts", "test": "ava --concurrency 1 --serial", + "test:copilot:e2e": "ava \"e2e/copilot.e2e.ts\"", "test:copilot:spec": "ava \"tests/**/copilot-*.spec.ts\"", "test:coverage": "c8 ava --concurrency 1 --serial", + "test:copilot:e2e:coverage": "c8 ava --timeout=5m \"e2e/copilot.e2e.ts\"", "test:copilot:spec:coverage": "c8 ava --timeout=5m \"tests/**/copilot-*.spec.ts\"", "postinstall": "prisma generate", "data-migration": "node --loader ts-node/esm/transpile-only.mjs ./src/data/index.ts", diff --git a/tests/affine-cloud-copilot/e2e/copilot.e2e.ts b/packages/backend/server/tests/copilot-provider.e2e.ts similarity index 95% rename from tests/affine-cloud-copilot/e2e/copilot.e2e.ts rename to packages/backend/server/tests/copilot-provider.e2e.ts index 0f6b17ff8b677..2e373bfdb0377 100644 --- a/tests/affine-cloud-copilot/e2e/copilot.e2e.ts +++ b/packages/backend/server/tests/copilot-provider.e2e.ts @@ -1,6 +1,10 @@ import { randomUUID } from 'node:crypto'; -import { createWorkspace } from '@affine/server/tests/utils'; +import { createRandomAIUser } from '@affine-test/kit/utils/cloud'; +import type { ExecutionContext, TestFn } from 'ava'; +import ava from 'ava'; + +import { createWorkspace } from './utils'; import { chatWithImages, chatWithText, @@ -10,10 +14,7 @@ import { ProviderActionTestCase, ProviderWorkflowTestCase, sse2array, -} from '@affine/server/tests/utils/copilot'; -import { createRandomAIUser } from '@affine-test/kit/utils/cloud'; -import type { ExecutionContext, TestFn } from 'ava'; -import ava from 'ava'; +} from './utils/copilot'; type Tester = { app: any; @@ -50,7 +51,7 @@ export const runPrisma = async ( cb: ( prisma: InstanceType< // eslint-disable-next-line @typescript-eslint/consistent-type-imports - typeof import('../../../packages/backend/server/node_modules/@prisma/client').PrismaClient + typeof import('../../../../packages/backend/server/node_modules/@prisma/client').PrismaClient > ) => Promise ): Promise => { @@ -58,7 +59,7 @@ export const runPrisma = async ( PrismaClient, // eslint-disable-next-line @typescript-eslint/no-var-requires } = await import( - '../../../packages/backend/server/node_modules/@prisma/client' + '../../../../packages/backend/server/node_modules/@prisma/client' ); const client = new PrismaClient(); await client.$connect(); diff --git a/packages/backend/server/tests/tsconfig.json b/packages/backend/server/tests/tsconfig.json index 445549efc4909..f24108f86cbdd 100644 --- a/packages/backend/server/tests/tsconfig.json +++ b/packages/backend/server/tests/tsconfig.json @@ -18,6 +18,6 @@ "path": "../../../../tests/kit/tsconfig.json" } ], - "include": ["."], + "include": [".", "utils"], "exclude": [] } diff --git a/tests/affine-cloud-copilot/package.json b/tests/affine-cloud-copilot/package.json deleted file mode 100644 index 60de9b9860e71..0000000000000 --- a/tests/affine-cloud-copilot/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "@affine-test/affine-cloud-copilot", - "private": true, - "type": "module", - "scripts": { - "test:e2e": "yarn playwright test", - "test:api": "ava \"e2e/copilot.e2e.ts\"", - "test:api:coverage": "c8 ava --timeout=5m \"e2e/copilot.e2e.ts\"" - }, - "devDependencies": { - "@affine-test/kit": "workspace:*", - "@affine/server": "workspace:*", - "@playwright/test": "=1.48.2", - "ava": "^6.1.2" - }, - "ava": { - "timeout": "1m", - "extensions": { - "ts": "module" - }, - "require": [ - "../../packages/backend/server/src/prelude.ts" - ], - "workerThreads": false, - "nodeArguments": [ - "--trace-sigint", - "--loader", - "ts-node/esm/transpile-only.mjs", - "--es-module-specifier-resolution=node" - ], - "files": [ - "**/__tests__/**/*.spec.ts", - "tests/**/*.spec.ts", - "tests/**/*.e2e.ts" - ], - "environmentVariables": { - "TS_NODE_PROJECT": "./tsconfig.json", - "NODE_ENV": "test", - "MAILER_HOST": "0.0.0.0", - "MAILER_PORT": "1025", - "MAILER_USER": "noreply@toeverything.info", - "MAILER_PASSWORD": "affine", - "MAILER_SENDER": "noreply@toeverything.info", - "FEATURES_EARLY_ACCESS_PREVIEW": "false", - "DEPLOYMENT_TYPE": "affine" - } - }, - "version": "0.17.0" -} diff --git a/tests/affine-cloud-copilot/tsconfig.json b/tests/affine-cloud-copilot/tsconfig.json deleted file mode 100644 index c98786d3e747e..0000000000000 --- a/tests/affine-cloud-copilot/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "composite": true, - "target": "ES2022", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "rootDir": ".", - "outDir": "lib", - "verbatimModuleSyntax": false, - "tsBuildInfoFile": "lib/.tsbuildinfo" - }, - "references": [ - { - "path": "../../tests/kit" - }, - { - "path": "../../tests/fixtures" - } - ] -} diff --git a/tests/affine-cloud/e2e/collaboration.spec.ts b/tests/affine-cloud/cloud/e2e/collaboration.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/collaboration.spec.ts rename to tests/affine-cloud/cloud/e2e/collaboration.spec.ts diff --git a/tests/affine-cloud/e2e/fixtures/0.9.0-canary.9-snapshots.sql b/tests/affine-cloud/cloud/e2e/fixtures/0.9.0-canary.9-snapshots.sql similarity index 100% rename from tests/affine-cloud/e2e/fixtures/0.9.0-canary.9-snapshots.sql rename to tests/affine-cloud/cloud/e2e/fixtures/0.9.0-canary.9-snapshots.sql diff --git a/tests/affine-cloud/e2e/login.spec.ts b/tests/affine-cloud/cloud/e2e/login.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/login.spec.ts rename to tests/affine-cloud/cloud/e2e/login.spec.ts diff --git a/tests/affine-cloud/e2e/logo.svg b/tests/affine-cloud/cloud/e2e/logo.svg similarity index 100% rename from tests/affine-cloud/e2e/logo.svg rename to tests/affine-cloud/cloud/e2e/logo.svg diff --git a/tests/affine-cloud/e2e/migration.spec.ts b/tests/affine-cloud/cloud/e2e/migration.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/migration.spec.ts rename to tests/affine-cloud/cloud/e2e/migration.spec.ts diff --git a/tests/affine-cloud/e2e/open-in-app.spec.ts b/tests/affine-cloud/cloud/e2e/open-in-app.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/open-in-app.spec.ts rename to tests/affine-cloud/cloud/e2e/open-in-app.spec.ts diff --git a/tests/affine-cloud/e2e/page-history.spec.ts b/tests/affine-cloud/cloud/e2e/page-history.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/page-history.spec.ts rename to tests/affine-cloud/cloud/e2e/page-history.spec.ts diff --git a/tests/affine-cloud/e2e/share-page.spec.ts b/tests/affine-cloud/cloud/e2e/share-page.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/share-page.spec.ts rename to tests/affine-cloud/cloud/e2e/share-page.spec.ts diff --git a/tests/affine-cloud/e2e/workspace.spec.ts b/tests/affine-cloud/cloud/e2e/workspace.spec.ts similarity index 100% rename from tests/affine-cloud/e2e/workspace.spec.ts rename to tests/affine-cloud/cloud/e2e/workspace.spec.ts diff --git a/tests/affine-cloud/package.json b/tests/affine-cloud/cloud/package.json similarity index 100% rename from tests/affine-cloud/package.json rename to tests/affine-cloud/cloud/package.json diff --git a/tests/affine-cloud/playwright.config.ts b/tests/affine-cloud/cloud/playwright.config.ts similarity index 100% rename from tests/affine-cloud/playwright.config.ts rename to tests/affine-cloud/cloud/playwright.config.ts diff --git a/tests/affine-cloud/tsconfig.json b/tests/affine-cloud/cloud/tsconfig.json similarity index 56% rename from tests/affine-cloud/tsconfig.json rename to tests/affine-cloud/cloud/tsconfig.json index 828052ad7803a..3c5d0565c01b0 100644 --- a/tests/affine-cloud/tsconfig.json +++ b/tests/affine-cloud/cloud/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../../tsconfig.json", "compilerOptions": { "esModuleInterop": true, "outDir": "lib" @@ -7,10 +7,10 @@ "include": ["e2e"], "references": [ { - "path": "../../tests/kit" + "path": "../../../tests/kit" }, { - "path": "../../tests/fixtures" + "path": "../../../tests/fixtures" } ] } diff --git a/tests/affine-cloud-copilot/e2e/copilot.spec.ts b/tests/affine-cloud/copilot/e2e/copilot.spec.ts similarity index 100% rename from tests/affine-cloud-copilot/e2e/copilot.spec.ts rename to tests/affine-cloud/copilot/e2e/copilot.spec.ts diff --git a/tests/affine-cloud/copilot/package.json b/tests/affine-cloud/copilot/package.json new file mode 100644 index 0000000000000..c32108f347733 --- /dev/null +++ b/tests/affine-cloud/copilot/package.json @@ -0,0 +1,14 @@ +{ + "name": "@affine-test/affine-cloud-copilot", + "private": true, + "scripts": { + "test:e2e": "yarn playwright test" + }, + "devDependencies": { + "@affine-test/kit": "workspace:*", + "@affine/server": "workspace:*", + "@playwright/test": "=1.48.2", + "ava": "^6.1.2" + }, + "version": "0.17.0" +} diff --git a/tests/affine-cloud-copilot/playwright.config.ts b/tests/affine-cloud/copilot/playwright.config.ts similarity index 98% rename from tests/affine-cloud-copilot/playwright.config.ts rename to tests/affine-cloud/copilot/playwright.config.ts index 712274c68b493..78a3323d6661d 100644 --- a/tests/affine-cloud-copilot/playwright.config.ts +++ b/tests/affine-cloud/copilot/playwright.config.ts @@ -6,6 +6,7 @@ import type { const config: PlaywrightTestConfig = { testDir: './e2e', + testMatch: '**/*.spec.ts', fullyParallel: !process.env.CI, timeout: 120_000, outputDir: testResultDir, diff --git a/tests/affine-cloud/copilot/tsconfig.json b/tests/affine-cloud/copilot/tsconfig.json new file mode 100644 index 0000000000000..3c5d0565c01b0 --- /dev/null +++ b/tests/affine-cloud/copilot/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "esModuleInterop": true, + "outDir": "lib" + }, + "include": ["e2e"], + "references": [ + { + "path": "../../../tests/kit" + }, + { + "path": "../../../tests/fixtures" + } + ] +} diff --git a/tsconfig.json b/tsconfig.json index d5872013e8f85..9f15c9506d29c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -158,7 +158,10 @@ "path": "./tests/affine-legacy/0.8.0-canary.7" }, { - "path": "./tests/affine-cloud" + "path": "./tests/affine-cloud/cloud" + }, + { + "path": "./tests/affine-cloud/copilot" }, { "path": "./tests/affine-desktop" diff --git a/yarn.lock b/yarn.lock index 0cd5284165d4a..e5b58be90e277 100644 --- a/yarn.lock +++ b/yarn.lock @@ -67,26 +67,6 @@ __metadata: languageName: unknown linkType: soft -"@affine-test/affine-cloud-copilot@workspace:tests/affine-cloud-copilot": - version: 0.0.0-use.local - resolution: "@affine-test/affine-cloud-copilot@workspace:tests/affine-cloud-copilot" - dependencies: - "@affine-test/kit": "workspace:*" - "@affine/server": "workspace:*" - "@playwright/test": "npm:=1.48.2" - ava: "npm:^6.1.2" - languageName: unknown - linkType: soft - -"@affine-test/affine-cloud@workspace:tests/affine-cloud": - version: 0.0.0-use.local - resolution: "@affine-test/affine-cloud@workspace:tests/affine-cloud" - dependencies: - "@affine-test/kit": "workspace:*" - "@playwright/test": "npm:=1.48.2" - languageName: unknown - linkType: soft - "@affine-test/affine-desktop-cloud@workspace:tests/affine-desktop-cloud": version: 0.0.0-use.local resolution: "@affine-test/affine-desktop-cloud@workspace:tests/affine-desktop-cloud" @@ -750,7 +730,7 @@ __metadata: languageName: unknown linkType: soft -"@affine/server@workspace:*, @affine/server@workspace:packages/backend/server": +"@affine/server@workspace:packages/backend/server": version: 0.0.0-use.local resolution: "@affine/server@workspace:packages/backend/server" dependencies: