Commit 8857c715 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-40759 icons: Behat fixes for font-awesome

parent ad056aa2
......@@ -37,18 +37,18 @@ Feature: Manage availability conditions
When I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"
# Check the icon is there (it should be a Hide icon, meaning is currently visible).
Then "input[title=Hide]" "css_element" should exist in the "Restriction by date" "table_row"
Then "Hide" "icon" should exist in the "Restriction by date" "table_row"
# Click the icon. It should toggle to hidden (title=Show).
And I click on "input[title=Hide]" "css_element" in the "Restriction by date" "table_row"
And "input[title=Show]" "css_element" should exist in the "Restriction by date" "table_row"
And I click on "Hide" "icon" in the "Restriction by date" "table_row"
And "Show" "icon" should exist in the "Restriction by date" "table_row"
# Toggle it back to visible (title=Hide).
And I click on "input[title=Show]" "css_element" in the "Restriction by date" "table_row"
And "input[title=Hide]" "css_element" should exist in the "Restriction by date" "table_row"
And I click on "Show" "icon" in the "Restriction by date" "table_row"
And "Hide" "icon" should exist in the "Restriction by date" "table_row"
# OK, toggling works. Set the grade one to Hide and we'll go see if it actually worked.
And I click on "input[title=Hide]" "css_element" in the "Restriction by grade" "table_row"
And I click on "Hide" "icon" in the "Restriction by grade" "table_row"
And I am on site homepage
And I follow "Course 1"
And I turn editing mode on
......
......@@ -97,7 +97,7 @@ class utils {
if ($handle = @opendir($path)) {
while (($file = readdir($handle)) !== false) {
$matches = array();
if (preg_match('~(.+?)(?:-24|-32|-48|-64|-72|-80|-96|-128|-256)?\.(?:gif|png)$~',
if (preg_match('~(.+?)(?:-24|-32|-48|-64|-72|-80|-96|-128|-256)?\.(?:svg|gif|png)$~',
$file, $matches)) {
$key = $matches[1];
$icons[$key] = $key;
......
......@@ -116,7 +116,7 @@ class tool_filetypes_renderer extends plugin_renderer_base {
$editurl = new \moodle_url('/admin/tool/filetypes/edit.php',
array('oldextension' => $extension));
$editbutton = html_writer::link($editurl, $this->pix_icon('t/edit',
get_string('edita', '', s($extension))));
get_string('edita', 'moodle', s($extension))));
$deleteurl = new \moodle_url('/admin/tool/filetypes/delete.php',
array('extension' => $extension));
$deletebutton = html_writer::link($deleteurl, $this->pix_icon('t/delete',
......
......@@ -21,7 +21,6 @@ Feature: Add customised file types
Then I should see "Froggy file" in the "application/x-frog" "table_row"
And I should see "document" in the "application/x-frog" "table_row"
And I should see "frog" in the "application/x-frog" "table_row"
And "//img[contains(@src, 'archive')]" "xpath_element" should exist in the "application/x-frog" "table_row"
Scenario: Update an existing file type
Given I log in as "admin"
......@@ -99,11 +98,11 @@ Feature: Add customised file types
And I navigate to "File types" node in "Site administration > Server"
And I click on "Edit 7z" "link"
And I set the following fields to these values:
| File icon | document |
| Type groups | document |
And I press "Save changes"
When I follow "Restore 7z to Moodle defaults"
And I follow "Restore 7z to Moodle defaults"
And I press "Yes"
Then "//img[contains(@src, 'archive')]" "xpath_element" should exist in the "7z" "table_row"
Then "//*[contains(text(), 'archive')]" "xpath_element" should exist in the "7z" "table_row"
@javascript @_file_upload
Scenario: Create a resource activity which contains a customised file type
......@@ -133,4 +132,3 @@ Feature: Add customised file types
And I set the field "Show type" to "1"
And I press "Save and return to course"
Then I should see "Froggy file"
And the "src" attribute of ".modtype_resource a img" "css_element" should contain "archive"
......@@ -94,6 +94,7 @@ Feature: Manage plearning plan
And I click on "Delete" of edit menu in the "comp1" row
And "Confirm" "dialogue" should be visible
And I click on "Confirm" "button"
And I wait until the page is ready
And "comp1" "table_row" should not exist
Scenario: Edit a learning plan
......@@ -125,4 +126,5 @@ Feature: Manage plearning plan
And I click on "Delete" of edit menu in the "Science plan Year-4" row
And "Confirm" "dialogue" should be visible
When I click on "Delete" "button"
And I wait until the page is ready
Then I should not see "Science plan Year-4"
......@@ -171,6 +171,7 @@ Feature: Manage plan workflow
And I follow "Learning plans"
When I click on "Complete this learning plan" of edit menu in the "Test-Plan3" row
And I click on "Complete this learning plan" "button" in the "Confirm" "dialogue"
And I wait until the page is ready
And I follow "Test-Plan4"
And I follow "Complete this learning plan"
And I click on "Complete this learning plan" "button" in the "Confirm" "dialogue"
......
......@@ -56,4 +56,5 @@ Feature: Manage plearning plan templates
And I click on "Delete" of edit menu in the "Science template Year-4" row
And "Confirm" "dialogue" should be visible
When I click on "Delete" "button"
And I wait until the page is ready
Then I should not see "Science template Year-4"
......@@ -67,5 +67,6 @@ Feature: Manage competencies linked to evidence of prior learning
And I should see "Test-Comp1"
And I should see "Test-Comp2"
When I click on "Delete" "link" in the "Test-Comp1" "table_row"
And I wait until the page is ready
Then I should not see "Test-Comp1"
And I should see "Test-Comp2"
......@@ -57,6 +57,7 @@ Feature: Manage evidence of prior learning
And I click on "Delete" of edit menu in the "Evidence-4" row
And "Confirm" "dialogue" should be visible
When I click on "Delete" "button"
And I wait until the page is ready
Then I should not see "Evidence-4"
Scenario: List evidences of prior learning
......
......@@ -23,6 +23,7 @@ Feature: Basic recycle bin functionality
| categorybinexpiry | 1209600 | tool_recyclebin |
| autohide | 0 | tool_recyclebin |
@javascript
Scenario: Restore a deleted assignment
Given I log in as "teacher1"
And I follow "Course 1"
......@@ -31,6 +32,7 @@ Feature: Basic recycle bin functionality
| Assignment name | Test assign |
| Description | Test |
And I delete "Test assign" activity
And I run all adhoc tasks
When I navigate to "Recycle bin" node in "Course administration"
Then I should see "Test assign"
And I should see "Contents will be permanently deleted after 7 days"
......
......@@ -55,5 +55,5 @@ Feature: availability_completion
Then I should not see "Page 2" in the "region-main" "region"
# Mark page 1 complete
When I click on ".togglecompletion input[type=image]" "css_element"
When I click on ".togglecompletion .icon" "css_element"
Then I should see "Page 2" in the "region-main" "region"
......@@ -76,7 +76,7 @@ Feature: availability_profile
# Set field value for user.
And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
And I click on "a[title=Edit]" "css_element" in the "s@example.com" "table_row"
And I click on ".icon[title=Edit]" "css_element" in the "s@example.com" "table_row"
And I expand all fieldsets
And I set the field "Super field" to "Bananaman"
And I click on "Update profile" "button"
......
......@@ -23,6 +23,7 @@ Feature: Backup Moodle courses
And I should see "URL of backup"
And I should see "Anonymize user information"
@javascript
Scenario: Backup a course with default options
When I backup "Course 1" course using this options:
| Initial | Include calendar events | 0 |
......@@ -34,7 +35,7 @@ Feature: Backup Moodle courses
And I should not see "Section 3"
And I press "Continue"
And I click on "Continue" "button" in the ".bcs-current-course" "css_element"
And "//div[contains(concat(' ', normalize-space(@class), ' '), ' fitem ')][contains(., 'Include calendar events')]/descendant::img" "xpath_element" should exist
And "No" "icon" should exist in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' fitem ')][contains(., 'Include calendar events')]" "xpath_element"
And "Include course logs" "checkbox" should exist
And I press "Next"
......
......@@ -158,7 +158,7 @@ Feature: Award badges
Then I should not see "badges"
And I am on homepage
And I follow "Course 1"
And I press "Mark as complete: Test assignment name"
And I click on "Not completed: Test assignment name. Select to mark as complete." "icon"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
Then I should see "Course Badge"
......@@ -213,7 +213,7 @@ Feature: Award badges
Then I should not see "badges"
And I am on homepage
And I follow "Course 1"
And I press "Mark as complete: Test assignment name"
And I click on "Not completed: Test assignment name. Select to mark as complete." "icon"
And I log out
# Completion cron won't mark the whole course completed unless the
# individual criteria was marked completed more than a second ago. So
......
......@@ -99,9 +99,9 @@ class behat_block_comments extends behat_base {
$commentnode = $this->find('xpath', $commentxpath, $exception);
// Click on delete icon.
$deleteexception = new ExpectationException('"' . $comment . '" comment can not be deleted', $this->getSession());
$deleteicon = $this->find('css', '.comment-delete a img', $deleteexception, $commentnode);
$deleteicon->click();
$this->execute('behat_general::i_click_on_in_the',
array(get_string('deletecomment'), "icon", $this->escape($commentxpath), "xpath_element")
);
// Wait for the animation to finish, in theory is just 1 sec, adding 4 just in case.
$this->getSession()->wait(4 * 1000, false);
......
......@@ -200,7 +200,7 @@ M.core_comment = {
list[i].content = '<div class="comment-delete">' +
'<a href="#" role="button" id ="comment-delete-' + this.client_id + '-' + list[i].id + '"' +
' title="' + deleteStr + '">' +
'<span data-replace-icon="t/delete" data-component="core" data-title=""/>' +
'<span></span>' +
'</a>' +
'</div>' + list[i].content;
}
......@@ -334,6 +334,13 @@ M.core_comment = {
// 13 and 32 are the keycodes for space and enter.
}
);
require(['core/templates', 'core/notification'], function(Templates, Notification) {
Templates.renderPix('t/delete', 'core', M.util.get_string('deletecomment', 'moodle')).then(function(html) {
Y.all('div.comment-delete a').set('innerHTML', html);
}).catch(Notification.exception);
});
},
register_pagination: function() {
var scope = this;
......
......@@ -49,13 +49,12 @@ class behat_completion extends behat_base {
public function user_has_completed_activity($userfullname, $activityname) {
// Will throw an exception if the element can not be hovered.
$titleliteral = behat_context_helper::escape($userfullname . ", " . $activityname . ": Completed");
$xpath = "//table[@id='completion-progress']" .
"/descendant::img[contains(@title, $titleliteral)]";
$titleliteral = $userfullname . ", " . $activityname . ": Completed";
$xpath = "//table[@id='completion-progress']";
$this->execute("behat_completion::go_to_the_current_course_activity_completion_report");
$this->execute("behat_general::should_exist",
array($this->escape($xpath), "xpath_element")
$this->execute("behat_general::should_exist_in_the",
array($titleliteral, "icon", $xpath, "xpath_element")
);
}
......@@ -69,12 +68,13 @@ class behat_completion extends behat_base {
public function user_has_not_completed_activity($userfullname, $activityname) {
// Will throw an exception if the element can not be hovered.
$titleliteral = behat_context_helper::escape($userfullname . ", " . $activityname . ": Not completed");
$xpath = "//table[@id='completion-progress']" .
"/descendant::img[contains(@title, $titleliteral)]";
$titleliteral = $userfullname . ", " . $activityname . ": Not completed";
$xpath = "//table[@id='completion-progress']";
$this->execute("behat_completion::go_to_the_current_course_activity_completion_report");
$this->execute("behat_general::should_exist", array($this->escape($xpath), "xpath_element"));
$this->execute("behat_general::should_exist_in_the",
array($titleliteral, "icon", $xpath, "xpath_element")
);
}
/**
......@@ -121,16 +121,14 @@ class behat_completion extends behat_base {
public function activity_marked_as_complete($activityname, $activitytype, $completiontype) {
if ($completiontype == "manual") {
$imgalttext = get_string("completion-alt-manual-y", 'core_completion', $activityname);
$xpathtocheck = "//input[@type='image'][contains(@alt, '$imgalttext')]";
} else {
$imgalttext = get_string("completion-alt-auto-y", 'core_completion', $activityname);
$xpathtocheck = "//img[contains(@alt, '$imgalttext')]";
}
$activityxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]";
$activityxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]";
$this->execute("behat_general::should_exist_in_the",
array($xpathtocheck, "xpath_element", $activityxpath, "xpath_element")
array($imgalttext, "icon", $activityxpath, "xpath_element")
);
}
......@@ -143,16 +141,14 @@ class behat_completion extends behat_base {
public function activity_marked_as_not_complete($activityname, $activitytype, $completiontype) {
if ($completiontype == "manual") {
$imgalttext = get_string("completion-alt-manual-n", 'core_completion', $activityname);
$xpathtocheck = "//input[@type='image'][contains(@alt, '$imgalttext')]";
} else {
$imgalttext = get_string("completion-alt-auto-n", 'core_completion', $activityname);
$xpathtocheck = "//img[contains(@alt, '$imgalttext')]";
}
$activityxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]";
$activityxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]";
$this->execute("behat_general::should_exist_in_the",
array($xpathtocheck, "xpath_element", $activityxpath, "xpath_element")
array($imgalttext, "icon", $activityxpath, "xpath_element")
);
}
}
......@@ -33,7 +33,7 @@ Feature: Allow students to manually mark an activity as complete
And I log in as "student1"
And I am on site homepage
And I follow "Course 1"
When I press "Mark as complete: Test forum name"
When I click on "Not completed: Test forum name. Select to mark as complete." "icon"
Then the "Test forum name" "forum" activity with "manual" completion should be marked as complete
And I log out
And I log in as "teacher1"
......
......@@ -48,7 +48,7 @@ Feature: Restrict sections availability through completion or grade conditions
And I follow "Course 1"
Then I should see "Not available unless: The activity Test label is marked complete"
And I should not see "Test page name"
And I press "Not completed: Test label. Select to mark as complete."
And I click on "Not completed: Test label. Select to mark as complete." "icon"
And I should see "Test page name"
And I should not see "Not available unless: The activity Test label is marked complete"
......
......@@ -20,22 +20,24 @@ M.core_completion.init = function(Y) {
var current = args.state.get('value');
var modulename = args.modulename.get('value'),
altstr,
titlestr;
iconkey;
if (current == 1) {
altstr = M.util.get_string('completion-alt-manual-y', 'completion', modulename);
titlestr = M.util.get_string('completion-title-manual-y', 'completion', modulename);
iconkey = 'i/completion-manual-y';
args.state.set('value', 0);
args.image.set('src', M.util.image_url('i/completion-manual-y', 'moodle'));
args.image.set('alt', altstr);
args.image.set('title', titlestr);
} else {
altstr = M.util.get_string('completion-alt-manual-n', 'completion', modulename);
titlestr = M.util.get_string('completion-title-manual-n', 'completion', modulename);
iconkey = 'i/completion-manual-n';
args.state.set('value', 1);
args.image.set('src', M.util.image_url('i/completion-manual-n', 'moodle'));
args.image.set('alt', altstr);
args.image.set('title', titlestr);
}
require(['core/templates', 'core/notification'], function(Templates, Notification) {
Templates.renderPix(iconkey, 'core', altstr).then(function(html) {
Templates.replaceNode(args.image.getDOMNode(), html, '');
}).catch(Notification.exception);
});
}
args.ajax.remove();
......@@ -70,10 +72,8 @@ M.core_completion.init = function(Y) {
modulename = Y.one(inputs[i]);
break;
}
if (inputs[i].type == 'image') {
image = Y.one(inputs[i]);
}
}
image = form.one('button .icon');
// start spinning the ajax indicator
var ajax = Y.Node.create('<div class="ajaxworking" />');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment