@lowdefy/block-dev 4.0.0-alpha.9 → 4.0.0-rc.1
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/dist/BlockSchemaErrors.js +3 -4
- package/dist/index.js +1 -1
- package/dist/mockBlock.js +3 -5
- package/dist/runBlockSchemaTests.js +1 -1
- package/dist/runMockMethodTests.js +11 -11
- package/dist/runMockRenderTests.js +13 -16
- package/dist/runRenderTests.js +13 -20
- package/dist/schemaTest.js +1 -1
- package/dist/stubBlockProps.js +11 -21
- package/package.json +18 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
17
17
|
if (!schemaErrors || schemaErrors.length === 0) return '';
|
|
18
|
-
return
|
|
18
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
19
19
|
style: {
|
|
20
20
|
padding: 10,
|
|
21
21
|
fontSize: '0.8rem',
|
|
@@ -25,7 +25,6 @@ const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
|
25
25
|
}
|
|
26
26
|
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "Schema Errors")), schemaErrors.map((error, i)=>/*#__PURE__*/ React.createElement("div", {
|
|
27
27
|
key: i
|
|
28
|
-
}, /*#__PURE__*/ React.createElement("br", null), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "keyword:"), " ", error.keyword), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "message:"), " ", error.message), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "params:"), " ", JSON.stringify(error.params)), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "dataPath:"), " ", error.dataPath), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "schemaPath:"), " ", error.schemaPath))
|
|
29
|
-
)));
|
|
28
|
+
}, /*#__PURE__*/ React.createElement("br", null), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "keyword:"), " ", error.keyword), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "message:"), " ", error.message), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "params:"), " ", JSON.stringify(error.params)), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "dataPath:"), " ", error.dataPath), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "schemaPath:"), " ", error.schemaPath))));
|
|
30
29
|
};
|
|
31
30
|
export default BlockSchemaErrors;
|
package/dist/index.js
CHANGED
package/dist/mockBlock.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
import stubBlockProps from './stubBlockProps.js';
|
|
17
17
|
const mockBlock = ({ meta , schema })=>{
|
|
18
18
|
const mockMath = Object.create(global.Math);
|
|
19
|
-
mockMath.random = ()=>0.5
|
|
20
|
-
;
|
|
19
|
+
mockMath.random = ()=>0.5;
|
|
21
20
|
global.Math = mockMath;
|
|
22
21
|
const moveItemDown = jest.fn();
|
|
23
22
|
const moveItemUp = jest.fn();
|
|
@@ -65,8 +64,7 @@ const mockBlock = ({ meta , schema })=>{
|
|
|
65
64
|
addEventListener: jest.fn(),
|
|
66
65
|
removeEventListener: jest.fn(),
|
|
67
66
|
dispatchEvent: jest.fn()
|
|
68
|
-
})
|
|
69
|
-
)
|
|
67
|
+
}))
|
|
70
68
|
});
|
|
71
69
|
}
|
|
72
70
|
if (typeof window !== 'undefined') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,12 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { type } from '@lowdefy/helpers';
|
|
17
|
-
import { render, screen } from '@testing-library/react';
|
|
18
|
-
import userEvent from '@testing-library/user-event';
|
|
19
|
-
import mockBlock from './mockBlock.js';
|
|
20
|
-
function _extends() {
|
|
15
|
+
*/ function _extends() {
|
|
21
16
|
_extends = Object.assign || function(target) {
|
|
22
17
|
for(var i = 1; i < arguments.length; i++){
|
|
23
18
|
var source = arguments[i];
|
|
@@ -31,8 +26,13 @@ function _extends() {
|
|
|
31
26
|
};
|
|
32
27
|
return _extends.apply(this, arguments);
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { type } from '@lowdefy/helpers';
|
|
31
|
+
import { render, screen } from '@testing-library/react';
|
|
32
|
+
import userEvent from '@testing-library/user-event';
|
|
33
|
+
import mockBlock from './mockBlock.js';
|
|
34
|
+
const runMockMethodTests = ({ Block , examples , mocks , schema , testConfig })=>{
|
|
35
|
+
const meta = Block.meta;
|
|
36
36
|
const { before , methods , getProps } = mockBlock({
|
|
37
37
|
meta,
|
|
38
38
|
schema
|
|
@@ -60,7 +60,7 @@ const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testCo
|
|
|
60
60
|
...methods,
|
|
61
61
|
registerMethod: props.methods.registerMethod
|
|
62
62
|
};
|
|
63
|
-
return
|
|
63
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
64
64
|
value: value
|
|
65
65
|
})), /*#__PURE__*/ React.createElement("button", {
|
|
66
66
|
id: `${ex.id}_button`,
|
|
@@ -68,7 +68,7 @@ const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testCo
|
|
|
68
68
|
props.methods[method.name](method.args);
|
|
69
69
|
},
|
|
70
70
|
"data-testid": "btn_method"
|
|
71
|
-
}))
|
|
71
|
+
}));
|
|
72
72
|
};
|
|
73
73
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
74
74
|
expect(container.firstChild).toMatchSnapshot();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,11 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { type } from '@lowdefy/helpers';
|
|
17
|
-
import { render, waitFor } from '@testing-library/react';
|
|
18
|
-
import mockBlock from './mockBlock.js';
|
|
19
|
-
function _extends() {
|
|
15
|
+
*/ function _extends() {
|
|
20
16
|
_extends = Object.assign || function(target) {
|
|
21
17
|
for(var i = 1; i < arguments.length; i++){
|
|
22
18
|
var source = arguments[i];
|
|
@@ -30,10 +26,13 @@ function _extends() {
|
|
|
30
26
|
};
|
|
31
27
|
return _extends.apply(this, arguments);
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { type } from '@lowdefy/helpers';
|
|
31
|
+
import { render, waitFor } from '@testing-library/react';
|
|
32
|
+
import mockBlock from './mockBlock.js';
|
|
33
|
+
const runMockRenderTests = ({ Block , examples , logger , mocks , reset =()=>null , schema , testConfig })=>{
|
|
35
34
|
const { before , getProps } = mockBlock({
|
|
36
|
-
meta:
|
|
35
|
+
meta: Block.meta,
|
|
37
36
|
logger,
|
|
38
37
|
schema
|
|
39
38
|
});
|
|
@@ -41,8 +40,7 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
|
|
|
41
40
|
const makeCssImp = (style, op)=>JSON.stringify({
|
|
42
41
|
style,
|
|
43
42
|
options: op
|
|
44
|
-
})
|
|
45
|
-
;
|
|
43
|
+
});
|
|
46
44
|
beforeEach(async ()=>{
|
|
47
45
|
await reset();
|
|
48
46
|
before();
|
|
@@ -51,7 +49,7 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
|
|
|
51
49
|
});
|
|
52
50
|
examples.forEach((ex)=>{
|
|
53
51
|
const values = [
|
|
54
|
-
type.enforceType(
|
|
52
|
+
type.enforceType(Block.meta.valueType, null)
|
|
55
53
|
];
|
|
56
54
|
if (!type.isNone(ex.value)) {
|
|
57
55
|
values.push(ex.value);
|
|
@@ -66,17 +64,16 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
|
|
|
66
64
|
const Block = await mock.getBlock();
|
|
67
65
|
const Shell = ()=>{
|
|
68
66
|
const props = getProps(ex);
|
|
69
|
-
return
|
|
67
|
+
return /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
70
68
|
methods: {
|
|
71
69
|
...props.methods,
|
|
72
70
|
makeCssClass
|
|
73
71
|
},
|
|
74
72
|
value: value
|
|
75
|
-
}))
|
|
73
|
+
}));
|
|
76
74
|
};
|
|
77
75
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
78
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
79
|
-
);
|
|
76
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
80
77
|
mockFns.forEach((mockFn)=>{
|
|
81
78
|
expect(mockFn.mock.calls).toMatchSnapshot();
|
|
82
79
|
});
|
package/dist/runRenderTests.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,11 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { render, waitFor } from '@testing-library/react';
|
|
17
|
-
import { type } from '@lowdefy/helpers';
|
|
18
|
-
import mockBlock from './mockBlock.js';
|
|
19
|
-
function _extends() {
|
|
15
|
+
*/ function _extends() {
|
|
20
16
|
_extends = Object.assign || function(target) {
|
|
21
17
|
for(var i = 1; i < arguments.length; i++){
|
|
22
18
|
var source = arguments[i];
|
|
@@ -30,8 +26,11 @@ function _extends() {
|
|
|
30
26
|
};
|
|
31
27
|
return _extends.apply(this, arguments);
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { render, waitFor } from '@testing-library/react';
|
|
31
|
+
import { type } from '@lowdefy/helpers';
|
|
32
|
+
import mockBlock from './mockBlock.js';
|
|
33
|
+
const runRenderTests = ({ Block , examples , logger , reset =()=>null , schema , testConfig , validationsExamples })=>{
|
|
35
34
|
const { before , methods , getProps } = mockBlock({
|
|
36
35
|
meta: Block.meta,
|
|
37
36
|
logger,
|
|
@@ -57,11 +56,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
57
56
|
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
58
57
|
value: value,
|
|
59
58
|
methods: methods
|
|
60
|
-
}))
|
|
61
|
-
;
|
|
59
|
+
}));
|
|
62
60
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
63
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
64
|
-
);
|
|
61
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
65
62
|
});
|
|
66
63
|
if (testConfig && testConfig.validation) {
|
|
67
64
|
(validationsExamples || []).map((validationEx)=>{
|
|
@@ -71,11 +68,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
71
68
|
value: value,
|
|
72
69
|
methods: methods,
|
|
73
70
|
validation: validationEx
|
|
74
|
-
}))
|
|
75
|
-
;
|
|
71
|
+
}));
|
|
76
72
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
77
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
78
|
-
);
|
|
73
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
79
74
|
});
|
|
80
75
|
});
|
|
81
76
|
}
|
|
@@ -86,11 +81,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
86
81
|
value: value,
|
|
87
82
|
methods: methods,
|
|
88
83
|
required: true
|
|
89
|
-
}))
|
|
90
|
-
;
|
|
84
|
+
}));
|
|
91
85
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
92
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
93
|
-
);
|
|
86
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
94
87
|
});
|
|
95
88
|
}
|
|
96
89
|
});
|
package/dist/schemaTest.js
CHANGED
package/dist/stubBlockProps.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -21,25 +21,21 @@ const Icons = {
|
|
|
21
21
|
AiIcon: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
22
22
|
"data-testid": "AiIcon",
|
|
23
23
|
onClick: onClick
|
|
24
|
-
}, "ICON PROPS: ", JSON.stringify(props))
|
|
25
|
-
,
|
|
24
|
+
}, "ICON PROPS: ", JSON.stringify(props)),
|
|
26
25
|
AiOutlineExclamationCircle: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
27
26
|
"data-testid": "AiOutlineExclamationCircle",
|
|
28
27
|
onClick: onClick
|
|
29
|
-
}, "ICON PROPS: ", JSON.stringify(props))
|
|
30
|
-
,
|
|
28
|
+
}, "ICON PROPS: ", JSON.stringify(props)),
|
|
31
29
|
AiOutlineLoading3Quarters: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
32
30
|
"data-testid": "AiOutlineLoading3Quarters",
|
|
33
31
|
onClick: onClick
|
|
34
|
-
}, "ICON PROPS: ", JSON.stringify(props))
|
|
35
|
-
,
|
|
32
|
+
}, "ICON PROPS: ", JSON.stringify(props)),
|
|
36
33
|
ErrorIcon: ()=>{
|
|
37
34
|
throw new Error('ErrorIcon');
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
37
|
const IconComponent = createIcon(Icons);
|
|
41
|
-
const stubBlockProps = ({ block , meta , logger =()=>null
|
|
42
|
-
, initialValue , schema })=>{
|
|
38
|
+
const stubBlockProps = ({ block , meta , logger =()=>null , initialValue , schema })=>{
|
|
43
39
|
const [value, setState] = useState(type.enforceType(meta.valueType, block.value || initialValue));
|
|
44
40
|
const setValue = (val)=>{
|
|
45
41
|
setState(type.enforceType(meta.valueType, val));
|
|
@@ -101,16 +97,11 @@ const stubBlockProps = ({ block , meta , logger =()=>null
|
|
|
101
97
|
});
|
|
102
98
|
});
|
|
103
99
|
block.methods = {
|
|
104
|
-
pushItem: ()=>log('List pushItem')
|
|
105
|
-
,
|
|
106
|
-
|
|
107
|
-
,
|
|
108
|
-
|
|
109
|
-
,
|
|
110
|
-
moveItemDown: (i)=>log(`List moveItemDown ${i}`)
|
|
111
|
-
,
|
|
112
|
-
moveItemUp: (i)=>log(`List moveItemUp ${i}`)
|
|
113
|
-
,
|
|
100
|
+
pushItem: ()=>log('List pushItem'),
|
|
101
|
+
unshiftItem: ()=>log('List unshiftItem'),
|
|
102
|
+
removeItem: (i)=>log(`List removeItem ${i}`),
|
|
103
|
+
moveItemDown: (i)=>log(`List moveItemDown ${i}`),
|
|
104
|
+
moveItemUp: (i)=>log(`List moveItemUp ${i}`),
|
|
114
105
|
...block.methods
|
|
115
106
|
};
|
|
116
107
|
}
|
|
@@ -124,8 +115,7 @@ const stubBlockProps = ({ block , meta , logger =()=>null
|
|
|
124
115
|
border: '1px solid red',
|
|
125
116
|
padding: 10
|
|
126
117
|
}
|
|
127
|
-
}, key)
|
|
128
|
-
;
|
|
118
|
+
}, key);
|
|
129
119
|
});
|
|
130
120
|
}
|
|
131
121
|
if (meta.category === 'input') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/block-dev",
|
|
3
|
-
"version": "4.0.0-
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Block Development Tools",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
7
7
|
"keywords": [
|
|
@@ -31,32 +31,31 @@
|
|
|
31
31
|
"dist/*"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
34
|
+
"build": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
|
|
35
35
|
"clean": "rm -rf dist",
|
|
36
|
-
"
|
|
37
|
-
"swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start"
|
|
36
|
+
"prepublishOnly": "pnpm build"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@emotion/jest": "11.
|
|
41
|
-
"@lowdefy/block-utils": "4.0.0-
|
|
42
|
-
"@lowdefy/helpers": "4.0.0-
|
|
43
|
-
"@testing-library/dom": "8.
|
|
44
|
-
"@testing-library/react": "13.
|
|
45
|
-
"@testing-library/user-event": "14.
|
|
46
|
-
"ajv": "8.
|
|
39
|
+
"@emotion/jest": "11.10.5",
|
|
40
|
+
"@lowdefy/block-utils": "4.0.0-rc.1",
|
|
41
|
+
"@lowdefy/helpers": "4.0.0-rc.1",
|
|
42
|
+
"@testing-library/dom": "8.19.1",
|
|
43
|
+
"@testing-library/react": "13.4.0",
|
|
44
|
+
"@testing-library/user-event": "14.4.3",
|
|
45
|
+
"ajv": "8.12.0",
|
|
47
46
|
"ajv-errors": "3.0.0",
|
|
48
|
-
"jest": "
|
|
47
|
+
"jest": "28.1.0",
|
|
49
48
|
"jest-serializer-html": "7.1.0",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
52
|
-
"yaml-loader": "0.
|
|
49
|
+
"react": "18.2.0",
|
|
50
|
+
"react-dom": "18.2.0",
|
|
51
|
+
"yaml-loader": "0.8.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
|
-
"@swc/cli": "0.1.
|
|
56
|
-
"@swc/core": "1.
|
|
54
|
+
"@swc/cli": "0.1.59",
|
|
55
|
+
"@swc/core": "1.3.24"
|
|
57
56
|
},
|
|
58
57
|
"publishConfig": {
|
|
59
58
|
"access": "public"
|
|
60
59
|
},
|
|
61
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ecc4f16c19eede929eda177db524cf13a8053379"
|
|
62
61
|
}
|