Skip to content

Commit

Permalink
MDL-76169 question: Use action menu steps consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Nov 3, 2022
1 parent 3d70f45 commit 8ffbaad
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 37 additions & 6 deletions question/tests/behat/behat_core_question.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,44 @@ public function the_state_of_question_is_shown_as($questiondescription, $state)
* @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',
]);
}

/**
Expand Down
15 changes: 5 additions & 10 deletions question/tests/behat/edit_question_versioning.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 6 additions & 6 deletions question/tests/behat/edit_questions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8ffbaad

Please sign in to comment.