@lowdefy/block-dev 4.0.0-alpha.1 → 4.0.0-alpha.7
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 +1 -2
- package/dist/mockBlock.js +3 -6
- package/dist/runMockMethodTests.js +1 -2
- package/dist/runMockRenderTests.js +16 -12
- package/dist/runRenderTests.js +11 -14
- package/dist/schemaTest.js +2 -4
- package/dist/stubBlockProps.js +5 -10
- package/package.json +12 -12
|
@@ -32,8 +32,7 @@ const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
|
32
32
|
}),
|
|
33
33
|
schemaErrors.map((error, i)=>/*#__PURE__*/ _jsxs("div", {
|
|
34
34
|
children: [
|
|
35
|
-
/*#__PURE__*/ _jsx("br", {
|
|
36
|
-
}),
|
|
35
|
+
/*#__PURE__*/ _jsx("br", {}),
|
|
37
36
|
/*#__PURE__*/ _jsxs("div", {
|
|
38
37
|
children: [
|
|
39
38
|
/*#__PURE__*/ _jsx("b", {
|
package/dist/mockBlock.js
CHANGED
|
@@ -75,15 +75,12 @@ const mockBlock = ({ meta , logger , schema })=>{
|
|
|
75
75
|
window.innerHeight = height || window.innerHeight;
|
|
76
76
|
window.dispatchEvent(new Event('resize'));
|
|
77
77
|
};
|
|
78
|
-
window.scrollTo = ()=>{
|
|
79
|
-
};
|
|
78
|
+
window.scrollTo = ()=>{};
|
|
80
79
|
// Fix css-animation or rc-motion deps on these
|
|
81
80
|
// https://github.com/react-component/motion/blob/9c04ef1a210a4f3246c9becba6e33ea945e00669/src/util/motion.ts#L27-L35
|
|
82
81
|
// https://github.com/yiminghe/css-animation/blob/a5986d73fd7dfce75665337f39b91483d63a4c8c/src/Event.js#L44
|
|
83
|
-
window.AnimationEvent = window.AnimationEvent || (()=>{
|
|
84
|
-
});
|
|
85
|
-
window.TransitionEvent = window.TransitionEvent || (()=>{
|
|
86
|
-
});
|
|
82
|
+
window.AnimationEvent = window.AnimationEvent || (()=>{});
|
|
83
|
+
window.TransitionEvent = window.TransitionEvent || (()=>{});
|
|
87
84
|
}
|
|
88
85
|
};
|
|
89
86
|
const getProps = (block)=>{
|
|
@@ -63,8 +63,7 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
|
|
|
63
63
|
]
|
|
64
64
|
}));
|
|
65
65
|
};
|
|
66
|
-
const { container } = render(/*#__PURE__*/ _jsx(Shell, {
|
|
67
|
-
}));
|
|
66
|
+
const { container } = render(/*#__PURE__*/ _jsx(Shell, {}));
|
|
68
67
|
expect(container.firstChild).toMatchSnapshot();
|
|
69
68
|
userEvent.click(screen.getByTestId('btn_method'));
|
|
70
69
|
mockFns.forEach((mockFn)=>{
|
|
@@ -15,12 +15,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
*/ import React from 'react';
|
|
17
17
|
import { type } from '@lowdefy/helpers';
|
|
18
|
-
import { render } from '@testing-library/react';
|
|
18
|
+
import { render, waitFor } from '@testing-library/react';
|
|
19
19
|
import mockBlock from './mockBlock.js';
|
|
20
|
-
const runMockRenderTests = ({
|
|
21
|
-
, schema })=>{
|
|
20
|
+
const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset =()=>null
|
|
21
|
+
, schema , testConfig , })=>{
|
|
22
22
|
const { before , getProps } = mockBlock({
|
|
23
|
-
meta,
|
|
23
|
+
meta: Block1.meta,
|
|
24
24
|
logger,
|
|
25
25
|
schema
|
|
26
26
|
});
|
|
@@ -36,13 +36,16 @@ const runMockRenderTests = ({ examples , logger , meta , mocks , reset =()=>null
|
|
|
36
36
|
makeCssClass.mockReset();
|
|
37
37
|
makeCssClass.mockImplementation(makeCssImp);
|
|
38
38
|
});
|
|
39
|
-
const values = meta.values ? [
|
|
40
|
-
type.enforceType(meta.valueType, null),
|
|
41
|
-
...meta.values
|
|
42
|
-
] : [
|
|
43
|
-
type.enforceType(meta.valueType, null)
|
|
44
|
-
];
|
|
45
39
|
examples.forEach((ex)=>{
|
|
40
|
+
const values = [
|
|
41
|
+
type.enforceType(Block1.meta.valueType, null)
|
|
42
|
+
];
|
|
43
|
+
if (!type.isNone(ex.value)) {
|
|
44
|
+
values.push(ex.value);
|
|
45
|
+
}
|
|
46
|
+
if (type.isArray(testConfig.values)) {
|
|
47
|
+
values.push(...testConfig.values);
|
|
48
|
+
}
|
|
46
49
|
values.forEach((value, v)=>{
|
|
47
50
|
mocks.forEach((mock)=>{
|
|
48
51
|
test(`Mock render - ${ex.id} - value[${v}] - ${mock.name}`, async ()=>{
|
|
@@ -59,8 +62,9 @@ const runMockRenderTests = ({ examples , logger , meta , mocks , reset =()=>null
|
|
|
59
62
|
value: value
|
|
60
63
|
}));
|
|
61
64
|
};
|
|
62
|
-
render(/*#__PURE__*/ _jsx(Shell, {
|
|
63
|
-
|
|
65
|
+
const { container } = render(/*#__PURE__*/ _jsx(Shell, {}));
|
|
66
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
67
|
+
);
|
|
64
68
|
mockFns.forEach((mockFn)=>{
|
|
65
69
|
expect(mockFn.mock.calls).toMatchSnapshot();
|
|
66
70
|
});
|
package/dist/runRenderTests.js
CHANGED
|
@@ -17,10 +17,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
17
|
import { render, waitFor } from '@testing-library/react';
|
|
18
18
|
import { type } from '@lowdefy/helpers';
|
|
19
19
|
import mockBlock from './mockBlock.js';
|
|
20
|
-
const runRenderTests = ({ Block , examples , logger ,
|
|
21
|
-
, schema ,
|
|
20
|
+
const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
21
|
+
, schema , testConfig , validationsExamples , })=>{
|
|
22
22
|
const { before , methods , getProps } = mockBlock({
|
|
23
|
-
meta,
|
|
23
|
+
meta: Block.meta,
|
|
24
24
|
logger,
|
|
25
25
|
schema
|
|
26
26
|
});
|
|
@@ -30,13 +30,13 @@ const runRenderTests = ({ Block , examples , logger , meta , reset =()=>null
|
|
|
30
30
|
});
|
|
31
31
|
examples.forEach((ex)=>{
|
|
32
32
|
const values = [
|
|
33
|
-
type.enforceType(meta.valueType, null)
|
|
33
|
+
type.enforceType(Block.meta.valueType, null)
|
|
34
34
|
];
|
|
35
35
|
if (!type.isNone(ex.value)) {
|
|
36
36
|
values.push(ex.value);
|
|
37
37
|
}
|
|
38
|
-
if (type.isArray(
|
|
39
|
-
values.push(...
|
|
38
|
+
if (type.isArray(testConfig.values)) {
|
|
39
|
+
values.push(...testConfig.values);
|
|
40
40
|
}
|
|
41
41
|
values.forEach((value, v)=>{
|
|
42
42
|
test(`Render ${ex.id} - value[${v}]`, async ()=>{
|
|
@@ -47,12 +47,11 @@ const runRenderTests = ({ Block , examples , logger , meta , reset =()=>null
|
|
|
47
47
|
methods: methods
|
|
48
48
|
})
|
|
49
49
|
;
|
|
50
|
-
const { container } = render(/*#__PURE__*/ _jsx(Shell, {
|
|
51
|
-
}));
|
|
50
|
+
const { container } = render(/*#__PURE__*/ _jsx(Shell, {}));
|
|
52
51
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
53
52
|
);
|
|
54
53
|
});
|
|
55
|
-
if (
|
|
54
|
+
if (testConfig && testConfig.validation) {
|
|
56
55
|
(validationsExamples || []).map((validationEx)=>{
|
|
57
56
|
test(`Render validation.status = ${validationEx.status} ${ex.id} - value[${v}]`, async ()=>{
|
|
58
57
|
// create shell to setup react hooks with getProps before render;
|
|
@@ -63,14 +62,13 @@ const runRenderTests = ({ Block , examples , logger , meta , reset =()=>null
|
|
|
63
62
|
validation: validationEx
|
|
64
63
|
})
|
|
65
64
|
;
|
|
66
|
-
const { container } = render(/*#__PURE__*/ _jsx(Shell, {
|
|
67
|
-
}));
|
|
65
|
+
const { container } = render(/*#__PURE__*/ _jsx(Shell, {}));
|
|
68
66
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
69
67
|
);
|
|
70
68
|
});
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
|
-
if (
|
|
71
|
+
if (testConfig && testConfig.required) {
|
|
74
72
|
test(`Render required = true ${ex.id} - value[${v}]`, async ()=>{
|
|
75
73
|
// create shell to setup react hooks with getProps before render;
|
|
76
74
|
const Shell = ()=>/*#__PURE__*/ _jsx(Block, {
|
|
@@ -80,8 +78,7 @@ const runRenderTests = ({ Block , examples , logger , meta , reset =()=>null
|
|
|
80
78
|
required: true
|
|
81
79
|
})
|
|
82
80
|
;
|
|
83
|
-
const { container } = render(/*#__PURE__*/ _jsx(Shell, {
|
|
84
|
-
}));
|
|
81
|
+
const { container } = render(/*#__PURE__*/ _jsx(Shell, {}));
|
|
85
82
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
86
83
|
);
|
|
87
84
|
});
|
package/dist/schemaTest.js
CHANGED
|
@@ -16,13 +16,11 @@
|
|
|
16
16
|
import AjvErrors from 'ajv-errors';
|
|
17
17
|
import { blockSchema } from '@lowdefy/block-utils';
|
|
18
18
|
const testSchemaProperties = {
|
|
19
|
-
value: {
|
|
20
|
-
},
|
|
19
|
+
value: {},
|
|
21
20
|
methods: {
|
|
22
21
|
type: 'object'
|
|
23
22
|
},
|
|
24
|
-
schemaErrors: {
|
|
25
|
-
},
|
|
23
|
+
schemaErrors: {},
|
|
26
24
|
eventLog: {
|
|
27
25
|
type: 'array'
|
|
28
26
|
},
|
package/dist/stubBlockProps.js
CHANGED
|
@@ -17,8 +17,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
17
|
import { type } from '@lowdefy/helpers';
|
|
18
18
|
import { makeCssClass, createIcon } from '@lowdefy/block-utils';
|
|
19
19
|
import schemaTest from './schemaTest.js';
|
|
20
|
-
const validate = {
|
|
21
|
-
};
|
|
20
|
+
const validate = {};
|
|
22
21
|
const Icons = {
|
|
23
22
|
AiIcon: (props)=>/*#__PURE__*/ _jsx("svg", {
|
|
24
23
|
...props,
|
|
@@ -60,14 +59,11 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
60
59
|
// block defaults
|
|
61
60
|
block.blockId = block.id;
|
|
62
61
|
if (meta.category === 'list' || meta.category === 'container' || meta.category === 'context') {
|
|
63
|
-
if (!block.areas) block.areas = {
|
|
64
|
-
};
|
|
65
|
-
if (!block.areas.content) block.areas.content = {
|
|
66
|
-
};
|
|
62
|
+
if (!block.areas) block.areas = {};
|
|
63
|
+
if (!block.areas.content) block.areas.content = {};
|
|
67
64
|
if (block.blocks) block.areas.content.blocks = block.blocks;
|
|
68
65
|
}
|
|
69
|
-
block.events = block.events || {
|
|
70
|
-
};
|
|
66
|
+
block.events = block.events || {};
|
|
71
67
|
block.eventLog = [];
|
|
72
68
|
block.components = {
|
|
73
69
|
Icon: IconComponent,
|
|
@@ -120,8 +116,7 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
120
116
|
};
|
|
121
117
|
}
|
|
122
118
|
if (meta.category === 'container') {
|
|
123
|
-
block.content = {
|
|
124
|
-
};
|
|
119
|
+
block.content = {};
|
|
125
120
|
Object.keys(block.areas).forEach((key)=>{
|
|
126
121
|
block.content[key] = ()=>/*#__PURE__*/ _jsx("div", {
|
|
127
122
|
"data-testid": `area-${key}`,
|
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.7",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Block Development Tools",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@emotion/jest": "11.
|
|
41
|
-
"@lowdefy/block-utils": "4.0.0-alpha.
|
|
42
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
43
|
-
"@testing-library/dom": "8.
|
|
40
|
+
"@emotion/jest": "11.7.1",
|
|
41
|
+
"@lowdefy/block-utils": "4.0.0-alpha.7",
|
|
42
|
+
"@lowdefy/helpers": "4.0.0-alpha.7",
|
|
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",
|
|
46
|
-
"ajv": "8.
|
|
46
|
+
"ajv": "8.9.0",
|
|
47
47
|
"ajv-errors": "3.0.0",
|
|
48
|
-
"jest": "27.
|
|
48
|
+
"jest": "27.5.1",
|
|
49
49
|
"jest-serializer-html": "7.1.0",
|
|
50
|
-
"react": "18.0.0-
|
|
51
|
-
"react-dom": "18.0.0-
|
|
50
|
+
"react": "18.0.0-rc.0",
|
|
51
|
+
"react-dom": "18.0.0-rc.0",
|
|
52
52
|
"yaml-loader": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@swc/cli": "0.1.
|
|
56
|
-
"@swc/core": "1.2.
|
|
55
|
+
"@swc/cli": "0.1.55",
|
|
56
|
+
"@swc/core": "1.2.135"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "52ec14639d00de910cf9b8ab25bf933ca891cff5"
|
|
62
62
|
}
|