Skip to content

Commit

Permalink
Change tests to verify legacy versions compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Carlos Rodríguez del Pino committed Nov 2, 2024
1 parent f52e39a commit e96f1b2
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 129 deletions.
2 changes: 1 addition & 1 deletion jail/jailserver_manager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public static function get_response($server, $request, &$error = null, $fresh =
$error = 'request failed: ' . s( curl_error( $ch ) );
curl_close( $ch );
} else {
curl_close( $ch );
$error = '';
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close( $ch );
if ( $httpcode != 200) {
$error = "HTTP Status Code: {$httpcode}";
if ($httpcode == 404) {
Expand Down
42 changes: 24 additions & 18 deletions tests/behat/behat_mod_vpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,28 @@ class behat_mod_vpl extends behat_base {
* @return void
*/
public function i_click_on_selector_in_vpl($selector) {
$script = "document.querySelector(\"$selector\").click();";
$script = "$(\"$selector\")[0].click();";
$this->getSession()->evaluateScript($script);
sleep(1);
}

/**
* Open a new activity in section i of type vpl
*
* @Given /^I open a new activity in section "([^"]*)" of type VPL$/
* @param string $section
* @return void
*/
public function i_open_a_new_activity_in_section_of_type_vpl($section) {
$script = "(function() {
var section='$section';
section = section.replace('\"','').replace(' ','');
var urlpattern = /(.*\\/course\\/)view\\.php\\?id=([0-9]*)/;
var urlreplacement = '$1modedit.php?add=vpl&type&course=$2&section=' + section;
window.location.href = window.location.href.replace(urlpattern, urlreplacement);
})();";
$this->getSession()->evaluateScript($script);
}

/**
* Accept confirm popup
Expand Down Expand Up @@ -115,14 +132,9 @@ public function i_drop_the_file_contening_on_in_vpl($filename, $contents, $selec
var file;
$scriptfile;
var fileList = [file];
var dropEvent = new Event('drop',
{
bubbles: true,
cancelable: true
});
dropEvent.dataTransfer = {files: fileList};
var element = document.querySelector('$selector');
element.dispatchEvent(dropEvent);
var drop = $.Event({type: 'drop', dataTransfer: {files: fileList}});
drop.isSimulated = true;
$('$selector').trigger(drop);
})()";
$this->getSession()->evaluateScript($script);
sleep(1);
Expand Down Expand Up @@ -155,15 +167,9 @@ public function i_drop_the_file_on_in_vpl($filenames, $selector) {
$scriptfile = $this->generate_drop_file($filename, $contents, 'file');
$script .= "$scriptfile; fileList.push(file);";
}
$script .= "var dropEvent = new Event('drop',
{
bubbles: true,
cancelable: true
});
dropEvent.dataTransfer = {files: fileList};
var element = document.querySelector('$selector');
element.dispatchEvent(dropEvent);
$script .= "var drop = $.Event({type: 'drop', dataTransfer: {files: fileList}});
drop.isSimulated = true;
$('$selector').trigger(drop);
})()";
$this->getSession()->evaluateScript($script);
sleep(count($files));
Expand Down
1 change: 1 addition & 0 deletions tests/behat/edit_access_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Feature: Create and change VPL activity access settings
| teacher1 | C1 | editingteacher |
| teacher2 | C1 | teacher |
| student1 | C1 | student |
And I log in as "teacher1"
And the following "activities" exist:
| activity | name | password | requirednet | sebrequired | sebkeys | course | section |
| vpl | VPL with password | key | | 0 | | C1 | 1 |
Expand Down
11 changes: 9 additions & 2 deletions tests/behat/edit_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ Feature: Create and change VPL activity settings
| student1 | C1 | student |

And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I expand all fieldsets
And I set the following fields to these values:
| id_name | VPL activity default |
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I press "Save and return to course"
And I open a new activity in section "1" of type VPL
And I expand all fieldsets
And I set the following fields to these values:
| id_name | VPL activity full setting |
| id_shortdescription | VPL activity short description |
| id_introeditor | Full description |
Expand All @@ -41,6 +47,7 @@ Feature: Create and change VPL activity settings
| id_grade_modgrade_point | 17 |
| id_reductionbyevaluation | 1% |
| id_freeevaluations | 3 |
And I press "Save and display"
And I log out

@javascript
Expand Down
9 changes: 6 additions & 3 deletions tests/behat/execution_files.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mod @mod_vpl @mod_vpl_execution_files
@mod @mod_vpl
Feature: In an VPL activity, editing teacher manage execution files
In order to manages activity requested files
As an editing teacher
Expand All @@ -15,12 +15,15 @@ Feature: In an VPL activity, editing teacher manage execution files
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity testing |
| id_shortdescription | VPL activity short description |
| id_duedate_enabled | "" |
| id_maxfiles | 33 |
| id_grade_modgrade_type | None |
And I press "Save and display"
And I log out

@javascript
Expand Down Expand Up @@ -84,7 +87,7 @@ Feature: In an VPL activity, editing teacher manage execution files
When I click on "#vpl_ide_more" in VPL
And I click on "#vpl_ide_delete" in VPL
Then I should see "Delete file?"
And I click on "div.ui-dialog:nth-last-child(2) > div:nth-of-type(3) button" in VPL
And I click on "div.vpl_ide_dialog:last + div button" in VPL
Then I should not see "other file_name.c"
Then I click on "#vpl_ide_save" in VPL
# Reload files
Expand Down
9 changes: 7 additions & 2 deletions tests/behat/execution_options.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@ Feature: In an VPL activity, editing teacher change options of execution
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity name |
| id_shortdescription | VPL activity short description |
| id_duedate_enabled | "" |
| id_maxfiles | 33 |
| id_grade_modgrade_type | None |
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I press "Save and return to course"
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL base activity |
| id_shortdescription | VPL activity short description |
| id_duedate_enabled | "" |
| id_maxfiles | 100 |
| id_grade_modgrade_type | None |
And I press "Save and display"
And I log out

@javascript
Expand Down
4 changes: 3 additions & 1 deletion tests/behat/files_to_keep.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ Feature: In a VPL activity feature files to keep when running
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity testing |
And I press "Save and display"
And I log out

@javascript
Expand Down
7 changes: 5 additions & 2 deletions tests/behat/grade_submissions.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mod @mod_vpl @mod_vpl_grade_submission
@mod @mod_vpl
Feature: In a VPL activity teacher grade submissions
In order to teacher grade submissions and
students submit files and teachers grade submissions
Expand All @@ -20,10 +20,13 @@ Feature: In a VPL activity teacher grade submissions
| teacher2 | C1 | teacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity testing |
| id_grade_modgrade_type | point |
| id_grade_modgrade_point | 5 |
And I press "Save and display"
And I log out
# Student1's submission
And I log in as "student1"
Expand Down
5 changes: 4 additions & 1 deletion tests/behat/local_execution_servers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ Feature: In a VPL activity feature Local execution servers
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity testing |
And I press "Save and display"
And I log out

@javascript
Expand Down
89 changes: 0 additions & 89 deletions tests/behat/overrides.feature

This file was deleted.

5 changes: 4 additions & 1 deletion tests/behat/requested_files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ Feature: In a VPL activity, an editing teacher sets "requested files" and a stud
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity testing |
| id_shortdescription | VPL activity short description |
| id_duedate_enabled | "" |
| id_maxfiles | 33 |
| id_grade_modgrade_type | None |
And I press "Save and display"
And I log out

@javascript
Expand Down
5 changes: 4 additions & 1 deletion tests/behat/similarity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ Feature: In a VPL activity, similarity feature
| student2 | C1 | student |
| student3 | C1 | student |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity testing |
| id_maxfiles | 8 |
And I press "Save and display"
And I log out

@javascript
Expand Down
17 changes: 12 additions & 5 deletions tests/behat/submision_list.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mod @mod_vpl @mod_vpl_submission_list
@mod @mod_vpl
Feature: List submissions of students
In order to list submissions of students
As an editing teacher or non-editing teacher
Expand All @@ -23,10 +23,17 @@ Feature: List submissions of students
| teacher2 | C1 | teacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activities" exist:
| activity | name | course | idnumber |
| vpl | VPL activity 1 | C1 | vpl1 |
| vpl | VPL activity 2 | C1 | vpl1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity 1 |
And I press "Save and return to course"
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity 2 |
And I press "Save and display"
And I log out

@javascript
Scenario: An editing teacher sees Submissions list
Expand Down
5 changes: 4 additions & 1 deletion tests/behat/test_cases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ Feature: In a VPL activity, editing teacher changes test cases
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | VPL activity name |
| id_shortdescription | VPL activity short description |
| id_duedate_enabled | "" |
| id_maxfiles | 33 |
| id_grade_modgrade_type | None |
And I press "Save and display"
And I log out

@javascript
Expand Down
5 changes: 4 additions & 1 deletion tests/behat/test_javascript.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ Feature: Runs JavaScript tests on browser
| user | course | role |
| manager1 | C1 | manager |
And I log in as "manager1"
And I add a "vpl" activity to course "Course 1" section "1" and I fill the form with:
And I am on "Course 1" course homepage with editing mode on
And I open a new activity in section "1" of type VPL
And I set the following fields to these values:
| id_name | JavaScript test |
And I press "Save and return to course"
And I click on "JavaScript test" "link" in the "region-main" "region"
# "Edit setting" for Moodle < 4 and "Setting" for Moodle >= 4
And I navigate to "ettings" in current page administration
Expand Down
Loading

0 comments on commit e96f1b2

Please sign in to comment.