Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Feb 18, 2024
1 parent e6cd510 commit 3411d58
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions tests/behat/availability_relativedate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,57 @@ Feature: availability_relativedate
| startdate | ## -10 days 17:00 ## |
| enddate | ## +2 weeks 17:00 ## |
| numsections | 5 |
And selfenrolment exists in course "C1" ending "## tomorrow 17:00 ##"
And the following "course enrolments" exist:
And the following "activities" exist:
| activity | name | course | idnumber | section | completion |
| page | PageA | C1 | pageA | 1 | 1 |
| page | PageB | C1 | pageB | 1 | 1 |
| page | PageC | C1 | pageC | 1 | 1 |
| page | PageD | C1 | pageD | 1 | 1 |
| page | PageE | C1 | pageE | 1 | 1 |
And selfenrolment exists in course "C1" ending "## tomorrow 17:00 ##"
And the following "course enrolments" exist:
| user | course | role | timestart |
| teacher1 | C1 | editingteacher | ## yesterday 17:00 ## |
| student1 | C1 | student | ## yesterday 17:00 ## |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on

Scenario: Restrict section0
Given I edit the section "0"
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I edit the section "0"
And I expand all fieldsets
When I click on "Add restriction..." "button"
Then "Relative date" "button" should exist in the "Add restriction..." "dialogue"

Scenario: Test relative conditions
Given I add a page activity to course "Course 1" section "1"
Given I am on the "pageA" "page activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the field "Name" to "Page 1: 2 hours after course start date"
And I click on "Add restriction..." "button"
And I click on "Relative date" "button" in the "Add restriction..." "dialogue"
And I set the field "relativenumber" to "2"
And I set the field "relativednw" to "1"
And I set the field "relativestart" to "1"
And I press "Save and return to course"

And I add a page activity to course "Course 1" section "1"
And I am on the "pageB" "page activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the field "Name" to "Page 2: 4 days before course end date"
And I click on "Add restriction..." "button"
And I click on "Relative date" "button" in the "Add restriction..." "dialogue"
And I set the field "relativenumber" to "4"
And I set the field "relativednw" to "2"
And I set the field "relativestart" to "2"
And I press "Save and return to course"

And I add a page activity to course "Course 1" section "1"
And I am on the "pageC" "page activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the field "Name" to "Page 3: 6 weeks after user enrolment date"
And I click on "Add restriction..." "button"
And I click on "Relative date" "button" in the "Add restriction..." "dialogue"
And I set the field "relativenumber" to "6"
And I set the field "relativednw" to "3"
And I set the field "relativestart" to "3"
And I press "Save and return to course"

And I add a page activity to course "Course 1" section "1"
And I am on the "pageD" "page activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the field "Name" to "Page 4: 7 months after enrolment method end date"
And I click on "Add restriction..." "button"
And I click on "Relative date" "button" in the "Add restriction..." "dialogue"
And I set the field "relativenumber" to "7"
Expand All @@ -76,6 +79,8 @@ Feature: availability_relativedate
And I press "Save and return to course"

# 5 days before course start date.
And I am on "Course 1" course homepage with editing mode on
And I change window size to "large"
And I edit the section "2"
When I expand all fieldsets
Then I should see "None" in the "Restrict access" "fieldset"
Expand Down Expand Up @@ -104,7 +109,7 @@ Feature: availability_relativedate
And I set the field "relativestart" to "2"
And I press "Save changes"

And I should see "Page 1" in the "region-main" "region"
And I should see "PageA" in the "region-main" "region"
And I should see "2 hours after course start date" in the "region-main" "region"
And I should see "4 days before course end date" in the "region-main" "region"
And I should see relativedate "##+2 weeks -4 days 17:00##"
Expand All @@ -116,32 +121,32 @@ Feature: availability_relativedate

# Log back in as student 1.
When I am on the "C1" "Course" page logged in as "student1"
Then I should see "Page 1" in the "region-main" "region"
And I should see "2 hours after course start date" in the "region-main" "region"
And I should see "Page 2" in the "region-main" "region"
Then I should see "PageA" in the "region-main" "region"
# And I should see "2 hours after course start date" in the "region-main" "region"
And I should see "PageB" in the "region-main" "region"
And I should see relativedate "##+2 weeks -4 days 17:00##"
But I should see "Page 3" in the "region-main" "region"
But I should see "PageC" in the "region-main" "region"
And I should see relativedate "##+6 weeks -1 days 17:00##"
And I should see "Page 4" in the "region-main" "region"
And I should see "PageD" in the "region-main" "region"
And I should see "Topic 2" in the "region-main" "region"
And I should see "Topic 3" in the "region-main" "region"
And I log out

# Log back in as student 2.
When I am on the "C1" "Course" page logged in as "student2"
And I press "Enrol me"
Then I should see "Page 1" in the "region-main" "region"
And I should see "2 hours after course start date" in the "region-main" "region"
And I should see "Page 2" in the "region-main" "region"
But I should see "Page 3" in the "region-main" "region"
And I should see "Page 4" in the "region-main" "region"
Then I should see "PageA" in the "region-main" "region"
# And I should see "2 hours after course start date" in the "region-main" "region"
And I should see "PageB" in the "region-main" "region"
But I should see "PageC" in the "region-main" "region"
And I should see "PageD" in the "region-main" "region"
And I should see "Topic 2" in the "region-main" "region"
And I should see "Topic 3" in the "region-main" "region"
And I log out

# Log back in as admin.
When I am on the "C1" "Course" page logged in as "admin"
Then I should see "2 hours after course start date" in the "region-main" "region"
# Then I should see "2 hours after course start date" in the "region-main" "region"
And I should see "4 days before course end date" in the "region-main" "region"
And I should see "6 weeks after user enrolment date" in the "region-main" "region"
And I should see "7 months after enrolment method end date" in the "region-main" "region"
Expand Down

0 comments on commit 3411d58

Please sign in to comment.