@augeo/smelt 1.2.2
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/.claude/settings.json +11 -0
- package/.github/workflows/verify.yml +64 -0
- package/.gitmodules +3 -0
- package/.prettierignore +25 -0
- package/.prettierrc.cjs +9 -0
- package/.zed/settings.json +21 -0
- package/AGENTS.md +232 -0
- package/LICENSE +21 -0
- package/README.md +266 -0
- package/biome.json +58 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +350 -0
- package/dist/schema.d.mts +265 -0
- package/dist/schema.mjs +21 -0
- package/docs/TESTING.md +293 -0
- package/docs/assets-plan.md +197 -0
- package/docs/build-spec.md +466 -0
- package/docs/library-conversion-plan.md +419 -0
- package/example/.gitattributes +7 -0
- package/example/.shopifyignore +28 -0
- package/example/.theme-check.yml +7 -0
- package/example/blocks/_built--sections--hero--blocks--feature.liquid +52 -0
- package/example/config/settings_schema.json +10 -0
- package/example/layout/theme.liquid +25 -0
- package/example/locales/en.default.json +1 -0
- package/example/package-lock.json +51 -0
- package/example/package.json +20 -0
- package/example/sections/built--sections--hero.liquid +83 -0
- package/example/snippets/built--components--button.liquid +38 -0
- package/example/snippets/built--components--card.liquid +33 -0
- package/example/src/components/button/button.css +13 -0
- package/example/src/components/card/card.css +16 -0
- package/example/src/components/card/card.liquid +9 -0
- package/example/src/sections/hero/blocks/feature/feature.css +11 -0
- package/example/src/sections/hero/blocks/feature/feature.liquid +9 -0
- package/example/src/sections/hero/blocks/feature/feature.schema.ts +14 -0
- package/example/src/sections/hero/hero.css +15 -0
- package/example/src/sections/hero/hero.liquid +16 -0
- package/example/src/sections/hero/hero.schema.ts +26 -0
- package/example/src/sections/hero/hero.test.ts +43 -0
- package/example/src/utilities/labels.ts +5 -0
- package/example/templates/index.liquid +1 -0
- package/example/tsconfig.json +10 -0
- package/example/vitest.config.ts +6 -0
- package/lib/build/build.test.ts +475 -0
- package/lib/build/build.ts +314 -0
- package/lib/build/command.ts +27 -0
- package/lib/build/index.ts +1 -0
- package/lib/cli.ts +17 -0
- package/lib/dev/command.ts +25 -0
- package/lib/dev/index.ts +1 -0
- package/lib/dev/watch.ts +52 -0
- package/lib/resolver.test.ts +275 -0
- package/lib/resolver.ts +156 -0
- package/lib/schema.ts +37 -0
- package/package.json +59 -0
- package/scripts/codegen-schema.ts +66 -0
- package/src/components/button/button.css +13 -0
- package/src/components/button/button.liquid +5 -0
- package/src/components/button/button.ts +5 -0
- package/src/tsconfig.json +10 -0
- package/tests/example.test.ts +101 -0
- package/tsconfig.json +20 -0
- package/tsdown.config.ts +14 -0
- package/vendor/theme-liquid-docs/.gitattributes +10 -0
- package/vendor/theme-liquid-docs/.github/CODEOWNERS +1 -0
- package/vendor/theme-liquid-docs/.github/CODE_OF_CONDUCT.md +73 -0
- package/vendor/theme-liquid-docs/.github/ISSUE_TEMPLATE/bug_report.md +17 -0
- package/vendor/theme-liquid-docs/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/vendor/theme-liquid-docs/.github/dependabot.yaml +6 -0
- package/vendor/theme-liquid-docs/.github/workflows/ci.yml +33 -0
- package/vendor/theme-liquid-docs/.github/workflows/cla.yml +27 -0
- package/vendor/theme-liquid-docs/.github/workflows/shopify-dev-preview-automation.yml +86 -0
- package/vendor/theme-liquid-docs/.github/workflows/update-latest.yml +56 -0
- package/vendor/theme-liquid-docs/.prettierrc.json +16 -0
- package/vendor/theme-liquid-docs/.vscode/settings.json +28 -0
- package/vendor/theme-liquid-docs/LICENSE.md +7 -0
- package/vendor/theme-liquid-docs/README.md +48 -0
- package/vendor/theme-liquid-docs/ai/claude/CLAUDE.md +1485 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/assets.mdc +15 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/blocks.mdc +339 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/examples/block-example-group.mdc +103 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/examples/block-example-text.mdc +59 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/examples/section-example.mdc +61 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/examples/snippet-example.mdc +72 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/liquid.mdc +837 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/locales.mdc +100 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/localization.mdc +67 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/mcp.mdc +2 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/schemas.mdc +184 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/sections.mdc +84 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/settings-schema.mdc +51 -0
- package/vendor/theme-liquid-docs/ai/cursor/rules/snippets.mdc +119 -0
- package/vendor/theme-liquid-docs/ai/github/copilot-instructions.md +1485 -0
- package/vendor/theme-liquid-docs/ai/liquid.mdc +638 -0
- package/vendor/theme-liquid-docs/data/filters.json +6148 -0
- package/vendor/theme-liquid-docs/data/latest.json +2 -0
- package/vendor/theme-liquid-docs/data/objects.json +20594 -0
- package/vendor/theme-liquid-docs/data/shopify_system_translations.json +2586 -0
- package/vendor/theme-liquid-docs/data/tags.json +1276 -0
- package/vendor/theme-liquid-docs/package.json +20 -0
- package/vendor/theme-liquid-docs/schemas/manifest_schema.json +31 -0
- package/vendor/theme-liquid-docs/schemas/manifest_theme.json +19 -0
- package/vendor/theme-liquid-docs/schemas/manifest_theme_app_extension.json +10 -0
- package/vendor/theme-liquid-docs/schemas/theme/app_block_entry.json +13 -0
- package/vendor/theme-liquid-docs/schemas/theme/default_setting_values.json +24 -0
- package/vendor/theme-liquid-docs/schemas/theme/local_block_entry.json +25 -0
- package/vendor/theme-liquid-docs/schemas/theme/preset.json +72 -0
- package/vendor/theme-liquid-docs/schemas/theme/preset_blocks.json +91 -0
- package/vendor/theme-liquid-docs/schemas/theme/section.json +208 -0
- package/vendor/theme-liquid-docs/schemas/theme/setting.json +1413 -0
- package/vendor/theme-liquid-docs/schemas/theme/settings.json +10 -0
- package/vendor/theme-liquid-docs/schemas/theme/targetted_block_entry.json +15 -0
- package/vendor/theme-liquid-docs/schemas/theme/theme_block.json +91 -0
- package/vendor/theme-liquid-docs/schemas/theme/theme_block_entry.json +14 -0
- package/vendor/theme-liquid-docs/schemas/theme/theme_settings.json +83 -0
- package/vendor/theme-liquid-docs/schemas/theme/translations.json +63 -0
- package/vendor/theme-liquid-docs/schemas/update/update_extension_schema_v1.json +186 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-nested-blocks.json +18 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-1.json +90 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-2.json +201 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-3.json +29 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-4.json +315 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-5.json +114 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-6.json +63 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-conditional-settings.json +145 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-preset-blocks-as-hash.json +60 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-schema-static-block-preset.json +76 -0
- package/vendor/theme-liquid-docs/tests/fixtures/section-settings.json +34 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-block-1.json +234 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-block-2.json +253 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-block-basics.json +48 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-block-conditional-settings.json +202 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-block-presets-as-hash.json +50 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-block-settings.json +34 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-settings-all-settings.json +313 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-settings-dawn.json +1469 -0
- package/vendor/theme-liquid-docs/tests/fixtures/theme-settings-metadata.json +10 -0
- package/vendor/theme-liquid-docs/tests/fixtures/translations-1.json +14 -0
- package/vendor/theme-liquid-docs/tests/section.spec.ts +367 -0
- package/vendor/theme-liquid-docs/tests/test-constants.ts +58 -0
- package/vendor/theme-liquid-docs/tests/test-helpers.ts +104 -0
- package/vendor/theme-liquid-docs/tests/theme-settings/color_palette.spec.ts +184 -0
- package/vendor/theme-liquid-docs/tests/theme-settings/color_scheme_group.spec.ts +143 -0
- package/vendor/theme-liquid-docs/tests/theme-settings/general.spec.ts +192 -0
- package/vendor/theme-liquid-docs/tests/theme-settings/metaobject.spec.ts +94 -0
- package/vendor/theme-liquid-docs/tests/theme-settings/resource_list.spec.ts +58 -0
- package/vendor/theme-liquid-docs/tests/theme-settings/theme-metadata.spec.ts +59 -0
- package/vendor/theme-liquid-docs/tests/theme_block.spec.ts +266 -0
- package/vendor/theme-liquid-docs/tests/translations_schema.spec.ts +31 -0
- package/vendor/theme-liquid-docs/yarn.lock +543 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import set from 'lodash.set';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { loadFixture, validateSchema } from '../test-helpers';
|
|
4
|
+
|
|
5
|
+
const themeSettingsMetadata = loadFixture('theme-settings-metadata.json');
|
|
6
|
+
|
|
7
|
+
const validate = validateSchema();
|
|
8
|
+
|
|
9
|
+
describe('Module: theme settings validation (config/settings_schema.json)', () => {
|
|
10
|
+
describe('Unit: Theme metadata', () => {
|
|
11
|
+
it('should report the double use of support attributes', async () => {
|
|
12
|
+
const file = JSON.parse(themeSettingsMetadata);
|
|
13
|
+
set(file, '0.theme_support_email', 'example@example.com');
|
|
14
|
+
set(file, '0.theme_support_url', 'https://example.com');
|
|
15
|
+
|
|
16
|
+
const diagnostics = await validate('config/settings_schema.json', file);
|
|
17
|
+
expect(diagnostics).toStrictEqual([
|
|
18
|
+
{
|
|
19
|
+
message: 'Matches a schema that is not allowed.',
|
|
20
|
+
severity: 1,
|
|
21
|
+
range: expect.objectContaining({
|
|
22
|
+
start: expect.objectContaining({
|
|
23
|
+
character: expect.any(Number),
|
|
24
|
+
line: expect.any(Number),
|
|
25
|
+
}),
|
|
26
|
+
end: expect.objectContaining({
|
|
27
|
+
character: expect.any(Number),
|
|
28
|
+
line: expect.any(Number),
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('reports on missing required fields', async () => {
|
|
36
|
+
const file = `[
|
|
37
|
+
{
|
|
38
|
+
"name": "theme_info"
|
|
39
|
+
}
|
|
40
|
+
]`;
|
|
41
|
+
|
|
42
|
+
const diagnostics = await validate('config/settings_schema.json', file);
|
|
43
|
+
expect(diagnostics).to.have.lengthOf(5);
|
|
44
|
+
for (const missingProp of [
|
|
45
|
+
'theme_support_email',
|
|
46
|
+
'theme_name',
|
|
47
|
+
'theme_author',
|
|
48
|
+
'theme_version',
|
|
49
|
+
'theme_documentation_url',
|
|
50
|
+
]) {
|
|
51
|
+
expect(diagnostics).toContainEqual(
|
|
52
|
+
expect.objectContaining({
|
|
53
|
+
message: `Missing property "${missingProp}".`,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { assert, describe, expect, it } from 'vitest';
|
|
2
|
+
import { SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF } from './test-constants';
|
|
3
|
+
import { complete, getService, hover, loadFixture, validateSchema } from './test-helpers';
|
|
4
|
+
|
|
5
|
+
const themeBlock1 = loadFixture('theme-block-1.json');
|
|
6
|
+
const themeBlock2 = loadFixture('theme-block-2.json');
|
|
7
|
+
const themeBlockBasics = loadFixture('theme-block-basics.json');
|
|
8
|
+
const themeBlockSettings = loadFixture('theme-block-settings.json');
|
|
9
|
+
const themeBlocksPresetsAsHash = loadFixture('theme-block-presets-as-hash.json');
|
|
10
|
+
const emptySchema = '{}';
|
|
11
|
+
|
|
12
|
+
const validate = validateSchema();
|
|
13
|
+
const service = getService();
|
|
14
|
+
|
|
15
|
+
describe('JSON Schema validation of Liquid theme block schema tags', () => {
|
|
16
|
+
it('should validate valid block schemas', async () => {
|
|
17
|
+
const schemas = [emptySchema, themeBlock1, themeBlock2, themeBlockBasics, themeBlocksPresetsAsHash];
|
|
18
|
+
for (const blockSchema of schemas) {
|
|
19
|
+
const diagnostics = await validate('blocks/block.liquid', blockSchema);
|
|
20
|
+
expect(diagnostics).toStrictEqual([]);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should report incorrect types', async () => {
|
|
25
|
+
const diagnostics = await validate('blocks/block.liquid', { name: 10 });
|
|
26
|
+
expect(diagnostics).toStrictEqual([
|
|
27
|
+
{
|
|
28
|
+
message: 'Incorrect type. Expected "string".',
|
|
29
|
+
severity: 1,
|
|
30
|
+
range: expect.objectContaining({
|
|
31
|
+
start: expect.objectContaining({
|
|
32
|
+
character: expect.any(Number),
|
|
33
|
+
line: expect.any(Number),
|
|
34
|
+
}),
|
|
35
|
+
end: expect.objectContaining({
|
|
36
|
+
character: expect.any(Number),
|
|
37
|
+
line: expect.any(Number),
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should accept `@theme` or `@app` blocks', async () => {
|
|
45
|
+
const diagnostics = await validate('blocks/block.liquid', {
|
|
46
|
+
blocks: [{ type: '@app' }, { type: '@theme' }],
|
|
47
|
+
});
|
|
48
|
+
expect(diagnostics).toStrictEqual([]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should accept specific theme blocks by name', async () => {
|
|
52
|
+
const diagnostics = await validate('blocks/block.liquid', {
|
|
53
|
+
blocks: [{ type: 'slide' }, { type: 'group' }],
|
|
54
|
+
});
|
|
55
|
+
expect(diagnostics).toStrictEqual([]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should complete the type property with the generic docs', async () => {
|
|
59
|
+
const result = await complete(
|
|
60
|
+
service,
|
|
61
|
+
'blocks/block.liquid',
|
|
62
|
+
`{
|
|
63
|
+
"blocks": [
|
|
64
|
+
{
|
|
65
|
+
"type█"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}`,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
assert(result);
|
|
72
|
+
expect(result.items).toContainEqual(
|
|
73
|
+
expect.objectContaining({
|
|
74
|
+
documentation: expect.stringContaining('The type of block that can be added to this block'),
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should complete the type value with the specific docs', async () => {
|
|
80
|
+
const result = await complete(
|
|
81
|
+
service,
|
|
82
|
+
'blocks/block.liquid',
|
|
83
|
+
`{
|
|
84
|
+
"blocks": [
|
|
85
|
+
{
|
|
86
|
+
"type": "█"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}`,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
assert(result);
|
|
93
|
+
// not showing generic docs
|
|
94
|
+
expect(result.items).not.toContainEqual(
|
|
95
|
+
expect.objectContaining({
|
|
96
|
+
documentation: expect.stringContaining('The type of block that can be added to this block'),
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
// show docs for @app and @theme
|
|
100
|
+
expect(result.items).toContainEqual(
|
|
101
|
+
expect.objectContaining({ documentation: expect.stringContaining('@app') }),
|
|
102
|
+
);
|
|
103
|
+
expect(result.items).toContainEqual(
|
|
104
|
+
expect.objectContaining({ documentation: expect.stringContaining('@theme') }),
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should hover the type property of a specific block with the specific block docs', async () => {
|
|
109
|
+
const result = await hover(
|
|
110
|
+
service,
|
|
111
|
+
'blocks/block.liquid',
|
|
112
|
+
`{
|
|
113
|
+
"blocks": [
|
|
114
|
+
{
|
|
115
|
+
"type": "slide█"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}`,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
assert(result);
|
|
122
|
+
// not showing generic docs
|
|
123
|
+
expect(result.contents).toContainEqual(
|
|
124
|
+
expect.stringContaining('found in the `blocks/` folder'),
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should refuse settings on blocks (local blocks are not a thing)', async () => {
|
|
129
|
+
const diagnostics = await validate('blocks/block.liquid', {
|
|
130
|
+
blocks: [{ type: 'theme', settings: [] }],
|
|
131
|
+
});
|
|
132
|
+
expect(diagnostics).toStrictEqual([
|
|
133
|
+
expect.objectContaining({ message: 'Property settings is not allowed.' }),
|
|
134
|
+
]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should require names for presets', async () => {
|
|
138
|
+
const diagnostics = await validate('blocks/block.liquid', {
|
|
139
|
+
presets: [{ settings: {} }],
|
|
140
|
+
});
|
|
141
|
+
expect(diagnostics).toStrictEqual([
|
|
142
|
+
expect.objectContaining({ message: 'Missing property "name".' }),
|
|
143
|
+
]);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should refuse setting arrays for presets', async () => {
|
|
147
|
+
const diagnostics = await validate('blocks/block.liquid', {
|
|
148
|
+
presets: [{ name: 'my preset', settings: [] }],
|
|
149
|
+
});
|
|
150
|
+
expect(diagnostics).toStrictEqual([
|
|
151
|
+
expect.objectContaining({ message: 'Incorrect type. Expected "object".' }),
|
|
152
|
+
]);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should accept null tag', async () => {
|
|
156
|
+
const diagnostics = await validate('blocks/block.liquid', { tag: null });
|
|
157
|
+
expect(diagnostics).toStrictEqual([]);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should refuse tag of length > 50', async () => {
|
|
161
|
+
const diagnostics = await validate('blocks/block.liquid', { tag: 'a'.repeat(51) });
|
|
162
|
+
expect(diagnostics).toStrictEqual([
|
|
163
|
+
expect.objectContaining({
|
|
164
|
+
message: 'String is longer than the maximum length of 50.',
|
|
165
|
+
}),
|
|
166
|
+
]);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should not accept invalid properties', async () => {
|
|
170
|
+
const diagnostics = await validate('blocks/block.liquid', { invalid: 'value' });
|
|
171
|
+
expect(diagnostics).toStrictEqual([
|
|
172
|
+
{
|
|
173
|
+
message: 'Property invalid is not allowed.',
|
|
174
|
+
severity: 1,
|
|
175
|
+
range: expect.objectContaining({
|
|
176
|
+
start: expect.objectContaining({
|
|
177
|
+
character: expect.any(Number),
|
|
178
|
+
line: expect.any(Number),
|
|
179
|
+
}),
|
|
180
|
+
end: expect.objectContaining({
|
|
181
|
+
character: expect.any(Number),
|
|
182
|
+
line: expect.any(Number),
|
|
183
|
+
}),
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should properly validate the default values of input settings per setting type', async () => {
|
|
190
|
+
// here we make sure that the input settings rules are working as intended
|
|
191
|
+
const diagnostics = await validate('blocks/block.liquid', themeBlockSettings);
|
|
192
|
+
expect(diagnostics).toContainEqual({
|
|
193
|
+
message: 'Incorrect type. Expected "boolean".',
|
|
194
|
+
severity: 1,
|
|
195
|
+
range: expect.objectContaining({
|
|
196
|
+
start: expect.objectContaining({
|
|
197
|
+
line: 7,
|
|
198
|
+
}),
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
expect(diagnostics).toContainEqual({
|
|
202
|
+
message: 'Incorrect type. Expected "number".',
|
|
203
|
+
severity: 1,
|
|
204
|
+
range: expect.objectContaining({
|
|
205
|
+
start: expect.objectContaining({
|
|
206
|
+
line: 13,
|
|
207
|
+
}),
|
|
208
|
+
}),
|
|
209
|
+
});
|
|
210
|
+
expect(diagnostics).toContainEqual({
|
|
211
|
+
message: 'Incorrect type. Expected "string".',
|
|
212
|
+
severity: 1,
|
|
213
|
+
range: expect.objectContaining({
|
|
214
|
+
start: expect.objectContaining({
|
|
215
|
+
line: 19,
|
|
216
|
+
}),
|
|
217
|
+
}),
|
|
218
|
+
});
|
|
219
|
+
expect(diagnostics).toContainEqual({
|
|
220
|
+
message: 'Missing property "options".',
|
|
221
|
+
severity: 1,
|
|
222
|
+
range: expect.objectContaining({
|
|
223
|
+
start: expect.objectContaining({
|
|
224
|
+
line: 21,
|
|
225
|
+
}),
|
|
226
|
+
}),
|
|
227
|
+
});
|
|
228
|
+
expect(diagnostics).toContainEqual({
|
|
229
|
+
code: 1,
|
|
230
|
+
message: 'Value is not accepted. Valid values: "youtube", "vimeo".',
|
|
231
|
+
severity: 1,
|
|
232
|
+
range: expect.objectContaining({
|
|
233
|
+
start: expect.objectContaining({
|
|
234
|
+
line: 30,
|
|
235
|
+
}),
|
|
236
|
+
}),
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('should validate theme block with conditional settings', async () => {
|
|
241
|
+
const themeBlockConditionalSettings = loadFixture('theme-block-conditional-settings.json');
|
|
242
|
+
const diagnostics = await validate('blocks/block.liquid', themeBlockConditionalSettings);
|
|
243
|
+
expect(diagnostics).toStrictEqual([]);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it.each(SETTINGS_TYPES_NOT_SUPPORTING_VISIBLE_IF)('should not allow visible_if on %s setting type', async (settingType) => {
|
|
247
|
+
const schema = {
|
|
248
|
+
settings: [
|
|
249
|
+
{
|
|
250
|
+
type: settingType,
|
|
251
|
+
id: 'test_setting',
|
|
252
|
+
label: 'Test Setting',
|
|
253
|
+
visible_if: '{{ block.settings.some_setting }}'
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const diagnostics = await validate('blocks/block.liquid', schema);
|
|
259
|
+
expect(diagnostics).toContainEqual(
|
|
260
|
+
expect.objectContaining({
|
|
261
|
+
message: 'Property visible_if is not allowed.',
|
|
262
|
+
severity: 1
|
|
263
|
+
})
|
|
264
|
+
);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it, beforeEach } from 'vitest';
|
|
2
|
+
import set from 'lodash.set';
|
|
3
|
+
|
|
4
|
+
import { loadFixture, validateSchema } from './test-helpers';
|
|
5
|
+
|
|
6
|
+
const translations1 = loadFixture('translations-1.json');
|
|
7
|
+
const emptySchema = '{}';
|
|
8
|
+
const validate = validateSchema();
|
|
9
|
+
|
|
10
|
+
describe('JSON Schema validation for translation files', () => {
|
|
11
|
+
it('should evaluate valid translation files expectedly', async () => {
|
|
12
|
+
for (const schema of [emptySchema, translations1]) {
|
|
13
|
+
const diagnostics = await validate('locales/en.json', schema);
|
|
14
|
+
expect(diagnostics).toStrictEqual([]);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should refuse arrays', async () => {
|
|
19
|
+
// Using JSON to make a deep copy of one of the valid schemas to mutate safely.
|
|
20
|
+
const schema = JSON.parse(translations1);
|
|
21
|
+
set(schema, 'general.foo', []);
|
|
22
|
+
|
|
23
|
+
const diagnostics = await validate('locales/en.json', JSON.stringify(schema));
|
|
24
|
+
expect(diagnostics).not.to.be.empty;
|
|
25
|
+
expect(diagnostics).toContainEqual({
|
|
26
|
+
message: 'Incorrect type. Expected "string".',
|
|
27
|
+
range: expect.anything(),
|
|
28
|
+
severity: 1,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|