@lowdefy/block-dev 4.0.0-alpha.7 → 4.0.0-alpha.8
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 +6 -62
- package/dist/runMockMethodTests.js +24 -17
- package/dist/runMockRenderTests.js +17 -5
- package/dist/runRenderTests.js +23 -13
- package/dist/stubBlockProps.js +29 -21
- package/package.json +6 -6
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
4
3
|
|
|
@@ -16,72 +15,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
16
15
|
*/ import React from 'react';
|
|
17
16
|
const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
18
17
|
if (!schemaErrors || schemaErrors.length === 0) return '';
|
|
19
|
-
return(/*#__PURE__*/
|
|
18
|
+
return(/*#__PURE__*/ React.createElement("div", {
|
|
20
19
|
style: {
|
|
21
20
|
padding: 10,
|
|
22
21
|
fontSize: '0.8rem',
|
|
23
22
|
border: '1px solid red',
|
|
24
23
|
background: '#fBB',
|
|
25
24
|
width: '100%'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
}),
|
|
33
|
-
schemaErrors.map((error, i)=>/*#__PURE__*/ _jsxs("div", {
|
|
34
|
-
children: [
|
|
35
|
-
/*#__PURE__*/ _jsx("br", {}),
|
|
36
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
37
|
-
children: [
|
|
38
|
-
/*#__PURE__*/ _jsx("b", {
|
|
39
|
-
children: "keyword:"
|
|
40
|
-
}),
|
|
41
|
-
" ",
|
|
42
|
-
error.keyword
|
|
43
|
-
]
|
|
44
|
-
}),
|
|
45
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
46
|
-
children: [
|
|
47
|
-
/*#__PURE__*/ _jsx("b", {
|
|
48
|
-
children: "message:"
|
|
49
|
-
}),
|
|
50
|
-
" ",
|
|
51
|
-
error.message
|
|
52
|
-
]
|
|
53
|
-
}),
|
|
54
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
55
|
-
children: [
|
|
56
|
-
/*#__PURE__*/ _jsx("b", {
|
|
57
|
-
children: "params:"
|
|
58
|
-
}),
|
|
59
|
-
" ",
|
|
60
|
-
JSON.stringify(error.params)
|
|
61
|
-
]
|
|
62
|
-
}),
|
|
63
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
64
|
-
children: [
|
|
65
|
-
/*#__PURE__*/ _jsx("b", {
|
|
66
|
-
children: "dataPath:"
|
|
67
|
-
}),
|
|
68
|
-
" ",
|
|
69
|
-
error.dataPath
|
|
70
|
-
]
|
|
71
|
-
}),
|
|
72
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
73
|
-
children: [
|
|
74
|
-
/*#__PURE__*/ _jsx("b", {
|
|
75
|
-
children: "schemaPath:"
|
|
76
|
-
}),
|
|
77
|
-
" ",
|
|
78
|
-
error.schemaPath
|
|
79
|
-
]
|
|
80
|
-
})
|
|
81
|
-
]
|
|
82
|
-
}, i)
|
|
83
|
-
)
|
|
84
|
-
]
|
|
85
|
-
}));
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "Schema Errors")), schemaErrors.map((error, i)=>/*#__PURE__*/ React.createElement("div", {
|
|
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
|
+
)));
|
|
86
30
|
};
|
|
87
31
|
export default BlockSchemaErrors;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
4
3
|
|
|
@@ -18,6 +17,20 @@ import { type } from '@lowdefy/helpers';
|
|
|
18
17
|
import { render, screen } from '@testing-library/react';
|
|
19
18
|
import userEvent from '@testing-library/user-event';
|
|
20
19
|
import mockBlock from './mockBlock.js';
|
|
20
|
+
function _extends() {
|
|
21
|
+
_extends = Object.assign || function(target) {
|
|
22
|
+
for(var i = 1; i < arguments.length; i++){
|
|
23
|
+
var source = arguments[i];
|
|
24
|
+
for(var key in source){
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
|
+
target[key] = source[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
return _extends.apply(this, arguments);
|
|
33
|
+
}
|
|
21
34
|
const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests })=>{
|
|
22
35
|
const { before , methods , getProps } = mockBlock({
|
|
23
36
|
meta,
|
|
@@ -47,23 +60,17 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
|
|
|
47
60
|
...methods,
|
|
48
61
|
registerMethod: props.methods.registerMethod
|
|
49
62
|
};
|
|
50
|
-
return(/*#__PURE__*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
props.methods[method.name](method.args);
|
|
60
|
-
},
|
|
61
|
-
"data-testid": "btn_method"
|
|
62
|
-
})
|
|
63
|
-
]
|
|
64
|
-
}));
|
|
63
|
+
return(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
64
|
+
value: value
|
|
65
|
+
})), /*#__PURE__*/ React.createElement("button", {
|
|
66
|
+
id: `${ex.id}_button`,
|
|
67
|
+
onClick: ()=>{
|
|
68
|
+
props.methods[method.name](method.args);
|
|
69
|
+
},
|
|
70
|
+
"data-testid": "btn_method"
|
|
71
|
+
})));
|
|
65
72
|
};
|
|
66
|
-
const { container } = render(/*#__PURE__*/
|
|
73
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
67
74
|
expect(container.firstChild).toMatchSnapshot();
|
|
68
75
|
userEvent.click(screen.getByTestId('btn_method'));
|
|
69
76
|
mockFns.forEach((mockFn)=>{
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
4
3
|
|
|
@@ -17,6 +16,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
16
|
import { type } from '@lowdefy/helpers';
|
|
18
17
|
import { render, waitFor } from '@testing-library/react';
|
|
19
18
|
import mockBlock from './mockBlock.js';
|
|
19
|
+
function _extends() {
|
|
20
|
+
_extends = Object.assign || function(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i];
|
|
23
|
+
for(var key in source){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
20
33
|
const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset =()=>null
|
|
21
34
|
, schema , testConfig , })=>{
|
|
22
35
|
const { before , getProps } = mockBlock({
|
|
@@ -53,16 +66,15 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
|
|
|
53
66
|
const Block = await mock.getBlock();
|
|
54
67
|
const Shell = ()=>{
|
|
55
68
|
const props = getProps(ex);
|
|
56
|
-
return(/*#__PURE__*/
|
|
57
|
-
...props,
|
|
69
|
+
return(/*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
58
70
|
methods: {
|
|
59
71
|
...props.methods,
|
|
60
72
|
makeCssClass
|
|
61
73
|
},
|
|
62
74
|
value: value
|
|
63
|
-
}));
|
|
75
|
+
})));
|
|
64
76
|
};
|
|
65
|
-
const { container } = render(/*#__PURE__*/
|
|
77
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
66
78
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
67
79
|
);
|
|
68
80
|
mockFns.forEach((mockFn)=>{
|
package/dist/runRenderTests.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
4
3
|
|
|
@@ -17,6 +16,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
16
|
import { render, waitFor } from '@testing-library/react';
|
|
18
17
|
import { type } from '@lowdefy/helpers';
|
|
19
18
|
import mockBlock from './mockBlock.js';
|
|
19
|
+
function _extends() {
|
|
20
|
+
_extends = Object.assign || function(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i];
|
|
23
|
+
for(var key in source){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
20
33
|
const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
21
34
|
, schema , testConfig , validationsExamples , })=>{
|
|
22
35
|
const { before , methods , getProps } = mockBlock({
|
|
@@ -41,13 +54,12 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
41
54
|
values.forEach((value, v)=>{
|
|
42
55
|
test(`Render ${ex.id} - value[${v}]`, async ()=>{
|
|
43
56
|
// create shell to setup react hooks with getProps before render;
|
|
44
|
-
const Shell = ()=>/*#__PURE__*/
|
|
45
|
-
...getProps(ex),
|
|
57
|
+
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
46
58
|
value: value,
|
|
47
59
|
methods: methods
|
|
48
|
-
})
|
|
60
|
+
}))
|
|
49
61
|
;
|
|
50
|
-
const { container } = render(/*#__PURE__*/
|
|
62
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
51
63
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
52
64
|
);
|
|
53
65
|
});
|
|
@@ -55,14 +67,13 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
55
67
|
(validationsExamples || []).map((validationEx)=>{
|
|
56
68
|
test(`Render validation.status = ${validationEx.status} ${ex.id} - value[${v}]`, async ()=>{
|
|
57
69
|
// create shell to setup react hooks with getProps before render;
|
|
58
|
-
const Shell = ()=>/*#__PURE__*/
|
|
59
|
-
...getProps(ex),
|
|
70
|
+
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
60
71
|
value: value,
|
|
61
72
|
methods: methods,
|
|
62
73
|
validation: validationEx
|
|
63
|
-
})
|
|
74
|
+
}))
|
|
64
75
|
;
|
|
65
|
-
const { container } = render(/*#__PURE__*/
|
|
76
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
66
77
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
67
78
|
);
|
|
68
79
|
});
|
|
@@ -71,14 +82,13 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
71
82
|
if (testConfig && testConfig.required) {
|
|
72
83
|
test(`Render required = true ${ex.id} - value[${v}]`, async ()=>{
|
|
73
84
|
// create shell to setup react hooks with getProps before render;
|
|
74
|
-
const Shell = ()=>/*#__PURE__*/
|
|
75
|
-
...getProps(ex),
|
|
85
|
+
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
76
86
|
value: value,
|
|
77
87
|
methods: methods,
|
|
78
88
|
required: true
|
|
79
|
-
})
|
|
89
|
+
}))
|
|
80
90
|
;
|
|
81
|
-
const { container } = render(/*#__PURE__*/
|
|
91
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
82
92
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
83
93
|
);
|
|
84
94
|
});
|
package/dist/stubBlockProps.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2020-2021 Lowdefy, Inc
|
|
4
3
|
|
|
@@ -17,22 +16,33 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
16
|
import { type } from '@lowdefy/helpers';
|
|
18
17
|
import { makeCssClass, createIcon } from '@lowdefy/block-utils';
|
|
19
18
|
import schemaTest from './schemaTest.js';
|
|
19
|
+
function _extends() {
|
|
20
|
+
_extends = Object.assign || function(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i];
|
|
23
|
+
for(var key in source){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
20
33
|
const validate = {};
|
|
21
34
|
const Icons = {
|
|
22
|
-
AiIcon: (props)=>/*#__PURE__*/
|
|
23
|
-
...props,
|
|
35
|
+
AiIcon: (props)=>/*#__PURE__*/ React.createElement("svg", _extends({}, props, {
|
|
24
36
|
"data-testid": "AiIcon"
|
|
25
|
-
})
|
|
37
|
+
}))
|
|
26
38
|
,
|
|
27
|
-
AiOutlineExclamationCircle: (props)=>/*#__PURE__*/
|
|
28
|
-
...props,
|
|
39
|
+
AiOutlineExclamationCircle: (props)=>/*#__PURE__*/ React.createElement("svg", _extends({}, props, {
|
|
29
40
|
"data-testid": "AiOutlineExclamationCircle"
|
|
30
|
-
})
|
|
41
|
+
}))
|
|
31
42
|
,
|
|
32
|
-
AiOutlineLoading3Quarters: (props)=>/*#__PURE__*/
|
|
33
|
-
...props,
|
|
43
|
+
AiOutlineLoading3Quarters: (props)=>/*#__PURE__*/ React.createElement("svg", _extends({}, props, {
|
|
34
44
|
"data-testid": "AiOutlineLoading3Quarters"
|
|
35
|
-
})
|
|
45
|
+
}))
|
|
36
46
|
,
|
|
37
47
|
ErrorIcon: ()=>{
|
|
38
48
|
throw new Error('ErrorIcon');
|
|
@@ -67,11 +77,9 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
67
77
|
block.eventLog = [];
|
|
68
78
|
block.components = {
|
|
69
79
|
Icon: IconComponent,
|
|
70
|
-
Link: (props)=>/*#__PURE__*/
|
|
71
|
-
"data-testid": `link-${props.href}
|
|
72
|
-
|
|
73
|
-
children: props.children
|
|
74
|
-
})
|
|
80
|
+
Link: (props)=>/*#__PURE__*/ React.createElement("a", _extends({
|
|
81
|
+
"data-testid": `link-${props.href}`
|
|
82
|
+
}, props), props.children)
|
|
75
83
|
};
|
|
76
84
|
// mock default block methods
|
|
77
85
|
block.methods = {
|
|
@@ -91,13 +99,13 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
91
99
|
block.list = [];
|
|
92
100
|
(block.areas.content.blocks || []).forEach((bl, i)=>{
|
|
93
101
|
block.list.push({
|
|
94
|
-
content: ()=>/*#__PURE__*/
|
|
102
|
+
content: ()=>/*#__PURE__*/ React.createElement("div", {
|
|
95
103
|
"data-testid": `list-${i}-${bl.id}`,
|
|
104
|
+
key: bl.id,
|
|
96
105
|
style: {
|
|
97
106
|
border: '1px solid red',
|
|
98
107
|
padding: 10
|
|
99
|
-
}
|
|
100
|
-
children: bl.id
|
|
108
|
+
}
|
|
101
109
|
}, bl.id)
|
|
102
110
|
});
|
|
103
111
|
});
|
|
@@ -118,13 +126,13 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
118
126
|
if (meta.category === 'container') {
|
|
119
127
|
block.content = {};
|
|
120
128
|
Object.keys(block.areas).forEach((key)=>{
|
|
121
|
-
block.content[key] = ()=>/*#__PURE__*/
|
|
129
|
+
block.content[key] = ()=>/*#__PURE__*/ React.createElement("div", {
|
|
122
130
|
"data-testid": `area-${key}`,
|
|
131
|
+
key: key,
|
|
123
132
|
style: {
|
|
124
133
|
border: '1px solid red',
|
|
125
134
|
padding: 10
|
|
126
|
-
}
|
|
127
|
-
children: key
|
|
135
|
+
}
|
|
128
136
|
}, key)
|
|
129
137
|
;
|
|
130
138
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/block-dev",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.8",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Block Development Tools",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@emotion/jest": "11.7.1",
|
|
41
|
-
"@lowdefy/block-utils": "4.0.0-alpha.
|
|
42
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
41
|
+
"@lowdefy/block-utils": "4.0.0-alpha.8",
|
|
42
|
+
"@lowdefy/helpers": "4.0.0-alpha.8",
|
|
43
43
|
"@testing-library/dom": "8.11.3",
|
|
44
44
|
"@testing-library/react": "13.0.0-alpha.4",
|
|
45
45
|
"@testing-library/user-event": "14.0.0-alpha.14",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"ajv-errors": "3.0.0",
|
|
48
48
|
"jest": "27.5.1",
|
|
49
49
|
"jest-serializer-html": "7.1.0",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
50
|
+
"react": "17.0.2",
|
|
51
|
+
"react-dom": "17.0.2",
|
|
52
52
|
"yaml-loader": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
|
|
62
62
|
}
|