@tachybase/test 0.23.8
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/.turbo/turbo-build.log +24 -0
- package/LICENSE +201 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/e2e.d.ts +1 -0
- package/e2e.js +1 -0
- package/es/client/index.d.ts +7 -0
- package/es/client/index.mjs +20 -0
- package/es/e2e/defineConfig.d.ts +2 -0
- package/es/e2e/e2eUtils.d.ts +298 -0
- package/es/e2e/index.d.ts +3 -0
- package/es/e2e/index.mjs +20547 -0
- package/es/e2e/templatesOfCollection.d.ts +41 -0
- package/es/e2e/templatesOfPage.d.ts +573 -0
- package/es/index.d.ts +1 -0
- package/es/index.mjs +223 -0
- package/es/scripts/test-db-creator.d.ts +1 -0
- package/es/scripts/test-db-distributor.d.ts +1 -0
- package/es/server/index.d.ts +17 -0
- package/es/server/mockServer.d.ts +75 -0
- package/lib/client/index.d.ts +7 -0
- package/lib/client/index.js +59 -0
- package/lib/e2e/defineConfig.d.ts +2 -0
- package/lib/e2e/defineConfig.js +78 -0
- package/lib/e2e/e2eUtils.d.ts +298 -0
- package/lib/e2e/e2eUtils.js +633 -0
- package/lib/e2e/index.d.ts +3 -0
- package/lib/e2e/index.js +25 -0
- package/lib/e2e/templatesOfCollection.d.ts +41 -0
- package/lib/e2e/templatesOfCollection.js +720 -0
- package/lib/e2e/templatesOfPage.d.ts +573 -0
- package/lib/e2e/templatesOfPage.js +19345 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +21 -0
- package/lib/scripts/test-db-creator.d.ts +1 -0
- package/lib/scripts/test-db-creator.js +163 -0
- package/lib/scripts/test-db-distributor.d.ts +1 -0
- package/lib/scripts/test-db-distributor.js +234 -0
- package/lib/server/index.d.ts +17 -0
- package/lib/server/index.js +105 -0
- package/lib/server/mockServer.d.ts +75 -0
- package/lib/server/mockServer.js +209 -0
- package/package.json +74 -0
- package/playwright/tests/auth.setup.ts +21 -0
- package/server.d.ts +1 -0
- package/server.js +1 -0
- package/setup/client.ts +69 -0
- package/setup/server.ts +5 -0
- package/vitest.d.ts +24 -0
- package/vitest.mjs +119 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
import { defineConfig } from './defineConfig';
|
|
3
|
+
export * from '@playwright/test';
|
|
4
|
+
export { defineConfig };
|
|
5
|
+
export interface CollectionSetting {
|
|
6
|
+
name: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @default 'general'
|
|
10
|
+
*/
|
|
11
|
+
template?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
logging?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Generate ID field automatically
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
autoGenId?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Store the creation user of each record
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
createdBy?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Store the last update user of each record
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
updatedBy?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Store the creation time of each record
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
createdAt?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Store the last update time of each record
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
updatedAt?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Records can be sorted
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
sortable?: boolean | string;
|
|
46
|
+
/**
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
inherit?: boolean;
|
|
50
|
+
inherits?: string[];
|
|
51
|
+
category?: any[];
|
|
52
|
+
hidden?: boolean;
|
|
53
|
+
description?: string;
|
|
54
|
+
view?: boolean;
|
|
55
|
+
key?: string;
|
|
56
|
+
fields?: Array<{
|
|
57
|
+
interface: string;
|
|
58
|
+
type?: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
unique?: boolean;
|
|
61
|
+
uiSchema?: {
|
|
62
|
+
type?: string;
|
|
63
|
+
title?: string;
|
|
64
|
+
required?: boolean;
|
|
65
|
+
'x-component'?: string;
|
|
66
|
+
'x-read-pretty'?: boolean;
|
|
67
|
+
'x-validator'?: any;
|
|
68
|
+
'x-component-props'?: Record<string, any>;
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
};
|
|
71
|
+
field?: string;
|
|
72
|
+
target?: string;
|
|
73
|
+
targetKey?: string;
|
|
74
|
+
foreignKey?: string;
|
|
75
|
+
allowNull?: boolean;
|
|
76
|
+
autoIncrement?: boolean;
|
|
77
|
+
primaryKey?: boolean;
|
|
78
|
+
key?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
collectionName?: string;
|
|
81
|
+
parentKey?: any;
|
|
82
|
+
reverseKey?: any;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
interface AclActionsSetting {
|
|
87
|
+
name: string;
|
|
88
|
+
fields?: any[];
|
|
89
|
+
scope?: any;
|
|
90
|
+
}
|
|
91
|
+
interface AclResourcesSetting {
|
|
92
|
+
name: string;
|
|
93
|
+
usingActionsConfig: boolean;
|
|
94
|
+
actions?: AclActionsSetting[];
|
|
95
|
+
}
|
|
96
|
+
interface AclRoleSetting {
|
|
97
|
+
name?: string;
|
|
98
|
+
title?: string;
|
|
99
|
+
/**
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
allowNewMenu?: boolean;
|
|
103
|
+
snippets?: string[];
|
|
104
|
+
strategy?: any;
|
|
105
|
+
resources?: AclResourcesSetting[];
|
|
106
|
+
/**
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
default?: boolean;
|
|
110
|
+
key?: string;
|
|
111
|
+
menuUiSchemas?: string[];
|
|
112
|
+
dataSourceKey?: string;
|
|
113
|
+
}
|
|
114
|
+
interface DatabaseSetting {
|
|
115
|
+
database: string;
|
|
116
|
+
host: string;
|
|
117
|
+
port: string;
|
|
118
|
+
schema?: string;
|
|
119
|
+
username?: string;
|
|
120
|
+
password?: string;
|
|
121
|
+
}
|
|
122
|
+
interface DataSourceSetting {
|
|
123
|
+
key: string;
|
|
124
|
+
displayName: string;
|
|
125
|
+
type: string;
|
|
126
|
+
options: DatabaseSetting;
|
|
127
|
+
enabled?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface PageConfig {
|
|
130
|
+
/**
|
|
131
|
+
* 页面类型
|
|
132
|
+
* @default 'page'
|
|
133
|
+
*/
|
|
134
|
+
type?: 'submenu' | 'page' | 'link';
|
|
135
|
+
/**
|
|
136
|
+
* type 为 link 时,表示跳转的链接
|
|
137
|
+
*/
|
|
138
|
+
url?: string;
|
|
139
|
+
/**
|
|
140
|
+
* 用户可见的页面名称
|
|
141
|
+
* @default uid()
|
|
142
|
+
*/
|
|
143
|
+
name?: string;
|
|
144
|
+
/**
|
|
145
|
+
* 页面的基础路径
|
|
146
|
+
* @default '/admin/'
|
|
147
|
+
*/
|
|
148
|
+
basePath?: string;
|
|
149
|
+
/**
|
|
150
|
+
* 页面数据表的配置
|
|
151
|
+
* @default undefined
|
|
152
|
+
*/
|
|
153
|
+
collections?: CollectionSetting[];
|
|
154
|
+
/**
|
|
155
|
+
* 页面整体的 Schema
|
|
156
|
+
* @default undefined
|
|
157
|
+
*/
|
|
158
|
+
pageSchema?: any;
|
|
159
|
+
}
|
|
160
|
+
interface ExtendUtils {
|
|
161
|
+
/**
|
|
162
|
+
* 根据配置,生成一个 TachyBase 的页面
|
|
163
|
+
* @param pageConfig 页面配置
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
mockPage: (pageConfig?: PageConfig) => NocoPage;
|
|
167
|
+
/**
|
|
168
|
+
* 根据配置,生成一个需要手动销毁的 NocoPage 页面
|
|
169
|
+
* @param pageConfig
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
mockManualDestroyPage: (pageConfig?: PageConfig) => NocoPage;
|
|
173
|
+
/**
|
|
174
|
+
* 根据配置,生成多个 collections
|
|
175
|
+
* @param collectionSettings
|
|
176
|
+
* @returns 返回一个 destroy 方法,用于销毁创建的 collections
|
|
177
|
+
*/
|
|
178
|
+
mockCollections: (collectionSettings: CollectionSetting[]) => Promise<any>;
|
|
179
|
+
/**
|
|
180
|
+
* 根据配置,生成一个 collection
|
|
181
|
+
* @param collectionSetting
|
|
182
|
+
* @returns 返回一个 destroy 方法,用于销毁创建的 collection
|
|
183
|
+
*/
|
|
184
|
+
mockCollection: (collectionSetting: CollectionSetting) => Promise<any>;
|
|
185
|
+
/**
|
|
186
|
+
* 自动生成一条对应 collection 的数据
|
|
187
|
+
* @param collectionName 数据表名称
|
|
188
|
+
* @param data 自定义的数据,缺失时会生成随机数据
|
|
189
|
+
* @returns 返回一条生成的数据
|
|
190
|
+
*/
|
|
191
|
+
mockRecord: <T = any>(collectionName: string, data?: any) => Promise<T>;
|
|
192
|
+
/**
|
|
193
|
+
* 自动生成多条对应 collection 的数据
|
|
194
|
+
*/
|
|
195
|
+
mockRecords: {
|
|
196
|
+
/**
|
|
197
|
+
* @param collectionName - 数据表名称
|
|
198
|
+
* @param count - 生成的数据条数
|
|
199
|
+
*/
|
|
200
|
+
<T = any>(collectionName: string, count?: number): Promise<T[]>;
|
|
201
|
+
/**
|
|
202
|
+
* @param collectionName - 数据表名称
|
|
203
|
+
* @param data - 指定生成的数据
|
|
204
|
+
*/
|
|
205
|
+
<T = any>(collectionName: string, data?: any[]): Promise<T[]>;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* 该方法已弃用,请使用 mockCollections
|
|
209
|
+
* @deprecated
|
|
210
|
+
* @param collectionSettings
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
createCollections: (collectionSettings: CollectionSetting | CollectionSetting[]) => Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* 根据页面 title 删除对应的页面
|
|
216
|
+
* @param pageName 显示在页面菜单中的名称
|
|
217
|
+
* @returns
|
|
218
|
+
*/
|
|
219
|
+
deletePage: (pageName: string) => Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* 生成一个新的角色,并和admin关联上
|
|
222
|
+
*/
|
|
223
|
+
mockRole: <T = any>(roleSetting: AclRoleSetting) => Promise<T>;
|
|
224
|
+
/**
|
|
225
|
+
* 更新角色权限配置
|
|
226
|
+
*/
|
|
227
|
+
updateRole: <T = any>(roleSetting: AclRoleSetting) => Promise<T>;
|
|
228
|
+
/**
|
|
229
|
+
* 创建一个外部数据源(pg)
|
|
230
|
+
*/
|
|
231
|
+
mockExternalDataSource: <T = any>(DataSourceSetting: DataSourceSetting) => Promise<T>;
|
|
232
|
+
/**
|
|
233
|
+
* 删除外部数据源
|
|
234
|
+
* @param key 外部数据源key
|
|
235
|
+
*/
|
|
236
|
+
destoryExternalDataSource: <T = any>(key: string) => Promise<T>;
|
|
237
|
+
/**
|
|
238
|
+
* 清空卡片模板
|
|
239
|
+
*/
|
|
240
|
+
clearBlockTemplates: () => Promise<void>;
|
|
241
|
+
}
|
|
242
|
+
export declare class NocoPage {
|
|
243
|
+
private options?;
|
|
244
|
+
private page?;
|
|
245
|
+
private url;
|
|
246
|
+
private uid;
|
|
247
|
+
private collectionsName;
|
|
248
|
+
private _waitForInit;
|
|
249
|
+
constructor(options?: PageConfig, page?: Page);
|
|
250
|
+
init(): Promise<void>;
|
|
251
|
+
goto(): Promise<void>;
|
|
252
|
+
getUrl(): Promise<string>;
|
|
253
|
+
getUid(): Promise<string>;
|
|
254
|
+
waitForInit(this: NocoPage): Promise<NocoPage>;
|
|
255
|
+
destroy(): Promise<void>;
|
|
256
|
+
}
|
|
257
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ExtendUtils, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions> & {
|
|
258
|
+
/** 只运行在 postgres 数据库中 */
|
|
259
|
+
pgOnly: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ExtendUtils, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions> | {
|
|
260
|
+
(title: string, body: (args: import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ExtendUtils & import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions, testInfo: import("@playwright/test").TestInfo) => Promise<void> | void): void;
|
|
261
|
+
(title: string, details: import("@playwright/test").TestDetails, body: (args: import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ExtendUtils & import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions, testInfo: import("@playwright/test").TestInfo) => Promise<void> | void): void;
|
|
262
|
+
(): void;
|
|
263
|
+
(condition: boolean, description?: string): void;
|
|
264
|
+
(callback: (args: import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ExtendUtils & import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions) => boolean, description?: string): void;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* 删除一些不需要的字段,如 key
|
|
269
|
+
* @param collectionSettings
|
|
270
|
+
* @returns
|
|
271
|
+
*/
|
|
272
|
+
export declare const omitSomeFields: (collectionSettings: CollectionSetting[]) => any[];
|
|
273
|
+
interface ExpectSettingsMenuParams {
|
|
274
|
+
showMenu: () => Promise<void>;
|
|
275
|
+
supportedOptions: string[];
|
|
276
|
+
page: Page;
|
|
277
|
+
unsupportedOptions?: string[];
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* 辅助断言 SchemaSettings 的菜单项是否存在
|
|
281
|
+
* @param param0
|
|
282
|
+
*/
|
|
283
|
+
export declare function expectSettingsMenu({ showMenu, supportedOptions, page, unsupportedOptions, }: ExpectSettingsMenuParams): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* 辅助断言 Initializer 的菜单项是否存在
|
|
286
|
+
* @param param0
|
|
287
|
+
*/
|
|
288
|
+
export declare function expectInitializerMenu({ showMenu, supportedOptions, page }: {
|
|
289
|
+
showMenu: any;
|
|
290
|
+
supportedOptions: any;
|
|
291
|
+
page: any;
|
|
292
|
+
}): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* 用于辅助在 page 中添加卡片
|
|
295
|
+
* @param page
|
|
296
|
+
* @param name
|
|
297
|
+
*/
|
|
298
|
+
export declare const createBlockInPage: (page: Page, name: string) => Promise<void>;
|