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

Incorrectly deprecated Behat step for using flat navigation

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • Hide

      Note: all we are testing is that it remains possible to execute the deprecated step, for devs who still might want to do that

      Setup

      1. Add the following to lib/tests/behat/action_modal.feature around line 27 (within the "The popup closes when clicked on dead space - Modal" scenario):

        When I select "Something" from flat navigation drawer
        

      Test step

      1. Execute the following:

        $ bin/moodle-docker-compose exec --user www-data webserver php admin/tool/behat/cli/run.php --name="The popup closes when clicked on dead space - Modal"
        

      2. Confirm you see the following:

        --- Failed steps:
         
        001 Scenario: The popup closes when clicked on dead space - Modal # /var/www/html/lib/tests/behat/action_modal.feature:25
              When I select "Something" from flat navigation drawer       # /var/www/html/lib/tests/behat/action_modal.feature:27
                Deprecated step, rather than using this step you can:
                - i_select_from_primary_navigation
                - i_select_from_secondary_navigation
                - Set $CFG->behat_usedeprecated in config.php to allow the use of deprecated steps
                                    if you don't have any other option (Exception)
        

      Test step with $CFG->behat_usedeprecated enabled

      1. Add the following to your site config.php file:

        $CFG->behat_usedeprecated = 1;
        

      2. Re-run the previous scenario
      3. Confirm you see the following (the deprecated step has executed):

        --- Failed steps:
         
        001 Scenario: The popup closes when clicked on dead space - Modal # /var/www/html/lib/tests/behat/action_modal.feature:25
              When I select "Something" from flat navigation drawer       # /var/www/html/lib/tests/behat/action_modal.feature:27
                Xpath matching locator "//button[contains(@data-action,'toggle-drawer')]" not found. (Behat\Mink\Exception\ElementNotFoundException)
        

      Show
      Note: all we are testing is that it remains possible to execute the deprecated step, for devs who still might want to do that Setup Add the following to lib/tests/behat/action_modal.feature around line 27 (within the "The popup closes when clicked on dead space - Modal" scenario): When I select "Something" from flat navigation drawer Test step Execute the following: $ bin/moodle-docker-compose exec --user www-data webserver php admin/tool/behat/cli/run.php --name="The popup closes when clicked on dead space - Modal" Confirm you see the following: --- Failed steps:   001 Scenario: The popup closes when clicked on dead space - Modal # /var/www/html/lib/tests/behat/action_modal.feature:25 When I select "Something" from flat navigation drawer # /var/www/html/lib/tests/behat/action_modal.feature:27 Deprecated step, rather than using this step you can: - i_select_from_primary_navigation - i_select_from_secondary_navigation - Set $CFG->behat_usedeprecated in config.php to allow the use of deprecated steps if you don't have any other option (Exception) Test step with $CFG->behat_usedeprecated enabled Add the following to your site config.php file: $CFG->behat_usedeprecated = 1; Re-run the previous scenario Confirm you see the following (the deprecated step has executed): --- Failed steps:   001 Scenario: The popup closes when clicked on dead space - Modal # /var/www/html/lib/tests/behat/action_modal.feature:25 When I select "Something" from flat navigation drawer # /var/www/html/lib/tests/behat/action_modal.feature:27 Xpath matching locator "//button[contains(@data-action,'toggle-drawer')]" not found. (Behat\Mink\Exception\ElementNotFoundException)

      The deprecation of this method doesn't appear to be correct:

      https://github.com/moodle/moodle/blob/c352b700223e534781e8971631c73566be3205e6/lib/tests/behat/behat_deprecated.php#L92-L97

      1. It passes true as the second argument to self::deprecated_message(), making the rest of the method redundant;
      2. If you fix that then you get a coding exception, because it's not executing the step correctly:

        The 'i_open_flat_navigation_drawer' method does not exist (coding_exception)
        

      There doesn't seem to be an obvious reason for not obeying $CFG->behat_usedeprecated like other deprecated Behat steps, so it seems like this is worth doing properly

      Found while reviewing MDL-73669

            pholden Paul Holden
            pholden Paul Holden
            Amaia Anabitarte Amaia Anabitarte
            Ilya Tregubov Ilya Tregubov
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            5 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, 55 minutes
                1h 55m

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