@tachybase/test 1.3.52 → 1.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/e2e/index.mjs +2 -1
- package/es/index.mjs +3 -2
- package/lib/e2e/e2eUtils.js +2 -1
- package/lib/scripts/test-db-creator.js +16 -15
- package/lib/scripts/test-db-distributor.js +9 -8
- package/lib/server/index.js +3 -2
- package/package.json +18 -17
- package/setup/server.ts +10 -0
- package/setup/settings.postgres.js +293 -0
- package/setup/settings.sqlite.js +293 -0
- package/vitest.ts +118 -0
- package/vitest.d.ts +0 -24
- package/vitest.mjs +0 -119
package/es/e2e/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import TachybaseGlobal from "@tachybase/globals";
|
|
1
2
|
import { uid } from "@tachybase/schema";
|
|
2
3
|
import "@faker-js/faker";
|
|
3
4
|
import { defineConfig as defineConfig$1, devices, test as test$2, request, expect } from "@playwright/test";
|
|
@@ -261,7 +262,7 @@ const _test = test$2.extend({
|
|
|
261
262
|
});
|
|
262
263
|
const test = Object.assign(_test, {
|
|
263
264
|
/** 只运行在 postgres 数据库中 */
|
|
264
|
-
pgOnly:
|
|
265
|
+
pgOnly: TachybaseGlobal.settings.database.dialect === "postgres" ? _test : _test.skip
|
|
265
266
|
});
|
|
266
267
|
const getStorageItem = (key, storageState) => {
|
|
267
268
|
var _a, _b;
|
package/es/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import TachybaseGlobal from "@tachybase/globals";
|
|
1
2
|
import { describe } from "vitest";
|
|
2
3
|
import ws from "ws";
|
|
3
4
|
import { mockDatabase } from "@tachybase/database";
|
|
@@ -161,8 +162,8 @@ async function createMockServer(options = {}) {
|
|
|
161
162
|
}
|
|
162
163
|
return app;
|
|
163
164
|
}
|
|
164
|
-
const pgOnly = () =>
|
|
165
|
-
const isPg = () =>
|
|
165
|
+
const pgOnly = () => TachybaseGlobal.settings.database.dialect === "postgres" ? describe : describe.skip;
|
|
166
|
+
const isPg = () => TachybaseGlobal.settings.database.dialect === "postgres";
|
|
166
167
|
function randomStr() {
|
|
167
168
|
return Math.random().toString(36).substring(2);
|
|
168
169
|
}
|
package/lib/e2e/e2eUtils.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(e2eUtils_exports, {
|
|
|
38
38
|
test: () => test
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(e2eUtils_exports);
|
|
41
|
+
var import_globals = __toESM(require("@tachybase/globals"));
|
|
41
42
|
var import_schema = require("@tachybase/schema");
|
|
42
43
|
var import_faker = require("@faker-js/faker");
|
|
43
44
|
var import_test = require("@playwright/test");
|
|
@@ -254,7 +255,7 @@ const _test = import_test.test.extend({
|
|
|
254
255
|
});
|
|
255
256
|
const test = Object.assign(_test, {
|
|
256
257
|
/** 只运行在 postgres 数据库中 */
|
|
257
|
-
pgOnly:
|
|
258
|
+
pgOnly: import_globals.default.settings.database.dialect === "postgres" ? _test : _test.skip
|
|
258
259
|
});
|
|
259
260
|
const getStorageItem = /* @__PURE__ */ __name((key, storageState) => {
|
|
260
261
|
var _a, _b;
|
|
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var import_node_http = __toESM(require("node:http"));
|
|
25
25
|
var import_node_path = __toESM(require("node:path"));
|
|
26
26
|
var import_node_url = __toESM(require("node:url"));
|
|
27
|
+
var import_globals = __toESM(require("@tachybase/globals"));
|
|
27
28
|
var import_dotenv = __toESM(require("dotenv"));
|
|
28
29
|
var import_mariadb = __toESM(require("mariadb"));
|
|
29
30
|
var import_promise = __toESM(require("mysql2/promise"));
|
|
@@ -68,11 +69,11 @@ const _PostgresClient = class _PostgresClient extends BaseClient {
|
|
|
68
69
|
}
|
|
69
70
|
async _createConnection() {
|
|
70
71
|
const client2 = new import_pg.default.Client({
|
|
71
|
-
host:
|
|
72
|
-
port:
|
|
73
|
-
user:
|
|
74
|
-
password:
|
|
75
|
-
database:
|
|
72
|
+
host: import_globals.default.settings.database.host,
|
|
73
|
+
port: import_globals.default.settings.database.port,
|
|
74
|
+
user: import_globals.default.settings.database.user,
|
|
75
|
+
password: import_globals.default.settings.database.password,
|
|
76
|
+
database: import_globals.default.settings.database.database
|
|
76
77
|
});
|
|
77
78
|
await client2.connect();
|
|
78
79
|
return client2;
|
|
@@ -89,11 +90,11 @@ const _MySQLClient = class _MySQLClient extends BaseClient {
|
|
|
89
90
|
}
|
|
90
91
|
async _createConnection() {
|
|
91
92
|
return import_promise.default.createConnection({
|
|
92
|
-
host:
|
|
93
|
-
port:
|
|
94
|
-
user:
|
|
95
|
-
password:
|
|
96
|
-
database:
|
|
93
|
+
host: import_globals.default.settings.database.host,
|
|
94
|
+
port: import_globals.default.settings.database.port,
|
|
95
|
+
user: import_globals.default.settings.database.user,
|
|
96
|
+
password: import_globals.default.settings.database.password,
|
|
97
|
+
database: import_globals.default.settings.database.database
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
};
|
|
@@ -108,11 +109,11 @@ const _MariaDBClient = class _MariaDBClient extends BaseClient {
|
|
|
108
109
|
}
|
|
109
110
|
async _createConnection() {
|
|
110
111
|
return await import_mariadb.default.createConnection({
|
|
111
|
-
host:
|
|
112
|
-
port:
|
|
113
|
-
user:
|
|
114
|
-
password:
|
|
115
|
-
database:
|
|
112
|
+
host: import_globals.default.settings.database.host,
|
|
113
|
+
port: import_globals.default.settings.database.port,
|
|
114
|
+
user: import_globals.default.settings.database.user,
|
|
115
|
+
password: import_globals.default.settings.database.password,
|
|
116
|
+
database: import_globals.default.settings.database.database
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
119
|
};
|
|
@@ -25,6 +25,7 @@ var import_node_fs = __toESM(require("node:fs"));
|
|
|
25
25
|
var import_node_http = __toESM(require("node:http"));
|
|
26
26
|
var import_node_path = __toESM(require("node:path"));
|
|
27
27
|
var import_node_url = __toESM(require("node:url"));
|
|
28
|
+
var import_globals = __toESM(require("@tachybase/globals"));
|
|
28
29
|
var import_dotenv = __toESM(require("dotenv"));
|
|
29
30
|
var import_pg = __toESM(require("pg"));
|
|
30
31
|
import_dotenv.default.config({ path: import_node_path.default.resolve(process.cwd(), ".env.test") });
|
|
@@ -149,14 +150,14 @@ const _PostgresPool = class _PostgresPool extends BasePool {
|
|
|
149
150
|
}
|
|
150
151
|
getDatabaseConfiguration() {
|
|
151
152
|
return {
|
|
152
|
-
host:
|
|
153
|
-
port:
|
|
154
|
-
username:
|
|
155
|
-
password:
|
|
153
|
+
host: import_globals.default.settings.database.host,
|
|
154
|
+
port: import_globals.default.settings.database.port,
|
|
155
|
+
username: import_globals.default.settings.database.user,
|
|
156
|
+
password: import_globals.default.settings.database.password
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
159
|
getConfiguredDatabaseName() {
|
|
159
|
-
return
|
|
160
|
+
return import_globals.default.settings.database.database;
|
|
160
161
|
}
|
|
161
162
|
};
|
|
162
163
|
__name(_PostgresPool, "PostgresPool");
|
|
@@ -170,17 +171,17 @@ const _SqlitePool = class _SqlitePool extends BasePool {
|
|
|
170
171
|
}
|
|
171
172
|
getDatabaseConfiguration() {
|
|
172
173
|
return {
|
|
173
|
-
storage:
|
|
174
|
+
storage: import_globals.default.settings.database.storage
|
|
174
175
|
};
|
|
175
176
|
}
|
|
176
177
|
getConfiguredDatabaseName() {
|
|
177
|
-
const storagePath =
|
|
178
|
+
const storagePath = import_globals.default.settings.database.storage;
|
|
178
179
|
if (storagePath && storagePath !== ":memory:") {
|
|
179
180
|
return import_node_path.default.basename(storagePath);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
getStoragePath() {
|
|
183
|
-
const storagePath =
|
|
184
|
+
const storagePath = import_globals.default.settings.database.storage;
|
|
184
185
|
if (storagePath && storagePath !== ":memory:") {
|
|
185
186
|
return import_node_path.default.dirname(storagePath);
|
|
186
187
|
}
|
package/lib/server/index.js
CHANGED
|
@@ -39,13 +39,14 @@ __export(server_exports, {
|
|
|
39
39
|
waitSecond: () => waitSecond
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(server_exports);
|
|
42
|
+
var import_globals = __toESM(require("@tachybase/globals"));
|
|
42
43
|
var import_vitest = require("vitest");
|
|
43
44
|
var import_ws = __toESM(require("ws"));
|
|
44
45
|
var import_database = require("@tachybase/database");
|
|
45
46
|
var import_supertest = __toESM(require("supertest"));
|
|
46
47
|
__reExport(server_exports, require("./mockServer"), module.exports);
|
|
47
|
-
const pgOnly = /* @__PURE__ */ __name(() =>
|
|
48
|
-
const isPg = /* @__PURE__ */ __name(() =>
|
|
48
|
+
const pgOnly = /* @__PURE__ */ __name(() => import_globals.default.settings.database.dialect === "postgres" ? import_vitest.describe : import_vitest.describe.skip, "pgOnly");
|
|
49
|
+
const isPg = /* @__PURE__ */ __name(() => import_globals.default.settings.database.dialect === "postgres", "isPg");
|
|
49
50
|
function randomStr() {
|
|
50
51
|
return Math.random().toString(36).substring(2);
|
|
51
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/test",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.53",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -34,38 +34,39 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"./package.json": "./package.json",
|
|
37
|
-
"./vitest
|
|
37
|
+
"./vitest": "./vitest.ts"
|
|
38
38
|
},
|
|
39
39
|
"main": "lib/index.js",
|
|
40
40
|
"module": "./src/index.ts",
|
|
41
41
|
"types": "./lib/index.d.ts",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@faker-js/faker": "9.9.0",
|
|
44
|
-
"@playwright/test": "^1.
|
|
45
|
-
"@testing-library/dom": "^10.4.
|
|
46
|
-
"@testing-library/jest-dom": "^6.
|
|
47
|
-
"@testing-library/react": "^16.
|
|
44
|
+
"@playwright/test": "^1.55.0",
|
|
45
|
+
"@testing-library/dom": "^10.4.1",
|
|
46
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
47
|
+
"@testing-library/react": "^16.3.0",
|
|
48
48
|
"@testing-library/user-event": "^14.6.1",
|
|
49
|
-
"@types/supertest": "^
|
|
50
|
-
"@vitejs/plugin-react": "^
|
|
49
|
+
"@types/supertest": "^6.0.3",
|
|
50
|
+
"@vitejs/plugin-react": "^5.0.2",
|
|
51
51
|
"dotenv": "16.6.1",
|
|
52
|
-
"jsdom": "^
|
|
52
|
+
"jsdom": "^27.0.0",
|
|
53
53
|
"jsdom-worker": "^0.3.0",
|
|
54
54
|
"jsonwebtoken": "^8.5.1",
|
|
55
55
|
"lodash": "4.17.21",
|
|
56
|
-
"mariadb": "^
|
|
56
|
+
"mariadb": "^3.4.5",
|
|
57
57
|
"mockjs": "^1.1.0",
|
|
58
|
-
"mysql2": "^3.14.
|
|
58
|
+
"mysql2": "^3.14.4",
|
|
59
59
|
"pg": "^8.16.3",
|
|
60
60
|
"pg-hstore": "^2.3.4",
|
|
61
61
|
"qs": "^6.14.0",
|
|
62
62
|
"sqlite3": "^5.1.7",
|
|
63
|
-
"supertest": "^7.1.
|
|
64
|
-
"vite": "^
|
|
63
|
+
"supertest": "^7.1.4",
|
|
64
|
+
"vite": "^7.1.10",
|
|
65
65
|
"vitest": "^3.2.4",
|
|
66
|
-
"ws": "^8.18.
|
|
67
|
-
"@tachybase/database": "1.3.
|
|
68
|
-
"@tachybase/
|
|
69
|
-
"@
|
|
66
|
+
"ws": "^8.18.3",
|
|
67
|
+
"@tachybase/database": "1.3.53",
|
|
68
|
+
"@tachybase/globals": "1.3.53",
|
|
69
|
+
"@tachybase/schema": "1.3.53",
|
|
70
|
+
"@tego/core": "1.3.53"
|
|
70
71
|
}
|
|
71
72
|
}
|
package/setup/server.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import TachybaseGlobal from '@tachybase/globals';
|
|
1
4
|
import { initEnv } from '@tego/devkit';
|
|
2
5
|
|
|
6
|
+
import settings from './settings.sqlite';
|
|
7
|
+
|
|
8
|
+
TachybaseGlobal.settings = settings;
|
|
9
|
+
// process.env.DB_TEST_DISTRIBUTOR_PORT = '23450';
|
|
10
|
+
// process.env.DB_TEST_PREFIX = 'test';
|
|
11
|
+
process.env.TEGO_RUNTIME_HOME = path.join(os.tmpdir(), 'test-sqlite');
|
|
12
|
+
|
|
3
13
|
process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || '.env.test';
|
|
4
14
|
|
|
5
15
|
initEnv();
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/** @type {import('@tachybase/globals').Settings} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
/**
|
|
4
|
+
* 如果对应的环境变量没设置,则使用这里面的值,如果有设置,不用这里的值
|
|
5
|
+
*/
|
|
6
|
+
env: {
|
|
7
|
+
APP_ENV: 'development',
|
|
8
|
+
APP_PORT: 3000,
|
|
9
|
+
APP_KEY: 'test-key',
|
|
10
|
+
API_BASE_PATH: '/api/',
|
|
11
|
+
INIT_APP_LANG: 'en-US',
|
|
12
|
+
INIT_ROOT_EMAIL: 'admin@tachybase.com',
|
|
13
|
+
INIT_ROOT_USERNAME: 'tego',
|
|
14
|
+
INIT_ROOT_PASSWORD: 'tego',
|
|
15
|
+
INIT_ROOT_NICKNAME: 'Admin',
|
|
16
|
+
PLUGIN_STORAGE_PATH: 'storage/plugins',
|
|
17
|
+
WS_PATH: '/ws',
|
|
18
|
+
SOCKET_PATH: 'storage/gateway.sock',
|
|
19
|
+
PLUGIN_PACKAGE_PREFIX: '@tachybase/plugin-,@tachybase/module-',
|
|
20
|
+
SERVER_TSCONFIG_PATH: './tsconfig.server.json',
|
|
21
|
+
PLAYWRIGHT_AUTH_FILE: 'storage/playwright/.auth/admin.json',
|
|
22
|
+
PLUGIN_STATICS_PATH: '/static/plugins/',
|
|
23
|
+
APP_SERVER_BASE_URL: '',
|
|
24
|
+
APP_PUBLIC_PATH: '/',
|
|
25
|
+
// 开发环境测试locale 强制使用 cache
|
|
26
|
+
// FORCE_LOCALE_CACHE: '1',
|
|
27
|
+
},
|
|
28
|
+
logger: {
|
|
29
|
+
/**
|
|
30
|
+
* console | file | dailyRotateFile
|
|
31
|
+
*/
|
|
32
|
+
transport: ['console', 'dailyRotateFile'],
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
basePath: 'storage/logs',
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* error | warn | info | debug
|
|
41
|
+
*/
|
|
42
|
+
level: 'error',
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* If LOGGER_TRANSPORT is dailyRotateFile and using days, add 'd' as the suffix.
|
|
46
|
+
*/
|
|
47
|
+
// maxFiles: '14d',
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* add 'k', 'm', 'g' as the suffix.
|
|
51
|
+
*/
|
|
52
|
+
// maxSize: '10m',
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* json | splitter, split by '|' character
|
|
56
|
+
*/
|
|
57
|
+
// format: '',
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
database: {
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
dialect: 'postgres',
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
// storage: 'storage/db/tego.sqlite',
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
// tablePrefix: ''
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
host: 'localhost',
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
port: 5432,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
database: 'postgres',
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
user: 'tachybase',
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
password: 'tachybase',
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
// logging: true,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
underscored: false,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* mysql/postgres
|
|
113
|
+
*/
|
|
114
|
+
timezone: '+00:00',
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* ssl config
|
|
118
|
+
*/
|
|
119
|
+
ssl: {
|
|
120
|
+
// ca: '',
|
|
121
|
+
// key: '',
|
|
122
|
+
// cert: '',
|
|
123
|
+
// rejectUnauthorized: true,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
cache: {
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
defaultStore: 'memory',
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* max number of items in memory cache
|
|
135
|
+
*/
|
|
136
|
+
memoryMax: 2000,
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
// redisUrl: ''
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
encryptionField: {
|
|
145
|
+
/**
|
|
146
|
+
*
|
|
147
|
+
*/
|
|
148
|
+
// key: '',
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
presets: {
|
|
152
|
+
/**
|
|
153
|
+
* 默认启用,并且不可删除
|
|
154
|
+
*/
|
|
155
|
+
builtinPlugins: [
|
|
156
|
+
'acl',
|
|
157
|
+
'app-info',
|
|
158
|
+
'auth',
|
|
159
|
+
'backup',
|
|
160
|
+
'cloud-component',
|
|
161
|
+
'collection',
|
|
162
|
+
'cron',
|
|
163
|
+
'data-source',
|
|
164
|
+
'error-handler',
|
|
165
|
+
'event-source',
|
|
166
|
+
'file',
|
|
167
|
+
'workflow',
|
|
168
|
+
'message',
|
|
169
|
+
'pdf',
|
|
170
|
+
'ui-schema',
|
|
171
|
+
'user',
|
|
172
|
+
'web',
|
|
173
|
+
'worker-thread',
|
|
174
|
+
'env-secrets',
|
|
175
|
+
],
|
|
176
|
+
/**
|
|
177
|
+
* 可删除
|
|
178
|
+
*/
|
|
179
|
+
externalPlugins: [
|
|
180
|
+
{ name: 'action-bulk-edit', enabledByDefault: true },
|
|
181
|
+
{ name: 'action-bulk-update', enabledByDefault: true },
|
|
182
|
+
{ name: 'action-custom-request', enabledByDefault: true },
|
|
183
|
+
{ name: 'action-duplicate', enabledByDefault: true },
|
|
184
|
+
{ name: 'action-export', enabledByDefault: true },
|
|
185
|
+
{ name: 'action-import', enabledByDefault: true },
|
|
186
|
+
{ name: 'action-print', enabledByDefault: true },
|
|
187
|
+
{ name: 'block-calendar', enabledByDefault: true },
|
|
188
|
+
{ name: 'block-charts', enabledByDefault: true },
|
|
189
|
+
{ name: 'block-gantt', enabledByDefault: true },
|
|
190
|
+
{ name: 'block-kanban', enabledByDefault: true },
|
|
191
|
+
{ name: 'block-presentation', enabledByDefault: true },
|
|
192
|
+
{ name: 'field-china-region', enabledByDefault: true },
|
|
193
|
+
{ name: 'field-formula', enabledByDefault: true },
|
|
194
|
+
{ name: 'field-sequence', enabledByDefault: true },
|
|
195
|
+
{ name: 'field-encryption', enabledByDefault: true },
|
|
196
|
+
{ name: 'log-viewer', enabledByDefault: true },
|
|
197
|
+
{ name: 'otp', enabledByDefault: true },
|
|
198
|
+
{ name: 'instrumentation', enabledByDefault: true },
|
|
199
|
+
{ name: 'full-text-search', enabledByDefault: true },
|
|
200
|
+
{ name: 'password-policy', enabledByDefault: true },
|
|
201
|
+
{ name: 'auth-pages', enabledByDefault: true },
|
|
202
|
+
{ name: 'manual-notification', enabledByDefault: true },
|
|
203
|
+
{ name: 'auth-main-app', enabledByDefault: true },
|
|
204
|
+
|
|
205
|
+
{ name: 'adapter-bullmq', enabledByDefault: false },
|
|
206
|
+
{ name: 'adapter-red-node', enabledByDefault: false },
|
|
207
|
+
{ name: 'adapter-remix', enabledByDefault: false },
|
|
208
|
+
{ name: 'api-keys', enabledByDefault: false },
|
|
209
|
+
{ name: 'audit-logs', enabledByDefault: false },
|
|
210
|
+
{ name: 'auth-cas', enabledByDefault: false },
|
|
211
|
+
{ name: 'auth-dingtalk', enabledByDefault: false },
|
|
212
|
+
{ name: 'auth-lark', enabledByDefault: false },
|
|
213
|
+
{ name: 'auth-oidc', enabledByDefault: false },
|
|
214
|
+
{ name: 'auth-saml', enabledByDefault: false },
|
|
215
|
+
{ name: 'auth-sms', enabledByDefault: false },
|
|
216
|
+
{ name: 'auth-wechat', enabledByDefault: false },
|
|
217
|
+
{ name: 'auth-wecom', enabledByDefault: false },
|
|
218
|
+
{ name: 'block-comments', enabledByDefault: false },
|
|
219
|
+
{ name: 'block-map', enabledByDefault: false },
|
|
220
|
+
{ name: 'block-step-form', enabledByDefault: false },
|
|
221
|
+
{ name: 'data-source-common', enabledByDefault: false },
|
|
222
|
+
{ name: 'demos-game-runesweeper', enabledByDefault: false },
|
|
223
|
+
{ name: 'devtools', enabledByDefault: false },
|
|
224
|
+
{ name: 'field-markdown-vditor', enabledByDefault: false },
|
|
225
|
+
{ name: 'field-snapshot', enabledByDefault: false },
|
|
226
|
+
{ name: 'hera', enabledByDefault: false },
|
|
227
|
+
{ name: 'i18n-editor', enabledByDefault: false },
|
|
228
|
+
{ name: 'multi-app', enabledByDefault: false },
|
|
229
|
+
{ name: 'multi-app-share-collection', enabledByDefault: false },
|
|
230
|
+
{ name: 'online-user', enabledByDefault: false },
|
|
231
|
+
{ name: 'simple-cms', enabledByDefault: false },
|
|
232
|
+
{ name: 'sub-accounts', enabledByDefault: false },
|
|
233
|
+
{ name: 'theme-editor', enabledByDefault: false },
|
|
234
|
+
{ name: 'workflow-approval', enabledByDefault: false },
|
|
235
|
+
{ name: 'ai-chat', enabledByDefault: false },
|
|
236
|
+
{ name: 'department', enabledByDefault: false },
|
|
237
|
+
{ name: 'workflow-analysis', enabledByDefault: false },
|
|
238
|
+
{ name: 'api-logs', enabledByDefault: false },
|
|
239
|
+
{ name: 'ocr-convert', enabledByDefault: false },
|
|
240
|
+
{ name: 'text-copy', enabledByDefault: false },
|
|
241
|
+
{ name: 'user-manual-feishu', enabledByDefault: false },
|
|
242
|
+
{ name: 'form-design', enabledByDefault: false },
|
|
243
|
+
],
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
*/
|
|
248
|
+
runtimePlugins: [],
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
worker: {
|
|
252
|
+
/**
|
|
253
|
+
* -1 为不限制,自动设置为核心数量
|
|
254
|
+
* 0 禁用 worker
|
|
255
|
+
* 其他值为 worker 数量
|
|
256
|
+
*/
|
|
257
|
+
count: -1,
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* -1 为最大为核心数量
|
|
261
|
+
* 其他值为最大 worker 数量
|
|
262
|
+
*/
|
|
263
|
+
countMax: -1,
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 错误尝试次数
|
|
267
|
+
*/
|
|
268
|
+
// errorRetry: 3
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* MB
|
|
272
|
+
*/
|
|
273
|
+
// maxMemory: 4096
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* export config, max length of export data to use main thread and page size in worker thread
|
|
278
|
+
*/
|
|
279
|
+
export: {
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
*/
|
|
283
|
+
// lengthMax: 2000,
|
|
284
|
+
/**
|
|
285
|
+
*
|
|
286
|
+
*/
|
|
287
|
+
// workerPageSize: 1000
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
misc: {
|
|
291
|
+
forbidSubAppPlugins: ['multi-app', 'manual-notification', 'multi-app-share-collection'],
|
|
292
|
+
},
|
|
293
|
+
};
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/** @type {import('@tachybase/globals').Settings} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
/**
|
|
4
|
+
* 如果对应的环境变量没设置,则使用这里面的值,如果有设置,不用这里的值
|
|
5
|
+
*/
|
|
6
|
+
env: {
|
|
7
|
+
APP_ENV: 'development',
|
|
8
|
+
APP_PORT: 3000,
|
|
9
|
+
APP_KEY: 'test-key',
|
|
10
|
+
API_BASE_PATH: '/api/',
|
|
11
|
+
INIT_APP_LANG: 'en-US',
|
|
12
|
+
INIT_ROOT_EMAIL: 'admin@tachybase.com',
|
|
13
|
+
INIT_ROOT_USERNAME: 'tego',
|
|
14
|
+
INIT_ROOT_PASSWORD: 'tego',
|
|
15
|
+
INIT_ROOT_NICKNAME: 'Admin',
|
|
16
|
+
PLUGIN_STORAGE_PATH: 'storage/plugins',
|
|
17
|
+
WS_PATH: '/ws',
|
|
18
|
+
SOCKET_PATH: 'storage/gateway.sock',
|
|
19
|
+
PLUGIN_PACKAGE_PREFIX: '@tachybase/plugin-,@tachybase/module-',
|
|
20
|
+
SERVER_TSCONFIG_PATH: './tsconfig.server.json',
|
|
21
|
+
PLAYWRIGHT_AUTH_FILE: 'storage/playwright/.auth/admin.json',
|
|
22
|
+
PLUGIN_STATICS_PATH: '/static/plugins/',
|
|
23
|
+
APP_SERVER_BASE_URL: '',
|
|
24
|
+
APP_PUBLIC_PATH: '/',
|
|
25
|
+
// 开发环境测试locale 强制使用 cache
|
|
26
|
+
// FORCE_LOCALE_CACHE: '1',
|
|
27
|
+
},
|
|
28
|
+
logger: {
|
|
29
|
+
/**
|
|
30
|
+
* console | file | dailyRotateFile
|
|
31
|
+
*/
|
|
32
|
+
transport: ['console', 'dailyRotateFile'],
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
basePath: 'storage/logs',
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* error | warn | info | debug
|
|
41
|
+
*/
|
|
42
|
+
level: 'error',
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* If LOGGER_TRANSPORT is dailyRotateFile and using days, add 'd' as the suffix.
|
|
46
|
+
*/
|
|
47
|
+
// maxFiles: '14d',
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* add 'k', 'm', 'g' as the suffix.
|
|
51
|
+
*/
|
|
52
|
+
// maxSize: '10m',
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* json | splitter, split by '|' character
|
|
56
|
+
*/
|
|
57
|
+
// format: '',
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
database: {
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
dialect: 'sqlite',
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
storage: 'storage/db/tego.sqlite',
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
// tablePrefix: ''
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
// host: 'localhost',
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
// port: 5432,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
// database: 'postgres',
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
// user: 'tachybase',
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
// password: 'tachybase',
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
// logging: true,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
underscored: false,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* mysql/postgres
|
|
113
|
+
*/
|
|
114
|
+
// timezone: '+00:00',
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* ssl config
|
|
118
|
+
*/
|
|
119
|
+
ssl: {
|
|
120
|
+
// ca: '',
|
|
121
|
+
// key: '',
|
|
122
|
+
// cert: '',
|
|
123
|
+
// rejectUnauthorized: true,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
cache: {
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
defaultStore: 'memory',
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* max number of items in memory cache
|
|
135
|
+
*/
|
|
136
|
+
memoryMax: 2000,
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
// redisUrl: ''
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
encryptionField: {
|
|
145
|
+
/**
|
|
146
|
+
*
|
|
147
|
+
*/
|
|
148
|
+
// key: '',
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
presets: {
|
|
152
|
+
/**
|
|
153
|
+
* 默认启用,并且不可删除
|
|
154
|
+
*/
|
|
155
|
+
builtinPlugins: [
|
|
156
|
+
'acl',
|
|
157
|
+
'app-info',
|
|
158
|
+
'auth',
|
|
159
|
+
'backup',
|
|
160
|
+
'cloud-component',
|
|
161
|
+
'collection',
|
|
162
|
+
'cron',
|
|
163
|
+
'data-source',
|
|
164
|
+
'error-handler',
|
|
165
|
+
'event-source',
|
|
166
|
+
'file',
|
|
167
|
+
'workflow',
|
|
168
|
+
'message',
|
|
169
|
+
'pdf',
|
|
170
|
+
'ui-schema',
|
|
171
|
+
'user',
|
|
172
|
+
'web',
|
|
173
|
+
'worker-thread',
|
|
174
|
+
'env-secrets',
|
|
175
|
+
],
|
|
176
|
+
/**
|
|
177
|
+
* 可删除
|
|
178
|
+
*/
|
|
179
|
+
externalPlugins: [
|
|
180
|
+
{ name: 'action-bulk-edit', enabledByDefault: true },
|
|
181
|
+
{ name: 'action-bulk-update', enabledByDefault: true },
|
|
182
|
+
{ name: 'action-custom-request', enabledByDefault: true },
|
|
183
|
+
{ name: 'action-duplicate', enabledByDefault: true },
|
|
184
|
+
{ name: 'action-export', enabledByDefault: true },
|
|
185
|
+
{ name: 'action-import', enabledByDefault: true },
|
|
186
|
+
{ name: 'action-print', enabledByDefault: true },
|
|
187
|
+
{ name: 'block-calendar', enabledByDefault: true },
|
|
188
|
+
{ name: 'block-charts', enabledByDefault: true },
|
|
189
|
+
{ name: 'block-gantt', enabledByDefault: true },
|
|
190
|
+
{ name: 'block-kanban', enabledByDefault: true },
|
|
191
|
+
{ name: 'block-presentation', enabledByDefault: true },
|
|
192
|
+
{ name: 'field-china-region', enabledByDefault: true },
|
|
193
|
+
{ name: 'field-formula', enabledByDefault: true },
|
|
194
|
+
{ name: 'field-sequence', enabledByDefault: true },
|
|
195
|
+
{ name: 'field-encryption', enabledByDefault: true },
|
|
196
|
+
{ name: 'log-viewer', enabledByDefault: true },
|
|
197
|
+
{ name: 'otp', enabledByDefault: true },
|
|
198
|
+
{ name: 'instrumentation', enabledByDefault: true },
|
|
199
|
+
{ name: 'full-text-search', enabledByDefault: true },
|
|
200
|
+
{ name: 'password-policy', enabledByDefault: true },
|
|
201
|
+
{ name: 'auth-pages', enabledByDefault: true },
|
|
202
|
+
{ name: 'manual-notification', enabledByDefault: true },
|
|
203
|
+
{ name: 'auth-main-app', enabledByDefault: true },
|
|
204
|
+
|
|
205
|
+
{ name: 'adapter-bullmq', enabledByDefault: false },
|
|
206
|
+
{ name: 'adapter-red-node', enabledByDefault: false },
|
|
207
|
+
{ name: 'adapter-remix', enabledByDefault: false },
|
|
208
|
+
{ name: 'api-keys', enabledByDefault: false },
|
|
209
|
+
{ name: 'audit-logs', enabledByDefault: false },
|
|
210
|
+
{ name: 'auth-cas', enabledByDefault: false },
|
|
211
|
+
{ name: 'auth-dingtalk', enabledByDefault: false },
|
|
212
|
+
{ name: 'auth-lark', enabledByDefault: false },
|
|
213
|
+
{ name: 'auth-oidc', enabledByDefault: false },
|
|
214
|
+
{ name: 'auth-saml', enabledByDefault: false },
|
|
215
|
+
{ name: 'auth-sms', enabledByDefault: false },
|
|
216
|
+
{ name: 'auth-wechat', enabledByDefault: false },
|
|
217
|
+
{ name: 'auth-wecom', enabledByDefault: false },
|
|
218
|
+
{ name: 'block-comments', enabledByDefault: false },
|
|
219
|
+
{ name: 'block-map', enabledByDefault: false },
|
|
220
|
+
{ name: 'block-step-form', enabledByDefault: false },
|
|
221
|
+
{ name: 'data-source-common', enabledByDefault: false },
|
|
222
|
+
{ name: 'demos-game-runesweeper', enabledByDefault: false },
|
|
223
|
+
{ name: 'devtools', enabledByDefault: false },
|
|
224
|
+
{ name: 'field-markdown-vditor', enabledByDefault: false },
|
|
225
|
+
{ name: 'field-snapshot', enabledByDefault: false },
|
|
226
|
+
{ name: 'hera', enabledByDefault: false },
|
|
227
|
+
{ name: 'i18n-editor', enabledByDefault: false },
|
|
228
|
+
{ name: 'multi-app', enabledByDefault: false },
|
|
229
|
+
{ name: 'multi-app-share-collection', enabledByDefault: false },
|
|
230
|
+
{ name: 'online-user', enabledByDefault: false },
|
|
231
|
+
{ name: 'simple-cms', enabledByDefault: false },
|
|
232
|
+
{ name: 'sub-accounts', enabledByDefault: false },
|
|
233
|
+
{ name: 'theme-editor', enabledByDefault: false },
|
|
234
|
+
{ name: 'workflow-approval', enabledByDefault: false },
|
|
235
|
+
{ name: 'ai-chat', enabledByDefault: false },
|
|
236
|
+
{ name: 'department', enabledByDefault: false },
|
|
237
|
+
{ name: 'workflow-analysis', enabledByDefault: false },
|
|
238
|
+
{ name: 'api-logs', enabledByDefault: false },
|
|
239
|
+
{ name: 'ocr-convert', enabledByDefault: false },
|
|
240
|
+
{ name: 'text-copy', enabledByDefault: false },
|
|
241
|
+
{ name: 'user-manual-feishu', enabledByDefault: false },
|
|
242
|
+
{ name: 'form-design', enabledByDefault: false },
|
|
243
|
+
],
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
*/
|
|
248
|
+
runtimePlugins: [],
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
worker: {
|
|
252
|
+
/**
|
|
253
|
+
* -1 为不限制,自动设置为核心数量
|
|
254
|
+
* 0 禁用 worker
|
|
255
|
+
* 其他值为 worker 数量
|
|
256
|
+
*/
|
|
257
|
+
count: -1,
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* -1 为最大为核心数量
|
|
261
|
+
* 其他值为最大 worker 数量
|
|
262
|
+
*/
|
|
263
|
+
countMax: -1,
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 错误尝试次数
|
|
267
|
+
*/
|
|
268
|
+
// errorRetry: 3
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* MB
|
|
272
|
+
*/
|
|
273
|
+
// maxMemory: 4096
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* export config, max length of export data to use main thread and page size in worker thread
|
|
278
|
+
*/
|
|
279
|
+
export: {
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
*/
|
|
283
|
+
// lengthMax: 2000,
|
|
284
|
+
/**
|
|
285
|
+
*
|
|
286
|
+
*/
|
|
287
|
+
// workerPageSize: 1000
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
misc: {
|
|
291
|
+
forbidSubAppPlugins: ['multi-app', 'manual-notification', 'multi-app-share-collection'],
|
|
292
|
+
},
|
|
293
|
+
};
|
package/vitest.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path, { resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
import { defineConfig } from 'vitest/config';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
const relativePathToAbsolute = (relativePath) => {
|
|
11
|
+
return path.resolve(process.cwd(), relativePath);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function tsConfigPathsToAlias() {
|
|
15
|
+
const json = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './tsconfig.paths.json'), { encoding: 'utf8' }));
|
|
16
|
+
const paths = json.compilerOptions.paths;
|
|
17
|
+
const alias = Object.keys(paths).reduce((acc, key) => {
|
|
18
|
+
if (key !== '@@/*') {
|
|
19
|
+
const value = paths[key][0];
|
|
20
|
+
acc.push({
|
|
21
|
+
find: key,
|
|
22
|
+
replacement: value,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return acc;
|
|
26
|
+
}, []);
|
|
27
|
+
alias.unshift(
|
|
28
|
+
{
|
|
29
|
+
find: '@tachybase/utils/plugin-symlink',
|
|
30
|
+
replacement: 'node_modules/@tachybase/utils/plugin-symlink.js',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
find: '@opentelemetry/resources',
|
|
34
|
+
replacement: 'node_modules/@opentelemetry/resources/build/src/index.js',
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
return [
|
|
38
|
+
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
|
39
|
+
...alias.map((item) => {
|
|
40
|
+
return {
|
|
41
|
+
...item,
|
|
42
|
+
replacement: relativePathToAbsolute(item.replacement),
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default defineConfig({
|
|
49
|
+
test: {
|
|
50
|
+
coverage: {
|
|
51
|
+
provider: 'v8',
|
|
52
|
+
// you can include other reporters, but 'json-summary' is required, json is recommended
|
|
53
|
+
reporter: ['text', 'json-summary', 'json'],
|
|
54
|
+
// If you want a coverage reports even if your tests are failing, include the reportOnFailure option
|
|
55
|
+
reportOnFailure: true,
|
|
56
|
+
thresholds: {
|
|
57
|
+
lines: 60,
|
|
58
|
+
branches: 60,
|
|
59
|
+
functions: 80,
|
|
60
|
+
statements: 80,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
silent: !!process.env.GITHUB_ACTIONS,
|
|
64
|
+
globals: true,
|
|
65
|
+
alias: tsConfigPathsToAlias(),
|
|
66
|
+
projects: [
|
|
67
|
+
{
|
|
68
|
+
root: process.cwd(),
|
|
69
|
+
resolve: {
|
|
70
|
+
mainFields: ['module'],
|
|
71
|
+
},
|
|
72
|
+
extends: true,
|
|
73
|
+
test: {
|
|
74
|
+
setupFiles: resolve(__dirname, './setup/server.ts'),
|
|
75
|
+
include: ['packages/**/__tests__/**/*.test.ts', 'apps/**/__tests__/**/*.test.ts'],
|
|
76
|
+
exclude: [
|
|
77
|
+
'**/node_modules/**',
|
|
78
|
+
'**/dist/**',
|
|
79
|
+
'**/lib/**',
|
|
80
|
+
'**/es/**',
|
|
81
|
+
'**/e2e/**',
|
|
82
|
+
'**/__e2e__/**',
|
|
83
|
+
'**/{vitest,commitlint}.config.*',
|
|
84
|
+
'packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}',
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
plugins: [react()],
|
|
91
|
+
resolve: {
|
|
92
|
+
mainFields: ['module'],
|
|
93
|
+
},
|
|
94
|
+
define: {
|
|
95
|
+
'process.env.__TEST__': true,
|
|
96
|
+
'process.env.__E2E__': false,
|
|
97
|
+
},
|
|
98
|
+
test: {
|
|
99
|
+
globals: true,
|
|
100
|
+
setupFiles: resolve(__dirname, './setup/client.ts'),
|
|
101
|
+
environment: 'jsdom',
|
|
102
|
+
css: false,
|
|
103
|
+
alias: tsConfigPathsToAlias(),
|
|
104
|
+
include: ['packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
|
|
105
|
+
exclude: [
|
|
106
|
+
'**/node_modules/**',
|
|
107
|
+
'**/dist/**',
|
|
108
|
+
'**/lib/**',
|
|
109
|
+
'**/es/**',
|
|
110
|
+
'**/e2e/**',
|
|
111
|
+
'**/__e2e__/**',
|
|
112
|
+
'**/{vitest,commitlint}.config.*',
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
});
|
package/vitest.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type UserConfig } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
const suite: (typeof import('vitest'))['suite'];
|
|
5
|
-
const test: (typeof import('vitest'))['test'];
|
|
6
|
-
const describe: (typeof import('vitest'))['describe'];
|
|
7
|
-
const it: (typeof import('vitest'))['it'];
|
|
8
|
-
const expectTypeOf: (typeof import('vitest'))['expectTypeOf'];
|
|
9
|
-
const assertType: (typeof import('vitest'))['assertType'];
|
|
10
|
-
const expect: (typeof import('vitest'))['expect'];
|
|
11
|
-
const assert: (typeof import('vitest'))['assert'];
|
|
12
|
-
const vitest: (typeof import('vitest'))['vitest'];
|
|
13
|
-
const vi: (typeof import('vitest'))['vitest'];
|
|
14
|
-
const beforeAll: (typeof import('vitest'))['beforeAll'];
|
|
15
|
-
const afterAll: (typeof import('vitest'))['afterAll'];
|
|
16
|
-
const beforeEach: (typeof import('vitest'))['beforeEach'];
|
|
17
|
-
const afterEach: (typeof import('vitest'))['afterEach'];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export declare const defineConfig: (
|
|
21
|
-
config?: UserConfig & {
|
|
22
|
-
server: boolean;
|
|
23
|
-
},
|
|
24
|
-
) => UserConfig;
|
package/vitest.mjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path, { resolve } from 'node:path';
|
|
3
|
-
import { URL } from 'node:url';
|
|
4
|
-
|
|
5
|
-
import react from '@vitejs/plugin-react';
|
|
6
|
-
import { defineConfig as vitestConfig } from 'vitest/config';
|
|
7
|
-
|
|
8
|
-
const __dirname = new URL('.', import.meta.url).pathname;
|
|
9
|
-
|
|
10
|
-
const relativePathToAbsolute = (relativePath) => {
|
|
11
|
-
return path.resolve(process.cwd(), relativePath);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function tsConfigPathsToAlias() {
|
|
15
|
-
const json = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './tsconfig.paths.json'), { encoding: 'utf8' }));
|
|
16
|
-
const paths = json.compilerOptions.paths;
|
|
17
|
-
const alias = Object.keys(paths).reduce((acc, key) => {
|
|
18
|
-
if (key !== '@@/*') {
|
|
19
|
-
const value = paths[key][0];
|
|
20
|
-
acc.push({
|
|
21
|
-
find: key,
|
|
22
|
-
replacement: value,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return acc;
|
|
26
|
-
}, []);
|
|
27
|
-
alias.unshift(
|
|
28
|
-
{
|
|
29
|
-
find: '@tachybase/utils/plugin-symlink',
|
|
30
|
-
replacement: 'node_modules/@tachybase/utils/plugin-symlink.js',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
find: '@opentelemetry/resources',
|
|
34
|
-
replacement: 'node_modules/@opentelemetry/resources/build/src/index.js',
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
return [
|
|
38
|
-
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
|
39
|
-
...alias.map((item) => {
|
|
40
|
-
return {
|
|
41
|
-
...item,
|
|
42
|
-
replacement: relativePathToAbsolute(item.replacement),
|
|
43
|
-
};
|
|
44
|
-
}),
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const defineConfig = (config = {}) => {
|
|
49
|
-
return vitestConfig(
|
|
50
|
-
process.env.TEST_ENV === 'server-side'
|
|
51
|
-
? {
|
|
52
|
-
root: process.cwd(),
|
|
53
|
-
resolve: {
|
|
54
|
-
mainFields: ['module'],
|
|
55
|
-
},
|
|
56
|
-
test: {
|
|
57
|
-
globals: true,
|
|
58
|
-
setupFiles: resolve(__dirname, './setup/server.ts'),
|
|
59
|
-
alias: tsConfigPathsToAlias(),
|
|
60
|
-
include: ['packages/**/__tests__/**/*.test.ts', 'apps/**/__tests__/**/*.test.ts'],
|
|
61
|
-
exclude: [
|
|
62
|
-
'**/node_modules/**',
|
|
63
|
-
'**/dist/**',
|
|
64
|
-
'**/lib/**',
|
|
65
|
-
'**/es/**',
|
|
66
|
-
'**/e2e/**',
|
|
67
|
-
'**/__e2e__/**',
|
|
68
|
-
'**/{vitest,commitlint}.config.*',
|
|
69
|
-
'packages/**/{sdk,client,schema}/**/__tests__/**/*.{test,spec}.{ts,tsx}',
|
|
70
|
-
],
|
|
71
|
-
testTimeout: 300000,
|
|
72
|
-
hookTimeout: 300000,
|
|
73
|
-
// bail: 1,
|
|
74
|
-
// 在 GitHub Actions 中不输出日志
|
|
75
|
-
silent: !!process.env.GITHUB_ACTIONS,
|
|
76
|
-
// poolOptions: {
|
|
77
|
-
// threads: {
|
|
78
|
-
// singleThread: process.env.SINGLE_THREAD == 'false' ? false : true,
|
|
79
|
-
// },
|
|
80
|
-
// },
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
: {
|
|
84
|
-
plugins: [react()],
|
|
85
|
-
resolve: {
|
|
86
|
-
mainFields: ['module'],
|
|
87
|
-
},
|
|
88
|
-
define: {
|
|
89
|
-
'process.env.__TEST__': true,
|
|
90
|
-
'process.env.__E2E__': false,
|
|
91
|
-
},
|
|
92
|
-
test: {
|
|
93
|
-
globals: true,
|
|
94
|
-
setupFiles: resolve(__dirname, './setup/client.ts'),
|
|
95
|
-
environment: 'jsdom',
|
|
96
|
-
css: false,
|
|
97
|
-
alias: tsConfigPathsToAlias(),
|
|
98
|
-
include: ['packages/**/{sdk,client,schema}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
|
|
99
|
-
exclude: [
|
|
100
|
-
'**/node_modules/**',
|
|
101
|
-
'**/dist/**',
|
|
102
|
-
'**/lib/**',
|
|
103
|
-
'**/es/**',
|
|
104
|
-
'**/e2e/**',
|
|
105
|
-
'**/__e2e__/**',
|
|
106
|
-
'**/{vitest,commitlint}.config.*',
|
|
107
|
-
],
|
|
108
|
-
testTimeout: 300000,
|
|
109
|
-
// 在 GitHub Actions 中不输出日志
|
|
110
|
-
silent: !!process.env.GITHUB_ACTIONS,
|
|
111
|
-
server: {
|
|
112
|
-
deps: {
|
|
113
|
-
inline: ['@juggle/resize-observer', 'clsx'],
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
};
|