mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-78575 mod_lti: add behat coverage of course tools list page
This commit is contained in:
parent
8d455f5adb
commit
5e077e1e46
98
mod/lti/tests/behat/managecoursetools.feature
Normal file
98
mod/lti/tests/behat/managecoursetools.feature
Normal file
@ -0,0 +1,98 @@
|
||||
@mod @mod_lti
|
||||
Feature: Manage course tools
|
||||
In order to provide richer experiences for learners
|
||||
As a teacher
|
||||
I need to be able to add external tools to a course
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Terry1 | Teacher1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
|
||||
Scenario: Create a course tool from the zero state
|
||||
Given I am on the "Course 1" course page logged in as teacher1
|
||||
And I navigate to "LTI External tools" in current page administration
|
||||
And I should see "LTI External tools are add-on apps"
|
||||
And I should see "There are no LTI external tools yet"
|
||||
When I click on "Add tool" "link"
|
||||
And I press "Cancel"
|
||||
Then I should see "LTI External tools are add-on apps"
|
||||
And I should see "There are no LTI external tools yet"
|
||||
And I click on "Add tool" "link"
|
||||
And I set the following fields to these values:
|
||||
| Tool name | Teaching Tool 1 |
|
||||
| Tool URL | http://example.com |
|
||||
| Tool description | A short description of the tool |
|
||||
And I press "Save changes"
|
||||
And I should see "Successfully added course tool"
|
||||
And I should see "A short description of the tool" in the "Teaching Tool 1" "table_row"
|
||||
|
||||
Scenario: Viewing a site level tool in the course tools table
|
||||
Given the following "mod_lti > tool types" exist:
|
||||
| name | description | baseurl | coursevisible |
|
||||
| Example tool | Another description | https://example.com/tool1 | 0 |
|
||||
| Test tool 2 | Tool2 description | https://example.com/tool2 | 1 |
|
||||
| Test tool 3 | Tool3 description | https://example.com/tool3 | 2 |
|
||||
And I am on the "Course 1" course page logged in as teacher1
|
||||
When I navigate to "LTI External tools" in current page administration
|
||||
Then I should see "Test tool 2" in the "reportbuilder-table" "table"
|
||||
And "This is a site level tool which cannot be edited" "icon" should exist in the "Test tool 2" "table_row"
|
||||
And I should see "Test tool 3" in the "reportbuilder-table" "table"
|
||||
And "This is a site level tool which cannot be edited" "icon" should exist in the "Test tool 3" "table_row"
|
||||
And I should not see "Example tool" in the "reportbuilder-table" "table"
|
||||
|
||||
Scenario: Viewing course tools without the capability to add/edit but having the capability to use
|
||||
Given the following "role capability" exists:
|
||||
| role | editingteacher |
|
||||
| mod/lti:addcoursetool | prohibit |
|
||||
| mod/lti:addpreconfiguredinstance | allow |
|
||||
And the following "mod_lti > course tools" exist:
|
||||
| name | description | baseurl | course |
|
||||
| Test tool | Example description | https://example.com/tool | C1 |
|
||||
And I am on the "Course 1" course page logged in as teacher1
|
||||
When I navigate to "LTI External tools" in current page administration
|
||||
Then "You don't have permission to add or edit course tools" "icon" should exist in the "Test tool" "table_row"
|
||||
|
||||
@javascript
|
||||
Scenario: Edit a course tool
|
||||
Given the following "mod_lti > course tools" exist:
|
||||
| name | description | baseurl | course |
|
||||
| Test tool | Example description | https://example.com/tool | C1 |
|
||||
And I am on the "Course 1" course page logged in as teacher1
|
||||
And I navigate to "LTI External tools" in current page administration
|
||||
And the "Edit" item should exist in the "Actions" action menu of the "Test tool" "table_row"
|
||||
And the "Delete" item should exist in the "Actions" action menu of the "Test tool" "table_row"
|
||||
When I open the action menu in "Test tool" "table_row"
|
||||
And I choose "Edit" in the open action menu
|
||||
And I press "Cancel"
|
||||
Then I should see "Test tool" in the "reportbuilder-table" "table"
|
||||
And I open the action menu in "Test tool" "table_row"
|
||||
And I choose "Edit" in the open action menu
|
||||
And I set the following fields to these values:
|
||||
| Tool name | Test tool (edited) |
|
||||
| Tool URL | http://example.com |
|
||||
| Tool description | A short description of the tool (edited) |
|
||||
And I press "Save changes"
|
||||
And I should see "The changes to the course tool 'Test tool (edited)' were saved"
|
||||
And I should see "A short description of the tool (edited)" in the "Test tool (edited)" "table_row"
|
||||
|
||||
@javascript
|
||||
Scenario: Navigate through the listing of course tools
|
||||
Given 20 "mod_lti > course tools" exist with the following data:
|
||||
| name | Test tool [count] |
|
||||
| description | Example description [count] |
|
||||
| baseurl | https://www.example.com/tool[count] |
|
||||
| course | C1 |
|
||||
And I am on the "Course 1" course page logged in as teacher1
|
||||
When I navigate to "LTI External tools" in current page administration
|
||||
Then I should see "Test tool 1" in the "reportbuilder-table" "table"
|
||||
And I click on "Name" "link"
|
||||
And I should see "Test tool 20" in the "reportbuilder-table" "table"
|
||||
And I click on "2" "link" in the "page" "region"
|
||||
And I should see "Test tool 1" in the "reportbuilder-table" "table"
|
@ -45,6 +45,12 @@ class behat_mod_lti_generator extends behat_generator_base {
|
||||
'datagenerator' => 'tool_types',
|
||||
'required' => ['baseurl'],
|
||||
],
|
||||
'course tools' => [
|
||||
'singular' => 'course tool',
|
||||
'datagenerator' => 'course_tool_types',
|
||||
'required' => ['baseurl', 'course'],
|
||||
'switchids' => ['course' => 'course']
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -100,4 +100,13 @@ class mod_lti_generator extends testing_module_generator {
|
||||
}
|
||||
lti_add_type((object) $type, (object) $config);
|
||||
}
|
||||
|
||||
public function create_course_tool_types(array $type, ?array $config = null) {
|
||||
if (!isset($type['baseurl'])) {
|
||||
throw new coding_exception('Must specify baseurl when creating a LTI tool type.');
|
||||
}
|
||||
$type['coursevisible'] = LTI_COURSEVISIBLE_PRECONFIGURED; // The default for course tools.
|
||||
lti_add_type((object) $type, (object) $config);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user