Skip to content

Commit

Permalink
MDL-40759 icons: Behat fixes for font-awesome
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Mar 17, 2017
1 parent ad056aa commit 8857c71
Show file tree
Hide file tree
Showing 78 changed files with 238 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/filetypes/classes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static function get_icons_from_path($path) {
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;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/filetypes/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function edit_table(array $filetypes, array $deleted, $restricted) {
$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',
Expand Down
8 changes: 3 additions & 5 deletions admin/tool/filetypes/tests/behat/add_filetypes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
2 changes: 2 additions & 0 deletions admin/tool/lp/tests/behat/plan_crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
1 change: 1 addition & 0 deletions admin/tool/lp/tests/behat/plan_workflow.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions admin/tool/lp/tests/behat/template_crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions admin/tool/lp/tests/behat/user_evidence_comp_link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions admin/tool/lp/tests/behat/user_evidence_crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/recyclebin/tests/behat/basic_functionality.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]" "table_row"
And I click on ".icon[title=Edit]" "css_element" in the "[email protected]" "table_row"
And I expand all fieldsets
And I set the field "Super field" to "Bananaman"
And I click on "Update profile" "button"
Expand Down
3 changes: 2 additions & 1 deletion backup/util/ui/tests/behat/backup_courses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions badges/tests/behat/award_badge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions blocks/comments/tests/behat/behat_block_comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public function i_delete_comment_from_comments_block($comment) {
$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);
Expand Down
9 changes: 8 additions & 1 deletion comment/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 11 additions & 15 deletions completion/tests/behat/behat_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
}

Expand All @@ -69,12 +68,13 @@ public function user_has_completed_activity($userfullname, $activityname) {
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")
);
}

/**
Expand Down Expand Up @@ -121,16 +121,14 @@ public function completion_is_toggled_in_course($completionstatus) {
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")
);

}
Expand All @@ -143,16 +141,14 @@ public function activity_marked_as_complete($activityname, $activitytype, $compl
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")
);
}
}
2 changes: 1 addition & 1 deletion completion/tests/behat/enable_manual_complete_mark.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
24 changes: 12 additions & 12 deletions course/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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" />');
Expand Down
6 changes: 3 additions & 3 deletions course/format/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ protected function section_edit_control_menu($controls, $course, $section) {
$icon = empty($value['icon']) ? '' : $value['icon'];
$name = empty($value['name']) ? '' : $value['name'];
$attr = empty($value['attr']) ? array() : $value['attr'];
$class = empty($item['pixattr']['class']) ? '' : $item['pixattr']['class'];
$alt = empty($item['pixattr']['alt']) ? '' : $item['pixattr']['alt'];
$class = empty($value['pixattr']['class']) ? '' : $value['pixattr']['class'];
$alt = empty($value['pixattr']['alt']) ? '' : $value['pixattr']['alt'];
$al = new action_menu_link_secondary(
new moodle_url($url),
new pix_icon($icon, $name, null, array('class' => "smallicon " . $class, 'alt' => $alt)),
new pix_icon($icon, $alt, null, array('class' => "smallicon " . $class)),
$name,
$attr
);
Expand Down
Loading

0 comments on commit 8857c71

Please sign in to comment.