Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75608

Behat: Expand all fieldsets step does not work with single fieldset

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-75608-master
    • Hide

      The attached feature file tests the 'Expand all fieldsets' step when there is only a single (collapsed) fieldset. Because I don't know of any forms in core Moodle that work like that, I made it work by loading a form with a single expanded fieldset, manually collapsing it, and then trying to use the step, which ought to expand the fieldset again (but doesn't, before this fix).

      1. Place attached mdl75608.feature in lib/tests/behat
      2. Run Behat init
      3. Run behat with --tags=mdl75608
        • Test should pass (after fix)
      Show
      The attached feature file tests the 'Expand all fieldsets' step when there is only a single (collapsed) fieldset. Because I don't know of any forms in core Moodle that work like that, I made it work by loading a form with a single expanded fieldset, manually collapsing it, and then trying to use the step, which ought to expand the fieldset again (but doesn't, before this fix). Place attached mdl75608.feature in lib/tests/behat Run Behat init Run behat with --tags=mdl75608 Test should pass (after fix)

      The 'I expand all fieldsets' step (function expand_all_fields in behat_forms.php) has 2 different cases:

      1) If there is an 'Expand all' link, it clicks it.

      2) If there is no 'Expand all' link, but there is a fieldset that needs expanding, it clicks that instead.

      Part 1 works, but Part 2 does not work any more because the HTML has changed. In core this does not cause a problem because the 'Expand all' link always appears if there is more than one fieldset, and if there is only one fieldset then it normally defaults to expanded so nobody would be using this step anyway.

      However, in some of our plugins we have forms which have a 'first section' without a heading (always visible) and a second fieldset with a heading which defaults to collapsed. E.g. a search form with a search box straight away, then an 'Advanced search' fieldset wwith more options. We have been using this step, and it used to work, but now (Moodle 4) it fails.

      This is the problem code:

      // Else, look for the first expand fieldset link.
      $expandonlysection = "//legend[@class='ftoggler']" .
          "//a[contains(concat(' ', @class, ' '), ' icons-collapse-expand ') and @aria-expanded = 'false']"; 

      Here is the current HTML from Boost theme (grabbed from a real page):

      <legend class="d-flex align-items-center" id="yui_3_17_2_1_1661849701443_46">
              <div class="position-relative d-flex ftoggler align-items-center position-relative mr-1" id="yui_3_17_2_1_1661849701443_45">
                  <a data-toggle="collapse" href="#id_settingsheadercontainer" role="button" aria-expanded="false" aria-controls="id_settingsheadercontainer" class="btn btn-icon mr-1 icons-collapse-expand stretched-link fheader collapsed" id="yui_3_17_2_1_1661849701443_44">
      

      As you can see, the legend doesn't have class 'ftoggler', it's now moved to a div inside it.

        1. MDL-75608_master.png
          MDL-75608_master.png
          46 kB
        2. MDL-75608_v400.png
          MDL-75608_v400.png
          40 kB
        3. mdl75608.feature
          0.5 kB

            quen Sam Marshall
            quen Sam Marshall
            Mahmoud Kassaei Mahmoud Kassaei
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            John Edward Pedregosa John Edward Pedregosa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 6 minutes
                1h 6m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.