Skip to content

Commit

Permalink
Improved behat test cases for 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
raja-lmsace committed Apr 10, 2024
1 parent 3bc9f48 commit 519358e
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,4 @@ public function i_set_previous_template_notification($notificationdata) {
$this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$notificationdata]);

}


/**
* Switches to a third window.
*
* @Given /^I switch to a third window$/
* @throws DriverException If there aren't exactly 3 windows open.
*/
public function switch_to_third_window() {
$names = $this->getSession()->getWindowNames();

if (count($names) !== 3) {
throw new DriverException('Expected to see 3 windows open, found ' . count($names));
}

$this->getSession()->switchToWindow($names[2]);
}
}
102 changes: 51 additions & 51 deletions actions/notification/tests/behat/pulse_notification_template.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,69 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
And the following "course" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| book | Test book name | Test book description | C1 | book1 |
| activity | name | intro | course | idnumber |
| book | Test book name | Test book description | C1 | book1 |
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | student | User 1 | student1@test.com |
| teacher1 | teacher | User 1 | teacher1@test.com |
| username | firstname | lastname | email |
| student1 | student | User 1 | student1@test.com |
| teacher1 | teacher | User 1 | teacher1@test.com |
And the following "course enrolments" exist:
| user | course | role |
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | teacher |
And the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| pulseaction/notification:receivenotification | Allow | teacher | System | |
| capability | permission | role | contextlevel | reference |
| pulseaction/notification:receivenotification | Allow | teacher | System | |

@javascript
Scenario: Create notification template and instance
Given I log in as "admin"
And I navigate to automation templates
And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values:
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to learning portal of {Site_FullName} |
| Footer content | Copyright @ 2023 {Site_FullName} |
| Footer content | Copyright @ 2023 {Site_FullName} |
Then I should see "Automation templates"
And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table"
And I navigate to course "Course 1" automation instances
And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values:
| Recipients | Student |
| Recipients | Student |
And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table"
And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row"
And I switch to a second window
Then ".reportbuilder-report" "css_element" should exist
And the following should exist in the "reportbuilder-table" table:
| Full name | Subject | Status |
| student User 1 | Welcome to Acceptance test site | Queued |
| Full name | Subject | Status |
| student User 1 | Welcome to Acceptance test site | Queued |

@javascript
Scenario: Override notification template
Given I log in as "admin"
And I navigate to automation templates
And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values:
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to learning portal of {Site_FullName} |
| Footer content | Copyright @ 2023 {Site_FullName} |
| Footer content | Copyright @ 2023 {Site_FullName} |
Then I should see "Automation templates"
And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table"
And I navigate to course "Course 1" automation instances
And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values:
| override[pulsenotification_subject] | 1 |
| Subject | Welcome to learning portal {Site_FullName} |
| override[pulsenotification_subject] | 1 |
| Subject | Welcome to learning portal {Site_FullName} |
And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table"
And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row"
And I switch to a second window
Then ".reportbuilder-report" "css_element" should exist
And the following should exist in the "reportbuilder-table" table:
| Full name | Subject | Status |
| student User 1 | Welcome to learning portal Acceptance test site | Queued |
| Full name | Subject | Status |
| student User 1 | Welcome to learning portal Acceptance test site | Queued |

@javascript
Scenario: Preview the notification content
Expand All @@ -80,11 +80,11 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp
| Title | WELCOME MESSAGE |
| Reference | WELCOMEMESSAGE_ |
And I set previous automation template notification to these values:
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to {Site_FullName} |
| Footer content | <p> Copyright @ 2023 {Site_FullName} </p> |
| Footer content | <p> Copyright @ 2023 {Site_FullName} </p> |
And I press "Preview"
And I should see "Preview" in the ".modal-header .modal-title" "css_element"
Then I set the field "userselector" to "student User 1"
Expand All @@ -97,9 +97,9 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp
And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table"
And I navigate to course "Course 1" automation instances
And I initiate new automation instance of template "WELCOME MESSAGE" to these values:
| Reference | COURSE_1 |
| Reference | COURSE_1 |
And I set previous automation template notification to these values:
| Recipients | Student |
| Recipients | Student |
And I press "Preview"
And I should see "Preview" in the ".modal-header .modal-title" "css_element"
Then I set the field "userselector" to "student User 1"
Expand All @@ -117,53 +117,53 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp
Given I log in as "admin"
And I navigate to automation templates
And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values:
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to learning portal of {Site_FullName} |
| Footer content | Copyright @ 2023 {Site_FullName} |
| Delay | After |
| pulsenotification_delayduration[number] | 10 |
| Sender | Course teacher |
| Recipients | Student |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to learning portal of {Site_FullName} |
| Footer content | Copyright @ 2023 {Site_FullName} |
| Delay | After |
| pulsenotification_delayduration[number] | 10 |
Then I should see "Automation templates"
And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table"
And I navigate to course "Course 1" automation instances
And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values:
| override[pulsenotification_subject] | 1 |
| Subject | Welcome to learning portal {Site_FullName} |
| override[pulsenotification_subject] | 1 |
| Subject | Welcome to learning portal {Site_FullName} |
And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table"
And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row"
And I switch to a second window
Then ".reportbuilder-report" "css_element" should exist
And the following should exist in the "reportbuilder-table" table:
| Full name | Subject | Status | Time created | Scheduled time |
| student User 1 | Welcome to learning portal Acceptance test site | Queued | ##now##%A, %d %B %Y, %I:%M %p## | ##+10 minutes##%A, %d %B %Y, %I:%M %p## |
| Full name | Subject | Status | Time created | Scheduled time |
| student User 1 | Welcome to learning portal Acceptance test site | Queued | ##now##%A, %d %B %Y, %I:%M %p## | ##+10 minutes##%A, %d %B %Y, %I:%M %p## |

@javascript
Scenario Outline: Pulse action Notification: Send notification for different role users
Given I log in as "admin"
And I navigate to automation templates
And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values:
| Sender | Custom |
| Sender email | test@test.com |
| Recipients | <recipient> |
| Subject | Welcome to {Site_FullName} |
| Sender | Custom |
| Sender email | test@test.com |
| Recipients | <recipient> |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to learning portal of {Site_FullName} |
Then I should see "Automation templates"
And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table"
And I navigate to course "Course 1" automation instances
# Demo content.
And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values:
| Recipients | Student |
| Recipients | Student |
And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table"
And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row"
And I switch to a second window
Then ".reportbuilder-report" "css_element" should exist
And the following <studentshouldorshouldnot> exist in the "reportbuilder-table" table:
| Full name | Status |
| student User 1 | Queued |
| Full name | Status |
| student User 1 | Queued |
And the following <teachershouldorshouldnot> exist in the "reportbuilder-table" table:
| Full name | Status |
| teacher User 1 | Queued |
| Full name | Status |
| teacher User 1 | Queued |

Examples:
| recipient | studentshouldorshouldnot | teachershouldorshouldnot |
Expand Down
Loading

0 comments on commit 519358e

Please sign in to comment.