first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,255 @@
@block @block_timeline @javascript
Feature: The timeline block allows users to see upcoming courses
In order to enable the timeline block
As a student
I can add the timeline block to my dashboard
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
And the following "courses" exist:
| fullname | shortname | category | startdate | enddate |
| Course 1 | C1 | 0 | ##yesterday## | ##tomorrow## |
| Course 2 | C2 | 0 | ##yesterday## | ##tomorrow## |
| Course 3 | C3 | 0 | ##yesterday## | ##tomorrow## |
| Course 4 | C4 | 0 | ##first day of next month## | ##last day of next month## |
| Course 5 | C5 | 0 | ##yesterday## | ##tomorrow## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | timeclose |
| choice | C2 | choice1 | Test choice 1 | Test choice description | ##yesterday## | ##tomorrow## |
| choice | C1 | choice2 | Test choice 2 | Test choice description | ##1 month ago## | ##15 days ago## |
| choice | C3 | choice3 | Test choice 3 | Test choice description | ##first day of +5 months## | ##last day of +5 months## |
| feedback | C2 | feedback1 | Test feedback 1 | Test feedback description | ##yesterday## | ##tomorrow## |
| feedback | C1 | feedback2 | Test feedback 2 | Test feedback description | ##first day of +10 months## | ##last day of +10 months## |
| feedback | C3 | feedback3 | Test feedback 3 | Test feedback description | ##first day of +5 months## | ##last day of +5 months## |
| feedback | C4 | feedback4 | Test feedback 4 | Test feedback description | ##yesterday## | ##tomorrow## |
| feedback | C1 | feedback5 | Test feedback 5 | Test feedback description | ##yesterday## | ##now +1 minute## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## |
| assign | C2 | assign2 | Test assign 2 | Test assign description | ##yesterday## | ##now -1 minute## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C3 | student |
| student1 | C4 | student |
Scenario: Next 30 days in course view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Next 30 days" "link" in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
When I click on "Sort by courses" "link" in the "Timeline" "block"
Then I should see "Course 1" in the ".block_timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block_timeline [data-region='view-courses']" "css_element"
And I should see "Show more courses" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 4" in the ".block_timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And I should see "Choice closes" in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes" in the "Timeline" "block"
And "Test feedback 4" "link" should exist in the "Timeline" "block"
And "Test feedback 5" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should not see "Course 3" in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test choice 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 2" "link" should not exist in the "Timeline" "block"
And "Test feedback 3" "link" should not exist in the "Timeline" "block"
And "Test assign 1" "link" should not exist in the "Timeline" "block"
Scenario: All in course view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
When I click on "Show more courses" "button" in the "Timeline" "block"
Then I should see "Course 3" in the "Timeline" "block"
And I should see "Course 2" in the "Timeline" "block"
And I should see "Course 1" in the "Timeline" "block"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And "Test choice 3" "link" should exist in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And "Test feedback 2" "link" should exist in the "Timeline" "block"
And "Test feedback 3" "link" should exist in the "Timeline" "block"
And "Test feedback 5" "link" should exist in the "Timeline" "block"
And "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due" in the "Timeline" "block"
And I should see "Choice closes" in the "Timeline" "block"
And I should see "Course 4" in the "Timeline" "block"
And I should see "Test feedback 4" in the "Timeline" "block"
And I should not see "Show more courses" in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
Scenario: Persistent sort filter
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by dates" "link" in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
When I reload the page
Then I should see "Course 1" in the "Timeline" "block"
And I should see "Course 2" in the "Timeline" "block"
And I should see "Show more courses" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 4" in the ".block_timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And "Test feedback 4" "link" should exist in the "Timeline" "block"
And "Test feedback 5" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should not see "Course 3" in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test choice 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 2" "link" should not exist in the "Timeline" "block"
And "Test feedback 3" "link" should not exist in the "Timeline" "block"
And "Test assign 1" "link" should not exist in the "Timeline" "block"
Scenario: Persistent All in course view
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I reload the page
And I should not see "Course 3" in the "Timeline" "block"
And I should see "Course 2" in the "Timeline" "block"
And I should see "Course 1" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
Then I should see "Course 3" in the "Timeline" "block"
And I should see "Course 2" in the "Timeline" "block"
And I should see "Course 1" in the "Timeline" "block"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And "Test choice 3" "link" should exist in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And "Test feedback 2" "link" should exist in the "Timeline" "block"
And "Test feedback 3" "link" should exist in the "Timeline" "block"
And "Test assign 1" "link" should exist in the "Timeline" "block"
And I should not see "Show more courses" in the "Timeline" "block"
And I should see "Course 4" in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test feedback 4" "link" should exist in the "Timeline" "block"
Scenario: Current filtering always applies in courses view
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
And I reload the page
And "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test feedback 2" "link" should not exist in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by dates" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
# Confirm that when we switch back to courses view, the "All" filer continues to be applied (and not "overdue").
When I click on "All" "link" in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test feedback 2" "link" should exist in the "Timeline" "block"
Scenario: Overdue in course view
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should not see "Test feedback 1" in the "Timeline" "block"
And I should not see "Test feedback 2" in the "Timeline" "block"
And I should not see "Test feedback 3" in the "Timeline" "block"
And I should not see "Test feedback 4" in the "Timeline" "block"
And I should not see "Test feedback 5" in the "Timeline" "block"
And I should not see "Test choice 1" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
And I should not see "Test choice 3" in the "Timeline" "block"
Scenario: Persistent Overdue in course view
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
And I reload the page
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And "Test feedback 1" "link" should not exist in the "Timeline" "block"
And "Test feedback 2" "link" should not exist in the "Timeline" "block"
And "Test feedback 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 4" "link" should not exist in the "Timeline" "block"
And "Test feedback 5" "link" should not exist in the "Timeline" "block"
And "Test choice 1" "link" should not exist in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test choice 3" "link" should not exist in the "Timeline" "block"
Scenario: Student not enrolled in any courses sees a message
Given I log in as "student2"
When I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
Then I should see "No in-progress courses" in the "Timeline" "block"
And I should not see "Test choice 1"
Scenario: Only courses with matching events are displayed and are refreshed when filtering changes
Given the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C5 | assign3 | Test assign 3 | Test assign description | ##yesterday## | ##now +1 minute## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C5 | student |
When I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test feedback 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
Then I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the "Timeline" "block"
And I should not see "Course 5" in the "Timeline" "block"
And I should not see "Show more courses" in the "Timeline" "block"
And "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And "Test assign 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 2" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test feedback 5" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Next 7 days" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the "Timeline" "block"
And I should not see "Show more courses" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test feedback 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 2" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
@@ -0,0 +1,125 @@
@block @block_timeline @javascript
Feature: The timeline block allows users to see courses with overdue activities
In order to view overdue activities in the timeline block
As a student
I can select the overdue filter in courses view
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "courses" exist:
| fullname | shortname | category | startdate | enddate |
| Course 1 | C1 | 0 | ##now -3 months## | ##tomorrow## |
| Course 2 | C2 | 0 | ##yesterday## | ##tomorrow## |
| Course 3 | C3 | 0 | ##yesterday## | ##tomorrow## |
| Course 4 | C4 | 0 | ##yesterday## | ##tomorrow## |
| Course 5 | C5 | 0 | ##yesterday## | ##tomorrow## |
| Course 6 | C6 | 0 | ##yesterday## | ##tomorrow## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C1 | assign1 | Test assign 1 | Assign due last month | ##now -2 months## | ##now -1 month## |
| assign | C2 | assign2 | Test assign 2 | Assign due yesterday | ##now -2 days## | ##yesterday## |
| assign | C3 | assign3 | Test assign 3 | Assign due yesterday | ##now -2 days## | ##yesterday## |
| assign | C4 | assign4 | Test assign 4 | Assign due later today | ##yesterday## | ##now +10 minutes## |
| assign | C5 | assign5 | Test assign 5 | Assign due yesterday | ##now -2 days## | ##yesterday## |
| assign | C6 | assign6 | Test assign 6 | Assign due tomorrow | ##yesterday## | ##tomorrow## |
Scenario: No activities to display as overdue displays expected message
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C4 | student |
| student1 | C6 | student |
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
Then I should see "No activities require action" in the "Timeline" "block"
And I reload the page
And I should see "No activities require action" in the "Timeline" "block"
Scenario: If filtering by overdue, only courses with a matching item are included
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C4 | student |
| student1 | C5 | student |
| student1 | C6 | student |
When I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
Then I should not see "Show more courses" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I reload the page
And I should not see "Show more courses" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
Scenario: If filtering by overdue, only courses with a matching item are included and loading more is supported
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C3 | student |
| student1 | C4 | student |
| student1 | C5 | student |
| student1 | C6 | student |
When I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
Then I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Show more courses" in the "Timeline" "block"
And I reload the page
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
@@ -0,0 +1,160 @@
@block @block_timeline @javascript
Feature: The timeline block allows users to see upcoming activities
In order to enable the timeline block
As a student
I can add the timeline block to my dashboard
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
And the following "courses" exist:
| fullname | shortname | category | startdate | enddate |
| Course 1 | C1 | 0 | ##1 month ago## | ##15 days ago## |
| Course 2 | C2 | 0 | ##yesterday## | ##tomorrow## |
| Course 3 | C3 | 0 | ##first day of next month## | ##last day of next month## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | timeclose |
| choice | C2 | choice1 | Test choice 1 | Test choice description | ##yesterday## | ##tomorrow## |
| choice | C1 | choice2 | Test choice 2 | Test choice description | ##1 month ago## | ##15 days ago## |
| choice | C3 | choice3 | Test choice 3 | Test choice description | ##first day of +5 months## | ##last day of +5 months## |
| feedback | C2 | feedback1 | Test feedback 1 | Test feedback description | ##yesterday## | ##tomorrow## |
| feedback | C1 | feedback2 | Test feedback 2 | Test feedback description | ##first day of +10 months## | ##last day of +10 months## |
| feedback | C3 | feedback3 | Test feedback 3 | Test feedback description | ##first day of +5 months## | ##last day of +5 months## |
| feedback | C2 | feedback4 | Test feedback 4 | Test feedback description | ##yesterday## | ##now +1 minute## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## |
| assign | C2 | assign2 | Test assign 2 | Test assign description | ##yesterday## | ##now -1 minute## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C3 | student |
And I change window size to "large"
Scenario: Next 7 days in date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Next 7 days" "link" in the "Timeline" "block"
Then "Test choice 1" "link" should exist in the "Timeline" "block"
And I should see "Choice closes · Course 2" in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 2" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And "Test feedback 4" "link" should exist in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test choice 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 3" "link" should not exist in the "Timeline" "block"
And "Test assign 1" "link" should not exist in the "Timeline" "block"
And I should not see "Assignment is due · Course 1" in the "Timeline" "block"
Scenario: Overdue in date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 1" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test feedback 1" "link" should not exist in the "Timeline" "block"
And "Test choice 1" "link" should not exist in the "Timeline" "block"
And "Test choice 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 4" "link" should not exist in the "Timeline" "block"
Scenario: All in date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "All" "link" in the "Timeline" "block"
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 1" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 2" in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 2" in the "Timeline" "block"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And I should see "Choice closes · Course 2" in the "Timeline" "block"
And "Test feedback 4" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 2" in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test feedback 2" "link" should not exist in the "Timeline" "block"
And I click on "Show more activities" "button"
And "Test feedback 2" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 1" in the "Timeline" "block"
And "Test choice 3" "link" should exist in the "Timeline" "block"
And I should see "Test assign 1" in the "Timeline" "block"
And I should see "Test feedback 1" in the "Timeline" "block"
And I should see "Test choice 1" in the "Timeline" "block"
And I should see "Test choice 3" in the "Timeline" "block"
And I should see "Test feedback 3" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
Scenario: Persistent All in date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "All" "link" in the "Timeline" "block"
And I reload the page
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 1" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 2" in the "Timeline" "block"
And "Test feedback 1" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 2" in the "Timeline" "block"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And I should see "Choice closes · Course 2" in the "Timeline" "block"
And "Test feedback 4" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 2" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
And I should not see "Test feedback 2" in the "Timeline" "block"
And I click on "Show more activities" "button"
And "Test feedback 2" "link" should exist in the "Timeline" "block"
And I should see "Feedback closes · Course 1" in the "Timeline" "block"
And I should see "Test assign 1" in the "Timeline" "block"
And I should see "Test feedback 1" in the "Timeline" "block"
And I should see "Test feedback 3" in the "Timeline" "block"
And I should see "Test choice 1" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
And I should see "Test choice 3" in the "Timeline" "block"
Scenario: Persistent Overdue in date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
And I reload the page
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 1" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And I should see "Assignment is due · Course 2" in the "Timeline" "block"
And "Test feedback 1" "link" should not exist in the "Timeline" "block"
And "Test feedback 3" "link" should not exist in the "Timeline" "block"
And "Test feedback 4" "link" should not exist in the "Timeline" "block"
And "Test choice 1" "link" should not exist in the "Timeline" "block"
And "Test choice 2" "link" should not exist in the "Timeline" "block"
And "Test choice 3" "link" should not exist in the "Timeline" "block"
Scenario: Current filtering always applies in date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
And I reload the page
And "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test feedback 2" "link" should not exist in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
# Confirm that when we switch back to date view, the "All" filer continues to be applied (and not "overdue")
When I click on "All" "link" in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by dates" "link" in the "Timeline" "block"
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And I click on "Show more activities" "button"
And "Test feedback 2" "link" should exist in the "Timeline" "block"
Scenario: Student not enrolled in any courses sees a message
Given I log in as "student2"
When I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by dates" "link" in the "Timeline" "block"
Then I should see "No in-progress courses" in the "Timeline" "block"
And I should not see "Test choice 1"
@@ -0,0 +1,90 @@
@block @block_timeline @javascript
Feature: The timeline block allows users to use the lazy loading to view more activities
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "courses" exist:
| fullname | shortname | category | startdate | enddate |
| Course 1 | C1 | 0 | ##yesterday## | ##last day of next month## |
| Course 2 | C2 | 0 | ##yesterday## | ##last day of next month## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | timeclose |
| choice | C1 | choice1 | Test choice 1 | Test choice description | ##yesterday## | ##tomorrow## |
| choice | C1 | choice2 | Test choice 2 | Test choice description | ##yesterday## | ##+1 days## |
| choice | C1 | choice3 | Test choice 3 | Test choice description | ##yesterday## | ##+2 days## |
| choice | C1 | choice4 | Test choice 4 | Test choice description | ##yesterday## | ##+3 days## |
| choice | C1 | choice5 | Test choice 5 | Test choice description | ##yesterday## | ##+4 days## |
| choice | C1 | choice6 | Test choice 6 | Test choice description | ##yesterday## | ##+5 days## |
| choice | C1 | choice7 | Test choice 7 | Test choice description | ##yesterday## | ##+6 days## |
| choice | C1 | choice8 | Test choice 8 | Test choice description | ##yesterday## | ##+7 days## |
| choice | C1 | choice9 | Test choice 9 | Test choice description | ##yesterday## | ##+8 days## |
| choice | C1 | choice10 | Test choice 10 | Test choice description | ##yesterday## | ##+9 days## |
| choice | C2 | choice10 | Test choice 11 | Test choice description | ##yesterday## | ##+9 days## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## |
Scenario: Lazy loading for date view
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "All" "link" in the "Timeline" "block"
Then I should see "Test choice 1" in the "Timeline" "block"
And "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And "Test choice 2" "link" should exist in the "Timeline" "block"
And "Test choice 3" "link" should exist in the "Timeline" "block"
And "Test choice 4" "link" should exist in the "Timeline" "block"
And "Test choice 5" "link" should not exist in the "Timeline" "block"
And "Test choice 6" "link" should not exist in the "Timeline" "block"
And "Test choice 7" "link" should not exist in the "Timeline" "block"
And "Test choice 8" "link" should not exist in the "Timeline" "block"
And "Test choice 9" "link" should not exist in the "Timeline" "block"
And "Test choice 10" "link" should not exist in the "Timeline" "block"
And "Test choice 11" "link" should not exist in the "Timeline" "block"
And I click on "Show more activities" "button" in the "[data-region='view-dates']" "css_element"
And "Test choice 5" "link" should exist in the "Timeline" "block"
And "Test choice 6" "link" should exist in the "Timeline" "block"
And "Test choice 7" "link" should exist in the "Timeline" "block"
And "Test choice 8" "link" should exist in the "Timeline" "block"
And "Test choice 9" "link" should exist in the "Timeline" "block"
And "Test choice 10" "link" should exist in the "Timeline" "block"
And "Test choice 11" "link" should exist in the "Timeline" "block"
Scenario: Lazy loading for course view
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
When I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
And "Test choice 1" "link" should exist in the "Timeline" "block"
And "Test choice 2" "link" should exist in the "Timeline" "block"
And "Test choice 3" "link" should exist in the "Timeline" "block"
And "Test choice 4" "link" should exist in the "Timeline" "block"
And "Test choice 5" "link" should exist in the "Timeline" "block"
And "Test choice 11" "link" should exist in the "Timeline" "block"
And "Test choice 6" "link" should not exist in the "Timeline" "block"
And "Test choice 7" "link" should not exist in the "Timeline" "block"
And "Test choice 8" "link" should not exist in the "Timeline" "block"
And "Test choice 9" "link" should not exist in the "Timeline" "block"
And "Test choice 10" "link" should not exist in the "Timeline" "block"
And I click on "Show more activities" "button" in the "[data-region='view-courses']" "css_element"
And "Test choice 6" "link" should exist in the "Timeline" "block"
And "Test choice 7" "link" should exist in the "Timeline" "block"
And "Test choice 8" "link" should exist in the "Timeline" "block"
And "Test choice 9" "link" should exist in the "Timeline" "block"
And "Test choice 10" "link" should exist in the "Timeline" "block"
Scenario: The lazy loading button will not be shown if the number of events is smaller than 5
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by dates" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
Then "Test assign 1" "link" should exist in the "Timeline" "block"
And "Show more activities" "button" should not exist in the "[data-region='view-courses']" "css_element"
@@ -0,0 +1,154 @@
@block @block_timeline @javascript
Feature: The timeline block allows users to search for upcoming activities
As a student
I can search for the upcoming activities in the timeline block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "courses" exist:
| fullname | shortname | category | startdate | enddate |
| Course 1 | C1 | 0 | ##1 month ago## | ##15 days ago## |
| Course 2 | C2 | 0 | ##yesterday## | ##tomorrow## |
| Course 3 | C3 | 0 | ##first day of next month## | ##last day of next month## |
| Course 4 | C4 | 0 | ##1 month ago## | ##tomorrow## |
| Course 5 | C5 | 0 | ##first day of last month## | ##last day of next month## |
| Course with advanced name | C6 | 0 | ##first day of last month## | ##last day of next month## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | timeclose | duedate |
| choice | C2 | choice1 | Test choice 1 | Test choice description | ##yesterday## | ##tomorrow## | |
| choice | C1 | choice2 | Test choice 2 | Test choice description | ##first day of +5 months## | ##last day of +5 months## | |
| choice | C3 | choice3 | Test choice 3 | Test choice description | ##first day of +5 months## | ##last day of +10 months## | |
| choice | C2 | choice4 | Test choice 4 | Test choice description | ##first day of +5 months## | ##last day of +15 months## | |
| choice | C1 | choice5 | Test choice 5 | Test choice description | ##first day of +5 months## | ##last day of +20 months## | |
| choice | C3 | choice6 | Test choice 6 | Test choice description | ##first day of +5 months## | ##last day of +25 months## | |
| choice | C4 | choice7 | Test choice 7 | Test choice description | ##first day of +5 months## | ##last day of +5 months## | |
| choice | C5 | choice8 | Test choice 8 | Test choice description | ##first day of +5 months## | ##last day of +10 months## | |
| feedback | C2 | feedback1 | Test feedback 1 | Test feedback description | ##yesterday## | ##tomorrow## | |
| feedback | C1 | feedback2 | Test feedback 2 | Test feedback description | ##first day of +5 months## | ##last day of +5 months## | |
| feedback | C3 | feedback3 | Test feedback 3 | Test feedback description | ##first day of +5 months## | ##last day of +10 months## | |
| assign | C6 | assign1 | Assign with advanced name | Test assign description | ##yesterday## | | ##tomorrow## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C3 | student |
| student1 | C4 | student |
| student1 | C5 | student |
| student1 | C6 | student |
Scenario: The search should return no events if I enter the wrong value
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "Fake example"
Then I should see "No activities require action" in the "Timeline" "block"
Scenario: Search for Course name
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "Course 1"
Then I should see "Test choice 2" in the "Timeline" "block"
And I should see "Test choice 5" in the "Timeline" "block"
And I should see "Test feedback 2" in the "Timeline" "block"
And I should not see "Test choice 1" in the "Timeline" "block"
And I should not see "Test choice 3" in the "Timeline" "block"
And I should not see "Test choice 4" in the "Timeline" "block"
And I should not see "Test feedback 1" in the "Timeline" "block"
And I should not see "Test feedback 3" in the "Timeline" "block"
Scenario: Search for Course name - Advanced
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "Course advanced"
Then I should see "Assign with advanced name" in the "Timeline" "block"
Scenario: Search for Activity name
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "Test choice 1"
And I wait until "Test choice 2" "text" does not exist
Then I should see "Test choice 1" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
And I should not see "Test choice 3" in the "Timeline" "block"
And I should not see "Test choice 4" in the "Timeline" "block"
And I should not see "Test choice 5" in the "Timeline" "block"
And I should not see "Test choice 6" in the "Timeline" "block"
And I should not see "Test feedback 1" in the "Timeline" "block"
And I should not see "Test feedback 2" in the "Timeline" "block"
And I should not see "Test feedback 3" in the "Timeline" "block"
Scenario: Search for Activity name - Advanced
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "Assign advanced"
Then I should see "Assign with advanced name" in the "Timeline" "block"
Scenario: Search for Activity type
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "feedback"
Then I should see "Test feedback 1" in the "Timeline" "block"
And I should see "Test feedback 2" in the "Timeline" "block"
And I should see "Test feedback 3" in the "Timeline" "block"
And I should not see "Test choice 1" in the "Timeline" "block"
And I should not see "Test choice 2" in the "Timeline" "block"
And I should not see "Test choice 3" in the "Timeline" "block"
And I should not see "Test choice 4" in the "Timeline" "block"
And I should not see "Test choice 5" in the "Timeline" "block"
Scenario: Timeline paginated search
Given I log in as "student1"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I set the field "Search" in the "Timeline" "block" to "choice"
Then I should see "Test choice 1" in the "Timeline" "block"
And I should see "Test choice 2" in the "Timeline" "block"
And I should see "Test choice 3" in the "Timeline" "block"
And I should see "Test choice 7" in the "Timeline" "block"
And I should see "Test choice 8" in the "Timeline" "block"
And I should not see "Test choice 4" in the "Timeline" "block"
And I should not see "Test choice 5" in the "Timeline" "block"
And I should not see "Test choice 6" in the "Timeline" "block"
And I click on "Show more activities" "button"
And I should see "Test choice 4" in the "Timeline" "block"
And I should see "Test choice 5" in the "Timeline" "block"
And I should see "Test choice 6" in the "Timeline" "block"
Scenario: Courses view is refreshed when search changes
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Test choice 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Test choice 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Test choice 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Test choice 7" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Test choice 8" in the ".block-timeline [data-region='view-courses']" "css_element"
When I set the field "Search by activity type or name" to "choice 1"
And I wait until "Course 4" "text" does not exist
Then I should see "Test choice 1" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Test choice 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Test choice 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Test choice 7" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Test choice 8" in the ".block-timeline [data-region='view-courses']" "css_element"
@@ -0,0 +1,88 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the block_timeline implementation of the privacy API.
*
* @package block_timeline
* @category test
* @copyright 2018 Peter Dias <peter@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_timeline\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\request\writer;
use block_timeline\privacy\provider;
/**
* Unit tests for the block_timeline implementation of the privacy API.
*
* @copyright 2018 Peter Dias <peter@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider_test extends \core_privacy\tests\provider_testcase {
/**
* Ensure that export_user_preferences returns no data if the user has not visited the myoverview block.
*/
public function test_export_user_preferences_no_pref(): void {
$this->resetAfterTest();
$user = $this->getDataGenerator()->create_user();
provider::export_user_preferences($user->id);
$writer = writer::with_context(\context_system::instance());
$this->assertFalse($writer->has_any_data());
}
/**
* Test the export_user_preferences given different inputs
*
* @param string $type The name of the user preference to get/set
* @param string $value The value you are storing
* @param string $expected The expected value override
*
* @dataProvider user_preference_provider
*/
public function test_export_user_preferences($type, $value, $expected): void {
$this->resetAfterTest();
$user = $this->getDataGenerator()->create_user();
set_user_preference($type, $value, $user);
provider::export_user_preferences($user->id);
$writer = writer::with_context(\context_system::instance());
$blockpreferences = $writer->get_user_preferences('block_timeline');
if (!$expected) {
$expected = get_string($value, 'block_timeline');
}
$this->assertEquals($expected, $blockpreferences->{$type}->value);
}
/**
* Create an array of valid user preferences for the timeline block.
*
* @return array Array of valid user preferences.
*/
public function user_preference_provider() {
return array(
array('block_timeline_user_sort_preference', 'sortbydates', ''),
array('block_timeline_user_sort_preference', 'sortbycourses', ''),
array('block_timeline_user_sort_preference', 'next7days', ''),
array('block_timeline_user_sort_preference', 'all', ''),
array('block_timeline_user_limit_preference', 5, 5),
);
}
}