Skip to content

Commit

Permalink
MDL-51287 Profile: Should notify users that changes are saved
Browse files Browse the repository at this point in the history
  • Loading branch information
sangnguyen committed Feb 4, 2021
1 parent 9dabd07 commit 1d50e83
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion user/calendar.php
Expand Up @@ -85,7 +85,7 @@
$USER->calendartype = $calendartype;
}

redirect($redirect);
redirect($redirect, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

// Display page header.
Expand Down
2 changes: 1 addition & 1 deletion user/course.php
Expand Up @@ -44,7 +44,7 @@
useredit_update_user_preference(['id' => $user->id,
'preference_usemodchooser' => $data->enableactivitychooser]);

redirect($redirect);
redirect($redirect, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

// Display page header.
Expand Down
2 changes: 1 addition & 1 deletion user/edit.php
Expand Up @@ -299,7 +299,7 @@
}

if (!$emailchanged || !$CFG->emailchangeconfirmation) {
redirect($returnurl);
redirect($returnurl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}
}

Expand Down
4 changes: 2 additions & 2 deletions user/editadvanced.php
Expand Up @@ -306,11 +306,11 @@
// Somebody double clicked when editing admin user during install.
redirect("$CFG->wwwroot/$CFG->admin/");
} else {
redirect($returnurl);
redirect($returnurl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}
} else {
\core\session\manager::gc(); // Remove stale sessions.
redirect("$CFG->wwwroot/$CFG->admin/user.php");
redirect("$CFG->wwwroot/$CFG->admin/user.php", get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}
// Never reached..
}
Expand Down
2 changes: 1 addition & 1 deletion user/editor.php
Expand Up @@ -52,7 +52,7 @@
// Trigger event.
\core\event\user_updated::create_from_userid($user->id)->trigger();

redirect($redirect);
redirect($redirect, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

// Display page header.
Expand Down
2 changes: 1 addition & 1 deletion user/forum.php
Expand Up @@ -72,7 +72,7 @@
}
}

redirect($redirect);
redirect($redirect, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

// Display page header.
Expand Down
2 changes: 1 addition & 1 deletion user/language.php
Expand Up @@ -60,7 +60,7 @@
$USER->lang = $lang;
}

redirect($redirect);
redirect($redirect, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

// Display page header.
Expand Down
58 changes: 58 additions & 0 deletions user/tests/behat/edit_profile_notification.feature
@@ -0,0 +1,58 @@
@core @core_user
Feature: Notification shown when user edit profile or preferences
In order to show notification
As a user
I press update profile button after make some changes in edit profile page

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| unicorn | Unicorn | 1 | unicorn@example.com |
And the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| unicorn | C1 | student |

@javascript
Scenario: Change own profile and has notification shown
Given I log in as "unicorn"
And I follow "Profile" in the user menu
When I click on "Edit profile" "link" in the "region-main" "region"
And I should see "Unicorn"
And I should see "1"
Then I set the field "Surname" to "Lil"
And I click on "Update profile" "button"
And I should see "Changes saved"
And I click on ".close" "css_element" in the "div.alert-block" "css_element"
And I should not see "Changes saved"
And I follow "Preferences" in the user menu
And I follow "Preferred language"
And I click on "Save changes" "button"
And I should see "Changes saved"
And I follow "Forum preferences"
And I set the field "Use experimental nested discussion view" to "Yes"
And I click on "Save changes" "button"
And I should see "Changes saved"

@javascript
Scenario: Do not show notification when cancel profile change
Given I log in as "unicorn"
And I follow "Profile" in the user menu
When I click on "Edit profile" "link" in the "region-main" "region"
And I should see "Unicorn"
And I should see "1"
Then I set the field "Surname" to "Lil"
And I click on "Cancel" "button"
And I should not see "Changes saved"

@javascript
Scenario: Show notification after admin edited profile of another user
Given I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
When I click on "Edit" "link" in the "Unicorn 1" "table_row"
And I expand all fieldsets
Then I set the field "Surname" to "Lil"
And I click on "Update profile" "button"
And I should see "Changes saved"

0 comments on commit 1d50e83

Please sign in to comment.