@nocobase/test 2.1.0-alpha.22 → 2.1.0-alpha.24

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.
@@ -46,7 +46,9 @@ __export(client_exports, {
46
46
  waitForApp: () => waitForApp
47
47
  });
48
48
  module.exports = __toCommonJS(client_exports);
49
+ var import_react = __toESM(require("react"));
49
50
  var import_react2 = require("@testing-library/react");
51
+ var import_flow_engine = require("@nocobase/flow-engine");
50
52
  var import_web = require("../web");
51
53
  __reExport(client_exports, require("./utils"), module.exports);
52
54
  var import_react_hooks = require("@testing-library/react-hooks");
@@ -59,9 +61,9 @@ __reExport(client_exports, require("./renderSingleSettings"), module.exports);
59
61
  __reExport(client_exports, require("./settingsChecker"), module.exports);
60
62
  __reExport(client_exports, require("./commonSettingsChecker"), module.exports);
61
63
  function customRender(ui, options = {}) {
64
+ const flowEngine = new import_flow_engine.FlowEngine();
62
65
  return (0, import_react2.render)(ui, {
63
- // wrap provider(s) here if needed
64
- wrapper: /* @__PURE__ */ __name(({ children }) => children, "wrapper"),
66
+ wrapper: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ import_react.default.createElement(import_flow_engine.FlowEngineProvider, { engine: flowEngine }, children), "wrapper"),
65
67
  ...options
66
68
  });
67
69
  }
@@ -42,8 +42,8 @@ __export(renderAppOptions_exports, {
42
42
  });
43
43
  module.exports = __toCommonJS(renderAppOptions_exports);
44
44
  var import_react = __toESM(require("react"));
45
- var import__ = require(".");
46
45
  var import_web = require("../web");
46
+ var import__ = require(".");
47
47
  var import_utils = require("./utils");
48
48
  const renderAppOptions = /* @__PURE__ */ __name(async (options) => {
49
49
  const App = (0, import_web.getAppComponent)(options);
@@ -35,15 +35,40 @@ module.exports = __toCommonJS(renderSettings_exports);
35
35
  var import_react = require("@testing-library/react");
36
36
  var import_renderAppOptions = require("./renderAppOptions");
37
37
  var import_utils = require("./utils");
38
+ const querySettingsButton = /* @__PURE__ */ __name((container) => {
39
+ return container.querySelector('[aria-label^="designer-schema-settings-"]');
40
+ }, "querySettingsButton");
41
+ const querySettingsTrigger = /* @__PURE__ */ __name((container) => {
42
+ const button = querySettingsButton(container);
43
+ if (!button) {
44
+ return null;
45
+ }
46
+ return button.closest(".ant-dropdown-trigger") || button;
47
+ }, "querySettingsTrigger");
48
+ const revealSchemaToolbar = /* @__PURE__ */ __name((container) => {
49
+ const blockItem = container.querySelector('[aria-label^="block-item-"]');
50
+ if (!blockItem) {
51
+ return;
52
+ }
53
+ import_react.fireEvent.mouseEnter(blockItem);
54
+ import_react.fireEvent.mouseOver(blockItem);
55
+ }, "revealSchemaToolbar");
38
56
  async function showSettingsMenu(container = document) {
39
57
  await (0, import_react.waitFor)(() => {
40
- return (0, import_utils.expectNoTsError)(container.querySelector('[aria-label^="designer-schema-settings-"]')).toBeInTheDocument();
58
+ if (!querySettingsButton(container)) {
59
+ revealSchemaToolbar(container);
60
+ }
61
+ return (0, import_utils.expectNoTsError)(querySettingsButton(container)).toBeInTheDocument();
41
62
  });
42
63
  const button = await (0, import_react.waitFor)(() => {
43
- return container.querySelector('[aria-label^="designer-schema-settings-"]');
64
+ if (!querySettingsButton(container)) {
65
+ revealSchemaToolbar(container);
66
+ }
67
+ return querySettingsButton(container);
44
68
  });
45
- import_react.fireEvent.mouseEnter(button);
46
- import_react.fireEvent.mouseOver(button);
69
+ const trigger = querySettingsTrigger(container) || button;
70
+ import_react.fireEvent.mouseEnter(trigger);
71
+ import_react.fireEvent.mouseOver(trigger);
47
72
  await (0, import_react.waitFor)(() => {
48
73
  return (0, import_utils.expectNoTsError)(import_react.screen.queryByTestId("schema-settings-menu")).toBeInTheDocument();
49
74
  });
@@ -80,6 +80,18 @@ const _BaseClient = class _BaseClient {
80
80
  };
81
81
  __name(_BaseClient, "BaseClient");
82
82
  let BaseClient = _BaseClient;
83
+ function escapeMysqlIdentifier(name) {
84
+ return `\`${String(name).replace(/`/g, "``")}\``;
85
+ }
86
+ __name(escapeMysqlIdentifier, "escapeMysqlIdentifier");
87
+ function escapeMysqlString(value) {
88
+ return `'${String(value).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
89
+ }
90
+ __name(escapeMysqlString, "escapeMysqlString");
91
+ function mysqlAppUser() {
92
+ return String(process.env["DB_APP_USER"] || process.env["DB_USER"] || "").trim();
93
+ }
94
+ __name(mysqlAppUser, "mysqlAppUser");
83
95
  const _PostgresClient = class _PostgresClient extends BaseClient {
84
96
  async _removeDB(name) {
85
97
  await this._client.query(`DROP DATABASE IF EXISTS ${name}`);
@@ -107,7 +119,15 @@ const _MySQLClient = class _MySQLClient extends BaseClient {
107
119
  await this._client.query(`DROP DATABASE IF EXISTS ${name}`);
108
120
  }
109
121
  async _createDB(name) {
110
- await this._client.query(`CREATE DATABASE IF NOT EXISTS ${name}`);
122
+ const database = escapeMysqlIdentifier(name);
123
+ const appUser = mysqlAppUser();
124
+ if (!appUser) {
125
+ throw new Error("DB_APP_USER or DB_USER is required for MySQL test database grants.");
126
+ }
127
+ const user = escapeMysqlString(appUser);
128
+ await this._client.query(`CREATE DATABASE IF NOT EXISTS ${database}`);
129
+ await this._client.query(`GRANT ALL PRIVILEGES ON ${database}.* TO ${user}@'%'`);
130
+ await this._client.query("FLUSH PRIVILEGES");
111
131
  }
112
132
  async _createConnection() {
113
133
  return import_promise.default.createConnection({
@@ -126,7 +146,15 @@ const _MariaDBClient = class _MariaDBClient extends BaseClient {
126
146
  await this._client.query(`DROP DATABASE IF EXISTS ${name}`);
127
147
  }
128
148
  async _createDB(name) {
129
- await this._client.query(`CREATE DATABASE IF NOT EXISTS ${name}`);
149
+ const database = escapeMysqlIdentifier(name);
150
+ const appUser = mysqlAppUser();
151
+ if (!appUser) {
152
+ throw new Error("DB_APP_USER or DB_USER is required for MariaDB test database grants.");
153
+ }
154
+ const user = escapeMysqlString(appUser);
155
+ await this._client.query(`CREATE DATABASE IF NOT EXISTS ${database}`);
156
+ await this._client.query(`GRANT ALL PRIVILEGES ON ${database}.* TO ${user}@'%'`);
157
+ await this._client.query("FLUSH PRIVILEGES");
130
158
  }
131
159
  async _createConnection() {
132
160
  return await import_mariadb.default.createConnection({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/test",
3
- "version": "2.1.0-alpha.22",
3
+ "version": "2.1.0-alpha.24",
4
4
  "main": "lib/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./lib/index.d.ts",
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@faker-js/faker": "8.1.0",
54
- "@nocobase/server": "2.1.0-alpha.22",
55
- "@nocobase/utils": "2.1.0-alpha.22",
54
+ "@nocobase/server": "2.1.0-alpha.24",
55
+ "@nocobase/utils": "2.1.0-alpha.24",
56
56
  "@playwright/test": "^1.45.3",
57
57
  "@testing-library/jest-dom": "^6.4.2",
58
58
  "@testing-library/react": "^14.0.0",
@@ -77,5 +77,5 @@
77
77
  "vitest-dom": "^0.1.1",
78
78
  "ws": "^8.13.0"
79
79
  },
80
- "gitHead": "a1ac28a12fd06c1233f2f7b062c90c0c9bb64222"
80
+ "gitHead": "effaf56a9b9ea2d40200c4c10854a84d9622f071"
81
81
  }