Skip to content

Commit ab73917

Browse files
fixed unit tests
1 parent 3381113 commit ab73917

22 files changed

+64
-110
lines changed

client/config/test/jest.config.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ export default {
2020
testEnvironment: "jsdom",
2121
moduleNameMapper: {
2222
"react-markdown": path.resolve(currentDir, "./mocks/react-markdown.js"),
23-
"react-redux": path.resolve(currentDir, "./mocks/react-redux.js"),
24-
"react-draggable": path.resolve(currentDir, "./mocks/react-draggable.js"),
25-
"react-resize-detector": path.resolve(currentDir, "./mocks/react-resize-detector.js"),
26-
"react-virtualized": path.resolve(currentDir, "./mocks/react-virtualized.js"),
27-
"@dnd-kit/sortable": path.resolve(currentDir, "./mocks/dnd-kit-sortable.js"),
28-
"@dnd-kit/core": path.resolve(currentDir, "./mocks/dnd-kit-core.js"),
29-
"antd": path.resolve(currentDir, "./mocks/antd.js"),
30-
"@rjsf/antd": path.resolve(currentDir, "./mocks/rjsf-antd.js"),
31-
"history": path.resolve(currentDir, "./mocks/history.js"),
3223
"\\.md\\?url$": path.resolve(currentDir, "./mocks/markdown-url-module.js"),
3324
"^@lowcoder-ee(.*)$": path.resolve(
3425
currentDir,
@@ -44,13 +35,6 @@ export default {
4435
path.resolve(currentDir, "../../packages/lowcoder-comps/src"),
4536
path.resolve(currentDir, "../../packages/lowcoder-design/src"),
4637
],
47-
// moduleDirectories: [
48-
// "<rootDir>/client/node_modules",
49-
// path.resolve(currentDir, "../../node_modules"),
50-
// path.resolve(currentDir, "../../packages/lowcoder/node_modules"),
51-
// path.resolve(currentDir, "../../packages/lowcoder-comps/node_modules"),
52-
// path.resolve(currentDir, "../../packages/lowcoder-design/node_modules"),
53-
// ],
5438
setupFiles: [path.resolve(currentDir, "./jest.setup.js")],
5539
setupFilesAfterEnv: [path.resolve(currentDir, "./jest.setup-after-env.js"), 'jest-canvas-mock'],
5640
transform: {

client/config/test/jest.setup-after-env.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Object.defineProperty(window, "navigator", {
4040
enumerateDevices: jest.fn(),
4141
},
4242
userAgent: '',
43+
language: '',
44+
browserLanguage: '',
4345
},
4446
});
4547

client/config/test/jest.setup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// if (typeof window !== "undefined") {
2-
// require("whatwg-fetch");
3-
// }
1+
if (typeof window !== "undefined") {
2+
require("whatwg-fetch");
3+
}

client/config/test/mocks/antd.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/dnd-kit-core.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/dnd-kit-sortable.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/history.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/react-draggable.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/react-redux.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

client/config/test/mocks/react-resize-detector.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/react-virtualized.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/test/mocks/rjsf-antd.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

client/packages/lowcoder/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"@fortawesome/free-solid-svg-icons": "^6.4.0",
2525
"@fortawesome/react-fontawesome": "latest",
2626
"@manaflair/redux-batch": "^1.0.0",
27-
"@rjsf/antd": "^5.10.0",
28-
"@rjsf/core": "^5.10.0",
29-
"@rjsf/utils": "^5.10.0",
30-
"@rjsf/validator-ajv8": "^5.10.0",
27+
"@rjsf/antd": "^5.15.1",
28+
"@rjsf/core": "^5.15.1",
29+
"@rjsf/utils": "^5.15.1",
30+
"@rjsf/validator-ajv8": "^5.15.1",
3131
"@types/lodash": "^4.14.194",
3232
"@types/node": "^16.7.13",
3333
"@types/react": "^18.2.45",

client/packages/lowcoder/src/comps/comps/autoCompleteComp/autoCompleteComp.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import {
3333
import { trans } from "i18n";
3434
import { IconControl } from "comps/controls/iconControl";
3535
import { hasIcon } from "comps/utils";
36-
import { default as AntInput, InputRef } from "antd/es/input";
36+
import { InputRef } from "antd/es/input";
37+
import { default as AntInputSearch } from "antd/es/input/Search";
3738
import { default as ConfigProvider } from "antd/es/config-provider";
3839
import { default as AutoComplete } from "antd/es/auto-complete";
3940
import { RefControl } from "comps/controls/refControl";
@@ -69,7 +70,7 @@ const InputStyle = styled(Input)<{ $style: InputLikeStyleType }>`
6970
`}
7071
`;
7172

72-
const CustomStyledSearch = styled(AntInput.Search)<{ $style: InputLikeStyleType }>`
73+
const CustomStyledSearch = styled(AntInputSearch)<{ $style: InputLikeStyleType }>`
7374
${(props) => css`
7475
padding: 0;
7576
input.ant-input {

client/packages/lowcoder/src/comps/comps/dateComp/timeRangeUIView.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import dayjs from "dayjs";
1111
import { hasIcon } from "comps/utils";
1212
import { omit } from "lodash";
1313

14-
const RangePickerStyled = styled(TimePicker.RangePicker)<{ $style: DateTimeStyleType }>`
14+
const { RangePicker } = TimePicker;
15+
16+
const RangePickerStyled = styled((props: any) => <RangePicker {...props} />)<{ $style: DateTimeStyleType }>`
1517
width: 100%;
1618
${(props) => props.$style && getStyle(props.$style)}
1719
`;
@@ -46,7 +48,7 @@ export const TimeRangeUIView = (props: TimeRangeUIViewProps) => {
4648
value={[props.start, props.end]}
4749
order={true}
4850
hideDisabledOptions
49-
onCalendarChange={(time) => {
51+
onCalendarChange={(time: any) => {
5052
props.onChange(time?.[0], time?.[1]);
5153
}}
5254
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}

client/packages/lowcoder/src/comps/comps/formComp/createForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { default as Form, FormInstance } from "antd/es/form";
2+
import { default as AntdFormItem } from "antd/es/form/FormItem";
23
import { default as Select } from "antd/es/select";
34
import {
45
CheckBox,
@@ -76,7 +77,7 @@ const SelectOptionWrapper = styled.div`
7677
width: 100%;
7778
align-items: center;
7879
`;
79-
const FormItem = styled(Form.Item)`
80+
const FormItem = styled(AntdFormItem)`
8081
margin: 0;
8182
line-height: 13px;
8283
width: 100%;

client/packages/lowcoder/src/comps/comps/jsonSchemaFormComp/jsonSchemaFormComp.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
2727
import { useContext } from "react";
2828
import { EditorContext } from "comps/editorState";
2929

30-
console.log('THEME', Theme);
3130
Theme.widgets.DateWidget = DateWidget(false);
3231
Theme.widgets.DateTimeWidget = DateWidget(true);
3332
const Form = withTheme(Theme);
@@ -321,11 +320,9 @@ let FormBasicComp = (function () {
321320
)}
322321

323322
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
324-
<>
325-
<Section name={sectionNames.style}>
326-
{children.style.getPropertyView()}
327-
</Section>
328-
</>
323+
<Section name={sectionNames.style}>
324+
{children.style.getPropertyView()}
325+
</Section>
329326
)}
330327

331328
</>

client/packages/lowcoder/src/comps/comps/meetingComp/controlButton.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import {
3333
ButtonStyleControl,
3434
} from "./videobuttonCompConstants";
3535
import { RefControl } from "comps/controls/refControl";
36+
import { AutoHeightControl } from "comps/controls/autoHeightControl";
3637
import {
37-
AutoHeightControl,
3838
heightCalculator,
3939
widthCalculator,
40-
} from "@lowcoder-ee/index.sdk";
40+
} from "comps/controls/styleControlConstants";
4141
import { useEffect, useRef, useState } from "react";
4242
import ReactResizeDetector from "react-resize-detector";
4343

@@ -176,21 +176,21 @@ function submitForm(editorState: EditorState, formName: string) {
176176
}
177177
}
178178

179-
let ButtonTmpComp = (function () {
180-
const childrenMap = {
181-
iconSize: withDefault(StringControl, "20px"),
182-
type: dropdownControl(typeOptions, ""),
183-
autoHeight: withDefault(AutoHeightControl, "fixed"),
184-
aspectRatio: withDefault(StringControl, "1 / 1"),
185-
onEvent: ButtonEventHandlerControl,
186-
disabled: BoolCodeControl,
187-
loading: BoolCodeControl,
188-
form: SelectFormControl,
189-
prefixIcon: IconControl,
190-
style: ButtonStyleControl,
191-
viewRef: RefControl<HTMLElement>,
192-
};
179+
const childrenMap = {
180+
iconSize: withDefault(StringControl, "20px"),
181+
type: dropdownControl(typeOptions, ""),
182+
autoHeight: withDefault(AutoHeightControl, "fixed"),
183+
aspectRatio: withDefault(StringControl, "1 / 1"),
184+
onEvent: ButtonEventHandlerControl,
185+
disabled: BoolCodeControl,
186+
loading: BoolCodeControl,
187+
form: SelectFormControl,
188+
prefixIcon: IconControl,
189+
style: ButtonStyleControl,
190+
viewRef: RefControl<HTMLElement>,
191+
};
193192

193+
let ButtonTmpComp = (function () {
194194
return new UICompBuilder(childrenMap, (props) => {
195195
const [width, setWidth] = useState(120);
196196
const [height, setHeight] = useState(0);

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingStreamComp.tsx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import { BoolCodeControl } from "comps/controls/codeControl";
1+
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
22
import { EditorContext } from "comps/editorState";
3-
import { withDefault } from "comps/generators";
3+
import { withDefault } from "comps/generators/simpleGenerators";
44
import { UICompBuilder } from "comps/generators/uiCompBuilder";
55
import ReactResizeDetector from "react-resize-detector";
6-
76
import {
87
Section,
98
sectionNames,
109
} from "lowcoder-design";
1110
import { trans } from "i18n";
12-
13-
import styled, { css } from "styled-components";
11+
import styled from "styled-components";
1412
import {
1513
CommonNameConfig,
1614
NameConfig,
@@ -19,22 +17,13 @@ import {
1917
import { ButtonStyleControl } from "./videobuttonCompConstants";
2018
import { RefControl } from "comps/controls/refControl";
2119
import { useEffect, useRef, useState } from "react";
22-
2320
import { AutoHeightControl } from "comps/controls/autoHeightControl";
2421
import { client } from "./videoMeetingControllerComp";
25-
2622
import { IAgoraRTCRemoteUser } from "agora-rtc-sdk-ng";
27-
28-
import {
29-
MeetingEventHandlerControl,
30-
StringControl,
31-
StringStateControl,
32-
hiddenPropertyView,
33-
stringExposingStateControl,
34-
} from "@lowcoder-ee/index.sdk";
35-
import { BoolShareVideoControl } from "./meetingControlerUtils";
36-
3723
import { useContext } from "react";
24+
import { MeetingEventHandlerControl } from "comps/controls/eventHandlerControl";
25+
import { StringStateControl, stringExposingStateControl } from "comps/controls/codeStateControl";
26+
import { hiddenPropertyView } from "comps/utils/propertyUtils";
3827

3928
const VideoContainer = styled.video`
4029
height: 100%;
@@ -59,7 +48,7 @@ const meetingStreamChildren = {
5948
noVideoText: stringExposingStateControl(trans("meeting.noVideo")),
6049
};
6150

62-
let VideoCompBuilder = (function (props) {
51+
let VideoCompBuilder = (function () {
6352
return new UICompBuilder(meetingStreamChildren, (props) => {
6453
const videoRef = useRef<HTMLVideoElement>(null);
6554
const conRef = useRef<HTMLDivElement>(null);

client/packages/lowcoder/src/comps/comps/meetingComp/videoSharingStreamComp.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BoolCodeControl } from "comps/controls/codeControl";
1+
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
22
import { EditorContext } from "comps/editorState";
33
import { withDefault } from "comps/generators";
44
import { UICompBuilder } from "comps/generators/uiCompBuilder";
@@ -8,8 +8,7 @@ import {
88
sectionNames,
99
} from "lowcoder-design";
1010
import { trans } from "i18n";
11-
12-
import styled, { css } from "styled-components";
11+
import styled from "styled-components";
1312
import {
1413
CommonNameConfig,
1514
NameConfig,
@@ -18,21 +17,13 @@ import {
1817
import { ButtonStyleControl } from "./videobuttonCompConstants";
1918
import { RefControl } from "comps/controls/refControl";
2019
import { useEffect, useRef, useState } from "react";
21-
2220
import { AutoHeightControl } from "comps/controls/autoHeightControl";
2321
import { client } from "./videoMeetingControllerComp";
24-
2522
import { IAgoraRTCRemoteUser } from "agora-rtc-sdk-ng";
26-
27-
import {
28-
MeetingEventHandlerControl,
29-
StringControl,
30-
hiddenPropertyView,
31-
stringExposingStateControl,
32-
} from "@lowcoder-ee/index.sdk";
33-
import { BoolShareVideoControl } from "./meetingControlerUtils";
34-
3523
import { useContext } from "react";
24+
import { MeetingEventHandlerControl } from "comps/controls/eventHandlerControl";
25+
import { stringExposingStateControl } from "comps/controls/codeStateControl";
26+
import { hiddenPropertyView } from "comps/utils/propertyUtils";
3627

3728
const VideoContainer = styled.video`
3829
height: 100%;
@@ -56,7 +47,7 @@ const sharingStreamChildren = {
5647
noVideoText: stringExposingStateControl(trans("meeting.noVideo")),
5748
};
5849

59-
let SharingCompBuilder = (function (props) {
50+
let SharingCompBuilder = (function () {
6051
return new UICompBuilder(sharingStreamChildren, (props) => {
6152
const videoRef = useRef<HTMLVideoElement>(null);
6253
const conRef = useRef<HTMLDivElement>(null);

client/packages/lowcoder/src/comps/comps/meetingComp/videobuttonCompConstants.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ export function getButtonStyle(buttonStyle: ButtonStyleType) {
3232
margin: ${buttonStyle.margin};
3333
padding: ${buttonStyle.padding};
3434
35-
:hover,
36-
:focus {
35+
&:hover,
36+
&:focus {
3737
color: ${buttonStyle.text};
3838
background-color: ${hoverColor};
3939
border-color: ${buttonStyle.border === buttonStyle.background
4040
? hoverColor
4141
: buttonStyle.border};
4242
}
4343
44-
:active {
44+
&:active {
4545
color: ${buttonStyle.text};
4646
background-color: ${activeColor};
4747
border-color: ${buttonStyle.border === buttonStyle.background

0 commit comments

Comments
 (0)