@gem-sdk/system 1.58.0-dev.137 → 1.58.0-dev.139
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/package.json +15 -6
- package/CHANGELOG.md +0 -16
- package/src/component/Research.txt +0 -53
- package/src/component/__tests__/createAttr.test.ts +0 -62
- package/src/component/__tests__/createClass.test.ts +0 -68
- package/src/component/__tests__/createContent.test.ts +0 -52
- package/src/component/__tests__/createStateOrContext.test.ts +0 -129
- package/src/component/__tests__/createStyle.test.ts +0 -63
- package/src/component/createAttr.ts +0 -44
- package/src/component/createClass.ts +0 -48
- package/src/component/createContent.ts +0 -20
- package/src/component/createStateOrContext.ts +0 -70
- package/src/component/createStyle.ts +0 -53
- package/src/component/types.ts +0 -9
- package/src/component/utils/__tests__/toCamelCaseKeys.test.ts +0 -79
- package/src/component/utils/toCamelCaseKeys.ts +0 -20
- package/src/e2e-tests/README.md +0 -1
- package/src/examples/components/text/DemoText.liquid.ts +0 -40
- package/src/examples/components/text/DemoText.tsx +0 -41
- package/src/examples/components/text/common/__tests__/globalTypoClasses.test.ts +0 -11
- package/src/examples/components/text/common/getAttr.ts +0 -7
- package/src/examples/components/text/common/getStyle.ts +0 -5
- package/src/examples/components/text/common/globalTypoClasses.ts +0 -5
- package/src/examples/components/text/e2e-tests/DemoText.spec.tsx +0 -23
- package/src/examples/components/text/e2e-tests/DemoText.tsx +0 -23
- package/src/index.ts +0 -24
- package/src/validator/README.md +0 -1
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/system",
|
|
3
|
-
"version": "1.58.0-dev.
|
|
3
|
+
"version": "1.58.0-dev.139",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "dist/cjs/index.js",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"src"
|
|
8
|
+
"dist"
|
|
10
9
|
],
|
|
11
10
|
"scripts": {
|
|
12
11
|
"cleanup": "rimraf es dist lib",
|
|
@@ -21,7 +20,17 @@
|
|
|
21
20
|
"type-check": "yarn tsc --noEmit"
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"@gem-sdk/core": "1.58.0-dev.
|
|
23
|
+
"@gem-sdk/core": "1.58.0-dev.135"
|
|
25
24
|
},
|
|
26
|
-
"devDependencies": {}
|
|
25
|
+
"devDependencies": {},
|
|
26
|
+
"module": "dist/esm/index.js",
|
|
27
|
+
"types": "dist/types/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/esm/index.js",
|
|
32
|
+
"require": "./dist/cjs/index.js",
|
|
33
|
+
"types": "./dist/types/index.d.ts"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
27
36
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# @gem-sdk/system
|
|
2
|
-
|
|
3
|
-
## 1.58.0-dev.135
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [`278d253`](https://github.com/gempages/web-builder-elements/commit/278d253fd16b9dc72140c075e7ce8a4e6bce0445) Thanks [@haicaodac](https://github.com/haicaodac)! - init pkg
|
|
8
|
-
|
|
9
|
-
- Updated dependencies [[`808d1db`](https://github.com/gempages/web-builder-elements/commit/808d1dbe7181e004111e7e31e996a78b9f98c011)]:
|
|
10
|
-
- @gem-sdk/core@1.58.0-dev.135
|
|
11
|
-
|
|
12
|
-
## 1.58.0-dev.134
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- [#9513](https://github.com/gempages/web-builder-elements/pull/9513) [`0d6a932`](https://github.com/gempages/web-builder-elements/commit/0d6a9324fba356bc1217190c09dc57c2ee243120) Thanks [@github-actions](https://github.com/apps/github-actions)! - trigger build
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<div id={`shopify-text-element-${builderProps?.uid}`} data-product-id={currentProductId}>
|
|
2
|
-
{!product ? null : setting?.linkProduct ? (
|
|
3
|
-
<Link href={destination} title={product?.title}>
|
|
4
|
-
<Text
|
|
5
|
-
builderProps={builderProps}
|
|
6
|
-
styles={styles}
|
|
7
|
-
setting={{ ...setting, text: product.title, excludeFlex: true }}
|
|
8
|
-
/>
|
|
9
|
-
</Link>
|
|
10
|
-
) : (
|
|
11
|
-
<Text
|
|
12
|
-
builderProps={builderProps}
|
|
13
|
-
styles={styles}
|
|
14
|
-
setting={{ ...setting, text: product.title, excludeFlex: true }}
|
|
15
|
-
/>
|
|
16
|
-
)}
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<div>
|
|
20
|
-
<If>
|
|
21
|
-
|
|
22
|
-
</If>
|
|
23
|
-
<For>
|
|
24
|
-
|
|
25
|
-
</For>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
{%- unless product -%}
|
|
29
|
-
<p>${getStaticLocale('ProductTitle', 'product_not_found')}</p>
|
|
30
|
-
{%- else -%}
|
|
31
|
-
${
|
|
32
|
-
setting?.linkProduct
|
|
33
|
-
? `
|
|
34
|
-
<a href="{{ product.url }}" title="{{ product.title }}" class="gp-product-title-link-wrapper">
|
|
35
|
-
${Text({
|
|
36
|
-
styles: styles,
|
|
37
|
-
setting: { ...setting, text: '{{ product.title }}', excludeFlex: true },
|
|
38
|
-
advanced: advanced,
|
|
39
|
-
builderProps
|
|
40
|
-
})}
|
|
41
|
-
</a>
|
|
42
|
-
`
|
|
43
|
-
: `
|
|
44
|
-
${Text({
|
|
45
|
-
styles: styles,
|
|
46
|
-
setting: { ...setting, text: '{{ product.title }}', excludeFlex: true },
|
|
47
|
-
advanced: advanced,
|
|
48
|
-
className: 'gp-product-title',
|
|
49
|
-
builderProps
|
|
50
|
-
})}
|
|
51
|
-
`
|
|
52
|
-
}
|
|
53
|
-
{%- endunless -%}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, jest } from '@jest/globals';
|
|
2
|
-
import { createAttr } from '../createAttr';
|
|
3
|
-
|
|
4
|
-
// Mock console.error to capture error messages
|
|
5
|
-
global.console.error = jest.fn();
|
|
6
|
-
|
|
7
|
-
describe('createAttr', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
// Clear the console.error mock before each test
|
|
10
|
-
(console.error as jest.Mock).mockClear();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('should log error for key without "data-gp-" prefix', () => {
|
|
14
|
-
createAttr({ invalidKey: 'some value' });
|
|
15
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
16
|
-
'Invalid attribute key: "invalidKey". Must start with "data-gp-".',
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('should log error for key with uppercase letters', () => {
|
|
21
|
-
createAttr({ 'data-gp-UppercaseKey': 'some value' });
|
|
22
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
23
|
-
'Invalid attribute key: "data-gp-UppercaseKey". Must not contain uppercase letters.',
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('should log error for nested object', () => {
|
|
28
|
-
createAttr({ 'data-gp-nested': { fontSize: '12px' } } as any);
|
|
29
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
30
|
-
'Invalid nested attribute for key "data-gp-nested". Nested objects are not supported.',
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('should log error for invalid value type', () => {
|
|
35
|
-
createAttr({ 'data-gp-invalidType': true as any });
|
|
36
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
37
|
-
'Invalid attribute value for key "data-gp-invalidType": true. Must be a string or number.',
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('should handle multiple errors in one call', () => {
|
|
42
|
-
createAttr({
|
|
43
|
-
invalidKey: 'some value', // Invalid prefix
|
|
44
|
-
'data-gp-UppercaseKey': 'some value', // Uppercase in key
|
|
45
|
-
'data-gp-nested': { fontSize: '12px' }, // Nested object
|
|
46
|
-
'data-gp-invalidType': true as any, // Invalid value type
|
|
47
|
-
} as any);
|
|
48
|
-
|
|
49
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
50
|
-
'Invalid attribute key: "invalidKey". Must start with "data-gp-".',
|
|
51
|
-
);
|
|
52
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
53
|
-
'Invalid attribute key: "data-gp-UppercaseKey". Must not contain uppercase letters.',
|
|
54
|
-
);
|
|
55
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
56
|
-
'Invalid nested attribute for key "data-gp-nested". Nested objects are not supported.',
|
|
57
|
-
);
|
|
58
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
59
|
-
'Invalid attribute value for key "data-gp-invalidType": true. Must be a string or number.',
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeAll, afterEach, jest } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
// Import the function
|
|
4
|
-
import { createClass } from '../createClass';
|
|
5
|
-
|
|
6
|
-
// Declare console.error as a Jest mock
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
global.console.error = jest.fn();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
// Clear the console.error mock after each test
|
|
13
|
-
(console.error as jest.Mock).mockClear();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe('createClass', () => {
|
|
17
|
-
test('should return empty string and log error for invalid input', () => {
|
|
18
|
-
expect(createClass(null as any)).toBe('');
|
|
19
|
-
expect(console.error).toHaveBeenCalledWith('Expected an object as input.');
|
|
20
|
-
|
|
21
|
-
expect(createClass(123 as any)).toBe('');
|
|
22
|
-
expect(console.error).toHaveBeenCalledWith('Expected an object as input.');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('should log an error for class names exceeding 30 characters', () => {
|
|
26
|
-
createClass({ averyverylongclassnameexceeding30characters: true });
|
|
27
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
28
|
-
'Class name "averyverylongclassnameexceeding30characters" exceeds the maximum length of 30 characters.',
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('should log an error for class names with spaces', () => {
|
|
33
|
-
createClass({ 'class with space': true });
|
|
34
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
35
|
-
'Class name "class with space" should not contain spaces.',
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('should log an error for class names with uppercase letters', () => {
|
|
40
|
-
createClass({ ClassWithUpperCase: true });
|
|
41
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
42
|
-
'Class name "ClassWithUpperCase" should be in lowercase.',
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('should not log any errors for valid class names', () => {
|
|
47
|
-
createClass({ validclassname: true, anotherclass: true });
|
|
48
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('should handle multiple errors in one call', () => {
|
|
52
|
-
createClass({
|
|
53
|
-
ValidClassWithUpper: true,
|
|
54
|
-
'class with space': true,
|
|
55
|
-
averyverylongclassnameexceeding30characters: true,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
59
|
-
'Class name "ValidClassWithUpper" should be in lowercase.',
|
|
60
|
-
);
|
|
61
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
62
|
-
'Class name "class with space" should not contain spaces.',
|
|
63
|
-
);
|
|
64
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
65
|
-
'Class name "averyverylongclassnameexceeding30characters" exceeds the maximum length of 30 characters.',
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, jest } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
import { createContent } from '../createContent';
|
|
4
|
-
|
|
5
|
-
// Mock console.error to capture error messages
|
|
6
|
-
global.console.error = jest.fn();
|
|
7
|
-
|
|
8
|
-
describe('createContent', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
// Clear the console.error mock before each test
|
|
11
|
-
(console.error as jest.Mock).mockClear();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('should return empty string and log error if content is not a string', () => {
|
|
15
|
-
expect(createContent(12345 as any)).toBe('');
|
|
16
|
-
expect(console.error).toHaveBeenCalledWith('Invalid content type: Content must be a string.');
|
|
17
|
-
|
|
18
|
-
expect(createContent({} as any)).toBe('');
|
|
19
|
-
expect(console.error).toHaveBeenCalledWith('Invalid content type: Content must be a string.');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('should return empty string and log error for content with invalid {{}} pattern', () => {
|
|
23
|
-
expect(createContent('{{Hello}} there')).toBe('');
|
|
24
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
25
|
-
'Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".',
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
expect(createContent('Welcome {{World}}')).toBe('');
|
|
29
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
30
|
-
'Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".',
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('should return valid content without errors', () => {
|
|
35
|
-
expect(createContent('This is valid content')).toBe('This is valid content');
|
|
36
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
37
|
-
|
|
38
|
-
expect(createContent('Content with {{123}} is valid')).toBe('Content with {{123}} is valid');
|
|
39
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
40
|
-
|
|
41
|
-
expect(createContent('Mix of {{valid1}} and {{valid2}}')).toBe(
|
|
42
|
-
'Mix of {{valid1}} and {{valid2}}',
|
|
43
|
-
);
|
|
44
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('should pass with valid {{}} pattern containing more than just letters', () => {
|
|
48
|
-
const content = '{{ product.title | t }}';
|
|
49
|
-
expect(createContent(content)).toBe(content);
|
|
50
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, jest } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
import { createStateOrContext } from '../createStateOrContext';
|
|
4
|
-
|
|
5
|
-
// Mock console.error to capture error messages
|
|
6
|
-
global.console.error = jest.fn();
|
|
7
|
-
|
|
8
|
-
describe('createStateOrContext', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
// Clear the console.error mock before each test
|
|
11
|
-
(console.error as jest.Mock).mockClear();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('should log error for key length exceeding 20 characters', () => {
|
|
15
|
-
createStateOrContext({ thisKeyIsWayTooLongForOurRequirements: 'value' });
|
|
16
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
17
|
-
'Invalid key "thisKeyIsWayTooLongForOurRequirements": Key length must not exceed 20 characters.',
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('should log error for key containing special characters', () => {
|
|
22
|
-
createStateOrContext({ invalid_key: 'value' });
|
|
23
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
24
|
-
'Invalid key "invalid_key": Key must contain only alphabetic characters (no numbers or special characters).',
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('should log error for key containing numbers', () => {
|
|
29
|
-
createStateOrContext({ invalidKey1: 'value' });
|
|
30
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
31
|
-
'Invalid key "invalidKey1": Key must contain only alphabetic characters (no numbers or special characters).',
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('should log error for key not in camelCase format', () => {
|
|
36
|
-
createStateOrContext({ Invalidkey: 'value' });
|
|
37
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
38
|
-
'Invalid key "Invalidkey": Key must be in camelCase format.',
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('should log error for nested object deeper than 3 levels', () => {
|
|
43
|
-
createStateOrContext({
|
|
44
|
-
levelOne: {
|
|
45
|
-
levelTwo: {
|
|
46
|
-
levelThree: {
|
|
47
|
-
tooDeepKey: 'too deep',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
53
|
-
'Invalid structure: Data must not be nested deeper than 3 levels.',
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('should log error for invalid values (undefined, null, blank, false)', () => {
|
|
58
|
-
createStateOrContext({
|
|
59
|
-
validKey: 'value', // Valid
|
|
60
|
-
undefinedKey: undefined, // Invalid
|
|
61
|
-
nullKey: null, // Invalid
|
|
62
|
-
emptyStringKey: '', // Invalid
|
|
63
|
-
falseKey: false, // Invalid
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
67
|
-
'Invalid value for key "undefinedKey": Value must not be undefined, null, blank, or false.',
|
|
68
|
-
);
|
|
69
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
70
|
-
'Invalid value for key "nullKey": Value must not be undefined, null, blank, or false.',
|
|
71
|
-
);
|
|
72
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
73
|
-
'Invalid value for key "emptyStringKey": Value must not be undefined, null, blank, or false.',
|
|
74
|
-
);
|
|
75
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
76
|
-
'Invalid value for key "falseKey": Value must not be undefined, null, blank, or false.',
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('should not log any errors for valid keys and values', () => {
|
|
81
|
-
createStateOrContext({
|
|
82
|
-
validKey: 'value',
|
|
83
|
-
anotherValidKey: 123,
|
|
84
|
-
nestedObject: {
|
|
85
|
-
validNestedKey: 'nestedValue',
|
|
86
|
-
anotherLevel: {
|
|
87
|
-
validKey: 'value',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test('should handle multiple errors in one call', () => {
|
|
95
|
-
createStateOrContext({
|
|
96
|
-
thisKeyIsWayTooLongForOurRequirements: 'value', // Key length
|
|
97
|
-
invalid_key: 'value', // Special character
|
|
98
|
-
invalidKey1: 'value', // Contains number
|
|
99
|
-
InvalidCamelCase: 'value', // Not camelCase
|
|
100
|
-
validKey: {
|
|
101
|
-
nestedTooDeep: {
|
|
102
|
-
anotherLevel: {
|
|
103
|
-
tooDeepKey: 'too deep', // Exceeds depth
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
undefinedValue: undefined, // Invalid value
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
111
|
-
'Invalid key "thisKeyIsWayTooLongForOurRequirements": Key length must not exceed 20 characters.',
|
|
112
|
-
);
|
|
113
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
114
|
-
'Invalid key "invalid_key": Key must contain only alphabetic characters (no numbers or special characters).',
|
|
115
|
-
);
|
|
116
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
117
|
-
'Invalid key "invalidKey1": Key must contain only alphabetic characters (no numbers or special characters).',
|
|
118
|
-
);
|
|
119
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
120
|
-
'Invalid key "InvalidCamelCase": Key must be in camelCase format.',
|
|
121
|
-
);
|
|
122
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
123
|
-
'Invalid structure: Data must not be nested deeper than 3 levels.',
|
|
124
|
-
);
|
|
125
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
126
|
-
'Invalid value for key "undefinedValue": Value must not be undefined, null, blank, or false.',
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, jest } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
// Import the function
|
|
4
|
-
import { createStyle } from '../createStyle';
|
|
5
|
-
|
|
6
|
-
global.console.error = jest.fn();
|
|
7
|
-
|
|
8
|
-
describe('createStyle', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
// Clear the mock for console.error
|
|
11
|
-
(console.error as jest.Mock).mockClear();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('should log error for ignored property', () => {
|
|
15
|
-
createStyle({ ignore: 'some value' });
|
|
16
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
17
|
-
'Ignored property detected: "ignore". This property is not supported in the current styling setup.',
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('should log error for invalid property type', () => {
|
|
22
|
-
createStyle({ 'valid-property': true as any });
|
|
23
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
24
|
-
'Invalid style value for "valid-property": true. Must be a string or number.',
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('should not log any errors for valid keys and values', () => {
|
|
29
|
-
createStyle({
|
|
30
|
-
'background-color': 'blue',
|
|
31
|
-
padding: 10,
|
|
32
|
-
});
|
|
33
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('should log error for key containing uppercase letters', () => {
|
|
37
|
-
createStyle({ fontSize: '14px' });
|
|
38
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
39
|
-
'Invalid key "fontSize": Keys must be lowercase letters and may only contain "-".',
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('should log error for key containing numbers', () => {
|
|
44
|
-
createStyle({ border1: 'solid' });
|
|
45
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
46
|
-
'Invalid key "border1": Keys must be lowercase letters and may only contain "-".',
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('should log error for key containing special characters other than "-"', () => {
|
|
51
|
-
createStyle({ invalid_key: 'value' });
|
|
52
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
53
|
-
'Invalid key "invalid_key": Keys must be lowercase letters and may only contain "-".',
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('should log error for nested objects', () => {
|
|
58
|
-
createStyle({ nestedProp: { width: '100px' } } as any);
|
|
59
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
60
|
-
'Invalid nested object for property "nestedProp". Nested objects are not supported.',
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export const createAttr = (obj: { [key: string]: string | number }) => {
|
|
2
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
3
|
-
console.error('Expected an object as input.');
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const isDevOrStaging =
|
|
8
|
-
!process.env.APP_ENV ||
|
|
9
|
-
process.env.APP_ENV === 'development' ||
|
|
10
|
-
process.env.APP_ENV === 'staging';
|
|
11
|
-
|
|
12
|
-
if (isDevOrStaging) {
|
|
13
|
-
for (const key in obj) {
|
|
14
|
-
const value = obj[key];
|
|
15
|
-
|
|
16
|
-
// 1. Check if the key starts with "data-gp-"
|
|
17
|
-
if (!key.startsWith('data-gp-')) {
|
|
18
|
-
console.error(`Invalid attribute key: "${key}". Must start with "data-gp-".`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 2. Check if the key contains uppercase letters
|
|
22
|
-
if (key !== key.toLowerCase()) {
|
|
23
|
-
console.error(`Invalid attribute key: "${key}". Must not contain uppercase letters.`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 3. Check if the value is an object (nested object check)
|
|
27
|
-
if (typeof value === 'object' && value !== null) {
|
|
28
|
-
console.error(
|
|
29
|
-
`Invalid nested attribute for key "${key}". Nested objects are not supported.`,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 4. Check if the value is a valid type (string or number)
|
|
34
|
-
const isValidType = typeof value === 'string' || typeof value === 'number';
|
|
35
|
-
if (!isValidType) {
|
|
36
|
-
console.error(
|
|
37
|
-
`Invalid attribute value for key "${key}": ${value}. Must be a string or number.`,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return obj;
|
|
44
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
type ClassValue = Record<string, boolean | undefined | null> | string | null | undefined;
|
|
2
|
-
|
|
3
|
-
function toVal(mix: ClassValue) {
|
|
4
|
-
if (typeof mix === 'string') {
|
|
5
|
-
return mix;
|
|
6
|
-
} else if (typeof mix === 'object' && mix !== null) {
|
|
7
|
-
return Object.keys(mix)
|
|
8
|
-
.filter((key) => mix[key])
|
|
9
|
-
.join(' ');
|
|
10
|
-
} else {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function cls(...classes: ClassValue[]) {
|
|
16
|
-
return classes.map(toVal).filter(Boolean).join(' ');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const createClass = (obj: { [key: string]: boolean | undefined }): string => {
|
|
20
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
21
|
-
console.error('Expected an object as input.');
|
|
22
|
-
return '';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const isDevOrStaging =
|
|
26
|
-
!process.env.APP_ENV ||
|
|
27
|
-
process.env.APP_ENV === 'development' ||
|
|
28
|
-
process.env.APP_ENV === 'staging';
|
|
29
|
-
|
|
30
|
-
if (isDevOrStaging) {
|
|
31
|
-
// Validate each class name length
|
|
32
|
-
for (const className in obj) {
|
|
33
|
-
if (className.length > 30) {
|
|
34
|
-
console.error(`Class name "${className}" exceeds the maximum length of 30 characters.`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (className.includes(' ')) {
|
|
38
|
-
console.error(`Class name "${className}" should not contain spaces.`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (className !== className.toLowerCase()) {
|
|
42
|
-
console.error(`Class name "${className}" should be in lowercase.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return cls(obj);
|
|
48
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const createContent = (content: string): string => {
|
|
2
|
-
// Check if content is a string
|
|
3
|
-
if (typeof content !== 'string') {
|
|
4
|
-
console.error('Invalid content type: Content must be a string.');
|
|
5
|
-
return '';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// Regex to match {{}} pattern with only letters inside, e.g., {{Hello}}
|
|
9
|
-
const invalidPattern = /\{\{[A-Za-z]+\}\}/g;
|
|
10
|
-
|
|
11
|
-
// Check if content contains any invalid patterns
|
|
12
|
-
if (invalidPattern.test(content)) {
|
|
13
|
-
console.error(
|
|
14
|
-
'Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".',
|
|
15
|
-
);
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return content;
|
|
20
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export const createStateOrContext = (obj: { [key: string]: any }) => {
|
|
2
|
-
const isDevOrStaging =
|
|
3
|
-
!process.env.APP_ENV ||
|
|
4
|
-
process.env.APP_ENV === 'development' ||
|
|
5
|
-
process.env.APP_ENV === 'staging';
|
|
6
|
-
|
|
7
|
-
const isValid = (value: any) => {
|
|
8
|
-
// Ensure value is neither undefined, null, empty string, nor false (except 0)
|
|
9
|
-
return value !== undefined && value !== null && value !== '' && value !== false;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const validateKey = (key: string) => {
|
|
13
|
-
// Check key length
|
|
14
|
-
if (key.length > 20) {
|
|
15
|
-
console.error(`Invalid key "${key}": Key length must not exceed 20 characters.`);
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Ensure no special characters or numbers
|
|
20
|
-
const validKeyRegex = /^[a-zA-Z]+$/;
|
|
21
|
-
if (!validKeyRegex.test(key)) {
|
|
22
|
-
console.error(
|
|
23
|
-
`Invalid key "${key}": Key must contain only alphabetic characters (no numbers or special characters).`,
|
|
24
|
-
);
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Check camelCase format (should start with lowercase)
|
|
29
|
-
const camelCaseRegex = /^[a-z][a-zA-Z]*$/;
|
|
30
|
-
if (!camelCaseRegex.test(key)) {
|
|
31
|
-
console.error(`Invalid key "${key}": Key must be in camelCase format.`);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const validateObject = (data: any, depth: number) => {
|
|
39
|
-
if (depth > 3) {
|
|
40
|
-
console.error('Invalid structure: Data must not be nested deeper than 3 levels.');
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
for (const key in data) {
|
|
45
|
-
const value = data[key];
|
|
46
|
-
|
|
47
|
-
// Key validation
|
|
48
|
-
if (!validateKey(key)) continue;
|
|
49
|
-
|
|
50
|
-
// Value validation
|
|
51
|
-
if (!isValid(value)) {
|
|
52
|
-
console.error(
|
|
53
|
-
`Invalid value for key "${key}": Value must not be undefined, null, blank, or false.`,
|
|
54
|
-
);
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Recursive check if the value is an object
|
|
59
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
60
|
-
validateObject(value, depth + 1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
if (isDevOrStaging) {
|
|
66
|
-
validateObject(obj, 1);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return obj;
|
|
70
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { toCamelCaseKeys } from './utils/toCamelCaseKeys';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Properties to ignore with explanations for each
|
|
5
|
-
*/
|
|
6
|
-
const ignoredProperties: { [key: string]: string } = {
|
|
7
|
-
ignore: 'This property is not supported in the current styling setup.',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const createStyle = (obj: { [key: string]: string | number }) => {
|
|
11
|
-
const isDevOrStaging =
|
|
12
|
-
!process.env.APP_ENV ||
|
|
13
|
-
process.env.APP_ENV === 'development' ||
|
|
14
|
-
process.env.APP_ENV === 'staging';
|
|
15
|
-
|
|
16
|
-
if (isDevOrStaging) {
|
|
17
|
-
for (const key in obj) {
|
|
18
|
-
const value = obj[key];
|
|
19
|
-
|
|
20
|
-
// Check if the property is in the ignored list and log the explanation
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(ignoredProperties, key)) {
|
|
22
|
-
console.error(`Ignored property detected: "${key}". ${ignoredProperties[key]}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Check for uppercase letters, numbers, and special characters (only allow lowercase letters and "-"
|
|
26
|
-
const isValidKey = /^[a-z-]+$/.test(key);
|
|
27
|
-
if (!isValidKey) {
|
|
28
|
-
console.error(
|
|
29
|
-
`Invalid key "${key}": Keys must be lowercase letters and may only contain "-".`,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Check for nested objects (only support single-level properties)
|
|
34
|
-
if (typeof value === 'object' && value !== null) {
|
|
35
|
-
console.error(
|
|
36
|
-
`Invalid nested object for property "${key}". Nested objects are not supported.`,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Check if the value is a valid type
|
|
41
|
-
const isValidType = typeof value === 'string' || typeof value === 'number';
|
|
42
|
-
if (!isValidType) {
|
|
43
|
-
console.error(`Invalid style value for "${key}": ${value}. Must be a string or number.`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return obj;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const createStyleReact = (obj: { [key: string]: string | number }) => {
|
|
52
|
-
return toCamelCaseKeys(createStyle(obj));
|
|
53
|
-
};
|
package/src/component/types.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
import { toCamelCaseKeys } from '../toCamelCaseKeys';
|
|
4
|
-
|
|
5
|
-
describe('toCamelCaseKeys', () => {
|
|
6
|
-
test('should convert hyphenated keys to camelCase', () => {
|
|
7
|
-
const input = {
|
|
8
|
-
'background-color': 'blue',
|
|
9
|
-
'font-size': '12px',
|
|
10
|
-
padding: 10,
|
|
11
|
-
};
|
|
12
|
-
const expectedOutput = {
|
|
13
|
-
backgroundColor: 'blue',
|
|
14
|
-
fontSize: '12px',
|
|
15
|
-
padding: 10,
|
|
16
|
-
};
|
|
17
|
-
expect(toCamelCaseKeys(input)).toEqual(expectedOutput);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('should keep keys with "--" prefix as-is', () => {
|
|
21
|
-
const input = {
|
|
22
|
-
'--custom-var': '20px',
|
|
23
|
-
'--another-var': '15px',
|
|
24
|
-
};
|
|
25
|
-
const expectedOutput = {
|
|
26
|
-
'--custom-var': '20px',
|
|
27
|
-
'--another-var': '15px',
|
|
28
|
-
};
|
|
29
|
-
expect(toCamelCaseKeys(input)).toEqual(expectedOutput);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('should convert hyphenated keys in nested objects to camelCase', () => {
|
|
33
|
-
const input = {
|
|
34
|
-
nested: {
|
|
35
|
-
'border-radius': '5px',
|
|
36
|
-
'text-align': 'center',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const expectedOutput = {
|
|
40
|
-
nested: {
|
|
41
|
-
borderRadius: '5px',
|
|
42
|
-
textAlign: 'center',
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
expect(toCamelCaseKeys(input)).toEqual(expectedOutput);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('should handle mixed keys with hyphens and "--" prefix correctly', () => {
|
|
49
|
-
const input = {
|
|
50
|
-
'background-color': 'blue',
|
|
51
|
-
'--custom-var': '20px',
|
|
52
|
-
nested: {
|
|
53
|
-
'font-size': '12px',
|
|
54
|
-
'--nested-var': '5px',
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
const expectedOutput = {
|
|
58
|
-
backgroundColor: 'blue',
|
|
59
|
-
'--custom-var': '20px',
|
|
60
|
-
nested: {
|
|
61
|
-
fontSize: '12px',
|
|
62
|
-
'--nested-var': '5px',
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
expect(toCamelCaseKeys(input)).toEqual(expectedOutput);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('should leave keys without hyphens or "--" prefix unchanged', () => {
|
|
69
|
-
const input = {
|
|
70
|
-
padding: 10,
|
|
71
|
-
margin: '5px',
|
|
72
|
-
};
|
|
73
|
-
const expectedOutput = {
|
|
74
|
-
padding: 10,
|
|
75
|
-
margin: '5px',
|
|
76
|
-
};
|
|
77
|
-
expect(toCamelCaseKeys(input)).toEqual(expectedOutput);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const toCamelCaseKeys = (obj: { [key: string]: any }): { [key: string]: any } => {
|
|
2
|
-
const newObj: { [key: string]: any } = {};
|
|
3
|
-
|
|
4
|
-
for (const key in obj) {
|
|
5
|
-
const value = obj[key];
|
|
6
|
-
|
|
7
|
-
// If the key starts with "--", keep it as is
|
|
8
|
-
const newKey = key.startsWith('--')
|
|
9
|
-
? key
|
|
10
|
-
: key.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
11
|
-
|
|
12
|
-
// Recursively apply to nested objects
|
|
13
|
-
newObj[newKey] =
|
|
14
|
-
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
15
|
-
? toCamelCaseKeys(value)
|
|
16
|
-
: value;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return newObj;
|
|
20
|
-
};
|
package/src/e2e-tests/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Đây là folder chưa các e2e-tests compare react vs liquid
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAttr,
|
|
3
|
-
createClass,
|
|
4
|
-
createContent,
|
|
5
|
-
createStateOrContext,
|
|
6
|
-
createStyle,
|
|
7
|
-
} from '../../../index';
|
|
8
|
-
import { getAttr } from './common/getAttr';
|
|
9
|
-
import { getStyle } from './common/getStyle';
|
|
10
|
-
import { globalTypoClasses } from './common/globalTypoClasses';
|
|
11
|
-
import type { TextProps } from './DemoText';
|
|
12
|
-
import { template } from '@gem-sdk/core';
|
|
13
|
-
|
|
14
|
-
const Text = ({ product, text }: TextProps) => {
|
|
15
|
-
const state = createStateOrContext({
|
|
16
|
-
productId: product.id,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const attrs = createAttr({
|
|
20
|
-
...getAttr({ product }),
|
|
21
|
-
});
|
|
22
|
-
const styles = createStyle({
|
|
23
|
-
...getStyle(),
|
|
24
|
-
});
|
|
25
|
-
const classes = createClass({
|
|
26
|
-
...globalTypoClasses(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const content = createContent(text);
|
|
30
|
-
|
|
31
|
-
return template`
|
|
32
|
-
<div ${attrs} gp-data="${state}">
|
|
33
|
-
<label class="${{ classes }}" style="${styles}">
|
|
34
|
-
${content}
|
|
35
|
-
</label>
|
|
36
|
-
</div>
|
|
37
|
-
`;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default Text;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAttrReact,
|
|
3
|
-
createClassReact,
|
|
4
|
-
createContentReact,
|
|
5
|
-
createStyleReact,
|
|
6
|
-
} from '../../../index';
|
|
7
|
-
import { globalTypoClasses } from './common/globalTypoClasses';
|
|
8
|
-
|
|
9
|
-
export type TextProps = {
|
|
10
|
-
product: {
|
|
11
|
-
id: string;
|
|
12
|
-
};
|
|
13
|
-
text: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const Text: React.FC<TextProps> = ({ product, text }) => {
|
|
17
|
-
const attrs = createAttrReact({
|
|
18
|
-
'data-gp-product-id': product.id,
|
|
19
|
-
});
|
|
20
|
-
const styles = createStyleReact({
|
|
21
|
-
'font-size': '16px',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const typoClasses = globalTypoClasses();
|
|
25
|
-
const classes = createClassReact({
|
|
26
|
-
'gp-text': true,
|
|
27
|
-
...typoClasses,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const content = createContentReact(text);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div {...attrs}>
|
|
34
|
-
<label className={classes} style={styles}>
|
|
35
|
-
{content}
|
|
36
|
-
</label>
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default Text;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from '@jest/globals';
|
|
2
|
-
import { globalTypoClasses } from '../globalTypoClasses';
|
|
3
|
-
|
|
4
|
-
describe('globalTypoClasses', () => {
|
|
5
|
-
test('Test case 1', () => {
|
|
6
|
-
const classes = globalTypoClasses();
|
|
7
|
-
expect(classes).toEqual({
|
|
8
|
-
'gp-global-h1': true,
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/experimental-ct-react';
|
|
2
|
-
import type { TextProps } from "../DemoText";
|
|
3
|
-
import DemoText from "../DemoText"
|
|
4
|
-
import DemoTextLiquid from "../DemoText.liquid"
|
|
5
|
-
|
|
6
|
-
test('should work', async ({ mount }, testInfo) => {
|
|
7
|
-
const props: TextProps = {
|
|
8
|
-
product: {
|
|
9
|
-
id: "1"
|
|
10
|
-
},
|
|
11
|
-
text: "Demo test"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const component = await mount((
|
|
15
|
-
<div>
|
|
16
|
-
<div className='react-el'><DemoText {...props}/></div>
|
|
17
|
-
<div className='liquid-el'><div dangerouslySetInnerHTML={{__html: DemoTextLiquid(props)}}></div></div>
|
|
18
|
-
</div>
|
|
19
|
-
));
|
|
20
|
-
|
|
21
|
-
await expect(component.locator('.react-el')).toHaveScreenshot(`${testInfo.title}.png`);
|
|
22
|
-
await expect(component.locator('.liquid-el')).toHaveScreenshot(`${testInfo.title}.png`);
|
|
23
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { E2ETests } from '../../../../component/types';
|
|
2
|
-
import type { TextProps } from '../DemoText';
|
|
3
|
-
import DemoTextReact from '../DemoText';
|
|
4
|
-
import DemoTextLiquid from '../DemoText.liquid';
|
|
5
|
-
|
|
6
|
-
export const e2eDemoText = (): E2ETests => {
|
|
7
|
-
return {
|
|
8
|
-
'DemoText basic': async () => {
|
|
9
|
-
const props: TextProps = {
|
|
10
|
-
product: {
|
|
11
|
-
id: '1',
|
|
12
|
-
},
|
|
13
|
-
text: 'Demo test',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
props,
|
|
18
|
-
reactComponent: DemoTextReact,
|
|
19
|
-
liquidComponent: DemoTextLiquid,
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createAttr } from './component/createAttr';
|
|
2
|
-
const createAttrReact = createAttr;
|
|
3
|
-
|
|
4
|
-
import { createStyle, createStyleReact } from './component/createStyle';
|
|
5
|
-
|
|
6
|
-
import { createContent } from './component/createContent';
|
|
7
|
-
const createContentReact = createContent;
|
|
8
|
-
|
|
9
|
-
import { createClass } from './component/createClass';
|
|
10
|
-
const createClassReact = createClass;
|
|
11
|
-
|
|
12
|
-
import { createStateOrContext } from './component/createStateOrContext';
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
createAttr,
|
|
16
|
-
createAttrReact,
|
|
17
|
-
createStyle,
|
|
18
|
-
createStyleReact,
|
|
19
|
-
createContent,
|
|
20
|
-
createContentReact,
|
|
21
|
-
createClass,
|
|
22
|
-
createClassReact,
|
|
23
|
-
createStateOrContext,
|
|
24
|
-
};
|
package/src/validator/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Đây là folder chưa các func validate component setting
|