Commit 3a5c27c3 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1590632: Behat test for adding / deleting a profile icon"

parents bcfc3766 05e80bb9
......@@ -284,7 +284,8 @@ $string['uploadprofileicon'] = 'Upload profile picture';
$string['uploadedprofileicon'] = 'Uploaded profile picture';
$string['profileiconsiconsizenotice'] = 'You may upload up to <strong>five</strong> profile pictures here and choose one to be displayed as your default picture at any one time. Your pictures must be between 16x16 and %sx%s pixels in size.';
$string['setdefault'] = 'Set default';
$string['markfordeletion'] = 'Mark for deletion';
$string['setdefaultfor'] = 'Set default for "%s"';
$string['markfordeletionspecific'] = 'Mark "%s" for deletion';
$string['Title'] = 'Title';
$string['imagetitle'] = 'Image title';
$string['standardavatartitle'] = 'Standard or external avatar';
......
......@@ -25,6 +25,13 @@ $result = get_records_sql_array('SELECT a.id, a.title, a.note, (u.profileicon =
GROUP BY a.id, a.title, a.note, isdefault
ORDER BY a.id', array($USER->get('id')));
if ($result) {
foreach ($result as $r) {
$r->default_str = get_string('setdefaultfor', 'artefact.file', ($r->title ? $r->title : $r->note));
$r->delete_str = get_string('markfordeletionspecific', 'artefact.file', ($r->title ? $r->title : $r->note));
}
}
$lastrow = array(
'id' => 0,
'isdefault' => 't',
......
......@@ -76,8 +76,7 @@ $profileiconattachedtoportfolioitems = json_encode(get_string('profileiconattach
$profileiconappearsinviews = json_encode(get_string('profileiconappearsinviews', 'artefact.file'));
$profileiconappearsinskins = json_encode(get_string('profileiconappearsinskins', 'artefact.file'));
$confirmdeletefile = json_encode(get_string('confirmdeletefile', 'artefact.file'));
$setdefault = json_encode(get_string('setdefault', 'artefact.file'));
$markfordeletion = json_encode(get_string('markfordeletion', 'artefact.file'));
$IJS = <<<EOF
formchangemanager.add('settings');
......@@ -108,7 +107,7 @@ var table = new TableRenderer(
if (rowdata['isdefault'] == 't' || rowdata['isdefault'] == 1) {
options.checked = 'checked';
}
var label = LABEL({'class': 'accessible-hidden sr-only', 'for': 'setdefault_' + rowdata.id}, {$setdefault});
var label = LABEL({'class': 'accessible-hidden sr-only', 'for': 'setdefault_' + rowdata.id}, rowdata.default_str);
return TD({'class': 'defaultcell'}, INPUT(options), label);
},
function(rowdata) {
......@@ -122,7 +121,7 @@ var table = new TableRenderer(
if (!rowdata.id) {
options.disabled = 'disabled';
}
var label = LABEL({'class': 'accessible-hidden sr-only', 'for': 'markdelete_' + rowdata.id}, {$markfordeletion});
var label = LABEL({'class': 'accessible-hidden sr-only', 'for': 'markdelete_' + rowdata.id}, rowdata.delete_str);
return TD({'class': 'deletecell'}, INPUT(options), label);
}
]
......
......@@ -589,4 +589,26 @@ class BehatForms extends BehatBase {
$deletenode->press();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
/**
* Tick the radio button
*
* @When /^I select the radio "(?P<fieldlabel>(?:[^"]|\\")*)"$/
* @param string $fieldlabel the label of the field
* @throws ElementNotFoundException
*/
public function i_check_radio($fieldlabel) {
$textliteral = $this->escaper->escapeLiteral($fieldlabel);
$page = $this->getSession()->getPage();
foreach ($page->findAll('css', 'label') as $label) {
if ($textliteral === "'" . $label->getText() . "'" ||
$textliteral === $this->escaper->escapeLiteral(preg_replace('/"/', '\"', $label->getHtml()))) {
$radioButton = $page->find('css', '#' . $label->getAttribute('for'));
$radioButton->click();
return;
}
}
throw new ElementNotFoundException($this->getSession(), 'form field', 'id|name|label|value', $textliteral);
}
}
......@@ -1020,23 +1020,6 @@ class BehatGeneral extends BehatBase {
}
}
/**
* Tick the radio button
* https://github.com/Kunstmaan/KunstmaanBehatBundle/blob/master/Features/Context/SubContext/RadioButtonSubContext.php
*
 * @When /^I select the radio "(?P<text>(?:[^"]|\\")*)"$/
* @param string $labeltext The label
*/
public function i_check_radio($labeltext) {
$radioButton = $this->getSession()->getPage()->findField($labeltext);
if (null === $radioButton) {
throw new ElementNotFoundException($this->getSession(), 'form field', 'id|name|label|value', $labeltext);
}
$this->getSession()->getDriver()->click($radioButton->getXPath());
}
/**
* Display the editting page
*
......
@javascript @core @core_account @core_content
Feature: Editing a profile page
In order to edit a profile page
In order to edit a profile
As an admin I need to go to Content
So I can edit the admin profile page
So I can edit the admin profile and picture
Scenario: Editing admin profile page (Bug: 1426983)
# Log in as users
# Log in
Given I log in as "admin" with password "Kupuhipa1"
# Updating Profile
When I follow "Content"
......@@ -73,3 +73,23 @@ Scenario: Editing admin profile page (Bug: 1426983)
# Verifying changes has been made navigating to dashboard page to checked
Then I follow "Dashboard"
And I should see "Admin User"
Scenario: Editing admin profile picture (Bug: 1578000)
# Log in
Given I log in as "admin" with password "Kupuhipa1"
# Add new profile picture
When I choose "Profile pictures" in "Content"
And I attach the file "Image2.png" to "Profile picture"
And I fill in the following:
| Image title | New avatar |
And I press "Upload"
Then I should see "Your profile picture has been uploaded to your 'images' folder."
# Update profile picture
And I select the radio "Set default for \"New avatar\""
And I press "Set default"
Then I should see "Default profile picture set successfully"
# Delete the new profile picture
And I fill in the following:
| Mark "New avatar" for deletion | 1 |
And I press "Delete"
Then I should see "Profile picture deleted"
Markdown is supported
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