bot settings: Clear typeahead when renaming a bot

Fixes #7534
When bot is renamed, the old name persists in mention typehead.
This commit clears the typeahead, whenever bot details are modified.
This commit is contained in:
Aastha Gupta 2017-12-11 16:23:25 +05:30 committed by showell
parent 20f3b0f599
commit 1df3e04cd7
3 changed files with 31 additions and 0 deletions

View File

@ -399,6 +399,32 @@ _.each(matches, function (person) {
assert(rendered);
}());
(function test_clear_rendered_persons() {
var rendered = false;
global.templates.render = function (template_name, args) {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, matches[5].full_name);
assert.equal(args.secondary, matches[5].email);
rendered = true;
return 'typeahead-item-stub';
};
assert.equal(th.render_person(matches[5]), 'typeahead-item-stub');
assert(rendered);
// Bot once rendered won't be rendered again until clear_rendered_person
// function is called. clear_rendered_person is used to clear rendered
// data once bot name is modified.
rendered = false;
assert.equal(th.render_person(matches[5]), 'typeahead-item-stub');
assert.equal(rendered, false);
// Here rendered will be true as it is being rendered again.
th.clear_rendered_persons();
assert.equal(th.render_person(matches[5]), 'typeahead-item-stub');
assert(rendered);
}());
(function test_render_stream() {
// Test render_stream with short description
var rendered = false;

View File

@ -306,6 +306,7 @@ exports.set_up = function () {
edit_button.show();
show_row_again();
avatar_widget.clear();
typeahead_helper.clear_rendered_persons();
bot_info.find('.name').text(full_name);
if (data.avatar_url) {

View File

@ -94,6 +94,10 @@ exports.render_person = function (person) {
return html;
};
exports.clear_rendered_persons = function () {
rendered.persons.clear();
};
exports.render_user_group = function (user_group) {
var html = rendered.user_groups.get(user_group.id);
if (html === undefined) {