DX: update `PropShapeToFieldInstanceTest` to not test all SDCs, but only those that meet XB's requirements

Created on 31 July 2025, 9 days ago
📌 Task
Status

Active

Version

1.0

Component

Shape matching

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @wim leers
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Starting point:

    diff --git a/tests/src/Kernel/PropShapeToFieldInstanceTest.php b/tests/src/Kernel/PropShapeToFieldInstanceTest.php
    index 8152f3580..8c6e46a4b 100644
    --- a/tests/src/Kernel/PropShapeToFieldInstanceTest.php
    +++ b/tests/src/Kernel/PropShapeToFieldInstanceTest.php
    @@ -169,12 +169,17 @@ class PropShapeToFieldInstanceTest extends KernelTestBase {
         );
         ksort($components);
     
    -    // Removing some test components that have been enabled due to all SDCs now
    -    // in xb_test_sdc module.
    -    $components_to_remove = ['crash', 'component-no-meta-enum', 'component-mismatch-meta-enum', 'empty-enum', 'deprecated', 'experimental', 'image-gallery', 'image-optional-with-example-and-additional-prop', 'obsolete', 'grid-container', 'html-invalid-format', 'my-cta', 'sparkline', 'sparkline_min_2', 'props-invalid-shapes', 'props-no-examples', 'props-no-slots', 'props-no-title', 'props-slots', 'image-optional-with-example', 'image-optional-without-example', 'image-required-with-example', 'image-required-with-invalid-example', 'image-required-without-example'];
    -    foreach ($components_to_remove as $key) {
    -      unset($components['xb_test_sdc:' . $key]);
    -    }
    +    $component_config_entities = \Drupal\experience_builder\Entity\Component::loadMultiple();
    +    $component_id_to_sdc_id = array_combine(
    +      array_map(
    +        fn ($s) => \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\SingleDirectoryComponent::convertMachineNameToId($s),
    +        array_keys($components)
    +      ),
    +      array_keys($components),
    +    );
    +    $components_to_keep = array_intersect_key($component_config_entities, $component_id_to_sdc_id);
    +    $sdc_ids_to_keep = array_flip(array_values(array_intersect_key($component_id_to_sdc_id, $components_to_keep)));
    +    $components = array_intersect_key($components, $sdc_ids_to_keep);
     
         foreach ($components as $component) {
           // Do not find a match for every unique SDC prop, but only for unique prop
    

    … then update the expectations to make this pass. 🙏

  • Hi Wim 👋

    Thanks for the detailed starting point!

    I’m picking up this ticket and assigning it to myself. I’ll begin working on updating the test logic and adjusting the expectations accordingly.

    Will share updates soon

Production build 0.71.5 2024