1@mod @mod_h5pactivity @core_h5p @_file_upload @_switch_iframe
2Feature: Add H5P activity
3  In order to let students access a H5P package
4  As a teacher
5  I need to add H5P activity to a course
6
7  Background:
8    Given the following "users" exist:
9      | username | firstname | lastname | email |
10      | teacher1 | Teacher | 1 | teacher1@example.com |
11    And the following "courses" exist:
12      | fullname | shortname | category |
13      | Course 1 | C1 | 0 |
14    And the following "course enrolments" exist:
15      | user | course | role |
16      | teacher1 | C1 | editingteacher |
17    And the following "permission overrides" exist:
18      | capability                 | permission | role           | contextlevel | reference |
19      | moodle/h5p:updatelibraries | Allow      | editingteacher | System       |           |
20    And I log in as "teacher1"
21    And I am on "Course 1" course homepage with editing mode on
22
23  @javascript
24  Scenario: Add a h5pactivity activity to a course
25    When I add a "H5P" to section "1"
26    And I set the following fields to these values:
27      | Name        | Awesome H5P package      |
28      | Description | H5P activity Description |
29    And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Package file" filemanager
30    And I click on "Save and display" "button"
31    And I wait until the page is ready
32    Then I should see "H5P activity Description"
33    And I switch to "h5p-player" class iframe
34    And I switch to "h5p-iframe" class iframe
35    And I should see "Lorum ipsum"
36    And I should not see "Reuse"
37    And I should not see "Rights of use"
38    And I should not see "Embed"
39    And I switch to the main frame
40
41  @javascript
42  Scenario: Add a h5pactivity activity with download
43    When I add a "H5P" to section "1"
44    And I set the following fields to these values:
45      | Name                       | Awesome H5P package |
46      | Description                | Description         |
47      | Allow download             | 1                   |
48    And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Package file" filemanager
49    And I click on "Save and display" "button"
50    And I wait until the page is ready
51    Then I switch to "h5p-player" class iframe
52    And I switch to "h5p-iframe" class iframe
53    And I should see "Reuse"
54    And I should not see "Rights of use"
55    And I should not see "Embed"
56    And I switch to the main frame
57
58  @javascript
59  Scenario: Add a h5pactivity activity with embed
60    When I add a "H5P" to section "1"
61    And I set the following fields to these values:
62      | Name              | Awesome H5P package |
63      | Description       | Description         |
64      | Embed button      | 1                   |
65    And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Package file" filemanager
66    And I click on "Save and display" "button"
67    And I wait until the page is ready
68    Then I switch to "h5p-player" class iframe
69    And I switch to "h5p-iframe" class iframe
70    And I should not see "Reuse"
71    And I should not see "Rights of use"
72    And I should see "Embed"
73    And I switch to the main frame
74
75  @javascript
76  Scenario: Add a h5pactivity activity with copyright
77    When I add a "H5P" to section "1"
78    And I set the following fields to these values:
79      | Name                  | Awesome H5P package |
80      | Description           | Description         |
81      | Copyright button      | 1                   |
82    And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Package file" filemanager
83    And I click on "Save and display" "button"
84    And I wait until the page is ready
85    Then I switch to "h5p-player" class iframe
86    And I switch to "h5p-iframe" class iframe
87    And I should not see "Reuse"
88    And I should see "Rights of use"
89    And I should not see "Embed"
90    And I switch to the main frame
91
92  @javascript
93  Scenario: Add a h5pactivity activity with copyright in a content without copyright
94    When I add a "H5P" to section "1"
95    And I set the following fields to these values:
96      | Name                  | Awesome H5P package |
97      | Description           | Description         |
98      | Copyright button      | 1                   |
99    And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Package file" filemanager
100    And I click on "Save and display" "button"
101    And I wait until the page is ready
102    Then I switch to "h5p-player" class iframe
103    And I switch to "h5p-iframe" class iframe
104    And I should not see "Reuse"
105    And I should not see "Rights of use"
106    And I should not see "Embed"
107    And I switch to the main frame
108
109  @javascript
110  Scenario: Add a h5pactivity activity to a course with all display options enabled
111    When I add a "H5P" to section "1"
112    And I set the following fields to these values:
113      | Name                       | Awesome H5P package |
114      | Description                | Description         |
115      | Allow download             | 1                   |
116      | Embed button               | 1                   |
117      | Copyright button           | 1                   |
118    And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Package file" filemanager
119    And I click on "Save and display" "button"
120    And I wait until the page is ready
121    Then I switch to "h5p-player" class iframe
122    And I switch to "h5p-iframe" class iframe
123    And I should see "Reuse"
124    And I should see "Rights of use"
125    And I should see "Embed"
126    And I switch to the main frame
127