2015-10-15 22:34:30 +02:00
|
|
|
set_global('page_params', {realm_emoji: {
|
2016-12-28 05:07:10 +01:00
|
|
|
burrito: {display_url: '/static/generated/emoji/images/emoji/burrito.png',
|
|
|
|
source_url: '/static/generated/emoji/images/emoji/burrito.png'},
|
2015-10-15 22:34:30 +02:00
|
|
|
}});
|
|
|
|
|
2013-11-27 22:05:33 +01:00
|
|
|
add_dependencies({
|
|
|
|
Handlebars: 'handlebars',
|
2016-05-13 12:44:03 +02:00
|
|
|
templates: 'js/templates',
|
2017-01-26 00:41:53 +01:00
|
|
|
emoji_codes: 'generated/emoji/emoji_codes.js',
|
2015-10-15 22:34:30 +02:00
|
|
|
emoji: 'js/emoji',
|
2016-12-03 23:17:57 +01:00
|
|
|
i18n: 'i18next',
|
2016-05-13 12:44:03 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
var i18n = global.i18n;
|
|
|
|
i18n.init({
|
|
|
|
nsSeparator: false,
|
|
|
|
keySeparator: false,
|
|
|
|
interpolation: {
|
|
|
|
prefix: "__",
|
2016-12-03 23:17:57 +01:00
|
|
|
suffix: "__",
|
2016-05-13 12:44:03 +02:00
|
|
|
},
|
2016-12-03 23:17:57 +01:00
|
|
|
lng: 'en',
|
2013-11-27 22:05:33 +01:00
|
|
|
});
|
|
|
|
|
2016-08-24 21:49:53 +02:00
|
|
|
var jsdom = require("jsdom");
|
|
|
|
var window = jsdom.jsdom().defaultView;
|
|
|
|
global.$ = require('jquery')(window);
|
2013-12-11 18:53:05 +01:00
|
|
|
var _ = global._;
|
2013-11-27 22:05:33 +01:00
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
// When writing these tests, the following command might be helpful:
|
|
|
|
// ./tools/get-handlebar-vars static/templates/*.handlebars
|
|
|
|
|
|
|
|
function render(template_name, args) {
|
2016-11-04 16:34:27 +01:00
|
|
|
return global.render_template(template_name, args);
|
2013-12-11 18:53:05 +01:00
|
|
|
}
|
|
|
|
|
2016-12-05 07:02:18 +01:00
|
|
|
(function test_finding_partials() {
|
2016-11-04 16:07:00 +01:00
|
|
|
var fns = global.find_included_partials('settings_tab');
|
|
|
|
assert.deepEqual(fns, [
|
|
|
|
'account-settings',
|
|
|
|
'display-settings',
|
|
|
|
'notification-settings',
|
|
|
|
'bot-settings',
|
|
|
|
'alert-word-settings',
|
2016-12-28 14:46:42 +01:00
|
|
|
'attachments-settings',
|
2016-11-26 04:39:53 +01:00
|
|
|
'muted-topics-settings',
|
2016-12-03 23:17:57 +01:00
|
|
|
'ui-settings',
|
2016-11-04 16:07:00 +01:00
|
|
|
]);
|
|
|
|
}());
|
|
|
|
|
2016-12-05 07:02:18 +01:00
|
|
|
(function test_handlebars_bug() {
|
2014-01-10 16:36:01 +01:00
|
|
|
// There was a bug in 1.0.9 where identically structured
|
|
|
|
// blocks get confused, so when foo is false, it still
|
|
|
|
// renders the foo-is-true block.
|
|
|
|
var s = '';
|
|
|
|
s += '{{#if foo}}';
|
|
|
|
s += '{{#if bar}}';
|
|
|
|
s += 'a';
|
|
|
|
s += '{{else}}';
|
|
|
|
s += 'b';
|
|
|
|
s += '{{/if}}';
|
|
|
|
s += '{{else}}';
|
|
|
|
s += '{{#if bar}}';
|
|
|
|
s += 'c';
|
|
|
|
s += '{{else}}';
|
|
|
|
s += 'd';
|
|
|
|
s += '{{/if}}';
|
|
|
|
s += '{{/if}}';
|
|
|
|
var template = global.Handlebars.compile(s);
|
|
|
|
var output = template({});
|
|
|
|
|
|
|
|
assert.equal(output, 'd'); // the buggy version would return 'b'
|
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function actions_popover_content() {
|
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
message: {
|
2013-12-11 18:53:05 +01:00
|
|
|
is_stream: true,
|
|
|
|
id: "99",
|
|
|
|
stream: "devel",
|
|
|
|
subject: "testing",
|
2016-12-03 23:17:57 +01:00
|
|
|
sender_full_name: "King Lear",
|
2013-12-11 18:53:05 +01:00
|
|
|
},
|
2016-12-03 03:08:47 +01:00
|
|
|
can_edit_message: true,
|
|
|
|
can_mute_topic: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
narrowed: true,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<div style="height: 250px">';
|
|
|
|
html += render('actions_popover_content', args);
|
|
|
|
html += "</div>";
|
2014-02-18 16:57:28 +01:00
|
|
|
var link = $(html).find("a.respond_button");
|
2017-02-02 13:08:17 +01:00
|
|
|
assert.equal(link.text().trim(), 'Quote and reply');
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("actions_popover_content", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
2017-03-31 23:38:16 +02:00
|
|
|
(function admin_realm_domains_list() {
|
2016-12-26 19:19:02 +01:00
|
|
|
var html = "<table>";
|
|
|
|
var args = {
|
2017-03-31 22:40:48 +02:00
|
|
|
realm_domain: {
|
2016-12-26 19:19:02 +01:00
|
|
|
domain: 'zulip.org',
|
2017-01-21 08:19:03 +01:00
|
|
|
allow_subdomains: true,
|
2016-12-26 19:19:02 +01:00
|
|
|
},
|
|
|
|
};
|
2017-03-31 23:38:16 +02:00
|
|
|
html += render("admin-realm-domains-list", args);
|
2016-12-26 19:19:02 +01:00
|
|
|
html += "</table>";
|
|
|
|
|
|
|
|
var button = $(html).find('.btn');
|
|
|
|
var domain = $(html).find('.domain');
|
2017-01-21 08:19:03 +01:00
|
|
|
var row = button.closest('tr');
|
|
|
|
var subdomains_checkbox = row.find('.allow-subdomains');
|
2016-12-26 19:19:02 +01:00
|
|
|
|
2017-01-18 01:24:15 +01:00
|
|
|
assert.equal(button.text().trim(), "Remove");
|
2017-03-31 22:40:48 +02:00
|
|
|
assert(button.hasClass("delete_realm_domain"));
|
2016-12-26 19:19:02 +01:00
|
|
|
assert.equal(domain.text(), "zulip.org");
|
|
|
|
|
2017-01-21 08:19:03 +01:00
|
|
|
assert.equal(subdomains_checkbox.prop('checked'), true);
|
|
|
|
|
2017-03-31 23:38:16 +02:00
|
|
|
global.write_handlebars_output("admin-realm-domains-list", html);
|
2016-12-26 19:19:02 +01:00
|
|
|
}());
|
|
|
|
|
2016-05-20 22:08:42 +02:00
|
|
|
(function admin_default_streams_list() {
|
|
|
|
var html = '<table>';
|
|
|
|
var streams = ['devel', 'trac', 'zulip'];
|
2017-04-14 23:08:22 +02:00
|
|
|
|
|
|
|
// When the logged in user is admin
|
2016-05-20 22:08:42 +02:00
|
|
|
_.each(streams, function (stream) {
|
2017-04-14 23:08:22 +02:00
|
|
|
var args = {stream: {name: stream, invite_only: false},
|
|
|
|
can_modify: true,
|
|
|
|
};
|
2016-05-20 22:08:42 +02:00
|
|
|
html += render('admin_default_streams_list', args);
|
|
|
|
});
|
|
|
|
html += "</table>";
|
|
|
|
var span = $(html).find(".default_stream_name:first");
|
|
|
|
assert.equal(span.text(), "devel");
|
2017-04-14 23:08:22 +02:00
|
|
|
|
|
|
|
// When the logged in user is not admin
|
|
|
|
html = '<table>';
|
|
|
|
_.each(streams, function (stream) {
|
|
|
|
var args = {stream: {name: stream, invite_only: false},
|
|
|
|
can_modify: false,
|
|
|
|
};
|
|
|
|
html += render('admin_default_streams_list', args);
|
|
|
|
});
|
|
|
|
html += "</table>";
|
|
|
|
span = $(html).find(".default_stream_name:first");
|
|
|
|
assert.equal(span.text(), "devel");
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("admin_default_streams_list", html);
|
2016-05-20 22:08:42 +02:00
|
|
|
}());
|
|
|
|
|
2016-07-30 04:52:29 +02:00
|
|
|
(function admin_emoji_list() {
|
|
|
|
var args = {
|
|
|
|
emoji: {
|
2016-12-03 03:08:47 +01:00
|
|
|
name: "MouseFace",
|
|
|
|
display_url: "http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png",
|
2016-12-03 23:17:57 +01:00
|
|
|
source_url: "http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png",
|
|
|
|
},
|
2016-07-30 04:52:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<tbody id="admin_emoji_table">';
|
|
|
|
html += render('admin_emoji_list', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
|
|
|
|
global.write_handlebars_output('admin_emoji_list', html);
|
|
|
|
|
|
|
|
var emoji_name = $(html).find('tr.emoji_row:first span.emoji_name');
|
|
|
|
var emoji_url = $(html).find('tr.emoji_row:first span.emoji_image img');
|
|
|
|
|
|
|
|
assert.equal(emoji_name.text(), 'MouseFace');
|
|
|
|
assert.equal(emoji_url.attr('src'), 'http://emojipedia-us.s3.amazonaws.com/cache/46/7f/467fe69069c408e07517621f263ea9b5.png');
|
|
|
|
}());
|
|
|
|
|
2016-02-13 19:17:15 +01:00
|
|
|
(function admin_filter_list() {
|
2017-04-14 23:56:33 +02:00
|
|
|
|
|
|
|
// When the logged in user is admin
|
2016-02-13 19:17:15 +01:00
|
|
|
var args = {
|
|
|
|
filter: {
|
2016-12-03 03:08:47 +01:00
|
|
|
pattern: "#(?P<id>[0-9]+)",
|
2016-12-03 23:17:57 +01:00
|
|
|
url_format_string: "https://trac.example.com/ticket/%(id)s",
|
|
|
|
},
|
2017-04-14 23:56:33 +02:00
|
|
|
can_modify: true,
|
2016-02-13 19:17:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<tbody id="admin_filters_table">';
|
|
|
|
html += render('admin_filter_list', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
|
|
|
|
var filter_pattern = $(html).find('tr.filter_row:first span.filter_pattern');
|
|
|
|
var filter_format = $(html).find('tr.filter_row:first span.filter_url_format_string');
|
|
|
|
|
|
|
|
assert.equal(filter_pattern.text(), '#(?P<id>[0-9]+)');
|
|
|
|
assert.equal(filter_format.text(), 'https://trac.example.com/ticket/%(id)s');
|
2017-04-14 23:56:33 +02:00
|
|
|
|
|
|
|
// When the logged in user is not admin
|
|
|
|
args = {
|
|
|
|
filter: {
|
|
|
|
pattern: "#(?P<id>[0-9]+)",
|
|
|
|
url_format_string: "https://trac.example.com/ticket/%(id)s",
|
|
|
|
},
|
|
|
|
can_modify: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
html = '';
|
|
|
|
html += '<tbody id="admin_filters_table">';
|
|
|
|
html += render('admin_filter_list', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
|
|
|
|
global.write_test_output('admin_filter_list', html);
|
|
|
|
|
|
|
|
filter_pattern = $(html).find('tr.filter_row:first span.filter_pattern');
|
|
|
|
filter_format = $(html).find('tr.filter_row:first span.filter_url_format_string');
|
|
|
|
|
|
|
|
assert.equal(filter_pattern.text(), '#(?P<id>[0-9]+)');
|
|
|
|
assert.equal(filter_format.text(), 'https://trac.example.com/ticket/%(id)s');
|
2016-02-13 19:17:15 +01:00
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function admin_streams_list() {
|
|
|
|
var html = '<table>';
|
|
|
|
var streams = ['devel', 'trac', 'zulip'];
|
|
|
|
_.each(streams, function (stream) {
|
2014-01-24 19:47:18 +01:00
|
|
|
var args = {stream: {name: stream, invite_only: false}};
|
2013-12-11 18:53:05 +01:00
|
|
|
html += render('admin_streams_list', args);
|
|
|
|
});
|
|
|
|
html += "</table>";
|
|
|
|
var span = $(html).find(".stream_name:first");
|
|
|
|
assert.equal(span.text(), "devel");
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("admin_streams_list", html);
|
2016-07-30 06:06:51 +02:00
|
|
|
}());
|
|
|
|
|
|
|
|
(function admin_tab() {
|
|
|
|
var args = {
|
2016-12-03 23:17:57 +01:00
|
|
|
realm_name: 'Zulip',
|
2016-07-30 06:06:51 +02:00
|
|
|
};
|
|
|
|
var html = render('admin_tab', args);
|
|
|
|
var admin_features = ["admin_users_table", "admin_bots_table",
|
|
|
|
"admin_streams_table", "admin_deactivated_users_table"];
|
|
|
|
_.each(admin_features, function (admin_feature) {
|
|
|
|
assert.notEqual($(html).find("#" + admin_feature).length, 0);
|
|
|
|
});
|
|
|
|
assert.equal($(html).find("input.admin-realm-name").val(), 'Zulip');
|
|
|
|
global.write_handlebars_output("admin_tab", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
|
|
|
(function admin_user_list() {
|
|
|
|
var html = '<table>';
|
|
|
|
var users = ['alice', 'bob', 'carl'];
|
2017-04-10 23:25:11 +02:00
|
|
|
|
|
|
|
// When the logged in user is admin
|
2013-12-11 18:53:05 +01:00
|
|
|
_.each(users, function (user) {
|
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
user: {
|
|
|
|
is_active: true,
|
|
|
|
is_active_human: true,
|
|
|
|
email: user + '@zulip.com',
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: user,
|
|
|
|
},
|
2017-04-10 23:25:11 +02:00
|
|
|
can_modify: true,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
html += render('admin_user_list', args);
|
|
|
|
});
|
|
|
|
html += "</table>";
|
2014-01-16 03:59:05 +01:00
|
|
|
|
2016-09-27 14:25:52 +02:00
|
|
|
var buttons = $(html).find('.button');
|
2014-01-16 03:59:05 +01:00
|
|
|
|
2016-09-27 14:25:52 +02:00
|
|
|
assert.equal($(buttons[0]).text().trim(), "Deactivate");
|
|
|
|
assert($(buttons[0]).hasClass("deactivate"));
|
|
|
|
|
|
|
|
assert.equal($(buttons[1]).text().trim(), "Make admin");
|
|
|
|
assert($(buttons[1]).hasClass("make-admin"));
|
|
|
|
|
2017-03-08 21:41:21 +01:00
|
|
|
assert.equal($(buttons[2]).attr('title').trim(), "Edit user");
|
2016-09-27 14:25:52 +02:00
|
|
|
assert($(buttons[2]).hasClass("open-user-form"));
|
2014-01-16 03:59:05 +01:00
|
|
|
|
2017-04-10 23:25:11 +02:00
|
|
|
// When the logged in user is not admin
|
|
|
|
html = '<table>';
|
|
|
|
_.each(users, function (user) {
|
|
|
|
var args = {
|
|
|
|
user: {
|
|
|
|
is_active: true,
|
|
|
|
is_active_human: true,
|
|
|
|
email: user + '@zulip.com',
|
|
|
|
full_name: user,
|
|
|
|
},
|
|
|
|
can_modify: false,
|
|
|
|
};
|
|
|
|
html += render('admin_user_list', args);
|
|
|
|
});
|
|
|
|
html += "</table>";
|
|
|
|
|
|
|
|
buttons = $(html).find('.button');
|
2017-03-18 10:44:00 +01:00
|
|
|
assert.equal($(buttons).length, 6);
|
2017-04-10 23:25:11 +02:00
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("admin_user_list", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
|
|
|
(function alert_word_settings_item() {
|
2016-06-24 01:53:49 +02:00
|
|
|
var html = '<ul id="alert-words">';
|
2013-12-11 18:53:05 +01:00
|
|
|
var words = ['lunch', 'support'];
|
|
|
|
_.each(words, function (word) {
|
|
|
|
var args = {
|
2016-12-03 23:17:57 +01:00
|
|
|
word: word,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
html += render('alert_word_settings_item', args);
|
|
|
|
});
|
|
|
|
html += "</ul>";
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("alert_word_settings_item", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
var li = $(html).find("li.alert-word-item:first");
|
|
|
|
assert.equal(li.attr('data-word'),'lunch');
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function announce_stream_docs() {
|
|
|
|
var html = render('announce_stream_docs');
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("announce_stream_docs", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
2016-12-28 14:46:42 +01:00
|
|
|
(function attachment_settings_item() {
|
|
|
|
var html = '<ul id="attachments">';
|
|
|
|
var attachments = [
|
|
|
|
{messages: [], id: 42, name: "foo.txt"},
|
|
|
|
{messages: [], id: 43, name: "bar.txt"},
|
|
|
|
];
|
|
|
|
_.each(attachments, function (attachment) {
|
|
|
|
var args = {attachment: attachment};
|
|
|
|
html += render('attachment-item', args);
|
|
|
|
});
|
|
|
|
html += "</ul>";
|
|
|
|
global.write_handlebars_output("attachment-item", html);
|
|
|
|
var li = $(html).find("li.attachment-item:first");
|
|
|
|
assert.equal(li.attr('data-attachment'), 42);
|
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function bankruptcy_modal() {
|
|
|
|
var args = {
|
2016-12-03 23:17:57 +01:00
|
|
|
unread_count: 99,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('bankruptcy_modal', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("bankruptcy_modal", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
var count = $(html).find("p b");
|
|
|
|
assert.equal(count.text(), 99);
|
|
|
|
}());
|
|
|
|
|
2016-11-02 21:51:56 +01:00
|
|
|
(function admin_auth_methods_list() {
|
|
|
|
var args = {
|
|
|
|
method: {
|
2016-12-03 03:08:47 +01:00
|
|
|
method: "Email",
|
2016-12-03 23:17:57 +01:00
|
|
|
enabled: false,
|
|
|
|
},
|
2016-11-02 21:51:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<tbody id="admin_auth_methods_table">';
|
|
|
|
html += render('admin_auth_methods_list', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
|
|
|
|
global.write_test_output('admin_auth_methods_list.handlebars', html);
|
|
|
|
|
|
|
|
var method = $(html).find('tr.method_row:first span.method');
|
|
|
|
assert.equal(method.text(), 'Email');
|
|
|
|
assert.equal(method.is("checked"), false);
|
|
|
|
}());
|
|
|
|
|
2016-07-30 05:42:39 +02:00
|
|
|
(function bookend() {
|
|
|
|
// Do subscribed/unsubscribed cases here.
|
|
|
|
var args = {
|
|
|
|
bookend_content: "subscribed to stream",
|
|
|
|
trailing: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
subscribed: true,
|
2016-07-30 05:42:39 +02:00
|
|
|
};
|
|
|
|
var html;
|
|
|
|
var all_html = '';
|
|
|
|
|
|
|
|
html = render('bookend', args);
|
2017-01-10 08:32:11 +01:00
|
|
|
assert.equal($(html).text().trim(), "subscribed to stream\n \n \n Unsubscribe");
|
2016-07-30 05:42:39 +02:00
|
|
|
|
|
|
|
all_html += html;
|
|
|
|
|
|
|
|
args = {
|
|
|
|
bookend_content: "Not subscribed to stream",
|
|
|
|
trailing: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
subscribed: false,
|
2016-07-30 05:42:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
html = render('bookend', args);
|
2017-01-10 08:32:11 +01:00
|
|
|
assert.equal($(html).text().trim(), 'Not subscribed to stream\n \n \n Subscribe');
|
2016-07-30 05:42:39 +02:00
|
|
|
|
|
|
|
all_html += '<hr />';
|
|
|
|
all_html += html;
|
|
|
|
|
|
|
|
global.write_handlebars_output("bookend", all_html);
|
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function bot_avatar_row() {
|
|
|
|
var html = '';
|
|
|
|
html += '<div id="settings">';
|
|
|
|
html += '<div id="bot-settings" class="settings-section">';
|
|
|
|
html += '<div class="bot-settings-form">';
|
2017-02-25 15:38:45 +01:00
|
|
|
html += '<ol id="active_bots_list" style="display: block">';
|
2013-12-11 18:53:05 +01:00
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
email: "hamlet@zulip.com",
|
|
|
|
api_key: "123456ABCD",
|
|
|
|
name: "Hamlet",
|
2016-12-03 23:17:57 +01:00
|
|
|
avatar_url: "/hamlet/avatar/url",
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
html += render('bot_avatar_row', args);
|
|
|
|
html += '</ol>';
|
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("bot_avatar_row", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
var img = $(html).find("img");
|
|
|
|
assert.equal(img.attr('src'), '/hamlet/avatar/url');
|
|
|
|
}());
|
|
|
|
|
2017-02-25 08:49:12 +01:00
|
|
|
(function bot_owner_select() {
|
|
|
|
var args = {
|
|
|
|
users_list: [
|
|
|
|
{
|
|
|
|
email: "hamlet@zulip.com",
|
|
|
|
api_key: "123456ABCD",
|
|
|
|
full_name: "Hamlet",
|
|
|
|
avatar_url: "/hamlet/avatar/url",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
var html = render('bot_owner_select', args);
|
|
|
|
global.write_handlebars_output("bot_owner_select", html);
|
|
|
|
var option = $(html).find("option:last");
|
|
|
|
assert.equal(option.val(), "hamlet@zulip.com");
|
|
|
|
assert.equal(option.text(), "Hamlet");
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function compose_invite_users() {
|
|
|
|
var args = {
|
|
|
|
email: 'hamlet@zulip.com',
|
2016-12-03 23:17:57 +01:00
|
|
|
name: 'Hamlet',
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('compose-invite-users', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("compose-invite-users", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
var button = $(html).find("button:first");
|
|
|
|
assert.equal(button.text(), "Subscribe");
|
|
|
|
}());
|
|
|
|
|
2016-06-04 04:31:35 +02:00
|
|
|
(function compose_all_everyone() {
|
|
|
|
var args = {
|
|
|
|
count: '101',
|
2016-12-03 23:17:57 +01:00
|
|
|
name: 'all',
|
2016-06-04 04:31:35 +02:00
|
|
|
};
|
|
|
|
var html = render('compose_all_everyone', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("compose_all_everyone", html);
|
2016-06-04 04:31:35 +02:00
|
|
|
var button = $(html).find("button:first");
|
2016-12-21 21:01:52 +01:00
|
|
|
assert.equal(button.text(), "Yes, send");
|
2016-06-04 04:31:35 +02:00
|
|
|
var error_msg = $(html).find('span.compose-all-everyone-msg').text().trim();
|
2016-11-17 21:27:19 +01:00
|
|
|
assert.equal(error_msg, "Are you sure you want to mention all 101 people in this stream?");
|
2016-06-04 04:31:35 +02:00
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function compose_notification() {
|
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
note: "You sent a message to a muted topic.",
|
|
|
|
link_text: "Narrow to here",
|
|
|
|
link_msg_id: "99",
|
2016-12-03 23:17:57 +01:00
|
|
|
link_class: "compose_notification_narrow_by_subject",
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = '<div id="out-of-view-notification" class="notification-alert">';
|
|
|
|
html += render('compose_notification', args);
|
|
|
|
html += '</div>';
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("compose_notification", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
var a = $(html).find("a.compose_notification_narrow_by_subject");
|
|
|
|
assert.equal(a.text(), "Narrow to here");
|
|
|
|
}());
|
|
|
|
|
2017-02-22 02:34:05 +01:00
|
|
|
(function draft_table_body() {
|
|
|
|
var args = {
|
|
|
|
drafts: [
|
|
|
|
{
|
|
|
|
draft_id: '1',
|
|
|
|
is_stream: true,
|
|
|
|
stream: 'all',
|
|
|
|
stream_color: '#FF0000', // rgb(255, 0, 0)
|
|
|
|
topic: 'tests',
|
|
|
|
content: 'Public draft',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
draft_id: '2',
|
|
|
|
is_stream: false,
|
|
|
|
recipients: 'Jordan, Michael',
|
|
|
|
content: 'Private draft',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<div id="drafts_table">';
|
|
|
|
html += render('draft_table_body', args);
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
global.write_handlebars_output("draft_table_body", html);
|
|
|
|
|
|
|
|
var row_1 = $(html).find(".draft-row[data-draft-id='1']");
|
|
|
|
assert.equal(row_1.find(".stream_label").text().trim(), "all");
|
|
|
|
assert.equal(row_1.find(".stream_label").css("background"), "rgb(255, 0, 0)");
|
|
|
|
assert.equal(row_1.find(".stream_topic").text().trim(), "tests");
|
|
|
|
assert(!row_1.find(".message_row").hasClass("private-message"));
|
|
|
|
assert.equal(row_1.find(".messagebox").css("box-shadow"),
|
|
|
|
"inset 2px 0px 0px 0px #FF0000, -1px 0px 0px 0px #FF0000");
|
|
|
|
assert.equal(row_1.find(".message_content").text().trim(), "Public draft");
|
|
|
|
|
|
|
|
var row_2 = $(html).find(".draft-row[data-draft-id='2']");
|
|
|
|
assert.equal(row_2.find(".stream_label").text().trim(), "You and Jordan, Michael");
|
|
|
|
assert(row_2.find(".message_row").hasClass("private-message"));
|
|
|
|
assert.equal(row_2.find(".message_content").text().trim(), "Private draft");
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function email_address_hint() {
|
|
|
|
var html = render('email_address_hint');
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("email_address_hint", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
var li = $(html).find("li:first");
|
|
|
|
assert.equal(li.text(), 'The email will be forwarded to this stream');
|
|
|
|
}());
|
|
|
|
|
2017-04-28 22:26:22 +02:00
|
|
|
(function emoji_popover_content() {
|
|
|
|
var args = {
|
|
|
|
search: 'Search',
|
|
|
|
message_id: 1,
|
|
|
|
emojis: [{
|
|
|
|
name: '100',
|
|
|
|
css_class: '100',
|
|
|
|
}],
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<div style="height: 250px">';
|
|
|
|
html += render('emoji_popover_content', args);
|
|
|
|
html += "</div>";
|
|
|
|
// test to make sure the first emoji is present in the popover
|
|
|
|
var emoji_key = $(html).find(".emoji-100").attr('title');
|
|
|
|
assert.equal(emoji_key, ':100:');
|
|
|
|
global.write_handlebars_output("emoji_popover_content", html);
|
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function group_pms() {
|
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
group_pms: [
|
2013-12-11 18:53:05 +01:00
|
|
|
{
|
2016-12-03 03:08:47 +01:00
|
|
|
fraction_present: 0.1,
|
|
|
|
emails: "alice@zulip.com,bob@zulip.com",
|
|
|
|
short_name: "Alice and Bob",
|
2016-12-03 23:17:57 +01:00
|
|
|
name: "Alice and Bob",
|
|
|
|
},
|
|
|
|
],
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('group_pms', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("group_pms", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var a = $(html).find("a:first");
|
|
|
|
assert.equal(a.text(), 'Alice and Bob');
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function invite_subscription() {
|
|
|
|
var args = {
|
|
|
|
streams: [
|
|
|
|
{
|
2016-12-03 23:17:57 +01:00
|
|
|
name: "devel",
|
2013-12-11 18:53:05 +01:00
|
|
|
},
|
|
|
|
{
|
2016-12-03 23:17:57 +01:00
|
|
|
name: "social",
|
|
|
|
},
|
|
|
|
],
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('invite_subscription', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("invite_subscription", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var input = $(html).find("label:first");
|
|
|
|
assert.equal(input.text().trim(), "devel");
|
|
|
|
}());
|
|
|
|
|
2014-02-18 16:37:13 +01:00
|
|
|
(function single_message() {
|
|
|
|
var message = {
|
2014-03-14 16:28:54 +01:00
|
|
|
msg: {
|
2013-11-27 22:05:33 +01:00
|
|
|
include_recipient: true,
|
|
|
|
display_recipient: 'devel',
|
|
|
|
subject: 'testing',
|
|
|
|
is_stream: true,
|
|
|
|
content: 'This is message one.',
|
|
|
|
last_edit_timestr: '11:00',
|
2016-12-03 23:17:57 +01:00
|
|
|
starred: true,
|
|
|
|
},
|
2013-11-27 22:05:33 +01:00
|
|
|
};
|
2014-02-18 16:37:13 +01:00
|
|
|
|
|
|
|
var html = render('single_message', message);
|
2013-12-09 20:15:33 +01:00
|
|
|
html = '<div class="message_table focused_table" id="zfilt">' + html + '</div>';
|
2013-11-27 22:05:33 +01:00
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("message", html);
|
2013-11-27 22:05:33 +01:00
|
|
|
|
2013-12-09 20:15:33 +01:00
|
|
|
var first_message = $(html).find("div.messagebox:first");
|
2013-11-27 22:05:33 +01:00
|
|
|
|
|
|
|
var first_message_text = first_message.find(".message_content").text().trim();
|
|
|
|
assert.equal(first_message_text, "This is message one.");
|
|
|
|
|
2017-02-23 23:33:57 +01:00
|
|
|
var starred_title = first_message.find(".star").attr("title");
|
2013-11-27 22:05:33 +01:00
|
|
|
assert.equal(starred_title, "Unstar this message");
|
|
|
|
}());
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2016-07-30 06:07:53 +02:00
|
|
|
(function message_edit_form() {
|
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
topic: "lunch",
|
|
|
|
content: "Let's go to lunch!",
|
2016-12-03 23:17:57 +01:00
|
|
|
is_stream: true,
|
2016-07-30 06:07:53 +02:00
|
|
|
};
|
|
|
|
var html = render('message_edit_form', args);
|
|
|
|
global.write_handlebars_output("message_edit_form", html);
|
|
|
|
|
|
|
|
var textarea = $(html).find("textarea.message_edit_content");
|
|
|
|
assert.equal(textarea.text(), "Let's go to lunch!");
|
|
|
|
}());
|
|
|
|
|
2014-02-18 16:37:13 +01:00
|
|
|
(function message_group() {
|
|
|
|
var messages = [
|
|
|
|
{
|
2014-03-18 23:24:23 +01:00
|
|
|
msg: {
|
|
|
|
id: 1,
|
|
|
|
match_content: 'This is message one.',
|
|
|
|
starred: true,
|
|
|
|
is_stream: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
content: 'This is message one.',
|
2014-03-18 23:24:23 +01:00
|
|
|
},
|
2014-02-18 16:37:13 +01:00
|
|
|
include_recipient: true,
|
|
|
|
display_recipient: 'devel',
|
2016-12-03 23:17:57 +01:00
|
|
|
last_edit_timestr: '11:00',
|
2014-02-18 16:37:13 +01:00
|
|
|
},
|
|
|
|
{
|
2014-03-18 23:24:23 +01:00
|
|
|
msg: {
|
|
|
|
content: 'This is message two.',
|
|
|
|
match_content: 'This is message <span class="highlight">two</span>.',
|
|
|
|
is_stream: true,
|
|
|
|
unread: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
id: 2,
|
|
|
|
},
|
|
|
|
},
|
2014-02-18 16:37:13 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
var groups = [
|
|
|
|
{
|
|
|
|
display_recipient: "support",
|
|
|
|
is_stream: true,
|
|
|
|
message_ids: [1, 2],
|
2014-03-17 19:38:35 +01:00
|
|
|
message_containers: messages,
|
2014-02-18 16:37:13 +01:00
|
|
|
show_date: '"<span id="timerender82">Jan 07</span>"',
|
2017-05-16 23:19:57 +02:00
|
|
|
show_date_separator: true,
|
2014-02-27 19:28:47 +01:00
|
|
|
subject: 'two messages',
|
2016-12-03 23:17:57 +01:00
|
|
|
match_subject: '<span class="highlight">two</span> messages',
|
|
|
|
},
|
2014-02-18 16:37:13 +01:00
|
|
|
];
|
|
|
|
|
2017-01-05 01:03:14 +01:00
|
|
|
render('loader');
|
2014-02-27 19:28:47 +01:00
|
|
|
var html = render('message_group', {message_groups: groups, use_match_properties: true});
|
2014-02-18 16:37:13 +01:00
|
|
|
|
|
|
|
var first_message_text = $(html).next('.recipient_row').find('div.messagebox:first .message_content').text().trim();
|
|
|
|
assert.equal(first_message_text, "This is message one.");
|
|
|
|
|
2014-02-27 19:28:47 +01:00
|
|
|
var last_message_html = $(html).next('.recipient_row').find('div.messagebox:last .message_content').html().trim();
|
|
|
|
assert.equal(last_message_html, 'This is message <span class="highlight">two</span>.');
|
|
|
|
|
|
|
|
var highlighted_subject_word = $(html).find('a.narrows_by_subject .highlight').text();
|
|
|
|
assert.equal(highlighted_subject_word, 'two');
|
2014-02-18 16:37:13 +01:00
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("message_group", html);
|
2014-02-18 16:37:13 +01:00
|
|
|
}());
|
|
|
|
|
2017-02-20 02:37:58 +01:00
|
|
|
(function message_edit_history() {
|
|
|
|
var message = {
|
|
|
|
content: "Let's go to lunch!",
|
|
|
|
edit_history: [
|
|
|
|
{
|
|
|
|
body_to_render: "<p>Let's go to <span class='highlight_text_replaced'>dinner</span>!</p>",
|
|
|
|
timestamp: 1468132659,
|
|
|
|
edited_by: 'Alice',
|
|
|
|
posted_or_edited: "Edited by",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
var html = render('message_edit_history', {
|
|
|
|
edited_messages: message.edit_history,
|
|
|
|
});
|
|
|
|
global.write_test_output("message_edit_history.handlebars", html);
|
|
|
|
var edited_message = $(html).find("div.messagebox-content");
|
|
|
|
assert.equal(edited_message.text().trim(),
|
2017-04-15 04:39:47 +02:00
|
|
|
"1468132659\n Let's go to dinner!\n Edited by Alice");
|
2017-02-20 02:37:58 +01:00
|
|
|
}());
|
|
|
|
|
2016-12-02 13:23:23 +01:00
|
|
|
(function message_reaction() {
|
|
|
|
var args = {
|
|
|
|
emoji_name: 'smile',
|
2017-01-12 00:17:43 +01:00
|
|
|
message_id: '1',
|
2016-12-02 13:23:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<div>';
|
|
|
|
html += render('message_reaction', args);
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
global.write_handlebars_output("message_reaction", html);
|
|
|
|
assert($(html).find(".message_reaction").has(".emoji .emoji-smile"));
|
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function new_stream_users() {
|
|
|
|
var args = {
|
|
|
|
users: [
|
|
|
|
{
|
|
|
|
email: 'lear@zulip.com',
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: 'King Lear',
|
2013-12-11 18:53:05 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
email: 'othello@zulip.com',
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: 'Othello the Moor',
|
|
|
|
},
|
|
|
|
],
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('new_stream_users', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("new_stream_users", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var label = $(html).find("label:first");
|
|
|
|
assert.equal(label.text().trim(), 'King Lear (lear@zulip.com)');
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function notification() {
|
|
|
|
var args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
content: "Hello",
|
|
|
|
gravatar_url: "/gravatar/url",
|
2016-12-03 23:17:57 +01:00
|
|
|
title: "You have a notification",
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('notification', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("notification", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var title = $(html).find(".title");
|
|
|
|
assert.equal(title.text().trim(), 'You have a notification');
|
|
|
|
}());
|
|
|
|
|
2016-07-30 06:09:32 +02:00
|
|
|
(function propagate_notification_change() {
|
|
|
|
var html = render('propagate_notification_change');
|
|
|
|
global.write_handlebars_output("propagate_notification_change", html);
|
|
|
|
|
|
|
|
var button_area = $(html).find(".propagate-notifications-controls");
|
|
|
|
assert.equal(button_area.find(".yes_propagate_notifications").text().trim(), 'Yes');
|
|
|
|
assert.equal(button_area.find(".no_propagate_notifications").text().trim(), 'No');
|
|
|
|
}());
|
|
|
|
|
2016-07-30 06:10:30 +02:00
|
|
|
(function settings_tab() {
|
|
|
|
var page_param_checkbox_options = {
|
2017-04-29 07:01:46 +02:00
|
|
|
enable_stream_desktop_notifications: true,
|
2017-04-29 08:13:47 +02:00
|
|
|
enable_stream_sounds: true, enable_desktop_notifications: true,
|
2017-04-29 06:53:28 +02:00
|
|
|
enable_sounds: true, enable_offline_email_notifications: true,
|
2016-09-19 22:55:18 +02:00
|
|
|
enable_offline_push_notifications: true, enable_online_push_notifications: true,
|
|
|
|
enable_digest_emails: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
autoscroll_forever: true, default_desktop_notifications: true,
|
2016-07-30 06:10:30 +02:00
|
|
|
};
|
|
|
|
var page_params = $.extend(page_param_checkbox_options, {
|
2017-04-27 00:26:49 +02:00
|
|
|
full_name: "Alyssa P. Hacker", password_auth_enabled: true,
|
2016-07-30 06:10:30 +02:00
|
|
|
avatar_url: "https://google.com",
|
|
|
|
});
|
|
|
|
|
|
|
|
var checkbox_ids = ["enable_stream_desktop_notifications",
|
|
|
|
"enable_stream_sounds", "enable_desktop_notifications",
|
|
|
|
"enable_sounds", "enable_offline_push_notifications",
|
2016-09-19 22:55:18 +02:00
|
|
|
"enable_online_push_notifications",
|
2016-07-30 06:10:30 +02:00
|
|
|
"enable_digest_emails", "autoscroll_forever",
|
|
|
|
"default_desktop_notifications"];
|
|
|
|
|
|
|
|
// Render with all booleans set to true.
|
|
|
|
var html = render('settings_tab', {page_params: page_params});
|
|
|
|
global.write_handlebars_output("settings_tab", html);
|
|
|
|
|
|
|
|
// All checkboxes should be checked.
|
|
|
|
_.each(checkbox_ids, function (checkbox) {
|
|
|
|
assert.equal($(html).find("#" + checkbox).is(":checked"), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Re-render with checkbox booleans set to false.
|
|
|
|
_.each(page_param_checkbox_options, function (value, option) {
|
|
|
|
page_params[option] = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
html = render('settings_tab', {page_params: page_params});
|
|
|
|
|
|
|
|
// All checkboxes should be unchecked.
|
|
|
|
_.each(checkbox_ids, function (checkbox) {
|
|
|
|
assert.equal($(html).find("#" + checkbox).is(":checked"), false);
|
|
|
|
});
|
|
|
|
|
|
|
|
}());
|
|
|
|
|
2016-08-25 03:57:29 +02:00
|
|
|
(function sidebar_private_message_list() {
|
|
|
|
var args = {
|
|
|
|
want_show_more_messages_links: true,
|
|
|
|
messages: [
|
|
|
|
{
|
2016-12-03 23:17:57 +01:00
|
|
|
recipients: "alice,bob",
|
|
|
|
},
|
|
|
|
],
|
2016-08-25 03:57:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += render('sidebar_private_message_list', args);
|
|
|
|
|
2017-05-31 01:32:55 +02:00
|
|
|
var conversations = $(html).find('a').text().trim().split('\n');
|
|
|
|
assert.equal(conversations[0], 'alice,bob');
|
|
|
|
assert.equal(conversations[1].trim(), '(more conversations)');
|
|
|
|
|
2016-08-25 03:57:29 +02:00
|
|
|
global.write_handlebars_output("sidebar_private_message_list", html);
|
|
|
|
}());
|
|
|
|
|
2014-02-01 17:12:28 +01:00
|
|
|
(function stream_member_list_entry() {
|
|
|
|
var everyone_items = ["subscriber-name", "subscriber-email"];
|
|
|
|
var admin_items = ["remove-subscriber-button"];
|
|
|
|
|
|
|
|
// First, as non-admin.
|
|
|
|
var html = render('stream_member_list_entry',
|
|
|
|
{name: "King Hamlet", email: "hamlet@zulip.com"});
|
|
|
|
_.each(everyone_items, function (item) {
|
|
|
|
assert.equal($(html).find("." + item).length, 1);
|
|
|
|
});
|
|
|
|
_.each(admin_items, function (item) {
|
|
|
|
assert.equal($(html).find("." + item).length, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Now, as admin.
|
|
|
|
html = render('stream_member_list_entry',
|
|
|
|
{name: "King Hamlet", email: "hamlet@zulip.com",
|
|
|
|
displaying_for_admin: true});
|
|
|
|
_.each(everyone_items, function (item) {
|
|
|
|
assert.equal($(html).find("." + item).length, 1);
|
|
|
|
});
|
|
|
|
_.each(admin_items, function (item) {
|
|
|
|
assert.equal($(html).find("." + item).length, 1);
|
|
|
|
});
|
2014-02-01 17:17:31 +01:00
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("stream_member_list_entry", html);
|
2014-02-01 17:12:28 +01:00
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function stream_sidebar_actions() {
|
|
|
|
var args = {
|
|
|
|
stream: {
|
|
|
|
color: 'red',
|
|
|
|
name: 'devel',
|
|
|
|
in_home_view: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
id: 55,
|
|
|
|
},
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('stream_sidebar_actions', args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("stream_sidebar_actions", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var li = $(html).find("li:first");
|
2016-08-23 02:46:12 +02:00
|
|
|
assert.equal(li.text().trim(), 'Stream settings');
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
|
|
|
(function stream_sidebar_row() {
|
|
|
|
var args = {
|
|
|
|
name: "devel",
|
|
|
|
color: "red",
|
|
|
|
dark_background: "maroon",
|
|
|
|
uri: "/devel/uri",
|
2016-12-03 23:17:57 +01:00
|
|
|
id: 999,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<ul id="stream_filters">';
|
|
|
|
html += render('stream_sidebar_row', args);
|
|
|
|
html += '</ul>';
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("stream_sidebar_row", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2017-04-17 22:19:47 +02:00
|
|
|
var swatch = $(html).find(".stream-privacy");
|
|
|
|
assert.equal(swatch.attr('id'), 'stream_sidebar_privacy_swatch_999');
|
|
|
|
|
|
|
|
// test to ensure that the hashtag element from stream_privacy exists.
|
|
|
|
assert.equal($(html).find(".stream-privacy").children("*").attr("class"), "hashtag");
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
|
|
|
|
2017-05-10 20:02:21 +02:00
|
|
|
(function subscription_settings() {
|
|
|
|
var sub = {
|
|
|
|
name: 'devel',
|
|
|
|
subscribed: true,
|
|
|
|
notifications: true,
|
|
|
|
is_admin: true,
|
|
|
|
render_subscribers: true,
|
|
|
|
color: 'purple',
|
|
|
|
invite_only: true,
|
|
|
|
can_make_public: true,
|
|
|
|
can_make_private: true, /* not logical, but that's ok */
|
|
|
|
email_address: 'xxxxxxxxxxxxxxx@zulip.com',
|
|
|
|
stream_id: 888,
|
|
|
|
in_home_view: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += render('subscription_settings', sub);
|
|
|
|
|
|
|
|
global.write_handlebars_output("subscription_settings", html);
|
|
|
|
|
|
|
|
var div = $(html).find(".subscription-type");
|
|
|
|
assert(div.text().indexOf('invite-only stream') > 0);
|
|
|
|
|
|
|
|
var anchor = $(html).find(".change-stream-privacy:first");
|
|
|
|
assert.equal(anchor.data("is-private"), true);
|
|
|
|
assert.equal(anchor.text(), "[Change]");
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
2017-02-24 00:46:42 +01:00
|
|
|
(function subscription_stream_privacy_modal() {
|
|
|
|
var args = {
|
|
|
|
stream_id: 999,
|
|
|
|
is_private: true,
|
|
|
|
};
|
|
|
|
var html = render('subscription_stream_privacy_modal', args);
|
|
|
|
|
|
|
|
global.write_handlebars_output("subscription_stream_privacy_modal", html);
|
|
|
|
|
|
|
|
var stream_desc = $(html).find(".modal-body b");
|
|
|
|
assert.equal(stream_desc.text(), 'an invite-only stream');
|
|
|
|
|
|
|
|
var button = $(html).find("#change-stream-privacy-button");
|
|
|
|
assert(button.hasClass("btn-primary"));
|
2017-02-26 03:33:21 +01:00
|
|
|
assert.equal(button.text().trim(), "Make stream public");
|
2017-02-24 00:46:42 +01:00
|
|
|
}());
|
|
|
|
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function subscription_table_body() {
|
|
|
|
var args = {
|
|
|
|
subscriptions: [
|
|
|
|
{
|
|
|
|
name: 'devel',
|
|
|
|
subscribed: true,
|
|
|
|
notifications: true,
|
2014-01-03 15:31:19 +01:00
|
|
|
is_admin: true,
|
2013-12-11 18:53:05 +01:00
|
|
|
render_subscribers: true,
|
|
|
|
color: 'purple',
|
|
|
|
invite_only: true,
|
2014-01-03 20:35:52 +01:00
|
|
|
can_make_public: true,
|
|
|
|
can_make_private: true, /* not logical, but that's ok */
|
2013-12-11 18:53:05 +01:00
|
|
|
email_address: 'xxxxxxxxxxxxxxx@zulip.com',
|
2017-02-24 00:46:42 +01:00
|
|
|
stream_id: 888,
|
2016-12-03 23:17:57 +01:00
|
|
|
in_home_view: true,
|
2013-12-11 18:53:05 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'social',
|
|
|
|
color: 'green',
|
2017-02-24 00:46:42 +01:00
|
|
|
stream_id: 999,
|
2016-12-03 23:17:57 +01:00
|
|
|
},
|
|
|
|
],
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<div id="subscriptions_table">';
|
|
|
|
html += render('subscription_table_body', args);
|
|
|
|
html += '</div>';
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("subscription_table_body", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2016-10-28 23:27:02 +02:00
|
|
|
var span = $(html).find(".stream-name:first");
|
2013-12-11 18:53:05 +01:00
|
|
|
assert.equal(span.text(), 'devel');
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
|
|
|
(function tab_bar() {
|
|
|
|
var args = {
|
|
|
|
tabs: [
|
|
|
|
{
|
|
|
|
cls: 'root',
|
|
|
|
title: 'Home',
|
|
|
|
hash: '#',
|
2016-12-03 23:17:57 +01:00
|
|
|
data: 'home',
|
2013-12-11 18:53:05 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
cls: 'stream',
|
|
|
|
title: 'Devel',
|
|
|
|
hash: '/stream/uri',
|
2016-12-03 23:17:57 +01:00
|
|
|
data: 'devel',
|
|
|
|
},
|
|
|
|
],
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('tab_bar', args);
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("tab_bar", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var a = $(html).find("li:first");
|
|
|
|
assert.equal(a.text().trim(), 'Home');
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function topic_edit_form() {
|
|
|
|
var html = render('topic_edit_form');
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("topic_edit_form", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var button = $(html).find("button:first");
|
2014-02-07 21:27:36 +01:00
|
|
|
assert.equal(button.find("i").attr("class"), 'icon-vector-ok');
|
2013-12-11 18:53:05 +01:00
|
|
|
}());
|
|
|
|
|
2016-10-29 18:11:01 +02:00
|
|
|
(function topic_list_item() {
|
|
|
|
var args = {
|
|
|
|
is_muted: false,
|
|
|
|
topic_name: 'lunch',
|
|
|
|
url: '/lunch/url',
|
2016-12-03 23:17:57 +01:00
|
|
|
unread: 5,
|
2016-10-29 18:11:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('topic_list_item', args);
|
|
|
|
|
|
|
|
global.write_handlebars_output("topic_list_item", html);
|
|
|
|
|
|
|
|
assert.equal($(html).attr('data-name'), 'lunch');
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function topic_sidebar_actions() {
|
|
|
|
var args = {
|
|
|
|
stream_name: 'social',
|
|
|
|
topic_name: 'lunch',
|
2016-12-03 23:17:57 +01:00
|
|
|
can_mute_topic: true,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('topic_sidebar_actions', args);
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("topic_sidebar_actions", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
var a = $(html).find("a.narrow_to_topic");
|
|
|
|
assert.equal(a.text().trim(), 'Narrow to topic lunch');
|
|
|
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function tutorial() {
|
|
|
|
var tutorials = [
|
|
|
|
'tutorial_home',
|
|
|
|
'tutorial_message',
|
|
|
|
'tutorial_reply',
|
|
|
|
'tutorial_stream',
|
|
|
|
'tutorial_subject',
|
2016-12-03 23:17:57 +01:00
|
|
|
'tutorial_title',
|
2013-12-11 18:53:05 +01:00
|
|
|
];
|
|
|
|
var html = '';
|
|
|
|
_.each(tutorials, function (tutorial) {
|
|
|
|
var args = {
|
|
|
|
placement: 'left',
|
2016-12-03 23:17:57 +01:00
|
|
|
title: 'Title',
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
html = render(tutorial, args);
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output(tutorial, html);
|
2013-12-11 18:53:05 +01:00
|
|
|
});
|
|
|
|
}());
|
|
|
|
|
2016-10-12 20:57:59 +02:00
|
|
|
(function typing_notifications() {
|
|
|
|
var args = {
|
|
|
|
users: [{
|
|
|
|
full_name: 'Hamlet',
|
|
|
|
email: 'hamlet@zulip.com',
|
|
|
|
}],
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<ul>';
|
|
|
|
html += render('typing_notifications', args);
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
global.write_handlebars_output('typing_notifications', html);
|
|
|
|
var li = $(html).find('li:first');
|
|
|
|
assert.equal(li.text(), 'Hamlet is typing...');
|
2017-03-03 21:36:37 +01:00
|
|
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function user_info_popover() {
|
|
|
|
var html = render('user_info_popover', {class: 'message-info-popover'});
|
|
|
|
global.write_handlebars_output("user_info_popover", html);
|
|
|
|
|
|
|
|
$(html).hasClass('popover message-info-popover');
|
2016-10-12 20:57:59 +02:00
|
|
|
}());
|
|
|
|
|
2017-03-04 13:26:46 +01:00
|
|
|
(function user_info_popover_content() {
|
|
|
|
var args = {
|
|
|
|
message: {
|
|
|
|
full_date_str: 'Monday',
|
|
|
|
full_time_str: '12:00',
|
|
|
|
user_full_name: 'Alice Smith',
|
|
|
|
user_email: 'alice@zulip.com',
|
|
|
|
},
|
|
|
|
sent_by_uri: '/sent_by/uri',
|
|
|
|
pm_with_uri: '/pm_with/uri',
|
2017-03-04 13:43:21 +01:00
|
|
|
private_message_class: 'compose_private_message',
|
2017-03-04 13:26:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('user_info_popover_content', args);
|
|
|
|
global.write_handlebars_output("user_info_popover_content", html);
|
|
|
|
|
2017-03-04 13:43:21 +01:00
|
|
|
var a = $(html).find("a.compose_private_message");
|
2017-03-04 13:26:46 +01:00
|
|
|
assert.equal(a.text().trim(), 'Send private message');
|
|
|
|
}());
|
|
|
|
|
|
|
|
(function user_info_popover_title() {
|
|
|
|
var html = render('user_info_popover_title', {user_avatar: 'avatar/hamlet@zulip.com'});
|
|
|
|
global.write_handlebars_output("user_info_popover_title", html);
|
|
|
|
|
|
|
|
html = '<div>' + html + '</div>';
|
|
|
|
assert($(html).find('.popover-avatar').css('background-image'), "url(avatar/hamlet@zulip.com)");
|
|
|
|
}());
|
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
(function user_presence_rows() {
|
|
|
|
var args = {
|
|
|
|
users: [
|
|
|
|
{
|
2016-12-03 03:08:47 +01:00
|
|
|
type_desc: "Active",
|
|
|
|
type: "active",
|
|
|
|
num_unread: 0,
|
|
|
|
email: "lear@zulip.com",
|
2016-12-03 23:17:57 +01:00
|
|
|
name: "King Lear",
|
2013-12-11 18:53:05 +01:00
|
|
|
},
|
|
|
|
{
|
2016-12-03 03:08:47 +01:00
|
|
|
type_desc: "Away",
|
|
|
|
type: "away",
|
|
|
|
num_unread: 5,
|
|
|
|
email: "othello@zulip.com",
|
2016-12-03 23:17:57 +01:00
|
|
|
name: "Othello",
|
|
|
|
},
|
|
|
|
],
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<ul class="filters">';
|
|
|
|
html += render('user_presence_rows', args);
|
|
|
|
html += '</ul>';
|
|
|
|
|
2016-07-30 04:02:09 +02:00
|
|
|
global.write_handlebars_output("user_presence_rows", html);
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2017-02-25 19:25:56 +01:00
|
|
|
var a = $(html).find("a:first");
|
2013-12-11 18:53:05 +01:00
|
|
|
assert.equal(a.text(), 'King Lear');
|
|
|
|
}());
|
|
|
|
|
2016-11-26 04:39:53 +01:00
|
|
|
(function muted_topic_ui_row() {
|
|
|
|
var args = {
|
|
|
|
stream: 'Verona',
|
|
|
|
topic: 'Verona2',
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<table id="muted-topics-table">';
|
|
|
|
html += '<tbody>';
|
|
|
|
html += render('muted_topic_ui_row', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
html += '</table>';
|
|
|
|
|
|
|
|
assert.equal($(html).find("tr").data("stream"), "Verona");
|
|
|
|
assert.equal($(html).find("tr").data("topic"), "Verona2");
|
|
|
|
}());
|
|
|
|
|
2014-01-17 20:13:25 +01:00
|
|
|
// By the end of this test, we should have compiled all our templates. Ideally,
|
|
|
|
// we will also have exercised them to some degree, but that's a little trickier
|
|
|
|
// to enforce.
|
|
|
|
global.make_sure_all_templates_have_been_compiled();
|