@etsoo/materialui 1.3.55 → 1.3.56
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/__tests__/ReactAppTests.tsx +107 -0
- package/package.json +5 -5
- package/src/app/ReactApp.ts +1 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddressUtils,
|
|
3
|
+
ApiAuthorizationScheme,
|
|
4
|
+
ExternalSettings,
|
|
5
|
+
en,
|
|
6
|
+
zhHans
|
|
7
|
+
} from "@etsoo/appscript";
|
|
8
|
+
import { ReactApp } from "../src";
|
|
9
|
+
import { DataTypes, DomUtils, IActionResult, Utils } from "@etsoo/shared";
|
|
10
|
+
import React, { act } from "react";
|
|
11
|
+
import { createRoot } from "react-dom/client";
|
|
12
|
+
|
|
13
|
+
// Without it will popup error:
|
|
14
|
+
// The current testing environment is not configured to support act
|
|
15
|
+
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
16
|
+
|
|
17
|
+
// Detected country or region
|
|
18
|
+
const { detectedCountry } = DomUtils;
|
|
19
|
+
|
|
20
|
+
// Detected culture
|
|
21
|
+
const { detectedCulture } = DomUtils;
|
|
22
|
+
|
|
23
|
+
// Supported cultures
|
|
24
|
+
const supportedCultures: DataTypes.CultureDefinition[] = [zhHans({}), en({})];
|
|
25
|
+
|
|
26
|
+
// Supported regions
|
|
27
|
+
const supportedRegions = ["CN"];
|
|
28
|
+
|
|
29
|
+
const settings = ExternalSettings.format({
|
|
30
|
+
/**
|
|
31
|
+
* Endpoint of the API service
|
|
32
|
+
*/
|
|
33
|
+
endpoint: "http://{hostname}/com.etsoo.SmartERPApi/api/",
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* App root url
|
|
37
|
+
*/
|
|
38
|
+
homepage: "/cms",
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Web url of the cloud
|
|
42
|
+
*/
|
|
43
|
+
webUrl: "http://localhost",
|
|
44
|
+
|
|
45
|
+
// Authorization scheme
|
|
46
|
+
authScheme: ApiAuthorizationScheme.Bearer,
|
|
47
|
+
|
|
48
|
+
// Detected culture
|
|
49
|
+
detectedCulture,
|
|
50
|
+
|
|
51
|
+
// Supported cultures
|
|
52
|
+
cultures: supportedCultures,
|
|
53
|
+
|
|
54
|
+
// Supported regions
|
|
55
|
+
regions: supportedRegions,
|
|
56
|
+
|
|
57
|
+
// Browser's time zone
|
|
58
|
+
timeZone: Utils.getTimeZone(),
|
|
59
|
+
|
|
60
|
+
// Current country or region
|
|
61
|
+
currentRegion: AddressUtils.getRegion(
|
|
62
|
+
supportedRegions,
|
|
63
|
+
detectedCountry,
|
|
64
|
+
detectedCulture
|
|
65
|
+
),
|
|
66
|
+
|
|
67
|
+
// Current culture
|
|
68
|
+
currentCulture: DomUtils.getCulture(supportedCultures, detectedCulture)![0]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const app = new ReactApp(settings, "test");
|
|
72
|
+
|
|
73
|
+
// Root
|
|
74
|
+
const root = document.body;
|
|
75
|
+
const container: HTMLElement = document.createElement("div");
|
|
76
|
+
root.append(container);
|
|
77
|
+
|
|
78
|
+
// The state provider
|
|
79
|
+
const Provider = ReactApp.notifierProvider;
|
|
80
|
+
const reactRoot = createRoot(container);
|
|
81
|
+
|
|
82
|
+
act(() => {
|
|
83
|
+
// Concorrent renderer needs act block
|
|
84
|
+
reactRoot.render(<Provider />);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("Test for properties", () => {
|
|
88
|
+
const result: IActionResult = {
|
|
89
|
+
ok: false,
|
|
90
|
+
type: "https://tools.ietf.org/html/rfc9110#section-15.5.1",
|
|
91
|
+
title: "One or more validation errors occurred.",
|
|
92
|
+
status: 400,
|
|
93
|
+
errors: {
|
|
94
|
+
$: [
|
|
95
|
+
"JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password"
|
|
96
|
+
],
|
|
97
|
+
rq: ["The rq field is required."]
|
|
98
|
+
},
|
|
99
|
+
traceId: "00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00"
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
act(() => {
|
|
103
|
+
app.alertResult(result);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(root.innerHTML).toContain(result.title);
|
|
107
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.56",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"@emotion/css": "^11.11.2",
|
|
51
51
|
"@emotion/react": "^11.11.4",
|
|
52
52
|
"@emotion/styled": "^11.11.5",
|
|
53
|
-
"@etsoo/appscript": "^1.4.
|
|
53
|
+
"@etsoo/appscript": "^1.4.89",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.42",
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
55
|
+
"@etsoo/react": "^1.7.43",
|
|
56
56
|
"@etsoo/shared": "^1.2.40",
|
|
57
57
|
"@mui/icons-material": "^5.15.17",
|
|
58
58
|
"@mui/material": "^5.15.17",
|
|
59
|
-
"@mui/x-data-grid": "^7.
|
|
59
|
+
"@mui/x-data-grid": "^7.4.0",
|
|
60
60
|
"chart.js": "^4.4.2",
|
|
61
61
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
62
62
|
"eventemitter3": "^5.0.1",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/jest": "^29.5.12",
|
|
83
83
|
"@types/pica": "^9.0.4",
|
|
84
84
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
85
|
-
"@types/react": "^18.3.
|
|
85
|
+
"@types/react": "^18.3.2",
|
|
86
86
|
"@types/react-avatar-editor": "^13.0.2",
|
|
87
87
|
"@types/react-dom": "^18.3.0",
|
|
88
88
|
"@types/react-input-mask": "^3.0.5",
|