@nocobase/test 1.6.0-beta.8 → 1.6.0
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/lib/e2e/e2eUtils.js
CHANGED
|
@@ -58,6 +58,24 @@ var import_test = require("@playwright/test");
|
|
|
58
58
|
var import_lodash = __toESM(require("lodash"));
|
|
59
59
|
var import_defineConfig = require("./defineConfig");
|
|
60
60
|
__reExport(e2eUtils_exports, require("@playwright/test"), module.exports);
|
|
61
|
+
function getPageMenuSchema({ pageSchemaUid, tabSchemaUid, tabSchemaName }) {
|
|
62
|
+
return {
|
|
63
|
+
type: "void",
|
|
64
|
+
"x-component": "Page",
|
|
65
|
+
properties: {
|
|
66
|
+
[tabSchemaName]: {
|
|
67
|
+
type: "void",
|
|
68
|
+
"x-component": "Grid",
|
|
69
|
+
"x-initializer": "page:addBlock",
|
|
70
|
+
properties: {},
|
|
71
|
+
"x-uid": tabSchemaUid,
|
|
72
|
+
"x-async": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"x-uid": pageSchemaUid
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
__name(getPageMenuSchema, "getPageMenuSchema");
|
|
61
79
|
const PORT = process.env.APP_PORT || 2e4;
|
|
62
80
|
const APP_BASE_URL = process.env.APP_BASE_URL || `http://localhost:${PORT}`;
|
|
63
81
|
const _NocoPage = class _NocoPage {
|
|
@@ -93,7 +111,7 @@ const _NocoPage = class _NocoPage {
|
|
|
93
111
|
const { schemaUid, routeId } = result[result.length - 1] || {};
|
|
94
112
|
this.uid = schemaUid;
|
|
95
113
|
this.desktopRouteId = routeId;
|
|
96
|
-
this.url = `${((_i = this.options) == null ? void 0 : _i.basePath) || "/admin/"}${this.uid}`;
|
|
114
|
+
this.url = `${((_i = this.options) == null ? void 0 : _i.basePath) || "/admin/"}${this.uid || this.desktopRouteId}`;
|
|
97
115
|
}
|
|
98
116
|
async goto() {
|
|
99
117
|
var _a;
|
|
@@ -125,7 +143,7 @@ const _NocoPage = class _NocoPage {
|
|
|
125
143
|
async destroy() {
|
|
126
144
|
var _a;
|
|
127
145
|
const waitList = [];
|
|
128
|
-
if (this.uid) {
|
|
146
|
+
if (this.uid || this.desktopRouteId !== void 0) {
|
|
129
147
|
waitList.push(deletePage(this.uid, this.desktopRouteId));
|
|
130
148
|
this.uid = void 0;
|
|
131
149
|
this.desktopRouteId = void 0;
|
|
@@ -392,137 +410,85 @@ const createPage = /* @__PURE__ */ __name(async (options) => {
|
|
|
392
410
|
const api = await import_test.request.newContext({
|
|
393
411
|
storageState: process.env.PLAYWRIGHT_AUTH_FILE
|
|
394
412
|
});
|
|
395
|
-
const typeToSchema = {
|
|
396
|
-
group: {
|
|
397
|
-
"x-component": "Menu.SubMenu",
|
|
398
|
-
"x-component-props": {}
|
|
399
|
-
},
|
|
400
|
-
page: {
|
|
401
|
-
"x-component": "Menu.Item",
|
|
402
|
-
"x-component-props": {}
|
|
403
|
-
},
|
|
404
|
-
link: {
|
|
405
|
-
"x-component": "Menu.URL",
|
|
406
|
-
"x-component-props": {
|
|
407
|
-
href: url
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
413
|
const state = await api.storageState();
|
|
412
414
|
const headers = getHeaders(state);
|
|
413
|
-
const menuSchemaUid = pageUidFromOptions || (0, import_shared.uid)();
|
|
414
|
-
const pageSchemaUid = (0, import_shared.uid)();
|
|
415
|
-
const tabSchemaUid = (0, import_shared.uid)();
|
|
416
|
-
const tabSchemaName = (0, import_shared.uid)();
|
|
417
|
-
const title = name || menuSchemaUid;
|
|
418
415
|
const newPageSchema = keepUid ? pageSchema : updateUidOfPageSchema(pageSchema);
|
|
416
|
+
const pageSchemaUid = (newPageSchema == null ? void 0 : newPageSchema["x-uid"]) || (0, import_shared.uid)();
|
|
417
|
+
const newTabSchemaUid = (0, import_shared.uid)();
|
|
418
|
+
const newTabSchemaName = (0, import_shared.uid)();
|
|
419
|
+
const title = name || pageSchemaUid;
|
|
419
420
|
let routeId;
|
|
420
421
|
let schemaUid;
|
|
421
422
|
if (type === "group") {
|
|
422
|
-
const
|
|
423
|
+
const result = await api.post("/api/desktopRoutes:create", {
|
|
423
424
|
headers,
|
|
424
425
|
data: {
|
|
425
426
|
type: "group",
|
|
426
427
|
title,
|
|
427
|
-
schemaUid: menuSchemaUid,
|
|
428
428
|
hideInMenu: false
|
|
429
429
|
}
|
|
430
430
|
});
|
|
431
|
-
if (!
|
|
432
|
-
throw new Error(await
|
|
431
|
+
if (!result.ok()) {
|
|
432
|
+
throw new Error(await result.text());
|
|
433
433
|
}
|
|
434
|
-
const data = await
|
|
434
|
+
const data = await result.json();
|
|
435
435
|
routeId = (_a = data.data) == null ? void 0 : _a.id;
|
|
436
|
-
schemaUid = menuSchemaUid;
|
|
437
436
|
}
|
|
438
437
|
if (type === "page") {
|
|
439
|
-
const
|
|
438
|
+
const routeResult = await api.post("/api/desktopRoutes:create", {
|
|
440
439
|
headers,
|
|
441
440
|
data: {
|
|
442
441
|
type: "page",
|
|
443
442
|
title,
|
|
444
|
-
schemaUid:
|
|
445
|
-
menuSchemaUid,
|
|
443
|
+
schemaUid: pageSchemaUid,
|
|
446
444
|
hideInMenu: false,
|
|
447
445
|
enableTabs: !!((_b = newPageSchema == null ? void 0 : newPageSchema["x-component-props"]) == null ? void 0 : _b.enablePageTabs),
|
|
448
446
|
children: newPageSchema ? schemaToRoutes(newPageSchema) : [
|
|
449
447
|
{
|
|
450
448
|
type: "tabs",
|
|
451
449
|
title: '{{t("Unnamed")}}',
|
|
452
|
-
schemaUid:
|
|
453
|
-
tabSchemaName,
|
|
450
|
+
schemaUid: newTabSchemaUid,
|
|
451
|
+
tabSchemaName: newTabSchemaName,
|
|
454
452
|
hideInMenu: false
|
|
455
453
|
}
|
|
456
454
|
]
|
|
457
455
|
}
|
|
458
456
|
});
|
|
459
|
-
if (!
|
|
460
|
-
throw new Error(await
|
|
457
|
+
if (!routeResult.ok()) {
|
|
458
|
+
throw new Error(await routeResult.text());
|
|
459
|
+
}
|
|
460
|
+
const schemaResult = await api.post(`/api/uiSchemas:insert`, {
|
|
461
|
+
headers,
|
|
462
|
+
data: newPageSchema || getPageMenuSchema({
|
|
463
|
+
pageSchemaUid,
|
|
464
|
+
tabSchemaUid: newTabSchemaUid,
|
|
465
|
+
tabSchemaName: newTabSchemaName
|
|
466
|
+
})
|
|
467
|
+
});
|
|
468
|
+
if (!schemaResult.ok()) {
|
|
469
|
+
throw new Error(await routeResult.text());
|
|
461
470
|
}
|
|
462
|
-
const data = await
|
|
471
|
+
const data = await routeResult.json();
|
|
463
472
|
routeId = (_c = data.data) == null ? void 0 : _c.id;
|
|
464
|
-
schemaUid =
|
|
473
|
+
schemaUid = pageSchemaUid;
|
|
465
474
|
}
|
|
466
475
|
if (type === "link") {
|
|
467
|
-
const
|
|
476
|
+
const result = await api.post("/api/desktopRoutes:create", {
|
|
468
477
|
headers,
|
|
469
478
|
data: {
|
|
470
479
|
type: "link",
|
|
471
480
|
title,
|
|
472
|
-
schemaUid: menuSchemaUid,
|
|
473
481
|
hideInMenu: false,
|
|
474
482
|
options: {
|
|
475
483
|
href: url
|
|
476
484
|
}
|
|
477
485
|
}
|
|
478
486
|
});
|
|
479
|
-
if (!
|
|
480
|
-
throw new Error(await
|
|
487
|
+
if (!result.ok()) {
|
|
488
|
+
throw new Error(await result.text());
|
|
481
489
|
}
|
|
482
|
-
const data = await
|
|
490
|
+
const data = await result.json();
|
|
483
491
|
routeId = (_d = data.data) == null ? void 0 : _d.id;
|
|
484
|
-
schemaUid = menuSchemaUid;
|
|
485
|
-
}
|
|
486
|
-
const result = await api.post(`/api/uiSchemas:insertAdjacent/nocobase-admin-menu?position=beforeEnd`, {
|
|
487
|
-
headers,
|
|
488
|
-
data: {
|
|
489
|
-
schema: {
|
|
490
|
-
_isJSONSchemaObject: true,
|
|
491
|
-
version: "2.0",
|
|
492
|
-
type: "void",
|
|
493
|
-
title,
|
|
494
|
-
...typeToSchema[type],
|
|
495
|
-
"x-decorator": "ACLMenuItemProvider",
|
|
496
|
-
properties: {
|
|
497
|
-
page: newPageSchema || {
|
|
498
|
-
_isJSONSchemaObject: true,
|
|
499
|
-
version: "2.0",
|
|
500
|
-
type: "void",
|
|
501
|
-
"x-component": "Page",
|
|
502
|
-
"x-async": true,
|
|
503
|
-
properties: {
|
|
504
|
-
[tabSchemaName]: {
|
|
505
|
-
_isJSONSchemaObject: true,
|
|
506
|
-
version: "2.0",
|
|
507
|
-
type: "void",
|
|
508
|
-
"x-component": "Grid",
|
|
509
|
-
"x-initializer": "page:addBlock",
|
|
510
|
-
"x-uid": tabSchemaUid,
|
|
511
|
-
name: tabSchemaName
|
|
512
|
-
}
|
|
513
|
-
},
|
|
514
|
-
"x-uid": pageSchemaUid,
|
|
515
|
-
name: "page"
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
name: (0, import_shared.uid)(),
|
|
519
|
-
"x-uid": menuSchemaUid
|
|
520
|
-
},
|
|
521
|
-
wrap: null
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
if (!result.ok()) {
|
|
525
|
-
throw new Error(await result.text());
|
|
526
492
|
}
|
|
527
493
|
return { schemaUid, routeId };
|
|
528
494
|
}, "createPage");
|
|
@@ -704,11 +670,13 @@ const deletePage = /* @__PURE__ */ __name(async (pageUid, routeId) => {
|
|
|
704
670
|
throw new Error(await routeResult.text());
|
|
705
671
|
}
|
|
706
672
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
673
|
+
if (pageUid) {
|
|
674
|
+
const result = await api.post(`/api/uiSchemas:remove/${pageUid}`, {
|
|
675
|
+
headers
|
|
676
|
+
});
|
|
677
|
+
if (!result.ok()) {
|
|
678
|
+
throw new Error(await result.text());
|
|
679
|
+
}
|
|
712
680
|
}
|
|
713
681
|
}, "deletePage");
|
|
714
682
|
const deleteCollections = /* @__PURE__ */ __name(async (collectionNames) => {
|
|
@@ -949,11 +917,11 @@ async function expectSettingsMenu({
|
|
|
949
917
|
await page.waitForTimeout(100);
|
|
950
918
|
await showMenu();
|
|
951
919
|
for (const option of supportedOptions) {
|
|
952
|
-
await (0, import_test.expect)(page.getByRole("menuitem", { name: option })).toBeVisible();
|
|
920
|
+
await (0, import_test.expect)(page.getByRole("menuitem", { name: option, exact: option === "Edit" })).toBeVisible();
|
|
953
921
|
}
|
|
954
922
|
if (unsupportedOptions) {
|
|
955
923
|
for (const option of unsupportedOptions) {
|
|
956
|
-
await (0, import_test.expect)(page.getByRole("menuitem", { name: option })).not.toBeVisible();
|
|
924
|
+
await (0, import_test.expect)(page.getByRole("menuitem", { name: option, exact: option === "Edit" })).not.toBeVisible();
|
|
957
925
|
}
|
|
958
926
|
}
|
|
959
927
|
}
|
|
@@ -241,36 +241,6 @@
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
},
|
|
244
|
-
{
|
|
245
|
-
"key": "qe7b1rsct5h",
|
|
246
|
-
"name": "jobs",
|
|
247
|
-
"type": "belongsToMany",
|
|
248
|
-
"interface": null,
|
|
249
|
-
"description": null,
|
|
250
|
-
"collectionName": "users",
|
|
251
|
-
"parentKey": null,
|
|
252
|
-
"reverseKey": null,
|
|
253
|
-
"through": "users_jobs",
|
|
254
|
-
"foreignKey": "userId",
|
|
255
|
-
"sourceKey": "id",
|
|
256
|
-
"otherKey": "jobId",
|
|
257
|
-
"targetKey": "id",
|
|
258
|
-
"target": "jobs"
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
"key": "vt0n1l1ruyz",
|
|
262
|
-
"name": "usersJobs",
|
|
263
|
-
"type": "hasMany",
|
|
264
|
-
"interface": null,
|
|
265
|
-
"description": null,
|
|
266
|
-
"collectionName": "users",
|
|
267
|
-
"parentKey": null,
|
|
268
|
-
"reverseKey": null,
|
|
269
|
-
"target": "users_jobs",
|
|
270
|
-
"foreignKey": "userId",
|
|
271
|
-
"sourceKey": "id",
|
|
272
|
-
"targetKey": "id"
|
|
273
|
-
},
|
|
274
244
|
{
|
|
275
245
|
"key": "ekol7p60nry",
|
|
276
246
|
"name": "sortName",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/test",
|
|
3
|
-
"version": "1.6.0
|
|
3
|
+
"version": "1.6.0",
|
|
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.6.0
|
|
54
|
+
"@nocobase/server": "1.6.0",
|
|
55
55
|
"@playwright/test": "^1.45.3",
|
|
56
56
|
"@testing-library/jest-dom": "^6.4.2",
|
|
57
57
|
"@testing-library/react": "^14.0.0",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"vitest-dom": "^0.1.1",
|
|
77
77
|
"ws": "^8.13.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "7422d72a4e515a11300860028a26030ed5732135"
|
|
80
80
|
}
|