Skip to content

Commit

Permalink
MDL-52606 behat: Added time delay to avoid random fails
Browse files Browse the repository at this point in the history
If attempts are created at same timestamp, then results are
not same, and lesson module finds that attmpt was in progress.
To avoid this problem, attempts should be created at different
timestamp.
  • Loading branch information
Rajesh Taneja committed Dec 24, 2015
1 parent afbb53d commit 26b9181
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 31 deletions.
11 changes: 6 additions & 5 deletions mod/lesson/tests/behat/completion_condition_time_spent.feature
Expand Up @@ -4,7 +4,6 @@ Feature: Set time spent as a completion condition for a lesson
As a teacher
I need to set time spent to mark the lesson activity as completed

@javascript
Scenario: Set time spent as a condition
Given the following "users" exist:
| username | firstname | lastname | email |
Expand All @@ -29,8 +28,8 @@ Feature: Set time spent as a completion condition for a lesson
| Description | Test lesson description |
| Completion tracking | Show activity as complete when conditions are met |
| completiontimespentenabled | 1 |
| completiontimespent[timeunit] | 60 |
| completiontimespent[number] | 1 |
| completiontimespent[timeunit] | 1 |
| completiontimespent[number] | 10 |
And I follow "Test lesson"
And I follow "Add a content page"
And I set the following fields to these values:
Expand All @@ -54,15 +53,17 @@ Feature: Set time spent as a completion condition for a lesson
Then the "Test lesson" "lesson" activity with "auto" completion should be marked as not complete
And I follow "Test lesson"
And I press "Next page"
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "Next page"
And I should see "You completed this lesson in"
And I should see ", which is less than the required time of 1 min. You might need to attempt the lesson again."
And I should see ", which is less than the required time of 10 secs. You might need to attempt the lesson again."
And I follow "Course 1"
And the "Test lesson" "lesson" activity with "auto" completion should be marked as not complete
And I follow "Course 1"
And I follow "Test lesson"
And I press "Next page"
And I wait "61" seconds
And I wait "11" seconds
And I press "Next page"
And I should not see "You might need to attempt the lesson again."
And I follow "Course 1"
Expand Down
7 changes: 2 additions & 5 deletions mod/lesson/tests/behat/date_availability.feature
Expand Up @@ -20,11 +20,10 @@ Feature: A teacher can set available from and deadline dates to access a lesson
And I follow "Course 1"
And I turn editing mode on

@javascript
Scenario: Forbidding lesson accesses until a specified date
Given I add a "Lesson" to section "1"
And I expand all fieldsets
And I click on "id_available_enabled" "checkbox"
And I set the field "id_available_enabled" to "1"
And I set the following fields to these values:
| Name | Test lesson |
| Description | Test lesson description |
Expand All @@ -48,11 +47,9 @@ Feature: A teacher can set available from and deadline dates to access a lesson
Then I should see "This lesson will be open on Wednesday, 1 January 2020, 8:00"
And I should not see "First page contents"

@javascript
Scenario: Forbidding lesson accesses until a specified date
Given I add a "Lesson" to section "1"
And I expand all fieldsets
And I click on "id_deadline_enabled" "checkbox"
And I set the field "id_deadline_enabled" to "1"
And I set the following fields to these values:
| Name | Test lesson |
| Description | Test lesson description |
Expand Down
54 changes: 33 additions & 21 deletions mod/lesson/tests/behat/lesson_student_resume.feature
Expand Up @@ -25,7 +25,6 @@ Feature: In a lesson activity a student should
And I press "Save and return to course"
And I follow "Test lesson name"

@javascript
Scenario: resume a lesson with both content then question pages
Given I follow "Add a content page"
And I set the following fields to these values:
Expand All @@ -34,7 +33,7 @@ Feature: In a lesson activity a student should
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -47,7 +46,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -60,7 +59,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Third page name |
| Page contents | Third page contents |
Expand All @@ -69,7 +68,7 @@ Feature: In a lesson activity a student should
| id_answer_editor_1 | Next page |
| id_jumpto_1 | Next page |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Second page name |
| Page contents | Second page contents |
Expand All @@ -84,6 +83,8 @@ Feature: In a lesson activity a student should
And I follow "Test lesson name"
And I should see "First page contents"
And I press "Next page"
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I should see "Second page contents"
And I press "Next page"
And I should see "Third page contents"
Expand All @@ -92,6 +93,8 @@ Feature: In a lesson activity a student should
And I should see "Do you want to start at the last page you saw?"
And I follow "Yes"
Then I should see "Third page contents"
# Add 1 sec delay so lesson knows differentiate 3rd and paper attempts.
And I wait "1" seconds
And I press "Next page"
And I should see "Paper is made from trees."
And I follow "Test lesson name"
Expand All @@ -115,7 +118,6 @@ Feature: In a lesson activity a student should
And I press "Continue"
And I should see "Congratulations - end of lesson reached"

@javascript
Scenario: resume a lesson with only content pages
Given I follow "Add a content page"
And I set the following fields to these values:
Expand All @@ -124,7 +126,7 @@ Feature: In a lesson activity a student should
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Fourth page name |
| Page contents | Fourth page contents |
Expand All @@ -133,7 +135,7 @@ Feature: In a lesson activity a student should
| id_answer_editor_1 | End of lesson |
| id_jumpto_1 | End of lesson |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Third page name |
| Page contents | Third page contents |
Expand All @@ -142,7 +144,7 @@ Feature: In a lesson activity a student should
| id_answer_editor_1 | Next page |
| id_jumpto_1 | Next page |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Second page name |
| Page contents | Second page contents |
Expand All @@ -158,6 +160,8 @@ Feature: In a lesson activity a student should
And I should see "First page contents"
And I press "Next page"
And I should see "Second page contents"
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "Next page"
And I should see "Third page contents"
And I follow "Test lesson name"
Expand All @@ -167,6 +171,8 @@ Feature: In a lesson activity a student should
And I should see "Third page contents"
And I press "Next page"
And I should see "Fourth page contents"
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "End of lesson"
And I log out
And I log in as "student1"
Expand All @@ -175,7 +181,6 @@ Feature: In a lesson activity a student should
And I should see "First page contents"
And I log out

@javascript
Scenario: resume a lesson with both question then content pages
Given I follow "Add a question page"
And I set the field "Select a question type" to "True/false"
Expand All @@ -190,7 +195,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -203,14 +208,14 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Content page 2 |
| Page contents | Second content page |
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -223,7 +228,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -236,7 +241,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -249,7 +254,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Add a content page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Content page 1 |
| Page contents | First content page |
Expand All @@ -275,6 +280,8 @@ Feature: In a lesson activity a student should
And I should see "1+1=2"
And I set the following fields to these values:
| True | 1 |
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "Submit"
And I press "Continue"
And I should see "2+2=4"
Expand All @@ -285,6 +292,8 @@ Feature: In a lesson activity a student should
And I should see "2+2=4"
And I set the following fields to these values:
| True | 1 |
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "Submit"
And I press "Continue"
And I should see "Second content page"
Expand All @@ -301,7 +310,6 @@ Feature: In a lesson activity a student should
And I press "Continue"
And I should see "Congratulations - end of lesson reached"

@javascript
Scenario: resume a lesson with only question pages
Given I follow "Add a question page"
And I set the field "Select a question type" to "True/false"
Expand All @@ -316,7 +324,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -329,7 +337,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -342,7 +350,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand All @@ -355,7 +363,7 @@ Feature: In a lesson activity a student should
| id_response_editor_1 | Wrong |
| id_jumpto_1 | This page |
And I press "Save page"
And I set the field "qtype" to "Question"
And I select "Question" from the "qtype" singleselect
And I set the field "Select a question type" to "True/false"
And I press "Add a question page"
And I set the following fields to these values:
Expand Down Expand Up @@ -385,6 +393,8 @@ Feature: In a lesson activity a student should
And I should see "1+1=2"
And I set the following fields to these values:
| True | 1 |
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "Submit"
And I press "Continue"
And I should see "2+2=4"
Expand All @@ -395,6 +405,8 @@ Feature: In a lesson activity a student should
And I should see "2+2=4"
And I set the following fields to these values:
| True | 1 |
# Add 1 sec delay so lesson knows a valid attempt has been made in past.
And I wait "1" seconds
And I press "Submit"
And I press "Continue"
And I should see "Kermit is a frog"
Expand Down

0 comments on commit 26b9181

Please sign in to comment.