@nocobase/test 1.9.0-beta.1 → 1.9.0-beta.10

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.
@@ -85,11 +85,12 @@ export type MockClusterOptions = MockServerOptions & {
85
85
  number?: number;
86
86
  clusterName?: string;
87
87
  appName?: string;
88
+ mockInstanceId?: boolean;
88
89
  };
89
90
  export type MockCluster = {
90
91
  nodes: MockServer[];
91
92
  destroy: () => Promise<void>;
92
93
  };
93
- export declare function createMockCluster({ number, clusterName, appName, ...options }?: MockClusterOptions): Promise<MockCluster>;
94
+ export declare function createMockCluster({ number, clusterName, appName, mockInstanceId, ...options }?: MockClusterOptions): Promise<MockCluster>;
94
95
  export declare function createMockServer(options?: MockServerOptions): Promise<MockServer>;
95
96
  export default mockServer;
@@ -85,11 +85,12 @@ export type MockClusterOptions = MockServerOptions & {
85
85
  number?: number;
86
86
  clusterName?: string;
87
87
  appName?: string;
88
+ mockInstanceId?: boolean;
88
89
  };
89
90
  export type MockCluster = {
90
91
  nodes: MockServer[];
91
92
  destroy: () => Promise<void>;
92
93
  };
93
- export declare function createMockCluster({ number, clusterName, appName, ...options }?: MockClusterOptions): Promise<MockCluster>;
94
+ export declare function createMockCluster({ number, clusterName, appName, mockInstanceId, ...options }?: MockClusterOptions): Promise<MockCluster>;
94
95
  export declare function createMockServer(options?: MockServerOptions): Promise<MockServer>;
95
96
  export default mockServer;
@@ -98,7 +98,7 @@ const _MockServer = class _MockServer extends import_server.Application {
98
98
  get(target, method, receiver) {
99
99
  if (["login", "loginUsingId"].includes(method)) {
100
100
  return async (userOrId, roleName) => {
101
- const userId = typeof userOrId === "number" ? userOrId : userOrId == null ? void 0 : userOrId.id;
101
+ const userId = (userOrId == null ? void 0 : userOrId.id) ? userOrId.id : userOrId;
102
102
  const tokenInfo = await authManager.tokenController.add({ userId });
103
103
  const expiresIn = (await authManager.tokenController.getConfig()).tokenExpirationTime;
104
104
  return proxy.auth(
@@ -228,6 +228,7 @@ async function createMockCluster({
228
228
  number = 2,
229
229
  clusterName = `cluster_${(0, import_utils.uid)()}`,
230
230
  appName = `app_${(0, import_utils.uid)()}`,
231
+ mockInstanceId = true,
231
232
  ...options
232
233
  } = {}) {
233
234
  const nodes = [];
@@ -242,7 +243,7 @@ async function createMockCluster({
242
243
  ...options,
243
244
  skipSupervisor: true,
244
245
  name: clusterName + "_" + appName,
245
- instanceId: `${clusterName}_${appName}_${i}`,
246
+ instanceId: mockInstanceId ? i : void 0,
246
247
  pubSubManager: {
247
248
  channelPrefix: clusterName
248
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/test",
3
- "version": "1.9.0-beta.1",
3
+ "version": "1.9.0-beta.10",
4
4
  "main": "lib/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./lib/index.d.ts",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@faker-js/faker": "8.1.0",
54
- "@nocobase/server": "1.9.0-beta.1",
54
+ "@nocobase/server": "1.9.0-beta.10",
55
55
  "@playwright/test": "^1.45.3",
56
56
  "@testing-library/jest-dom": "^6.4.2",
57
57
  "@testing-library/react": "^14.0.0",
@@ -75,5 +75,5 @@
75
75
  "vitest-dom": "^0.1.1",
76
76
  "ws": "^8.13.0"
77
77
  },
78
- "gitHead": "e0597219574e23bbf15b57848cb9b0fb4953634f"
78
+ "gitHead": "a4a5180d8e9b6bebe9df1a931c2c0f8b5c5d26e6"
79
79
  }
@@ -0,0 +1,209 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import { CollectionOptions } from '@nocobase/database';
11
+
12
+ export default {
13
+ title: 'Categories',
14
+ name: 'categories',
15
+ createdBy: true,
16
+ updatedBy: true,
17
+ fields: [
18
+ {
19
+ type: 'string',
20
+ name: 'title',
21
+ unique: true,
22
+ interface: 'input',
23
+ uiSchema: {
24
+ type: 'string',
25
+ title: 'Title',
26
+ 'x-component': 'Input',
27
+ },
28
+ },
29
+ {
30
+ type: 'string',
31
+ name: 'subTitle',
32
+ unique: true,
33
+ interface: 'input',
34
+ uiSchema: {
35
+ type: 'string',
36
+ title: 'Sub Title',
37
+ 'x-component': 'Input',
38
+ },
39
+ },
40
+ {
41
+ type: 'text',
42
+ name: 'description',
43
+ unique: true,
44
+ interface: 'textarea',
45
+ uiSchema: {
46
+ type: 'string',
47
+ title: 'Description',
48
+ 'x-component': 'Input.TextArea',
49
+ },
50
+ },
51
+ {
52
+ type: 'string',
53
+ name: 'slug',
54
+ unique: true,
55
+ interface: 'input',
56
+ uiSchema: {
57
+ type: 'string',
58
+ title: 'Slug',
59
+ 'x-component': 'Input',
60
+ },
61
+ },
62
+ { type: 'sort', name: 'sort' },
63
+ {
64
+ type: 'string',
65
+ name: 'coverImageUrl',
66
+ interface: 'url',
67
+ uiSchema: {
68
+ type: 'string',
69
+ title: 'Cover Image URL',
70
+ 'x-component': 'Input.URL',
71
+ },
72
+ },
73
+ {
74
+ type: 'string',
75
+ name: 'url',
76
+ interface: 'url',
77
+ uiSchema: {
78
+ type: 'string',
79
+ title: 'URL',
80
+ 'x-component': 'Input.URL',
81
+ },
82
+ },
83
+ {
84
+ type: 'integer',
85
+ name: 'followerCount',
86
+ defaultValue: 0,
87
+ interface: 'integer',
88
+ uiSchema: {
89
+ type: 'number',
90
+ title: 'Follower Count',
91
+ 'x-component': 'InputNumber',
92
+ },
93
+ },
94
+ {
95
+ type: 'integer',
96
+ name: 'articleCount',
97
+ defaultValue: 0,
98
+ interface: 'integer',
99
+ uiSchema: {
100
+ type: 'number',
101
+ title: 'Article Count',
102
+ 'x-component': 'InputNumber',
103
+ },
104
+ },
105
+ {
106
+ type: 'date',
107
+ name: 'lastPostedAt',
108
+ interface: 'date',
109
+ uiSchema: {
110
+ type: 'string',
111
+ title: 'Last Posted At',
112
+ 'x-component': 'DatePicker',
113
+ },
114
+ },
115
+ {
116
+ type: 'boolean',
117
+ name: 'hidden',
118
+ defaultValue: false,
119
+ interface: 'checkbox',
120
+ uiSchema: {
121
+ type: 'string',
122
+ title: 'Hidden',
123
+ 'x-component': 'Checkbox',
124
+ },
125
+ },
126
+ {
127
+ type: 'string',
128
+ name: 'themeColor',
129
+ interface: 'input',
130
+ uiSchema: {
131
+ type: 'string',
132
+ title: 'Theme Color',
133
+ 'x-component': 'Input',
134
+ },
135
+ },
136
+ {
137
+ type: 'string',
138
+ name: 'icon',
139
+ interface: 'input',
140
+ uiSchema: {
141
+ type: 'string',
142
+ title: 'Icon',
143
+ 'x-component': 'Input',
144
+ },
145
+ },
146
+ {
147
+ type: 'boolean',
148
+ name: 'allowComments',
149
+ defaultValue: true,
150
+ interface: 'checkbox',
151
+ uiSchema: {
152
+ type: 'string',
153
+ title: 'Allow Comments',
154
+ 'x-component': 'Checkbox',
155
+ },
156
+ },
157
+ {
158
+ type: 'belongsTo',
159
+ name: 'parent',
160
+ target: 'categories',
161
+ interface: 'm2o',
162
+ uiSchema: {
163
+ type: 'object',
164
+ title: 'Parent',
165
+ 'x-component': 'AssociationField',
166
+ 'x-component-props': {
167
+ fieldNames: {
168
+ value: 'id',
169
+ label: 'title',
170
+ },
171
+ },
172
+ },
173
+ },
174
+ {
175
+ type: 'hasMany',
176
+ name: 'posts',
177
+ interface: 'o2m',
178
+ uiSchema: {
179
+ type: 'array',
180
+ title: 'Posts',
181
+ 'x-component': 'AssociationField',
182
+ 'x-component-props': {
183
+ multiple: true,
184
+ fieldNames: {
185
+ value: 'id',
186
+ label: 'title',
187
+ },
188
+ },
189
+ },
190
+ },
191
+ {
192
+ type: 'belongsTo',
193
+ name: 'moderator',
194
+ target: 'users',
195
+ interface: 'm2o',
196
+ uiSchema: {
197
+ type: 'object',
198
+ title: 'Moderator',
199
+ 'x-component': 'AssociationField',
200
+ 'x-component-props': {
201
+ fieldNames: {
202
+ value: 'id',
203
+ label: 'nickname',
204
+ },
205
+ },
206
+ },
207
+ },
208
+ ],
209
+ } as CollectionOptions;
@@ -0,0 +1,268 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import { CollectionOptions } from '@nocobase/database';
11
+
12
+ export default {
13
+ title: 'Comments',
14
+ name: 'comments',
15
+ createdBy: true,
16
+ updatedBy: true,
17
+ fields: [
18
+ {
19
+ type: 'text',
20
+ name: 'content',
21
+ interface: 'textarea',
22
+ uiSchema: {
23
+ type: 'string',
24
+ title: 'Content',
25
+ 'x-component': 'Input.TextArea',
26
+ },
27
+ },
28
+ {
29
+ type: 'string',
30
+ name: 'authorName',
31
+ interface: 'input',
32
+ uiSchema: {
33
+ type: 'string',
34
+ title: 'Author Name',
35
+ 'x-component': 'Input',
36
+ },
37
+ },
38
+ {
39
+ type: 'string',
40
+ name: 'authorEmail',
41
+ interface: 'input',
42
+ uiSchema: {
43
+ type: 'string',
44
+ title: 'Author Email',
45
+ 'x-component': 'Input',
46
+ },
47
+ },
48
+ {
49
+ type: 'string',
50
+ name: 'authorUrl',
51
+ interface: 'input',
52
+ uiSchema: {
53
+ type: 'string',
54
+ title: 'Author URL',
55
+ 'x-component': 'Input',
56
+ },
57
+ },
58
+ {
59
+ type: 'string',
60
+ name: 'ipAddress',
61
+ interface: 'input',
62
+ uiSchema: {
63
+ type: 'string',
64
+ title: 'IP Address',
65
+ 'x-component': 'Input',
66
+ },
67
+ },
68
+ {
69
+ type: 'string',
70
+ name: 'userAgent',
71
+ interface: 'input',
72
+ uiSchema: {
73
+ type: 'string',
74
+ title: 'User Agent',
75
+ 'x-component': 'Input',
76
+ },
77
+ },
78
+ {
79
+ type: 'string',
80
+ name: 'status',
81
+ defaultValue: 'pending',
82
+ uiSchema: {
83
+ type: 'string',
84
+ title: 'Status',
85
+ 'x-component': 'Select',
86
+ enum: [
87
+ { label: 'Pending', value: 'pending' },
88
+ { label: 'Approved', value: 'approved' },
89
+ { label: 'Spam', value: 'spam' },
90
+ ],
91
+ },
92
+ },
93
+ {
94
+ type: 'integer',
95
+ name: 'likeCount',
96
+ interface: 'integer',
97
+ defaultValue: 0,
98
+ uiSchema: {
99
+ type: 'number',
100
+ title: 'Like Count',
101
+ 'x-component': 'InputNumber',
102
+ },
103
+ },
104
+ {
105
+ type: 'integer',
106
+ name: 'dislikeCount',
107
+ interface: 'integer',
108
+ defaultValue: 0,
109
+ uiSchema: {
110
+ type: 'number',
111
+ title: 'Dislike Count',
112
+ 'x-component': 'InputNumber',
113
+ },
114
+ },
115
+ {
116
+ type: 'integer',
117
+ name: 'rating',
118
+ interface: 'number',
119
+ defaultValue: 0,
120
+ uiSchema: {
121
+ type: 'number',
122
+ title: 'Rating',
123
+ 'x-component': 'InputNumber',
124
+ 'x-component-props': {
125
+ step: 0.1,
126
+ min: 0,
127
+ max: 5,
128
+ },
129
+ },
130
+ }, // 1-5
131
+ {
132
+ type: 'boolean',
133
+ name: 'isApproved',
134
+ interface: 'checkbox',
135
+ defaultValue: false,
136
+ uiSchema: {
137
+ type: 'string',
138
+ title: 'Is Approved',
139
+ 'x-component': 'Checkbox',
140
+ },
141
+ },
142
+ {
143
+ type: 'boolean',
144
+ name: 'isFeatured',
145
+ interface: 'checkbox',
146
+ defaultValue: false,
147
+ uiSchema: {
148
+ type: 'string',
149
+ title: 'Is Featured',
150
+ 'x-component': 'Checkbox',
151
+ },
152
+ },
153
+ {
154
+ type: 'boolean',
155
+ name: 'isSticky',
156
+ interface: 'checkbox',
157
+ defaultValue: false,
158
+ uiSchema: {
159
+ type: 'string',
160
+ title: 'Is Sticky',
161
+ 'x-component': 'Checkbox',
162
+ },
163
+ },
164
+ {
165
+ type: 'string',
166
+ name: 'path',
167
+ interface: 'input',
168
+ uiSchema: {
169
+ type: 'string',
170
+ uiSchema: {
171
+ type: 'string',
172
+ title: 'Path',
173
+ 'x-component': 'Input',
174
+ },
175
+ },
176
+ }, // For threaded comments (materialized path)
177
+ {
178
+ type: 'belongsTo',
179
+ name: 'post',
180
+ interface: 'm2o',
181
+ uiSchema: {
182
+ type: 'object',
183
+ title: 'Post',
184
+ 'x-component': 'AssociationField',
185
+ 'x-component-props': {
186
+ fieldNames: {
187
+ value: 'id',
188
+ label: 'title',
189
+ },
190
+ },
191
+ },
192
+ },
193
+ {
194
+ type: 'belongsTo',
195
+ name: 'parent',
196
+ target: 'comments',
197
+ interface: 'm2o',
198
+ uiSchema: {
199
+ type: 'object',
200
+ title: 'Parent Comment',
201
+ 'x-component': 'AssociationField',
202
+ 'x-component-props': {
203
+ fieldNames: {
204
+ value: 'id',
205
+ label: 'id',
206
+ },
207
+ },
208
+ },
209
+ },
210
+ {
211
+ type: 'hasMany',
212
+ name: 'children',
213
+ target: 'comments',
214
+ foreignKey: 'parentId',
215
+ interface: 'o2m',
216
+ uiSchema: {
217
+ type: 'array',
218
+ title: 'Child Comments',
219
+ 'x-component': 'AssociationField',
220
+ 'x-component-props': {
221
+ multiple: true,
222
+ fieldNames: {
223
+ value: 'id',
224
+ label: 'id',
225
+ },
226
+ },
227
+ },
228
+ },
229
+ {
230
+ type: 'belongsToMany',
231
+ name: 'mentions',
232
+ target: 'users',
233
+ interface: 'm2m',
234
+ uiSchema: {
235
+ type: 'object',
236
+ title: 'Mentions',
237
+ 'x-component': 'AssociationField',
238
+ 'x-component-props': {
239
+ multiple: true,
240
+ fieldNames: {
241
+ value: 'id',
242
+ label: 'nickname',
243
+ },
244
+ },
245
+ },
246
+ },
247
+ {
248
+ type: 'json',
249
+ name: 'attachments',
250
+ interface: 'json',
251
+ uiSchema: {
252
+ type: 'object',
253
+ title: 'Attachments',
254
+ 'x-component': 'Input.JSON',
255
+ },
256
+ },
257
+ {
258
+ type: 'text',
259
+ name: 'moderationNotes',
260
+ interface: 'textarea',
261
+ uiSchema: {
262
+ type: 'string',
263
+ title: 'Moderation Notes',
264
+ 'x-component': 'Input.TextArea',
265
+ },
266
+ },
267
+ ],
268
+ } as CollectionOptions;