@nocobase/test 1.7.0-beta.8 → 1.7.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/es/e2e/e2eUtils.d.ts +7 -0
- package/es/server/index.d.ts +0 -1
- package/es/server/mock-server.d.ts +1 -1
- package/lib/client/utils/utils.js +0 -1
- package/lib/e2e/e2eUtils.d.ts +7 -0
- package/lib/e2e/e2eUtils.js +24 -7
- package/lib/scripts/test-db-creator.js +5 -5
- package/lib/server/index.d.ts +0 -1
- package/lib/server/index.js +0 -4
- package/lib/server/mock-server.d.ts +1 -1
- package/package.json +3 -4
package/es/e2e/e2eUtils.d.ts
CHANGED
|
@@ -161,10 +161,17 @@ export interface PageConfig {
|
|
|
161
161
|
*/
|
|
162
162
|
collections?: CollectionSetting[];
|
|
163
163
|
/**
|
|
164
|
+
* @deprecate 在菜单被重构之后,没有办法直接复制完整的页面 Schema 了。所以这个选项不推荐使用了。
|
|
165
|
+
* 推荐使用 tabSchema,复制一个页面 tab 的 Schema 传给 tabSchema。
|
|
166
|
+
*
|
|
164
167
|
* 页面整体的 Schema
|
|
165
168
|
* @default undefined
|
|
166
169
|
*/
|
|
167
170
|
pageSchema?: any;
|
|
171
|
+
/**
|
|
172
|
+
* 页面 Tab 的 Schema。当 pageSchema 和 tabSchema 都存在时,最终显示的会是 tabSchema 的内容
|
|
173
|
+
*/
|
|
174
|
+
tabSchema?: any;
|
|
168
175
|
/** 如果为 true 则表示不会更改 PageSchema 的 uid */
|
|
169
176
|
keepUid?: boolean;
|
|
170
177
|
/** 在 URL 中的 uid,例如:/admin/0ig6xhe03u2 */
|
package/es/server/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export { default as supertest } from 'supertest';
|
|
|
12
12
|
export * from './memory-pub-sub-adapter';
|
|
13
13
|
export * from './mock-isolated-cluster';
|
|
14
14
|
export * from './mock-server';
|
|
15
|
-
export declare const pgOnly: () => any;
|
|
16
15
|
export declare const isPg: () => boolean;
|
|
17
16
|
export declare const isMysql: () => boolean;
|
|
18
17
|
export declare function randomStr(): string;
|
|
@@ -56,7 +56,7 @@ interface Resource {
|
|
|
56
56
|
sort: (params?: SortActionParams) => Promise<supertest.Response>;
|
|
57
57
|
[name: string]: (params?: ActionParams) => Promise<supertest.Response>;
|
|
58
58
|
}
|
|
59
|
-
interface ExtendedAgent extends SuperAgentTest {
|
|
59
|
+
export interface ExtendedAgent extends SuperAgentTest {
|
|
60
60
|
login: (user: any, roleName?: string) => Promise<ExtendedAgent>;
|
|
61
61
|
loginUsingId: (userId: number, roleName?: string) => Promise<ExtendedAgent>;
|
|
62
62
|
resource: (name: string, resourceOf?: any) => Resource;
|
|
@@ -40,7 +40,6 @@ const WaitApp = /* @__PURE__ */ __name(async () => {
|
|
|
40
40
|
});
|
|
41
41
|
const loadError = import_react.screen.queryByText("App Error");
|
|
42
42
|
if (loadError) {
|
|
43
|
-
expectNoTsError(import_react.screen.queryByText("App Error")).not.toBeInTheDocument();
|
|
44
43
|
}
|
|
45
44
|
const renderError = import_react.screen.queryByText("Render Failed");
|
|
46
45
|
if (renderError) {
|
package/lib/e2e/e2eUtils.d.ts
CHANGED
|
@@ -161,10 +161,17 @@ export interface PageConfig {
|
|
|
161
161
|
*/
|
|
162
162
|
collections?: CollectionSetting[];
|
|
163
163
|
/**
|
|
164
|
+
* @deprecate 在菜单被重构之后,没有办法直接复制完整的页面 Schema 了。所以这个选项不推荐使用了。
|
|
165
|
+
* 推荐使用 tabSchema,复制一个页面 tab 的 Schema 传给 tabSchema。
|
|
166
|
+
*
|
|
164
167
|
* 页面整体的 Schema
|
|
165
168
|
* @default undefined
|
|
166
169
|
*/
|
|
167
170
|
pageSchema?: any;
|
|
171
|
+
/**
|
|
172
|
+
* 页面 Tab 的 Schema。当 pageSchema 和 tabSchema 都存在时,最终显示的会是 tabSchema 的内容
|
|
173
|
+
*/
|
|
174
|
+
tabSchema?: any;
|
|
168
175
|
/** 如果为 true 则表示不会更改 PageSchema 的 uid */
|
|
169
176
|
keepUid?: boolean;
|
|
170
177
|
/** 在 URL 中的 uid,例如:/admin/0ig6xhe03u2 */
|
package/lib/e2e/e2eUtils.js
CHANGED
|
@@ -76,6 +76,20 @@ function getPageMenuSchema({ pageSchemaUid, tabSchemaUid, tabSchemaName }) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
__name(getPageMenuSchema, "getPageMenuSchema");
|
|
79
|
+
function getPageMenuSchemaWithTabSchema({ tabSchema }) {
|
|
80
|
+
if (!tabSchema) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
type: "void",
|
|
85
|
+
"x-component": "Page",
|
|
86
|
+
properties: {
|
|
87
|
+
[tabSchema.name]: tabSchema
|
|
88
|
+
},
|
|
89
|
+
"x-uid": (0, import_shared.uid)()
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
__name(getPageMenuSchemaWithTabSchema, "getPageMenuSchemaWithTabSchema");
|
|
79
93
|
const PORT = process.env.APP_PORT || 2e4;
|
|
80
94
|
const APP_BASE_URL = process.env.APP_BASE_URL || `http://localhost:${PORT}`;
|
|
81
95
|
const _NocoPage = class _NocoPage {
|
|
@@ -90,7 +104,7 @@ const _NocoPage = class _NocoPage {
|
|
|
90
104
|
collectionsName;
|
|
91
105
|
_waitForInit;
|
|
92
106
|
async init() {
|
|
93
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
107
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
94
108
|
const waitList = [];
|
|
95
109
|
if ((_b = (_a = this.options) == null ? void 0 : _a.collections) == null ? void 0 : _b.length) {
|
|
96
110
|
const collections = omitSomeFields(this.options.collections);
|
|
@@ -102,16 +116,17 @@ const _NocoPage = class _NocoPage {
|
|
|
102
116
|
type: (_c = this.options) == null ? void 0 : _c.type,
|
|
103
117
|
name: (_d = this.options) == null ? void 0 : _d.name,
|
|
104
118
|
pageSchema: (_e = this.options) == null ? void 0 : _e.pageSchema,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
tabSchema: (_f = this.options) == null ? void 0 : _f.tabSchema,
|
|
120
|
+
url: (_g = this.options) == null ? void 0 : _g.url,
|
|
121
|
+
keepUid: (_h = this.options) == null ? void 0 : _h.keepUid,
|
|
122
|
+
pageUid: (_i = this.options) == null ? void 0 : _i.pageUid
|
|
108
123
|
})
|
|
109
124
|
);
|
|
110
125
|
const result = await Promise.all(waitList);
|
|
111
126
|
const { schemaUid, routeId } = result[result.length - 1] || {};
|
|
112
127
|
this.uid = schemaUid;
|
|
113
128
|
this.desktopRouteId = routeId;
|
|
114
|
-
this.url = `${((
|
|
129
|
+
this.url = `${((_j = this.options) == null ? void 0 : _j.basePath) || "/admin/"}${this.uid || this.desktopRouteId}`;
|
|
115
130
|
}
|
|
116
131
|
async goto() {
|
|
117
132
|
var _a;
|
|
@@ -406,13 +421,14 @@ const updateUidOfPageSchema = /* @__PURE__ */ __name((uiSchema) => {
|
|
|
406
421
|
}, "updateUidOfPageSchema");
|
|
407
422
|
const createPage = /* @__PURE__ */ __name(async (options) => {
|
|
408
423
|
var _a, _b, _c, _d;
|
|
409
|
-
const { type = "page", url, name, pageSchema, keepUid, pageUid: pageUidFromOptions } = options || {};
|
|
424
|
+
const { type = "page", url, name, pageSchema, tabSchema, keepUid, pageUid: pageUidFromOptions } = options || {};
|
|
410
425
|
const api = await import_test.request.newContext({
|
|
411
426
|
storageState: process.env.PLAYWRIGHT_AUTH_FILE
|
|
412
427
|
});
|
|
428
|
+
const schema = getPageMenuSchemaWithTabSchema({ tabSchema }) || pageSchema;
|
|
413
429
|
const state = await api.storageState();
|
|
414
430
|
const headers = getHeaders(state);
|
|
415
|
-
const newPageSchema = keepUid ?
|
|
431
|
+
const newPageSchema = keepUid ? schema : updateUidOfPageSchema(schema);
|
|
416
432
|
const pageSchemaUid = (newPageSchema == null ? void 0 : newPageSchema["x-uid"]) || (0, import_shared.uid)();
|
|
417
433
|
const newTabSchemaUid = (0, import_shared.uid)();
|
|
418
434
|
const newTabSchemaName = (0, import_shared.uid)();
|
|
@@ -916,6 +932,7 @@ async function expectSettingsMenu({
|
|
|
916
932
|
}) {
|
|
917
933
|
await page.waitForTimeout(100);
|
|
918
934
|
await showMenu();
|
|
935
|
+
await page.waitForTimeout(2e3);
|
|
919
936
|
for (const option of supportedOptions) {
|
|
920
937
|
await (0, import_test.expect)(page.getByRole("menuitem", { name: option, exact: option === "Edit" })).toBeVisible();
|
|
921
938
|
}
|
|
@@ -30,13 +30,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
31
|
mod
|
|
32
32
|
));
|
|
33
|
-
var import_http = __toESM(require("http"));
|
|
34
|
-
var import_url = __toESM(require("url"));
|
|
35
|
-
var import_pg = __toESM(require("pg"));
|
|
36
33
|
var import_dotenv = __toESM(require("dotenv"));
|
|
37
|
-
var
|
|
38
|
-
var import_promise = __toESM(require("mysql2/promise"));
|
|
34
|
+
var import_http = __toESM(require("http"));
|
|
39
35
|
var import_mariadb = __toESM(require("mariadb"));
|
|
36
|
+
var import_promise = __toESM(require("mysql2/promise"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_pg = __toESM(require("pg"));
|
|
39
|
+
var import_url = __toESM(require("url"));
|
|
40
40
|
import_dotenv.default.config({ path: import_path.default.resolve(process.cwd(), ".env.test") });
|
|
41
41
|
const _BaseClient = class _BaseClient {
|
|
42
42
|
_client = null;
|
package/lib/server/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export { default as supertest } from 'supertest';
|
|
|
12
12
|
export * from './memory-pub-sub-adapter';
|
|
13
13
|
export * from './mock-isolated-cluster';
|
|
14
14
|
export * from './mock-server';
|
|
15
|
-
export declare const pgOnly: () => any;
|
|
16
15
|
export declare const isPg: () => boolean;
|
|
17
16
|
export declare const isMysql: () => boolean;
|
|
18
17
|
export declare function randomStr(): string;
|
package/lib/server/index.js
CHANGED
|
@@ -44,7 +44,6 @@ __export(server_exports, {
|
|
|
44
44
|
isMysql: () => isMysql,
|
|
45
45
|
isPg: () => isPg,
|
|
46
46
|
mockDatabase: () => import_database.mockDatabase,
|
|
47
|
-
pgOnly: () => pgOnly,
|
|
48
47
|
randomStr: () => randomStr,
|
|
49
48
|
sleep: () => sleep,
|
|
50
49
|
startServerWithRandomPort: () => startServerWithRandomPort,
|
|
@@ -52,14 +51,12 @@ __export(server_exports, {
|
|
|
52
51
|
waitSecond: () => waitSecond
|
|
53
52
|
});
|
|
54
53
|
module.exports = __toCommonJS(server_exports);
|
|
55
|
-
var import_vitest = require("vitest");
|
|
56
54
|
var import_ws = __toESM(require("ws"));
|
|
57
55
|
var import_database = require("@nocobase/database");
|
|
58
56
|
var import_supertest = __toESM(require("supertest"));
|
|
59
57
|
__reExport(server_exports, require("./memory-pub-sub-adapter"), module.exports);
|
|
60
58
|
__reExport(server_exports, require("./mock-isolated-cluster"), module.exports);
|
|
61
59
|
__reExport(server_exports, require("./mock-server"), module.exports);
|
|
62
|
-
const pgOnly = /* @__PURE__ */ __name(() => process.env.DB_DIALECT == "postgres" ? import_vitest.describe : import_vitest.describe.skip, "pgOnly");
|
|
63
60
|
const isPg = /* @__PURE__ */ __name(() => process.env.DB_DIALECT == "postgres", "isPg");
|
|
64
61
|
const isMysql = /* @__PURE__ */ __name(() => process.env.DB_DIALECT == "mysql", "isMysql");
|
|
65
62
|
function randomStr() {
|
|
@@ -119,7 +116,6 @@ const createWsClient = /* @__PURE__ */ __name(async ({ serverPort, options = {}
|
|
|
119
116
|
isMysql,
|
|
120
117
|
isPg,
|
|
121
118
|
mockDatabase,
|
|
122
|
-
pgOnly,
|
|
123
119
|
randomStr,
|
|
124
120
|
sleep,
|
|
125
121
|
startServerWithRandomPort,
|
|
@@ -56,7 +56,7 @@ interface Resource {
|
|
|
56
56
|
sort: (params?: SortActionParams) => Promise<supertest.Response>;
|
|
57
57
|
[name: string]: (params?: ActionParams) => Promise<supertest.Response>;
|
|
58
58
|
}
|
|
59
|
-
interface ExtendedAgent extends SuperAgentTest {
|
|
59
|
+
export interface ExtendedAgent extends SuperAgentTest {
|
|
60
60
|
login: (user: any, roleName?: string) => Promise<ExtendedAgent>;
|
|
61
61
|
loginUsingId: (userId: number, roleName?: string) => Promise<ExtendedAgent>;
|
|
62
62
|
resource: (name: string, resourceOf?: any) => Resource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/test",
|
|
3
|
-
"version": "1.7.0
|
|
3
|
+
"version": "1.7.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.7.0
|
|
54
|
+
"@nocobase/server": "1.7.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",
|
|
@@ -69,12 +69,11 @@
|
|
|
69
69
|
"mysql2": "^3.11.0",
|
|
70
70
|
"pg": "^8.7.3",
|
|
71
71
|
"pg-hstore": "^2.3.4",
|
|
72
|
-
"sqlite3": "^5.0.8",
|
|
73
72
|
"supertest": "^6.1.6",
|
|
74
73
|
"vite": "^5.0.0",
|
|
75
74
|
"vitest": "^1.5.0",
|
|
76
75
|
"vitest-dom": "^0.1.1",
|
|
77
76
|
"ws": "^8.13.0"
|
|
78
77
|
},
|
|
79
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "767ae089e404a104d718962272289c0bec01803a"
|
|
80
79
|
}
|