/mod/h5pactivity/tests/behat/inline_editing_content.feature

https://github.com/markn86/moodle · Gherkin Specification · 192 lines · 165 code · 4 blank · 23 comment · 4 complexity · dd60b28a5bad96afacde132989b72b3c MD5 · raw file

  1. @mod @mod_h5pactivity @core_h5p @_file_upload @_switch_iframe
  2. Feature: Inline editing H5P content
  3. In order to edit an existing H5P activity file
  4. As a teacher
  5. I need to see the button and access to the H5P editor
  6. Background:
  7. Given the following "users" exist:
  8. | username | firstname | lastname | email |
  9. | teacher1 | Teacher | 1 | teacher1@example.com |
  10. | teacher2 | Teacher | 2 | teacher2@example.com |
  11. | student1 | Student | 1 | student1@example.com |
  12. And the following "courses" exist:
  13. | fullname | shortname | category |
  14. | Course 1 | C1 | 0 |
  15. And the following "course enrolments" exist:
  16. | user | course | role |
  17. | teacher1 | C1 | editingteacher |
  18. | teacher2 | C1 | editingteacher |
  19. | student1 | C1 | student |
  20. And the following "permission overrides" exist:
  21. | capability | permission | role | contextlevel | reference |
  22. | moodle/h5p:updatelibraries | Allow | editingteacher | System | |
  23. @javascript
  24. Scenario: Add H5P activity using link to content bank file
  25. Given the following "contentbank content" exist:
  26. | contextlevel | reference | contenttype | user | contentname | filepath |
  27. | Course | C1 | contenttype_h5p | teacher1 | Greeting card | /h5p/tests/fixtures/greeting-card-887.h5p |
  28. And I log in as "admin"
  29. # Add the navigation block.
  30. And I am on "Course 1" course homepage with editing mode on
  31. And I add the "Navigation" block if not present
  32. # Create an H5P activity with a link to the content-bank file.
  33. And I add a "H5P" to section "1"
  34. And I set the following fields to these values:
  35. | Name | H5P package added as link to content bank |
  36. | Description | Description |
  37. And I click on "Add..." "button" in the "Package file" "form_row"
  38. And I select "Content bank" repository in file picker
  39. And I click on "Greeting card" "file" in repository content area
  40. And I click on "Link to the file" "radio"
  41. And I click on "Select this file" "button"
  42. And I click on "Save and display" "button"
  43. And I switch to "h5p-player" class iframe
  44. And I switch to "h5p-iframe" class iframe
  45. And I should see "Hello world!"
  46. And I switch to the main frame
  47. # Modify the H5P content using the edit button (which opens the H5P editor).
  48. And I follow "Edit H5P content"
  49. And I should see "This content may be in use in other places."
  50. And I switch to "h5p-editor-iframe" class iframe
  51. And I set the field "Greeting text" to "It's a Wonderful Life!"
  52. And I switch to the main frame
  53. And I click on "Save changes" "button"
  54. And I switch to "h5p-player" class iframe
  55. And I switch to "h5p-iframe" class iframe
  56. # Check the H5P content has changed.
  57. And I should not see "Hello world!"
  58. And I should see "It's a Wonderful Life!"
  59. And I switch to the main frame
  60. # Check the H5P has also changed into the content bank.
  61. And I am on "Course 1" course homepage
  62. And I click on "Site pages" "list_item" in the "Navigation" "block"
  63. And I click on "Content bank" "link" in the "Navigation" "block"
  64. And I click on "Greeting card" "link"
  65. And I switch to "h5p-player" class iframe
  66. And I switch to "h5p-iframe" class iframe
  67. And I should not see "Hello world!"
  68. And I should see "It's a Wonderful Life!"
  69. And I switch to the main frame
  70. And I log out
  71. # Check teacher1 can see the Edit button (because she is the author of this file in the content bank).
  72. And I am on the "H5P package added as link to content bank" "h5pactivity activity" page logged in as teacher1
  73. And I should see "Edit H5P content"
  74. And I log out
  75. # Check teacher2 can't see the Edit button (because the file was created by the teacher1).
  76. When I am on the "H5P package added as link to content bank" "h5pactivity activity" page logged in as teacher2
  77. Then I should not see "Edit H5P content"
  78. And I log out
  79. # Check student1 can't see the Edit button.
  80. And I am on the "H5P package added as link to content bank" "h5pactivity activity" page logged in as student1
  81. And I should not see "Edit H5P content"
  82. @javascript
  83. Scenario: Add H5P activity using copy to content bank file
  84. Given the following "contentbank content" exist:
  85. | contextlevel | reference | contenttype | user | contentname | filepath |
  86. | Course | C1 | contenttype_h5p | admin | Greeting card | /h5p/tests/fixtures/greeting-card-887.h5p |
  87. And I log in as "admin"
  88. # Add the navigation block.
  89. And I am on "Course 1" course homepage with editing mode on
  90. And I add the "Navigation" block if not present
  91. # Create an H5P activity with a copy to the content-bank file.
  92. And I add a "H5P" to section "1"
  93. And I set the following fields to these values:
  94. | Name | H5P package added as copy to content bank |
  95. | Description | Description |
  96. And I click on "Add..." "button" in the "Package file" "form_row"
  97. And I select "Content bank" repository in file picker
  98. And I click on "Greeting card" "file" in repository content area
  99. And I click on "Make a copy of the file" "radio"
  100. And I click on "Select this file" "button"
  101. And I click on "Save and display" "button"
  102. And I switch to "h5p-player" class iframe
  103. And I switch to "h5p-iframe" class iframe
  104. And I should see "Hello world!"
  105. And I switch to the main frame
  106. # Modify the H5P content using the edit button (which opens the H5P editor).
  107. And I follow "Edit H5P content"
  108. And I should not see "This content may be in use in other places."
  109. And I switch to "h5p-editor-iframe" class iframe
  110. And I set the field "Greeting text" to "The nightmare before Christmas"
  111. And I switch to the main frame
  112. And I click on "Save changes" "button"
  113. # Check the H5P content has changed.
  114. And I switch to "h5p-player" class iframe
  115. And I switch to "h5p-iframe" class iframe
  116. And I should not see "Hello world!"
  117. And I should see "The nightmare before Christmas"
  118. And I switch to the main frame
  119. # Check the H5P has also changed into the content bank.
  120. And I am on "Course 1" course homepage
  121. And I click on "Site pages" "list_item" in the "Navigation" "block"
  122. And I click on "Content bank" "link" in the "Navigation" "block"
  123. And I click on "Greeting card" "link"
  124. And I switch to "h5p-player" class iframe
  125. And I switch to "h5p-iframe" class iframe
  126. And I should see "Hello world!"
  127. And I should not see "The nightmare before Christmas"
  128. And I switch to the main frame
  129. And I log out
  130. # Check teacher1 can see the Edit button (because the file is a copy).
  131. And I am on the "H5P package added as copy to content bank" "h5pactivity activity" page logged in as teacher1
  132. And I should see "Edit H5P content"
  133. And I log out
  134. # Check teacher2 can also see the Edit button (because the file is a copy).
  135. When I am on the "H5P package added as copy to content bank" "h5pactivity activity" page logged in as teacher2
  136. Then I should see "Edit H5P content"
  137. And I log out
  138. # Check student1 can't see the Edit button.
  139. And I am on the "H5P package added as copy to content bank" "h5pactivity activity" page logged in as student1
  140. And I should not see "Edit H5P content"
  141. @javascript
  142. Scenario: Add H5P activity using private user file
  143. Given I log in as "teacher1"
  144. # Upload the H5P to private user files.
  145. And I follow "Manage private files..."
  146. And I upload "h5p/tests/fixtures/greeting-card-887.h5p" file to "Files" filemanager
  147. And I click on "Save changes" "button"
  148. # Create an H5P activity with a private user file.
  149. And I am on "Course 1" course homepage with editing mode on
  150. And I add a "H5P" to section "1"
  151. And I set the following fields to these values:
  152. | Name | H5P package added as private user file |
  153. | Description | Description |
  154. And I click on "Add..." "button" in the "Package file" "form_row"
  155. And I select "Private files" repository in file picker
  156. And I click on "greeting-card-887.h5p" "file" in repository content area
  157. And I click on "Link to the file" "radio"
  158. And I click on "Select this file" "button"
  159. And I click on "Save and display" "button"
  160. And I switch to "h5p-player" class iframe
  161. And I switch to "h5p-iframe" class iframe
  162. And I should see "Hello world!"
  163. And I switch to the main frame
  164. # Modify the H5P content using the edit button (which opens the H5P editor).
  165. And I follow "Edit H5P content"
  166. And I should see "This content may be in use in other places."
  167. And I switch to "h5p-editor-iframe" class iframe
  168. And I set the field "Greeting text" to "Little women"
  169. And I switch to the main frame
  170. And I click on "Save changes" "button"
  171. # Check the H5P content has changed.
  172. And I switch to "h5p-player" class iframe
  173. And I switch to "h5p-iframe" class iframe
  174. And I should not see "Hello world!"
  175. And I should see "Little women"
  176. And I switch to the main frame
  177. And I log out
  178. # Check admin can't see the Edit button (because the file belongs to teacher1).
  179. And I am on the "H5P package added as private user file" "h5pactivity activity" page logged in as admin
  180. And I should not see "Edit H5P content"
  181. And I log out
  182. # Check teacher2 can't see the Edit button (because the file belongs to teacher1).
  183. When I am on the "H5P package added as private user file" "h5pactivity activity" page logged in as teacher2
  184. Then I should not see "Edit H5P content"
  185. And I log out
  186. # Check student1 can't see the Edit button.
  187. And I am on the "H5P package added as private user file" "h5pactivity activity" page logged in as student1
  188. And I should not see "Edit H5P content"