@nocobase/test 0.18.0-alpha.1 → 0.18.0-alpha.9

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.
@@ -24,7 +24,10 @@ module.exports = __toCommonJS(defineConfig_exports);
24
24
  var import_test = require("@playwright/test");
25
25
  const defineConfig = /* @__PURE__ */ __name((config) => {
26
26
  return (0, import_test.defineConfig)({
27
- timeout: process.env.CI ? 2 * 60 * 1e3 : 30 * 1e3,
27
+ timeout: process.env.CI ? 5 * 60 * 1e3 : 30 * 1e3,
28
+ expect: {
29
+ timeout: process.env.CI ? 1 * 60 * 1e3 : 5e3
30
+ },
28
31
  // Look for test files in the "tests" directory, relative to this configuration file.
29
32
  testDir: "packages",
30
33
  // Match all test files in the e2e and __e2e__ directories.
@@ -82,6 +82,33 @@ export interface CollectionSetting {
82
82
  [key: string]: any;
83
83
  }>;
84
84
  }
85
+ interface AclActionsSetting {
86
+ name: string;
87
+ fields?: any[];
88
+ scope?: any;
89
+ }
90
+ interface AclResourcesSetting {
91
+ name: string;
92
+ usingActionsConfig: boolean;
93
+ actions?: AclActionsSetting[];
94
+ }
95
+ interface AclRoleSetting {
96
+ name?: string;
97
+ title?: string;
98
+ /**
99
+ * @default true
100
+ */
101
+ allowNewMenu?: boolean;
102
+ snippets?: string[];
103
+ strategy?: any;
104
+ resources?: AclResourcesSetting[];
105
+ /**
106
+ * @default false
107
+ */
108
+ default?: boolean;
109
+ key?: string;
110
+ menuUiSchemas?: string[];
111
+ }
85
112
  export interface PageConfig {
86
113
  /**
87
114
  * 页面类型
@@ -173,6 +200,14 @@ interface ExtendUtils {
173
200
  * @returns
174
201
  */
175
202
  deletePage: (pageName: string) => Promise<void>;
203
+ /**
204
+ * 生成一个新的角色,并和admin关联上
205
+ */
206
+ mockRole: <T = any>(roleSetting: AclRoleSetting) => Promise<T>;
207
+ /**
208
+ * 更新角色权限配置
209
+ */
210
+ updateRole: <T = any>(roleSetting: AclRoleSetting) => Promise<T>;
176
211
  }
177
212
  export declare class NocoPage {
178
213
  private options?;
@@ -185,6 +220,7 @@ export declare class NocoPage {
185
220
  init(): Promise<void>;
186
221
  goto(): Promise<void>;
187
222
  getUrl(): Promise<string>;
223
+ getUid(): Promise<string>;
188
224
  waitForInit(this: NocoPage): Promise<NocoPage>;
189
225
  destroy(): Promise<void>;
190
226
  }
@@ -203,15 +239,17 @@ export declare const test: import("@playwright/test").TestType<import("@playwrig
203
239
  * @returns
204
240
  */
205
241
  export declare const omitSomeFields: (collectionSettings: CollectionSetting[]) => any[];
242
+ interface ExpectSettingsMenuParams {
243
+ showMenu: () => Promise<void>;
244
+ supportedOptions: string[];
245
+ page: Page;
246
+ unsupportedOptions?: string[];
247
+ }
206
248
  /**
207
249
  * 辅助断言 SchemaSettings 的菜单项是否存在
208
250
  * @param param0
209
251
  */
210
- export declare function expectSettingsMenu({ showMenu, supportedOptions, page }: {
211
- showMenu: any;
212
- supportedOptions: any;
213
- page: any;
214
- }): Promise<void>;
252
+ export declare function expectSettingsMenu({ showMenu, supportedOptions, page, unsupportedOptions, }: ExpectSettingsMenuParams): Promise<void>;
215
253
  /**
216
254
  * 辅助断言 Initializer 的菜单项是否存在
217
255
  * @param param0
@@ -80,6 +80,10 @@ const _NocoPage = class _NocoPage {
80
80
  await this._waitForInit;
81
81
  return this.url;
82
82
  }
83
+ async getUid() {
84
+ await this._waitForInit;
85
+ return this.uid;
86
+ }
83
87
  async waitForInit() {
84
88
  await this._waitForInit;
85
89
  return this;
@@ -100,7 +104,6 @@ __name(_NocoPage, "NocoPage");
100
104
  let NocoPage = _NocoPage;
101
105
  const _test = import_test.test.extend({
102
106
  mockPage: async ({ page }, use) => {
103
- import_faker.faker.seed(1);
104
107
  const nocoPages = [];
105
108
  const mockPage = /* @__PURE__ */ __name((config) => {
106
109
  const nocoPage = new NocoPage(config, page);
@@ -110,6 +113,7 @@ const _test = import_test.test.extend({
110
113
  await use(mockPage);
111
114
  for (const nocoPage of nocoPages) {
112
115
  await nocoPage.destroy();
116
+ await setDefaultRole("root");
113
117
  }
114
118
  },
115
119
  mockManualDestroyPage: async ({ browser }, use) => {
@@ -125,24 +129,24 @@ const _test = import_test.test.extend({
125
129
  collectionSettings = omitSomeFields(
126
130
  Array.isArray(collectionSettings) ? collectionSettings : [collectionSettings]
127
131
  );
128
- collectionsName = collectionSettings.map((item) => item.name);
132
+ collectionsName = [...collectionsName, ...collectionSettings.map((item) => item.name)];
129
133
  await createCollections(collectionSettings);
130
134
  }, "_createCollections");
131
135
  await use(_createCollections);
132
136
  if (collectionsName.length) {
133
- await deleteCollections(collectionsName);
137
+ await deleteCollections(import_lodash.default.uniq(collectionsName));
134
138
  }
135
139
  },
136
140
  mockCollections: async ({ page }, use) => {
137
141
  let collectionsName = [];
138
142
  const destroy = /* @__PURE__ */ __name(async () => {
139
143
  if (collectionsName.length) {
140
- await deleteCollections(collectionsName);
144
+ await deleteCollections(import_lodash.default.uniq(collectionsName));
141
145
  }
142
146
  }, "destroy");
143
147
  const mockCollections = /* @__PURE__ */ __name(async (collectionSettings) => {
144
148
  collectionSettings = omitSomeFields(collectionSettings);
145
- collectionsName = collectionSettings.map((item) => item.name);
149
+ collectionsName = [...collectionsName, ...collectionSettings.map((item) => item.name)];
146
150
  return createCollections(collectionSettings);
147
151
  }, "mockCollections");
148
152
  await use(mockCollections);
@@ -152,12 +156,12 @@ const _test = import_test.test.extend({
152
156
  let collectionsName = [];
153
157
  const destroy = /* @__PURE__ */ __name(async () => {
154
158
  if (collectionsName.length) {
155
- await deleteCollections(collectionsName);
159
+ await deleteCollections(import_lodash.default.uniq(collectionsName));
156
160
  }
157
161
  }, "destroy");
158
162
  const mockCollection = /* @__PURE__ */ __name(async (collectionSetting, options) => {
159
163
  const collectionSettings = omitSomeFields([collectionSetting]);
160
- collectionsName = collectionSettings.map((item) => item.name);
164
+ collectionsName = [...collectionsName, ...collectionSettings.map((item) => item.name)];
161
165
  return createCollections(collectionSettings);
162
166
  }, "mockCollection");
163
167
  await use(mockCollection);
@@ -203,6 +207,18 @@ const _test = import_test.test.extend({
203
207
  deleteRecords("roles", { name: { $ne: ["root", "admin", "member"] } })
204
208
  ];
205
209
  await Promise.all(deletePromises);
210
+ },
211
+ mockRole: async ({ page }, use) => {
212
+ const mockRole = /* @__PURE__ */ __name(async (roleSetting) => {
213
+ return createRole(roleSetting);
214
+ }, "mockRole");
215
+ await use(mockRole);
216
+ },
217
+ updateRole: async ({ page }, use) => {
218
+ async (roleSetting) => {
219
+ return updateRole(roleSetting);
220
+ };
221
+ await use(updateRole);
206
222
  }
207
223
  });
208
224
  const test = Object.assign(_test, {
@@ -364,7 +380,54 @@ const createCollections = /* @__PURE__ */ __name(async (collectionSettings) => {
364
380
  }
365
381
  return (await result.json()).data;
366
382
  }, "createCollections");
383
+ const createRole = /* @__PURE__ */ __name(async (roleSetting) => {
384
+ const api = await import_test.request.newContext({
385
+ storageState: process.env.PLAYWRIGHT_AUTH_FILE
386
+ });
387
+ const state = await api.storageState();
388
+ const headers = getHeaders(state);
389
+ const name = roleSetting.name || (0, import_shared.uid)();
390
+ const result = await api.post(`/api/users/1/roles:create`, {
391
+ headers,
392
+ data: { ...roleSetting, name, title: name }
393
+ });
394
+ if (!result.ok()) {
395
+ throw new Error(await result.text());
396
+ }
397
+ const roleData = (await result.json()).data;
398
+ await setDefaultRole(name);
399
+ return roleData;
400
+ }, "createRole");
401
+ const updateRole = /* @__PURE__ */ __name(async (roleSetting) => {
402
+ const api = await import_test.request.newContext({
403
+ storageState: process.env.PLAYWRIGHT_AUTH_FILE
404
+ });
405
+ const state = await api.storageState();
406
+ const headers = getHeaders(state);
407
+ const name = roleSetting.name;
408
+ const result = await api.post(`/api/users/1/roles:update?filterByTk=${name}`, {
409
+ headers,
410
+ data: { ...roleSetting }
411
+ });
412
+ if (!result.ok()) {
413
+ throw new Error(await result.text());
414
+ }
415
+ const roleData = (await result.json()).data;
416
+ return roleData;
417
+ }, "updateRole");
418
+ const setDefaultRole = /* @__PURE__ */ __name(async (name) => {
419
+ const api = await import_test.request.newContext({
420
+ storageState: process.env.PLAYWRIGHT_AUTH_FILE
421
+ });
422
+ const state = await api.storageState();
423
+ const headers = getHeaders(state);
424
+ await api.post(`/api/users:setDefaultRole`, {
425
+ headers,
426
+ data: { roleName: name }
427
+ });
428
+ }, "setDefaultRole");
367
429
  const generateFakerData = /* @__PURE__ */ __name((collectionSetting) => {
430
+ var _a;
368
431
  const excludeField = ["id", "createdAt", "updatedAt", "createdBy", "updatedBy"];
369
432
  const basicInterfaceToData = {
370
433
  input: () => import_faker.faker.lorem.words(),
@@ -383,33 +446,16 @@ const generateFakerData = /* @__PURE__ */ __name((collectionSetting) => {
383
446
  time: () => "00:00:00"
384
447
  };
385
448
  const result = {};
386
- collectionSetting.fields.forEach((field) => {
387
- if (excludeField.includes(field.name)) {
449
+ (_a = collectionSetting.fields) == null ? void 0 : _a.forEach((field) => {
450
+ if (field.name && excludeField.includes(field.name)) {
388
451
  return;
389
452
  }
390
- if (basicInterfaceToData[field.interface]) {
453
+ if (basicInterfaceToData[field.interface] && field.name) {
391
454
  result[field.name] = basicInterfaceToData[field.interface]();
392
455
  }
393
456
  });
394
457
  return result;
395
458
  }, "generateFakerData");
396
- const createFakerData = /* @__PURE__ */ __name(async (collectionSettings) => {
397
- const api = await import_test.request.newContext({
398
- storageState: process.env.PLAYWRIGHT_AUTH_FILE
399
- });
400
- const state = await api.storageState();
401
- const headers = getHeaders(state);
402
- for (const item of collectionSettings) {
403
- const data = generateFakerData(item);
404
- const result = await api.post(`/api/${item.name}:create`, {
405
- headers,
406
- form: data
407
- });
408
- if (!result.ok()) {
409
- throw new Error(await result.text());
410
- }
411
- }
412
- }, "createFakerData");
413
459
  const createRandomData = /* @__PURE__ */ __name(async (collectionName, count = 10, data) => {
414
460
  const api = await import_test.request.newContext({
415
461
  storageState: process.env.PLAYWRIGHT_AUTH_FILE
@@ -463,17 +509,27 @@ function getHeaders(storageState) {
463
509
  return headers;
464
510
  }
465
511
  __name(getHeaders, "getHeaders");
466
- async function expectSettingsMenu({ showMenu, supportedOptions, page }) {
512
+ async function expectSettingsMenu({
513
+ showMenu,
514
+ supportedOptions,
515
+ page,
516
+ unsupportedOptions
517
+ }) {
467
518
  await showMenu();
468
519
  for (const option of supportedOptions) {
469
520
  await (0, import_test.expect)(page.getByRole("menuitem", { name: option })).toBeVisible();
470
521
  }
522
+ if (unsupportedOptions) {
523
+ for (const option of unsupportedOptions) {
524
+ await (0, import_test.expect)(page.getByRole("menuitem", { name: option })).not.toBeVisible();
525
+ }
526
+ }
471
527
  }
472
528
  __name(expectSettingsMenu, "expectSettingsMenu");
473
529
  async function expectInitializerMenu({ showMenu, supportedOptions, page }) {
474
530
  await showMenu();
475
531
  for (const option of supportedOptions) {
476
- await (0, import_test.expect)(page.getByRole("menuitem", { name: option })).toBeVisible();
532
+ await (0, import_test.expect)(page.getByRole("menuitem", { name: option }).first()).toBeVisible();
477
533
  }
478
534
  }
479
535
  __name(expectInitializerMenu, "expectInitializerMenu");
@@ -76,6 +76,14 @@ export declare const oneDetailBlockWithM2oFieldToGeneral: PageConfig;
76
76
  * 5. 所有字段都是 basic 字段
77
77
  */
78
78
  export declare const oneTableBlockWithAddNewAndViewAndEditAndBasicFields: PageConfig;
79
+ /**
80
+ * 1. 一个 Table 区块
81
+ * 2. 点击 Add new 有一个 Form 区块,里面有一个 sub-table 字段
82
+ * 3. 点击 View 有一个 Details 区块,里面有一个 sub-table 字段
83
+ * 4. 点击 Edit 有一个 Form 区块,里面有一个 sub-table 字段
84
+ * 5. sub-table 中的所有字段都是 basic 字段
85
+ */
86
+ export declare const oneTableBlockWithAddNewAndViewAndEditAndBasicFieldsAndSubTable: PageConfig;
79
87
  /**
80
88
  * 1. 一个 Table 区块
81
89
  * 2. 点击 Add new 有一个 Form 区块
@@ -46,6 +46,7 @@ __export(templatesOfPage_exports, {
46
46
  oneTableBlockWithAddNewAndViewAndEditAndAdvancedFields: () => oneTableBlockWithAddNewAndViewAndEditAndAdvancedFields,
47
47
  oneTableBlockWithAddNewAndViewAndEditAndAssociationFields: () => oneTableBlockWithAddNewAndViewAndEditAndAssociationFields,
48
48
  oneTableBlockWithAddNewAndViewAndEditAndBasicFields: () => oneTableBlockWithAddNewAndViewAndEditAndBasicFields,
49
+ oneTableBlockWithAddNewAndViewAndEditAndBasicFieldsAndSubTable: () => oneTableBlockWithAddNewAndViewAndEditAndBasicFieldsAndSubTable,
49
50
  oneTableBlockWithAddNewAndViewAndEditAndChoicesFields: () => oneTableBlockWithAddNewAndViewAndEditAndChoicesFields,
50
51
  oneTableBlockWithAddNewAndViewAndEditAndDatetimeFields: () => oneTableBlockWithAddNewAndViewAndEditAndDatetimeFields,
51
52
  oneTableBlockWithAddNewAndViewAndEditAndMediaFields: () => oneTableBlockWithAddNewAndViewAndEditAndMediaFields,
@@ -5776,6 +5777,414 @@ const oneTableBlockWithAddNewAndViewAndEditAndBasicFields = {
5776
5777
  "x-index": 1
5777
5778
  }
5778
5779
  };
5780
+ const oneTableBlockWithAddNewAndViewAndEditAndBasicFieldsAndSubTable = {
5781
+ collections: [
5782
+ ...import_templatesOfCollection.generalWithBasic,
5783
+ {
5784
+ name: "subTable",
5785
+ fields: [
5786
+ {
5787
+ name: "manyToMany",
5788
+ interface: "m2m",
5789
+ target: "general"
5790
+ },
5791
+ {
5792
+ name: "oneToMany",
5793
+ interface: "o2m",
5794
+ target: "general"
5795
+ }
5796
+ ]
5797
+ }
5798
+ ],
5799
+ pageSchema: {
5800
+ _isJSONSchemaObject: true,
5801
+ version: "2.0",
5802
+ type: "void",
5803
+ "x-component": "Page",
5804
+ properties: {
5805
+ "7m533o9wcl2": {
5806
+ _isJSONSchemaObject: true,
5807
+ version: "2.0",
5808
+ type: "void",
5809
+ "x-component": "Grid",
5810
+ "x-initializer": "BlockInitializers",
5811
+ properties: {
5812
+ mbtse8e9kap: {
5813
+ _isJSONSchemaObject: true,
5814
+ version: "2.0",
5815
+ type: "void",
5816
+ "x-component": "Grid.Row",
5817
+ properties: {
5818
+ ir5rfzx0z5o: {
5819
+ _isJSONSchemaObject: true,
5820
+ version: "2.0",
5821
+ type: "void",
5822
+ "x-component": "Grid.Col",
5823
+ properties: {
5824
+ yr9pww7k8mq: {
5825
+ _isJSONSchemaObject: true,
5826
+ version: "2.0",
5827
+ type: "void",
5828
+ "x-decorator": "TableBlockProvider",
5829
+ "x-acl-action": "subTable:list",
5830
+ "x-decorator-props": {
5831
+ collection: "subTable",
5832
+ resource: "subTable",
5833
+ action: "list",
5834
+ params: {
5835
+ pageSize: 20
5836
+ },
5837
+ rowKey: "id",
5838
+ showIndex: true,
5839
+ dragSort: false,
5840
+ disableTemplate: false
5841
+ },
5842
+ "x-designer": "TableBlockDesigner",
5843
+ "x-component": "CardItem",
5844
+ "x-filter-targets": [],
5845
+ properties: {
5846
+ actions: {
5847
+ _isJSONSchemaObject: true,
5848
+ version: "2.0",
5849
+ type: "void",
5850
+ "x-initializer": "TableActionInitializers",
5851
+ "x-component": "ActionBar",
5852
+ "x-component-props": {
5853
+ style: {
5854
+ marginBottom: "var(--nb-spacing)"
5855
+ }
5856
+ },
5857
+ "x-uid": "0bvmtmgkrx0",
5858
+ "x-async": false,
5859
+ "x-index": 1
5860
+ },
5861
+ "39vo8hzhsor": {
5862
+ _isJSONSchemaObject: true,
5863
+ version: "2.0",
5864
+ type: "array",
5865
+ "x-initializer": "TableColumnInitializers",
5866
+ "x-component": "TableV2",
5867
+ "x-component-props": {
5868
+ rowKey: "id",
5869
+ rowSelection: {
5870
+ type: "checkbox"
5871
+ },
5872
+ useProps: "{{ useTableBlockProps }}"
5873
+ },
5874
+ properties: {
5875
+ actions: {
5876
+ _isJSONSchemaObject: true,
5877
+ version: "2.0",
5878
+ type: "void",
5879
+ title: '{{ t("Actions") }}',
5880
+ "x-action-column": "actions",
5881
+ "x-decorator": "TableV2.Column.ActionBar",
5882
+ "x-component": "TableV2.Column",
5883
+ "x-designer": "TableV2.ActionColumnDesigner",
5884
+ "x-initializer": "TableActionColumnInitializers",
5885
+ properties: {
5886
+ actions: {
5887
+ _isJSONSchemaObject: true,
5888
+ version: "2.0",
5889
+ type: "void",
5890
+ "x-decorator": "DndContext",
5891
+ "x-component": "Space",
5892
+ "x-component-props": {
5893
+ split: "|"
5894
+ },
5895
+ properties: {
5896
+ dghwbcfocgv: {
5897
+ "x-uid": "rhc8oxdqglj",
5898
+ _isJSONSchemaObject: true,
5899
+ version: "2.0",
5900
+ type: "void",
5901
+ title: "Edit record",
5902
+ "x-action": "update",
5903
+ "x-designer": "Action.Designer",
5904
+ "x-component": "Action.Link",
5905
+ "x-component-props": {
5906
+ openMode: "drawer",
5907
+ danger: false
5908
+ },
5909
+ "x-decorator": "ACLActionProvider",
5910
+ "x-designer-props": {
5911
+ linkageAction: true
5912
+ },
5913
+ properties: {
5914
+ drawer: {
5915
+ _isJSONSchemaObject: true,
5916
+ version: "2.0",
5917
+ type: "void",
5918
+ title: '{{ t("Edit record") }}',
5919
+ "x-component": "Action.Container",
5920
+ "x-component-props": {
5921
+ className: "nb-action-popup"
5922
+ },
5923
+ properties: {
5924
+ tabs: {
5925
+ _isJSONSchemaObject: true,
5926
+ version: "2.0",
5927
+ type: "void",
5928
+ "x-component": "Tabs",
5929
+ "x-component-props": {},
5930
+ "x-initializer": "TabPaneInitializers",
5931
+ properties: {
5932
+ tab1: {
5933
+ _isJSONSchemaObject: true,
5934
+ version: "2.0",
5935
+ type: "void",
5936
+ title: '{{t("Edit")}}',
5937
+ "x-component": "Tabs.TabPane",
5938
+ "x-designer": "Tabs.Designer",
5939
+ "x-component-props": {},
5940
+ properties: {
5941
+ grid: {
5942
+ _isJSONSchemaObject: true,
5943
+ version: "2.0",
5944
+ type: "void",
5945
+ "x-component": "Grid",
5946
+ "x-initializer": "RecordBlockInitializers",
5947
+ properties: {
5948
+ trny88kf0bk: {
5949
+ _isJSONSchemaObject: true,
5950
+ version: "2.0",
5951
+ type: "void",
5952
+ "x-component": "Grid.Row",
5953
+ properties: {
5954
+ "78r8m6ecsh4": {
5955
+ _isJSONSchemaObject: true,
5956
+ version: "2.0",
5957
+ type: "void",
5958
+ "x-component": "Grid.Col",
5959
+ properties: {
5960
+ lj0yhupvh3o: {
5961
+ _isJSONSchemaObject: true,
5962
+ version: "2.0",
5963
+ type: "void",
5964
+ "x-acl-action-props": {
5965
+ skipScopeCheck: false
5966
+ },
5967
+ "x-acl-action": "subTable:update",
5968
+ "x-decorator": "FormBlockProvider",
5969
+ "x-decorator-props": {
5970
+ useSourceId: "{{ useSourceIdFromParentRecord }}",
5971
+ useParams: "{{ useParamsFromRecord }}",
5972
+ action: "get",
5973
+ resource: "subTable",
5974
+ collection: "subTable"
5975
+ },
5976
+ "x-designer": "FormV2.Designer",
5977
+ "x-component": "CardItem",
5978
+ "x-component-props": {},
5979
+ properties: {
5980
+ "0ykr2ijd1qa": {
5981
+ _isJSONSchemaObject: true,
5982
+ version: "2.0",
5983
+ type: "void",
5984
+ "x-component": "FormV2",
5985
+ "x-component-props": {
5986
+ useProps: "{{ useFormBlockProps }}"
5987
+ },
5988
+ properties: {
5989
+ grid: {
5990
+ _isJSONSchemaObject: true,
5991
+ version: "2.0",
5992
+ type: "void",
5993
+ "x-component": "Grid",
5994
+ "x-initializer": "FormItemInitializers",
5995
+ properties: {
5996
+ "7mwkv9h74ki": {
5997
+ _isJSONSchemaObject: true,
5998
+ version: "2.0",
5999
+ type: "void",
6000
+ "x-component": "Grid.Row",
6001
+ properties: {
6002
+ "0f4fktqpnee": {
6003
+ _isJSONSchemaObject: true,
6004
+ version: "2.0",
6005
+ type: "void",
6006
+ "x-component": "Grid.Col",
6007
+ properties: {
6008
+ manyToMany: {
6009
+ "x-uid": "lclf348ur56",
6010
+ _isJSONSchemaObject: true,
6011
+ version: "2.0",
6012
+ type: "string",
6013
+ "x-designer": "FormItem.Designer",
6014
+ "x-component": "CollectionField",
6015
+ "x-decorator": "FormItem",
6016
+ "x-collection-field": "subTable.manyToMany",
6017
+ "x-component-props": {
6018
+ mode: "SubTable"
6019
+ },
6020
+ properties: {
6021
+ ry6csw9ij4n: {
6022
+ _isJSONSchemaObject: true,
6023
+ version: "2.0",
6024
+ type: "void",
6025
+ "x-component": "AssociationField.SubTable",
6026
+ "x-initializer": "TableColumnInitializers",
6027
+ "x-initializer-props": {
6028
+ action: false
6029
+ },
6030
+ "x-index": 1,
6031
+ properties: {
6032
+ rmz41gp1stq: {
6033
+ _isJSONSchemaObject: true,
6034
+ version: "2.0",
6035
+ type: "void",
6036
+ "x-decorator": "TableV2.Column.Decorator",
6037
+ "x-designer": "TableV2.Column.Designer",
6038
+ "x-component": "TableV2.Column",
6039
+ properties: {
6040
+ singleLineText: {
6041
+ "x-uid": "tlprzxnyyqb",
6042
+ _isJSONSchemaObject: true,
6043
+ version: "2.0",
6044
+ "x-collection-field": "general.singleLineText",
6045
+ "x-component": "CollectionField",
6046
+ "x-component-props": {
6047
+ ellipsis: true
6048
+ },
6049
+ "x-decorator": "FormItem",
6050
+ "x-decorator-props": {
6051
+ labelStyle: {
6052
+ display: "none"
6053
+ }
6054
+ },
6055
+ default: null,
6056
+ "x-async": false,
6057
+ "x-index": 1
6058
+ }
6059
+ },
6060
+ "x-uid": "zmslu38eujy",
6061
+ "x-async": false,
6062
+ "x-index": 1
6063
+ }
6064
+ },
6065
+ "x-uid": "vl5lkem00dr",
6066
+ "x-async": false
6067
+ }
6068
+ },
6069
+ "x-async": false,
6070
+ "x-index": 1
6071
+ }
6072
+ },
6073
+ "x-uid": "gzxknc793se",
6074
+ "x-async": false,
6075
+ "x-index": 1
6076
+ }
6077
+ },
6078
+ "x-uid": "lr63kqkjvgo",
6079
+ "x-async": false,
6080
+ "x-index": 1
6081
+ }
6082
+ },
6083
+ "x-uid": "8iw3zvh7vxd",
6084
+ "x-async": false,
6085
+ "x-index": 1
6086
+ },
6087
+ actions: {
6088
+ _isJSONSchemaObject: true,
6089
+ version: "2.0",
6090
+ type: "void",
6091
+ "x-initializer": "UpdateFormActionInitializers",
6092
+ "x-component": "ActionBar",
6093
+ "x-component-props": {
6094
+ layout: "one-column",
6095
+ style: {
6096
+ marginTop: 24
6097
+ }
6098
+ },
6099
+ "x-uid": "95vrlwf03yk",
6100
+ "x-async": false,
6101
+ "x-index": 2
6102
+ }
6103
+ },
6104
+ "x-uid": "17ju1kwigyw",
6105
+ "x-async": false,
6106
+ "x-index": 1
6107
+ }
6108
+ },
6109
+ "x-uid": "by4uluzexjq",
6110
+ "x-async": false,
6111
+ "x-index": 1
6112
+ }
6113
+ },
6114
+ "x-uid": "nzw5judm7ah",
6115
+ "x-async": false,
6116
+ "x-index": 1
6117
+ }
6118
+ },
6119
+ "x-uid": "keraakujlcb",
6120
+ "x-async": false,
6121
+ "x-index": 1
6122
+ }
6123
+ },
6124
+ "x-uid": "dtc6ufrnn2w",
6125
+ "x-async": false,
6126
+ "x-index": 1
6127
+ }
6128
+ },
6129
+ "x-uid": "kgrdpc9e834",
6130
+ "x-async": false,
6131
+ "x-index": 1
6132
+ }
6133
+ },
6134
+ "x-uid": "h60qmmbj1ez",
6135
+ "x-async": false,
6136
+ "x-index": 1
6137
+ }
6138
+ },
6139
+ "x-uid": "f930il0aqu3",
6140
+ "x-async": false,
6141
+ "x-index": 1
6142
+ }
6143
+ },
6144
+ "x-async": false,
6145
+ "x-index": 2
6146
+ }
6147
+ },
6148
+ "x-uid": "gb81ougszo2",
6149
+ "x-async": false,
6150
+ "x-index": 1
6151
+ }
6152
+ },
6153
+ "x-uid": "aa33l45v6qb",
6154
+ "x-async": false,
6155
+ "x-index": 1
6156
+ }
6157
+ },
6158
+ "x-uid": "lm8sj8ojma9",
6159
+ "x-async": false,
6160
+ "x-index": 2
6161
+ }
6162
+ },
6163
+ "x-uid": "z5n8ihuvx64",
6164
+ "x-async": false,
6165
+ "x-index": 1
6166
+ }
6167
+ },
6168
+ "x-uid": "snt3mrh4ug9",
6169
+ "x-async": false,
6170
+ "x-index": 1
6171
+ }
6172
+ },
6173
+ "x-uid": "kzi69u1gb24",
6174
+ "x-async": false,
6175
+ "x-index": 1
6176
+ }
6177
+ },
6178
+ "x-uid": "hbmkoataojj",
6179
+ "x-async": false,
6180
+ "x-index": 1
6181
+ }
6182
+ },
6183
+ "x-uid": "sfa1nw7kqmi",
6184
+ "x-async": true,
6185
+ "x-index": 1
6186
+ }
6187
+ };
5779
6188
  const oneTableBlockWithAddNewAndViewAndEditAndChoicesFields = {
5780
6189
  collections: import_templatesOfCollection.generalWithChoices,
5781
6190
  pageSchema: {
@@ -18600,6 +19009,7 @@ const checkboxForTableRow = {
18600
19009
  oneTableBlockWithAddNewAndViewAndEditAndAdvancedFields,
18601
19010
  oneTableBlockWithAddNewAndViewAndEditAndAssociationFields,
18602
19011
  oneTableBlockWithAddNewAndViewAndEditAndBasicFields,
19012
+ oneTableBlockWithAddNewAndViewAndEditAndBasicFieldsAndSubTable,
18603
19013
  oneTableBlockWithAddNewAndViewAndEditAndChoicesFields,
18604
19014
  oneTableBlockWithAddNewAndViewAndEditAndDatetimeFields,
18605
19015
  oneTableBlockWithAddNewAndViewAndEditAndMediaFields,
@@ -69,7 +69,6 @@ const _MockServer = class _MockServer extends import_server.default {
69
69
  const oldDatabase = this._db;
70
70
  const databaseOptions = oldDatabase ? oldDatabase.options : (options == null ? void 0 : options.database) || {};
71
71
  const database = (0, import_database.mockDatabase)(databaseOptions);
72
- database.setLogger(this._logger);
73
72
  database.setContext({ app: this });
74
73
  return database;
75
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/test",
3
- "version": "0.18.0-alpha.1",
3
+ "version": "0.18.0-alpha.9",
4
4
  "main": "lib/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./lib/index.d.ts",
@@ -40,12 +40,13 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@faker-js/faker": "8.1.0",
43
- "@nocobase/server": "0.18.0-alpha.1",
43
+ "@nocobase/server": "0.18.0-alpha.9",
44
44
  "@playwright/test": "^1.40.1",
45
45
  "@testing-library/react": "^14.0.0",
46
46
  "@testing-library/user-event": "^14.4.3",
47
47
  "@types/supertest": "^2.0.11",
48
48
  "@vitejs/plugin-react": "^4.0.0",
49
+ "jsdom": "^16.0.0",
49
50
  "jsdom-worker": "^0.3.0",
50
51
  "mariadb": "^2.5.6",
51
52
  "mockjs": "^1.1.0",
@@ -59,5 +60,5 @@
59
60
  "vitest-dom": "^0.1.1",
60
61
  "ws": "^8.13.0"
61
62
  },
62
- "gitHead": "0f5f1c0a37dc397a9dc4c8eec0c4ec20fd8107b0"
63
+ "gitHead": "34ca0df4eede2e83fc86297b0fe19eba970e2b1b"
63
64
  }
package/vitest.mjs CHANGED
@@ -23,10 +23,16 @@ function tsConfigPathsToAlias() {
23
23
  }
24
24
  return acc;
25
25
  }, []);
26
- alias.unshift({
27
- find: '@nocobase/utils/plugin-symlink',
28
- replacement: 'node_modules/@nocobase/utils/plugin-symlink.js',
29
- });
26
+ alias.unshift(
27
+ {
28
+ find: '@nocobase/utils/plugin-symlink',
29
+ replacement: 'node_modules/@nocobase/utils/plugin-symlink.js',
30
+ },
31
+ {
32
+ find: '@opentelemetry/resources',
33
+ replacement: 'node_modules/@opentelemetry/resources/build/src/index.js',
34
+ },
35
+ );
30
36
  return [
31
37
  { find: /^~antd\/(.*)/, replacement: 'antd/$1' },
32
38
  ...alias.map((item) => {
@@ -42,69 +48,70 @@ export const defineConfig = (config = {}) => {
42
48
  return vitestConfig(
43
49
  process.env.TEST_ENV === 'server-side'
44
50
  ? {
45
- root: process.cwd(),
46
- resolve: {
47
- mainFields: ['module'],
48
- },
49
- test: {
50
- globals: true,
51
- setupFiles: resolve(__dirname, './setup/server.ts'),
52
- alias: tsConfigPathsToAlias(),
53
- include: ['packages/**/__tests__/**/*.test.ts'],
54
- exclude: [
55
- '**/node_modules/**',
56
- '**/dist/**',
57
- '**/lib/**',
58
- '**/es/**',
59
- '**/e2e/**',
60
- '**/{vitest,commitlint}.config.*',
61
- 'packages/**/{dumi-theme-nocobase,sdk,client}/**/__tests__/**/*.{test,spec}.{ts,tsx}',
62
- ],
63
- testTimeout: 300000,
64
- bail: 1,
65
- // 在 GitHub Actions 中不输出日志
66
- silent: !!process.env.GITHUB_ACTIONS,
67
- // poolOptions: {
68
- // threads: {
69
- // singleThread: process.env.SINGLE_THREAD == 'false' ? false : true,
70
- // },
71
- // },
72
- },
73
- }
51
+ root: process.cwd(),
52
+ resolve: {
53
+ mainFields: ['module'],
54
+ },
55
+ test: {
56
+ globals: true,
57
+ setupFiles: resolve(__dirname, './setup/server.ts'),
58
+ alias: tsConfigPathsToAlias(),
59
+ include: ['packages/**/__tests__/**/*.test.ts'],
60
+ exclude: [
61
+ '**/node_modules/**',
62
+ '**/dist/**',
63
+ '**/lib/**',
64
+ '**/es/**',
65
+ '**/e2e/**',
66
+ '**/__e2e__/**',
67
+ '**/{vitest,commitlint}.config.*',
68
+ 'packages/**/{dumi-theme-nocobase,sdk,client}/**/__tests__/**/*.{test,spec}.{ts,tsx}',
69
+ ],
70
+ testTimeout: 300000,
71
+ bail: 1,
72
+ // 在 GitHub Actions 中不输出日志
73
+ silent: !!process.env.GITHUB_ACTIONS,
74
+ // poolOptions: {
75
+ // threads: {
76
+ // singleThread: process.env.SINGLE_THREAD == 'false' ? false : true,
77
+ // },
78
+ // },
79
+ },
80
+ }
74
81
  : {
75
- plugins: [react()],
76
- resolve: {
77
- mainFields: ['module'],
78
- },
79
- define: {
80
- 'process.env.__TEST__': true,
81
- 'process.env.__E2E__': false,
82
- },
83
- test: {
84
- globals: true,
85
- setupFiles: resolve(__dirname, './setup/client.ts'),
86
- environment: 'jsdom',
87
- css: false,
88
- alias: tsConfigPathsToAlias(),
89
- include: ['packages/**/{dumi-theme-nocobase,sdk,client}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
90
- exclude: [
91
- '**/node_modules/**',
92
- '**/dist/**',
93
- '**/lib/**',
94
- '**/es/**',
95
- '**/e2e/**',
96
- '**/__e2e__/**',
97
- '**/{vitest,commitlint}.config.*',
98
- ],
99
- testTimeout: 300000,
100
- // 在 GitHub Actions 中不输出日志
101
- silent: !!process.env.GITHUB_ACTIONS,
102
- server: {
103
- deps: {
104
- inline: ['@juggle/resize-observer', 'clsx'],
105
- },
82
+ plugins: [react()],
83
+ resolve: {
84
+ mainFields: ['module'],
85
+ },
86
+ define: {
87
+ 'process.env.__TEST__': true,
88
+ 'process.env.__E2E__': false,
89
+ },
90
+ test: {
91
+ globals: true,
92
+ setupFiles: resolve(__dirname, './setup/client.ts'),
93
+ environment: 'jsdom',
94
+ css: false,
95
+ alias: tsConfigPathsToAlias(),
96
+ include: ['packages/**/{dumi-theme-nocobase,sdk,client}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
97
+ exclude: [
98
+ '**/node_modules/**',
99
+ '**/dist/**',
100
+ '**/lib/**',
101
+ '**/es/**',
102
+ '**/e2e/**',
103
+ '**/__e2e__/**',
104
+ '**/{vitest,commitlint}.config.*',
105
+ ],
106
+ testTimeout: 300000,
107
+ // 在 GitHub Actions 中不输出日志
108
+ silent: !!process.env.GITHUB_ACTIONS,
109
+ server: {
110
+ deps: {
111
+ inline: ['@juggle/resize-observer', 'clsx'],
106
112
  },
107
113
  },
108
114
  },
115
+ },
109
116
  );
110
117
  };