[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/message/tests/behat/ -> delete_messages.feature (source)

   1  @core @core_message
   2  Feature: Check that messages can be deleted
   3    In order to check a user can delete a message
   4    As a user
   5    I can delete a message
   6  
   7    Background:
   8      Given the following "users" exist:
   9        | username | firstname | lastname | email            |
  10        | user1    | User      | 1        | user1@asd.com    |
  11        | user2    | User      | 2        | user2@asd.com    |
  12      And I log in as "admin"
  13      And I set the following administration settings values:
  14        | forceloginforprofiles | 0 |
  15      And I log out
  16  
  17    @javascript
  18    Scenario: Test basic functionality of deleting a message
  19      # Send two messages from User 1 to User 2.
  20      And I log in as "user1"
  21      And I send "Hey bud, what's happening?" message to "User 2" user
  22      And I set the field with xpath "//textarea[@id='id_message']" to "Whoops, forgot to mention that I drank all your beers. Lol."
  23      And I press "Send message"
  24      # Confirm that there is a delete link next to each message.
  25      And "Delete" "link" should exist in the "#message_1" "css_element"
  26      And "Delete" "link" should exist in the "#message_2" "css_element"
  27      # Confirm that there is a confirmation box before deleting, and that when we cancel the messages remain.
  28      And I click on "#message_2" "css_element"
  29      And I click on "Delete" "link" in the "#message_2" "css_element"
  30      And I press "Cancel"
  31      And I should see "Hey bud, what's happening?"
  32      And I should see "Whoops, forgot to mention that I drank all your beers. Lol."
  33      # Confirm we can delete a message and then can no longer see it.
  34      And I click on "#message_2" "css_element"
  35      And I click on "Delete" "link" in the "#message_2" "css_element"
  36      And I press "Delete"
  37      And I should see "Hey bud, what's happening?"
  38      And I should not see "Whoops, forgot to mention that I drank all your beers. Lol."
  39      # Check that when we do a search for the keywords in the message we deleted nothing is returned.
  40      And I follow "Messages" in the user menu
  41      And I set the field "Search people and messages" to "beers"
  42      And I press "Search people and messages"
  43      And I should see "Messages found: 0"
  44      # Check that we can still search the message that we did not delete.
  45      And I follow "Messages" in the user menu
  46      And I set the field "Search people and messages" to "bud"
  47      And I press "Search people and messages"
  48      And I should see "Messages found: 1"
  49      # Check that the message we deleted does not show up on the recent conversation.
  50      And I set the field "Message navigation:" to "Recent conversations"
  51      And I should see "Hey bud, what's happening?"
  52      And I log out
  53      # Log in as User 2 and send two replies.
  54      And I log in as "user2"
  55      And I follow "Messages" in the user menu
  56      And I follow "User 1 (2)"
  57      And I set the field with xpath "//textarea[@id='id_message']" to "Not much brah, just writing a behat test and communicating to myself."
  58      And I press "Send message"
  59      And I set the field with xpath "//textarea[@id='id_message']" to "Oh man, I was looking forward to those tonight!"
  60      And I press "Send message"
  61      # Confirm that we can see all messages.
  62      And I should see "Hey bud, what's happening?"
  63      And I should see "Whoops, forgot to mention that I drank all your beers. Lol."
  64      And I should see "Not much brah, just writing a behat test and communicating to myself."
  65      And I should see "Oh man, I was looking forward to those tonight!"
  66      # Confirm that there is a delete link next to each message.
  67      And "Delete" "link" should exist in the "#message_1" "css_element"
  68      And "Delete" "link" should exist in the "#message_2" "css_element"
  69      And "Delete" "link" should exist in the "#message_3" "css_element"
  70      And "Delete" "link" should exist in the "#message_4" "css_element"
  71      # Now, delete one of the messages that User 1 sent and one by User 2.
  72      And I click on "#message_1" "css_element"
  73      And I click on "Delete" "link" in the "#message_1" "css_element"
  74      And I press "Delete"
  75      And I click on "#message_2" "css_element"
  76      And I click on "Delete" "link" in the "#message_2" "css_element"
  77      And I press "Delete"
  78      # Confirm that the messages are no longer listed.
  79      And I should not see "Hey bud, what's happening?"
  80      And I should see "Whoops, forgot to mention that I drank all your beers. Lol."
  81      And I should not see "Not much brah, just writing a behat test and communicating to myself."
  82      And I should see "Oh man, I was looking forward to those tonight!"
  83      # Check that when we do a search for the keywords in the messages we deleted nothing is returned.
  84      And I follow "Messages" in the user menu
  85      And I set the field "Search people and messages" to "bud"
  86      And I press "Search people and messages"
  87      And I should see "Messages found: 0"
  88      And I set the field "Search people and messages" to "brah"
  89      And I press "Search people and messages"
  90      And I should see "Messages found: 0"
  91      # Check that we can still search the message that we did not delete.
  92      And I follow "Messages" in the user menu
  93      And I set the field "Search people and messages" to "Whoops"
  94      And I press "Search people and messages"
  95      And I should see "Messages found: 1"
  96      And I set the field "Search people and messages" to "tonight"
  97      And I press "Search people and messages"
  98      And I should see "Messages found: 1"
  99      # Check that the messages we deleted do not show up on the recent conversation.
 100      And I set the field "Message navigation:" to "Recent conversations"
 101      And I should see "Oh man, I was looking forward to those tonight!"
 102      And I log out
 103  
 104    @javascript
 105    Scenario: Check that we can prevent some users from deleting messages
 106      # Prevent the ability to delete messages.
 107      Given I log in as "admin"
 108      And I set the following system permissions of "Authenticated user" role:
 109        | capability                   | permission |
 110        | moodle/site:deleteownmessage | Prevent   |
 111      # Send a message from the admin to User 1
 112      And I send "Hey there, this is the all-powerful administrator. Obey my commands." message to "User 1" user
 113      # Check the admin is still able to delete messages.
 114      And I click on "#message_1" "css_element"
 115      And I click on "Delete" "link" in the "#message_1" "css_element"
 116      And I press "Delete"
 117      And I should not see "Hey there, this is the all-powerful administrator. Obey my commands."
 118      And I log out
 119      # Check that User 1 is unable to delete the message the admin sent.
 120      And I log in as "user1"
 121      And I follow "Messages" in the user menu
 122      And I follow "Admin User (1)"
 123      And I should see "Hey there, this is the all-powerful administrator. Obey my commands."
 124      And "Delete" "link" should not exist in the "#message_1" "css_element"


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1