diff --git a/question/bank/deletequestion/tests/behat/delete_question_column.feature b/question/bank/deletequestion/tests/behat/delete_question_column.feature index e24f0d63f95..c20b49baecf 100644 --- a/question/bank/deletequestion/tests/behat/delete_question_column.feature +++ b/question/bank/deletequestion/tests/behat/delete_question_column.feature @@ -23,15 +23,11 @@ Feature: Use the qbank plugin manager page for deletequestion And I should see "Delete question" And I click on "Disable" "link" in the "Delete question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - Then I should not see "Delete" in the "region-main" "region" + Then the "Delete" action should not exist for the "First question" question in the question bank And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Delete question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - - # TODO This is a worthless test - the word "Delete" can appear anywhere in the page to make this test pass. - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should see "Delete" in the "region-main" "region" + And the "Delete" action should exist for the "First question" question in the question bank @javascript Scenario: Enable/disable delete questions bulk action from the base view diff --git a/question/bank/editquestion/tests/behat/qbank_editquestion.feature b/question/bank/editquestion/tests/behat/qbank_editquestion.feature index 9b4e94a3d9a..7614c0989b7 100644 --- a/question/bank/editquestion/tests/behat/qbank_editquestion.feature +++ b/question/bank/editquestion/tests/behat/qbank_editquestion.feature @@ -24,14 +24,11 @@ Feature: Use the qbank plugin manager page for editquestion And I click on "Disable" "link" in the "Edit question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page Then I should not see "Status" - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should not see "Edit question" in the "region-main" "region" - And I should not see "Duplicate" in the "region-main" "region" + And the "Edit question" action should not exist for the "First question" question in the question bank + And the "Duplicate" action should not exist for the "First question" question in the question bank And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Edit question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" Then I should see "Status" - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should see "Edit question" in the "region-main" "region" - And I should see "Duplicate" in the "region-main" "region" + And the "Edit question" action should exist for the "First question" question in the question bank + And the "Duplicate" action should exist for the "First question" question in the question bank diff --git a/question/bank/exporttoxml/tests/behat/export_to_xml_action.feature b/question/bank/exporttoxml/tests/behat/export_to_xml_action.feature index 4af997ba530..64ef39857c7 100644 --- a/question/bank/exporttoxml/tests/behat/export_to_xml_action.feature +++ b/question/bank/exporttoxml/tests/behat/export_to_xml_action.feature @@ -22,10 +22,8 @@ Feature: Use the qbank plugin manager page for exporttoxml And I should see "Export to XML" And I click on "Disable" "link" in the "Export to XML" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - Then I should not see "Export as Moodle XML" + Then the "Export as Moodle XML" action should not exist for the "First question" question in the question bank And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Export to XML" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should see "Export as Moodle XML" + And the "Export as Moodle XML" action should exist for the "First question" question in the question bank diff --git a/question/bank/history/tests/behat/question_history_action.feature b/question/bank/history/tests/behat/question_history_action.feature index f2ea0c30c6e..6a39b0852f9 100644 --- a/question/bank/history/tests/behat/question_history_action.feature +++ b/question/bank/history/tests/behat/question_history_action.feature @@ -23,13 +23,11 @@ Feature: Use the qbank plugin manager page for question history And I should see "Question history" And I click on "Disable" "link" in the "Question history" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - Then I should not see "History" in the "region-main" "region" + Then the "History" action should not exist for the "First question" question in the question bank And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Question history" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should see "History" in the "region-main" "region" + Then the "History" action should exist for the "First question" question in the question bank Scenario: History page shows only the specified features and questions Given I am on the "Test quiz" "mod_quiz > question bank" page logged in as "admin" @@ -42,8 +40,6 @@ Feature: Use the qbank plugin manager page for question history And I should see "Version" And I should see "Created by" And I should see "First question" - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - But I should not see "History" + And the "History" action should not exist for the "First question" question in the question bank And I click on "#qbank-history-close" "css_element" - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should see "History" in the "region-main" "region" + And the "History" action should exist for the "First question" question in the question bank diff --git a/question/bank/previewquestion/tests/behat/preview_question_action.feature b/question/bank/previewquestion/tests/behat/preview_question_action.feature index 1ac19093d35..2ed058f546e 100644 --- a/question/bank/previewquestion/tests/behat/preview_question_action.feature +++ b/question/bank/previewquestion/tests/behat/preview_question_action.feature @@ -23,13 +23,11 @@ Feature: Use the qbank plugin manager page for previewquestion And I should see "Preview question" And I click on "Disable" "link" in the "Preview question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".action-menu" "css_element" in the "First question" "table_row" - Then I should not see "Preview" in the "region-main" "region" + Then the "Preview" item should not exist in the "Edit" action menu of the "First question" "table_row" And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Preview question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".action-menu" "css_element" in the "First question" "table_row" - And I should see "Preview" in the "region-main" "region" + And the "Preview" item should exist in the "Edit" action menu of the "First question" "table_row" Scenario: Enable/disable preview button from question edit form Given I log in as "admin" diff --git a/question/bank/tagquestion/tests/behat/tag_question_action.feature b/question/bank/tagquestion/tests/behat/tag_question_action.feature index 845a046effe..f62bf00a65d 100644 --- a/question/bank/tagquestion/tests/behat/tag_question_action.feature +++ b/question/bank/tagquestion/tests/behat/tag_question_action.feature @@ -18,21 +18,19 @@ Feature: Use the qbank plugin manager page for tagquestion Scenario: Enable/disable tagquestion column from the base view Given I log in as "admin" - When I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration + And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I should see "Tag question" And I click on "Disable" "link" in the "Tag question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - Then I should not see "Manage tags" - And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration + And the "Manage tags" action should not exist for the "First question" question in the question bank + When I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Tag question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page - And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" - And I should see "Manage tags" + Then the "Manage tags" action should exist for the "First question" question in the question bank Scenario: Enable/disable tagquestion section from question edit form Given I log in as "admin" - When I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration + And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I should see "Tag question" And I click on "Disable" "link" in the "Tag question" "table_row" And I am on the "Test quiz" "mod_quiz > question bank" page diff --git a/question/tests/behat/behat_core_question.php b/question/tests/behat/behat_core_question.php index 494e4d54025..601d2f884c3 100644 --- a/question/tests/behat/behat_core_question.php +++ b/question/tests/behat/behat_core_question.php @@ -174,13 +174,44 @@ class behat_core_question extends behat_question_base { * @param string $questionname the question name. */ public function i_action_the_question($action, $questionname) { - // Open the menu. - $this->execute("behat_general::i_click_on_in_the", - [get_string('edit'), 'link', $questionname, 'table_row']); + $this->execute('behat_action_menu::i_choose_in_the_named_menu_in_container', [ + $action, + get_string('edit', 'core'), + $questionname, + 'table_row', + ]); + } - // Click the action from the menu. - $this->execute("behat_general::i_click_on_in_the", - [$action, 'link', $questionname, 'table_row']); + /** + * Checks that action does exist for a question. + * + * @Then the :action action should exist for the :questionname question in the question bank + * @param string $action the label for the action you want to activate. + * @param string $questionname the question name. + */ + public function action_exists($action, $questionname) { + $this->execute('behat_action_menu::item_should_exist_in_the', [ + $action, + get_string('edit', 'core'), + $questionname, + 'table_row', + ]); + } + + /** + * Checks that action does not exist for a question. + * + * @Then the :action action should not exist for the :questionname question in the question bank + * @param string $action the label for the action you want to activate. + * @param string $questionname the question name. + */ + public function action_not_exists($action, $questionname) { + $this->execute('behat_action_menu::item_should_not_exist_in_the', [ + $action, + get_string('edit', 'core'), + $questionname, + 'table_row', + ]); } /** diff --git a/question/tests/behat/edit_question_versioning.feature b/question/tests/behat/edit_question_versioning.feature index 8db0192074f..4fa0bf7f561 100644 --- a/question/tests/behat/edit_question_versioning.feature +++ b/question/tests/behat/edit_question_versioning.feature @@ -30,24 +30,19 @@ Feature: Questions in the question bank have versions @javascript Scenario: Question version is displayed Given I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1" - And I should see "First question" - And I click on "Edit" "link" in the "First question" "table_row" - And I follow "Edit question" + When I choose "Edit question" action for "First question" in the question bank Then I should see "Version 1" @javascript Scenario: Question version change when question is altered Given I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1" - And I should see "First question" - And I click on "Edit" "link" in the "First question" "table_row" - And I follow "Edit question" + When I choose "Edit question" action for "First question" in the question bank And I should see "Version 1" - And I set the field "id_name" to "Renamed question v2" + When I set the field "id_name" to "Renamed question v2" And I set the field "id_questiontext" to "edited question" And I press "id_submitbutton" - And I should not see "First question" + Then I should not see "First question" And I should see "Renamed question v2" - And I click on "Edit" "link" in the "Renamed question v2" "table_row" - And I follow "Edit question" + When I choose "Edit question" action for "Renamed question v2" in the question bank Then I should see "Version 2" And I should not see "Version 1" diff --git a/question/tests/behat/edit_questions.feature b/question/tests/behat/edit_questions.feature index bb999f10acd..266370d1cfc 100644 --- a/question/tests/behat/edit_questions.feature +++ b/question/tests/behat/edit_questions.feature @@ -83,9 +83,9 @@ Feature: A teacher can edit questions in the question bank | questioncategory | qtype | name | questiontext | | Test questions | missingtype | Broken question | Write something | When I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1" - Then "Edit question" "link" should not exist in the "Broken question" "table_row" - And "Duplicate" "link" should not exist in the "Broken question" "table_row" - And "Manage tags" "link" should exist in the "Broken question" "table_row" - And "Preview" "link" should not exist in the "Broken question" "table_row" - And "Delete" "link" should exist in the "Broken question" "table_row" - And "Export as Moodle XML" "link" should not exist in the "Broken question" "table_row" + Then the "Edit question" item should not exist in the "Edit" action menu of the "Broken question" "table_row" + And the "Duplicate" item should not exist in the "Edit" action menu of the "Broken question" "table_row" + And the "Preview" item should not exist in the "Edit" action menu of the "Broken question" "table_row" + And the "Export as XML" item should not exist in the "Edit" action menu of the "Broken question" "table_row" + And the "Manage tags" item should exist in the "Edit" action menu of the "Broken question" "table_row" + And the "Delete" item should exist in the "Edit" action menu of the "Broken question" "table_row" diff --git a/report/questioninstances/tests/behat/question_reports.feature b/report/questioninstances/tests/behat/question_reports.feature index 5306a38be7d..87fcb9a42a0 100644 --- a/report/questioninstances/tests/behat/question_reports.feature +++ b/report/questioninstances/tests/behat/question_reports.feature @@ -44,7 +44,7 @@ Feature: A Teacher can generate question instance reports @javascript Scenario: Generate report displaying hidden questions Given I am on the "Test quiz Q001" "mod_quiz > question bank" page logged in as "admin" - And I choose "Delete" in the open action menu + And I choose "Delete" action for "TF" in the question bank And I press "Delete" And I navigate to "Reports > Question instances" in site administration When I press "Get the report"