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

Global search: Allow Behat testing of search results screens

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      This is basically just new Behat code so it doesn't need manual testing, but I've included a few manual test steps to exercise the bits of live code that have an 'if behat' code branch and make sure they aren't broken.

      1 Run the new Behat tag core_search.

      2 Using a system where global search is configured and working, do a search and confirm the results are as expected (you can search for any word that appears on the site - as long as some results appear, it's OK).

      3 Temporarily stop the Solr server for the system and attempt a search - confirm that you see the error 'The search engine is not available. Please contact your administrator.'

      Show
      This is basically just new Behat code so it doesn't need manual testing, but I've included a few manual test steps to exercise the bits of live code that have an 'if behat' code branch and make sure they aren't broken. 1 Run the new Behat tag core_search. 2 Using a system where global search is configured and working, do a search and confirm the results are as expected (you can search for any word that appears on the site - as long as some results appear, it's OK). 3 Temporarily stop the Solr server for the system and attempt a search - confirm that you see the error 'The search engine is not available. Please contact your administrator.'
    • Affected Branches:
      MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-59926-master

      Description

      I would like a nice way to fake search results from inside a behat test. This will allow us to Behat-test the search user interface.

      Prior to this change, it is not possible to get search results without having a genuine search engine installed and configured, so you can't really test this from within Behat (Behat tests do not rely on external components like a search engine).

      Added steps

      I added two steps.

      Given global search expects the query "frogs" and will return:
        | type     | idnumber |
        |
      activity | PAGE1    |

      This tells the search system you are about to do a query, and it should return a link to the given page activity. The results are indicated by type (only 'activity' is supported at present) and by the idnumber of the activity - you should create an activity first for it to find. The activity should be one that will be available to the current user.

      The procedure is to do this step just before carrying out the query, then you should be able to see the expected results.

      When I search for "frogs" using the header global search box

      This step does a search using the search box in the header. I had to make a new step because I couldn't find a way to search using standard Behat commands, because I can't get it to press Return (the step about pressing a key doesn't work with that field). It's probably neater anyway.

       

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Nov/17