diff --git a/config/schema/experience_builder.schema.yml b/config/schema/experience_builder.schema.yml index c642bc56c9557b84aa2bcc3c13adc9ec6e10c2fd..42bee5f6b07e06f32bbe53e994fbe4e19dd9a834 100644 --- a/config/schema/experience_builder.schema.yml +++ b/config/schema/experience_builder.schema.yml @@ -127,6 +127,7 @@ experience_builder.js_component.*: # @see \Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType::computeStorablePropShape() Choice: - 'json-schema-definitions://experience_builder.module/image' + - 'json-schema-definitions://experience_builder.module/textarea' description: requiredKey: false type: label diff --git a/tests/src/Kernel/Config/JavaScriptComponentValidationTest.php b/tests/src/Kernel/Config/JavaScriptComponentValidationTest.php index eac476fe4baebe8f64dac400f5d12acb9d2680fa..0bcd69fe445d4b557e3f0df078bdc4cafe22289b 100644 --- a/tests/src/Kernel/Config/JavaScriptComponentValidationTest.php +++ b/tests/src/Kernel/Config/JavaScriptComponentValidationTest.php @@ -304,7 +304,7 @@ class JavaScriptComponentValidationTest extends ConfigEntityValidationTestBase { ], 'Valid: image prop' => [ [ - 'machineName' => 'test-props-no-slots', + 'machineName' => 'image-prop-no-slots', 'name' => 'Test', 'props' => [ 'image' => [ @@ -333,7 +333,7 @@ class JavaScriptComponentValidationTest extends ConfigEntityValidationTestBase { ], 'Invalid: image prop missing examples' => [ [ - 'machineName' => 'test-props-no-slots', + 'machineName' => 'image-prop-no-slots-no-examples', 'name' => 'Test', '$ref' => "json-schema-definitions://experience_builder.module/image", 'props' => [ @@ -360,6 +360,36 @@ class JavaScriptComponentValidationTest extends ConfigEntityValidationTestBase { ], ], 'Invalid: image prop $ref' => [ + [ + 'machineName' => 'image-prop-no-slots-no-ref', + 'name' => 'Test', + 'props' => [ + 'image' => [ + 'title' => 'Image title', + 'type' => 'object', + 'examples' => [ + 'src' => 'https://example.com/image.png', + 'alt' => 'Alternative text', + 'width' => 800, + 'height' => 600, + ], + ], + ], + 'slots' => [], + 'js' => [ + 'original' => 'console.log("Test")', + 'compiled' => 'console.log("Test")', + ], + 'css' => [ + 'original' => '.test { display: none; }', + 'compiled' => '.test{display:none;}', + ], + ], + [ + 'props.image' => 'Prop "<em class="placeholder">image</em>" has a shape that is unfortunately not supported by Experience Builder.', + ], + ], + 'Invalid: image prop with incorrect $ref' => [ [ 'machineName' => 'test-props-no-slots', 'name' => 'Test', @@ -367,6 +397,7 @@ class JavaScriptComponentValidationTest extends ConfigEntityValidationTestBase { 'image' => [ 'title' => 'Image title', 'type' => 'object', + '$ref' => "json-schema-definitions://experience_builder.module/textarea", 'examples' => [ 'src' => 'https://example.com/image.png', 'alt' => 'Alternative text', @@ -389,6 +420,33 @@ class JavaScriptComponentValidationTest extends ConfigEntityValidationTestBase { 'props.image' => 'Prop "<em class="placeholder">image</em>" has a shape that is unfortunately not supported by Experience Builder.', ], ], + 'Valid: textarea prop with $ref' => [ + [ + 'machineName' => 'test-props-no-slots', + 'name' => 'Test', + 'props' => [ + 'textarea' => [ + 'title' => 'Textarea', + 'type' => 'string', + '$ref' => "json-schema-definitions://experience_builder.module/textarea", + 'examples' => [ + 'Simple', + 'Example', + ], + ], + ], + 'slots' => [], + 'js' => [ + 'original' => 'console.log("Test")', + 'compiled' => 'console.log("Test")', + ], + 'css' => [ + 'original' => '.test { display: none; }', + 'compiled' => '.test{display:none;}', + ], + ], + [], + ], ]; }