1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-14 04:52:36 +02:00

MDL-45192 assign: added behat script & new definitions to handle alert dialog

The behat script is to test the batch action to lock and unlock submissions.
The new definitions are to prevent the "unexpected alert open" error in Selenium.
This commit is contained in:
Mohamed Alsharaf 2014-04-11 11:14:51 +12:00 committed by David Monllao
parent c1ed254643
commit bcad873102
3 changed files with 91 additions and 3 deletions

@ -60,6 +60,21 @@ class behat_forms extends behat_base {
$buttonnode->press();
}
/**
* Presses button with specified id|name|title|alt|value, and confirming the alert dialog.
*
* @When /^I press "(?P<button_string>(?:[^"]|\\")*)", confirming the dialog$/
* @throws ElementNotFoundException Thrown by behat_base::find
* @param string $button
*/
public function press_button_confirm_dialog($button) {
// Ensures the button is present.
$buttonnode = $this->find_button($button);
$buttonnode->press();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
/**
* Fills a form with field/value data. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
*

@ -190,6 +190,21 @@ class behat_general extends behat_base {
$linknode->click();
}
/**
* Clicks link with specified id|title|alt|text, and confirming the alert dialog.
*
* @When /^I follow "(?P<link_string>(?:[^"]|\\")*)", confirming the dialog$/
* @throws ElementNotFoundException Thrown by behat_base::find
* @param string $link
*/
public function click_link_confirm_dialog($link) {
$linknode = $this->find_link($link);
$this->ensure_node_is_visible($linknode);
$linknode->click();
$this->accept_currently_displayed_alert_dialog();
}
/**
* Waits X seconds. Required after an action that requires data from an AJAX request.
*

@ -4,8 +4,7 @@ Feature: Prevent or allow assignment submission changes
As a teacher
I need to prevent or allow student submission at any time
@javascript
Scenario: Preventing changes and allowing them again
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
@ -13,11 +12,16 @@ Feature: Prevent or allow assignment submission changes
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
| student1 | Student | 1 | student1@asd.com |
| student2 | Student | 2 | student2@asd.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
| student2 | C1 | student |
@javascript
Scenario: Preventing changes and allowing them again
Given I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
@ -69,3 +73,57 @@ Feature: Prevent or allow assignment submission changes
| Online text | I'm the student submission edited again |
And I press "Save changes"
And I should see "I'm the student submission edited again"
@javascript @_alert
Scenario: Preventing changes and allowing them again (batch action)
Given the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled |
| assign | C1 | assign1 | Test assignment name | Test assignment description | 1 | 0 |
And I log in as "student1"
And I follow "Course 1"
And I follow "Test assignment name"
And I press "Add submission"
And I set the following fields to these values:
| Online text | I'm the student submission |
And I press "Save changes"
And I log out
And I log in as "student2"
And I follow "Course 1"
And I follow "Test assignment name"
And I press "Add submission"
And I set the following fields to these values:
| Online text | I'm the student2 submission |
And I press "Save changes"
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Test assignment name"
When I follow "View/grade all submissions"
And I set the field "selectall" to "1"
And I press "Go", confirming the dialog
Then I should see "Submission changes not allowed" in the "Student 1" "table_row"
And I should see "Submission changes not allowed" in the "Student 2" "table_row"
And I log out
When I log in as "student2"
And I follow "Course 1"
And I follow "Test assignment name"
Then I should not see "Edit submission"
And I log out
When I log in as "teacher1"
And I follow "Course 1"
And I follow "Test assignment name"
And I follow "View/grade all submissions"
And I set the field "selectall" to "1"
And I set the field "id_operation" to "Unlock submissions"
And I press "Go", confirming the dialog
Then I should not see "Submission changes not allowed" in the "Student 1" "table_row"
And I should not see "Submission changes not allowed" in the "Student 2" "table_row"
And I log out
When I log in as "student2"
And I follow "Course 1"
And I follow "Test assignment name"
And I press "Edit submission"
And I set the following fields to these values:
| Online text | I'm the student2 submission and he/she edited me |
And I press "Save changes"
And I log out