2017-11-08 19:24:52 +01:00
|
|
|
zrequire('Handlebars', 'handlebars');
|
|
|
|
zrequire('templates');
|
2016-05-13 12:44:03 +02:00
|
|
|
|
2017-11-08 19:17:57 +01:00
|
|
|
set_global('i18n', global.stub_i18n);
|
2013-11-27 22:05:33 +01:00
|
|
|
|
2018-05-20 16:35:54 +02:00
|
|
|
const { JSDOM } = require("jsdom");
|
|
|
|
const { window } = new JSDOM();
|
2016-08-24 21:49:53 +02:00
|
|
|
global.$ = require('jquery')(window);
|
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
|
|
|
}
|
|
|
|
|
2018-05-15 12:40:07 +02:00
|
|
|
run_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-11-04 16:07:00 +01:00
|
|
|
]);
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|
2016-11-04 16:07:00 +01:00
|
|
|
|
2018-05-15 12:40:07 +02:00
|
|
|
run_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'
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|
2014-01-10 16:36:01 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('actions_popover_content', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
var args = {
|
2018-03-28 00:28:57 +02:00
|
|
|
should_display_quote_and_reply: true,
|
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-11-08 19:17:57 +01:00
|
|
|
assert.equal(link.text().trim(), 'translated: Quote and reply');
|
2018-03-28 00:28:57 +02:00
|
|
|
|
|
|
|
var deletedArgs = {
|
|
|
|
should_display_edit_and_view_source: false,
|
|
|
|
should_display_quote_and_reply: false,
|
|
|
|
narrowed: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
var deletedHtml = '<div style="height: 250px">';
|
|
|
|
deletedHtml += render('actions_popover_content', deletedArgs);
|
|
|
|
deletedHtml += "</div>";
|
|
|
|
var viewSourceLink = $(deletedHtml).find("a.popover_edit_message");
|
|
|
|
assert.equal(viewSourceLink.length, 0);
|
|
|
|
var quoteLink = $(deletedHtml).find("a.respond_button");
|
|
|
|
assert.equal(quoteLink.length, 0);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('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>";
|
|
|
|
|
2017-07-18 01:39:05 +02:00
|
|
|
var button = $(html).find('.button');
|
2016-12-26 19:19:02 +01:00
|
|
|
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-11-08 19:17:57 +01:00
|
|
|
assert.equal(button.text().trim(), "translated: 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);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-12-26 19:19:02 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_realm_dropdown_stream_list', () => {
|
2017-06-10 07:03:53 +02:00
|
|
|
var html = "<ul>";
|
|
|
|
var args = {
|
|
|
|
stream: {
|
|
|
|
name: "Italy",
|
|
|
|
subscriber_count: 9,
|
|
|
|
stream_id: 18,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
html += render("admin-realm-dropdown-stream-list", args);
|
|
|
|
html += "</ul>";
|
|
|
|
|
|
|
|
var link = $(html).find("a");
|
|
|
|
var list_item = $(html).find("li");
|
|
|
|
|
|
|
|
assert.equal(link.text().trim(), "Italy");
|
|
|
|
assert(list_item.hasClass("stream_name"));
|
|
|
|
assert.equal(list_item.attr("data-stream-id"), "18");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-06-10 07:03:53 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_default_streams_list', () => {
|
2016-05-20 22:08:42 +02:00
|
|
|
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) {
|
2018-05-07 03:30:13 +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) {
|
2018-05-07 03:30:13 +02:00
|
|
|
var args = {
|
|
|
|
stream: {name: stream, invite_only: false},
|
|
|
|
can_modify: false,
|
|
|
|
};
|
2017-04-14 23:08:22 +02:00
|
|
|
html += render('admin_default_streams_list', args);
|
|
|
|
});
|
|
|
|
html += "</table>";
|
|
|
|
span = $(html).find(".default_stream_name:first");
|
|
|
|
assert.equal(span.text(), "devel");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-05-20 22:08:42 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_emoji_list', () => {
|
2016-07-30 04:52:29 +02:00
|
|
|
var args = {
|
|
|
|
emoji: {
|
2016-12-03 03:08:47 +01:00
|
|
|
name: "MouseFace",
|
2018-08-05 22:40:29 +02:00
|
|
|
display_name: "MouseFace",
|
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>';
|
|
|
|
|
|
|
|
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');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-07-30 04:52:29 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_profile_field_list', () => {
|
2017-12-14 05:51:45 +01:00
|
|
|
|
|
|
|
// When the logged in user is admin
|
|
|
|
var args = {
|
|
|
|
profile_field: {
|
|
|
|
name: "teams",
|
2018-05-06 11:40:31 +02:00
|
|
|
type: "Long text",
|
2017-12-14 05:51:45 +01:00
|
|
|
},
|
|
|
|
can_modify: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<tbody id="admin_profile_fields_table">';
|
|
|
|
html += render('admin_profile_field_list', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
|
|
|
|
var field_name = $(html).find('tr.profile-field-row:first span.profile_field_name');
|
|
|
|
var field_type = $(html).find('tr.profile-field-row:first span.profile_field_type');
|
|
|
|
var td = $(html).find('tr.profile-field-row:first td');
|
|
|
|
|
|
|
|
assert.equal(field_name.text(), 'teams');
|
2018-05-06 11:40:31 +02:00
|
|
|
assert.equal(field_type.text(), 'Long text');
|
2018-03-31 09:23:57 +02:00
|
|
|
assert.equal(td.length, 4);
|
2017-12-14 05:51:45 +01:00
|
|
|
|
|
|
|
// When the logged in user is not admin
|
|
|
|
args = {
|
|
|
|
profile_field: {
|
|
|
|
name: "teams",
|
2018-05-06 11:40:31 +02:00
|
|
|
type: "Long text",
|
2017-12-14 05:51:45 +01:00
|
|
|
},
|
|
|
|
can_modify: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
html = '';
|
|
|
|
html += '<tbody id="admin_profile_fields_table">';
|
|
|
|
html += render('admin_profile_field_list', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
|
|
|
|
field_name = $(html).find('tr.profile-field-row:first span.profile_field_name');
|
|
|
|
field_type = $(html).find('tr.profile-field-row:first span.profile_field_type');
|
|
|
|
td = $(html).find('tr.profile-field-row:first td');
|
|
|
|
|
|
|
|
assert.equal(field_name.text(), 'teams');
|
2018-05-06 11:40:31 +02:00
|
|
|
assert.equal(field_type.text(), 'Long text');
|
2018-03-31 09:23:57 +02:00
|
|
|
assert.equal(td.length, 3);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-12-14 05:51:45 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('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>';
|
|
|
|
|
|
|
|
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');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-02-13 19:17:15 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_invites_list', () => {
|
2017-10-21 03:15:12 +02:00
|
|
|
var html = '<table>';
|
|
|
|
var invites = ['alice', 'bob', 'carl'];
|
|
|
|
var invite_id = 0;
|
|
|
|
_.each(invites, function (invite) {
|
|
|
|
var args = {
|
|
|
|
invite: {
|
|
|
|
email: invite + '@zulip.com',
|
|
|
|
ref: 'iago@zulip.com',
|
|
|
|
invited: "2017-01-01 01:01:01",
|
|
|
|
id: invite_id,
|
2017-12-12 15:10:09 +01:00
|
|
|
invited_as_admin: true,
|
2017-10-21 03:15:12 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
html += render('admin_invites_list', args);
|
|
|
|
invite_id += 1;
|
|
|
|
});
|
|
|
|
html += "</table>";
|
|
|
|
var buttons = $(html).find('.button');
|
|
|
|
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal($(buttons[0]).text().trim(), "translated: Revoke");
|
2017-10-21 03:15:12 +02:00
|
|
|
assert($(buttons[0]).hasClass("revoke"));
|
|
|
|
assert.equal($(buttons[0]).attr("data-invite-id"), 0);
|
|
|
|
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal($(buttons[3]).text().trim(), "translated: Resend");
|
2017-10-21 03:15:12 +02:00
|
|
|
assert($(buttons[3]).hasClass("resend"));
|
|
|
|
assert.equal($(buttons[3]).attr("data-invite-id"), 1);
|
|
|
|
|
|
|
|
var span = $(html).find(".email:first");
|
|
|
|
assert.equal(span.text(), "alice@zulip.com");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-10-21 03:15:12 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_tab', () => {
|
2016-07-30 06:06:51 +02:00
|
|
|
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",
|
2018-04-30 13:22:38 +02:00
|
|
|
"admin_deactivated_users_table", "admin_invites_table"];
|
2016-07-30 06:06:51 +02:00
|
|
|
_.each(admin_features, function (admin_feature) {
|
|
|
|
assert.notEqual($(html).find("#" + admin_feature).length, 0);
|
|
|
|
});
|
|
|
|
assert.equal($(html).find("input.admin-realm-name").val(), 'Zulip');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_user_group_list', () => {
|
2017-11-17 04:31:37 +01:00
|
|
|
var args = {
|
|
|
|
user_group: {
|
|
|
|
id: "9",
|
|
|
|
name: "uranohoshi",
|
|
|
|
description: "Students at Uranohoshi Academy",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<div id="user-groups">';
|
|
|
|
html += render('admin_user_group_list', args);
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
var group_id = $(html).find('.user-group:first').prop('id');
|
2018-03-27 22:08:50 +02:00
|
|
|
var group_pills_id = $(html).find('.user-group:first .pill-container').attr('data-group-pills');
|
2018-03-14 17:22:19 +01:00
|
|
|
var group_name_display = $(html).find('.user-group:first .name').text().trim().replace(/\s+/g, ' ');
|
|
|
|
var group_description = $(html).find('.user-group:first .description').text().trim().replace(/\s+/g, ' ');
|
2017-11-17 04:31:37 +01:00
|
|
|
|
|
|
|
assert.equal(group_id, '9');
|
2018-03-27 22:08:50 +02:00
|
|
|
assert.equal(group_pills_id, '9');
|
2018-03-14 17:22:19 +01:00
|
|
|
assert.equal(group_name_display, 'uranohoshi');
|
|
|
|
assert.equal(group_description, 'Students at Uranohoshi Academy');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-11-17 04:31:37 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_user_list', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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
|
|
|
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal($(buttons[0]).text().trim(), "translated: Deactivate");
|
2016-09-27 14:25:52 +02:00
|
|
|
assert($(buttons[0]).hasClass("deactivate"));
|
|
|
|
|
2018-08-01 16:27:13 +02:00
|
|
|
assert.equal($(buttons[1]).attr('title').trim(), "translated: Edit user");
|
|
|
|
assert($(buttons[1]).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');
|
2018-07-14 12:43:04 +02:00
|
|
|
// No buttons should be availabe to non-admins
|
|
|
|
assert.equal($(buttons).length, 0);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('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'];
|
2017-06-07 21:36:43 +02:00
|
|
|
var args;
|
2013-12-11 18:53:05 +01:00
|
|
|
_.each(words, function (word) {
|
2017-06-07 21:36:43 +02:00
|
|
|
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);
|
|
|
|
});
|
2017-06-07 21:36:43 +02:00
|
|
|
args = {
|
|
|
|
word: '',
|
|
|
|
editing: true,
|
|
|
|
};
|
|
|
|
html += render('alert_word_settings_item', args);
|
2013-12-11 18:53:05 +01:00
|
|
|
html += "</ul>";
|
2017-06-07 21:36:43 +02:00
|
|
|
|
2013-12-11 18:53:05 +01:00
|
|
|
var li = $(html).find("li.alert-word-item:first");
|
2017-06-07 21:36:43 +02:00
|
|
|
var value = li.find('.value');
|
|
|
|
var button = li.find('button');
|
2018-12-07 22:14:28 +01:00
|
|
|
assert.equal(li.attr('data-word'), 'lunch');
|
2017-06-07 21:36:43 +02:00
|
|
|
assert.equal(value.length, 1);
|
|
|
|
assert.equal(value.text(), 'lunch');
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(button.attr('title'), 'translated: Delete alert word');
|
2018-12-07 22:14:28 +01:00
|
|
|
assert.equal(button.attr('data-word'), 'lunch');
|
2017-06-07 21:36:43 +02:00
|
|
|
|
|
|
|
var title = $(html).find('.new-alert-word-section-title');
|
|
|
|
var textbox = $(html).find('#create_alert_word_name');
|
|
|
|
button = $(html).find('#create_alert_word_button');
|
|
|
|
assert.equal(title.length, 1);
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(title.text().trim(), 'translated: Add a new alert word');
|
2017-06-07 21:36:43 +02:00
|
|
|
assert.equal(textbox.length, 1);
|
|
|
|
assert.equal(textbox.attr('maxlength'), 100);
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(textbox.attr('placeholder'), 'translated: Alert word');
|
2017-06-07 21:36:43 +02:00
|
|
|
assert.equal(textbox.attr('class'), 'required');
|
|
|
|
assert.equal(button.length, 1);
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(button.text().trim(), 'translated: Add alert word');
|
2017-06-07 21:36:43 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('all_messages_sidebar_actions', () => {
|
2018-04-16 14:09:01 +02:00
|
|
|
render('all_messages_sidebar_actions');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-15 20:38:06 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('announce_stream_docs', () => {
|
2018-04-16 14:09:01 +02:00
|
|
|
render('announce_stream_docs');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('bankruptcy_modal', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
var count = $(html).find("p b");
|
|
|
|
assert.equal(count.text(), 99);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('admin_auth_methods_list', () => {
|
2016-11-02 21:51:56 +01:00
|
|
|
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>';
|
|
|
|
|
|
|
|
var method = $(html).find('tr.method_row:first span.method');
|
|
|
|
assert.equal(method.text(), 'Email');
|
|
|
|
assert.equal(method.is("checked"), false);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-11-02 21:51:56 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('bookend', () => {
|
2016-07-30 05:42:39 +02:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
html = render('bookend', args);
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal($(html).text().trim(), "subscribed to stream\n \n \n translated: Unsubscribe");
|
2016-07-30 05:42:39 +02:00
|
|
|
|
|
|
|
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-11-08 19:17:57 +01:00
|
|
|
assert.equal($(html).text().trim(), 'Not subscribed to stream\n \n \n translated: Subscribe');
|
2016-07-30 05:42:39 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-07-30 05:42:39 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('bot_avatar_row', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
var html = '';
|
|
|
|
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);
|
|
|
|
|
|
|
|
var img = $(html).find("img");
|
|
|
|
assert.equal(img.attr('src'), '/hamlet/avatar/url');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('bot_owner_select', () => {
|
2017-02-25 08:49:12 +01:00
|
|
|
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);
|
|
|
|
var option = $(html).find("option:last");
|
|
|
|
assert.equal(option.val(), "hamlet@zulip.com");
|
|
|
|
assert.equal(option.text(), "Hamlet");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-02-25 08:49:12 +01:00
|
|
|
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('compose_invite_users', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
var args = {
|
|
|
|
email: 'hamlet@zulip.com',
|
2016-12-03 23:17:57 +01:00
|
|
|
name: 'Hamlet',
|
2018-08-13 00:46:29 +02:00
|
|
|
can_subscribe_other_users: true,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('compose-invite-users', args);
|
|
|
|
var button = $(html).find("button:first");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(button.text(), "translated: Subscribe");
|
2018-08-13 00:46:29 +02:00
|
|
|
|
|
|
|
args.can_subscribe_other_users = false;
|
|
|
|
html = render('compose-invite-users', args);
|
|
|
|
button = $(html).find("button:first");
|
|
|
|
assert.equal(button.length, 0);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('compose_all_everyone', () => {
|
2016-06-04 04:31:35 +02:00
|
|
|
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);
|
|
|
|
var button = $(html).find("button:first");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(button.text(), "translated: Yes, send");
|
2016-06-04 04:31:35 +02:00
|
|
|
var error_msg = $(html).find('span.compose-all-everyone-msg').text().trim();
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(error_msg, "translated: Are you sure you want to mention all 101 people in this stream?");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-06-04 04:31:35 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('compose_announce', () => {
|
2017-12-18 16:09:41 +01:00
|
|
|
var args = {
|
|
|
|
count: '101',
|
|
|
|
};
|
|
|
|
var html = render('compose_announce', args);
|
|
|
|
var button = $(html).find("button:first");
|
|
|
|
assert.equal(button.text(), "translated: Yes, send");
|
|
|
|
var error_msg = $(html).find('span.compose-announce-msg').text().trim();
|
|
|
|
assert.equal(error_msg, "translated: This stream is reserved for announcements.\n \n Are you sure you want to message all 101 people in this stream?");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-12-18 16:09:41 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('compose_not_subscribed', () => {
|
2018-10-31 19:59:40 +01:00
|
|
|
var html = render('compose_not_subscribed', {should_display_sub_button: true});
|
2018-04-04 19:38:09 +02:00
|
|
|
var button = $(html).find("button:first");
|
|
|
|
assert.equal(button.text(), "translated: Subscribe");
|
2018-10-31 19:59:40 +01:00
|
|
|
html = render('compose_not_subscribed', {should_display_sub_button: false});
|
|
|
|
button = $(html).find("button:first");
|
|
|
|
assert.equal(button.length, 0);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-04-04 19:38:09 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('compose_notification', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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",
|
2018-11-13 16:11:42 +01:00
|
|
|
link_class: "compose_notification_narrow_by_topic",
|
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>';
|
2018-11-13 16:11:42 +01:00
|
|
|
var a = $(html).find("a.compose_notification_narrow_by_topic");
|
2013-12-11 18:53:05 +01:00
|
|
|
assert.equal(a.text(), "Narrow to here");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('compose_private_stream_alert', () => {
|
2017-10-14 15:18:21 +02:00
|
|
|
var args = {
|
2018-05-07 03:30:13 +02:00
|
|
|
stream_name: 'Denmark',
|
2017-10-14 15:18:21 +02:00
|
|
|
};
|
|
|
|
var html = render('compose_private_stream_alert', args);
|
2017-11-27 17:34:47 +01:00
|
|
|
assert($(html).hasClass('compose_private_stream_alert'));
|
|
|
|
|
|
|
|
var actual_text = $(html).text();
|
|
|
|
var expected_text = 'translated: Warning: Denmark is a private stream.';
|
|
|
|
assert(actual_text.indexOf(expected_text) >= 1);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-10-14 15:18:21 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('custom_user_profile_field', () => {
|
2018-05-01 19:33:33 +02:00
|
|
|
var field = {name: "GitHub user name", id: 2, hint: "Or link to profile"};
|
2018-12-31 07:45:33 +01:00
|
|
|
var args = {field: field, field_value: {value: "@GitHub", rendered_value: "<p>@GitHub</p>"}, field_type: "text"};
|
2018-02-26 20:08:23 +01:00
|
|
|
var html = render('custom-user-profile-field', args);
|
2018-05-06 00:38:23 +02:00
|
|
|
assert.equal($(html).attr('data-field-id'), 2);
|
2018-05-04 16:46:46 +02:00
|
|
|
assert.equal($(html).find('.custom_user_field_value').val(), "@GitHub");
|
2018-05-01 19:33:33 +02:00
|
|
|
assert.equal($(html).find('.field_hint').text(), "Or link to profile");
|
|
|
|
assert.equal($(html).find('label').text(), "GitHub user name");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-26 20:08:23 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('deactivate_stream_modal', () => {
|
2018-02-21 05:16:45 +01:00
|
|
|
var args = {
|
|
|
|
stream_name: "Public stream",
|
|
|
|
};
|
|
|
|
var html = render('deactivation-stream-modal', args);
|
|
|
|
|
|
|
|
var modal_header = $(html).find("#deactivation_stream_modal_label");
|
|
|
|
assert.equal(modal_header.text(), "translated: Delete stream " + args.stream_name);
|
|
|
|
|
|
|
|
var button = $(html).find("#do_deactivate_stream_button");
|
|
|
|
assert.equal(button.text(), "translated: Yes, delete this stream");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-21 05:16:45 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('dev_env_email_access', () => {
|
2018-04-16 14:09:01 +02:00
|
|
|
render('dev_env_email_access');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-10-02 23:26:20 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('draft_table_body', () => {
|
2017-02-22 02:34:05 +01:00
|
|
|
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>';
|
|
|
|
|
|
|
|
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(".message_content").text().trim(), "Public draft");
|
|
|
|
|
|
|
|
var row_2 = $(html).find(".draft-row[data-draft-id='2']");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(row_2.find(".stream_label").text().trim(), "translated: You and Jordan, Michael");
|
2017-02-22 02:34:05 +01:00
|
|
|
assert(row_2.find(".message_row").hasClass("private-message"));
|
|
|
|
assert.equal(row_2.find(".message_content").text().trim(), "Private draft");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-02-22 02:34:05 +01:00
|
|
|
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('email_address_hint', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
var html = render('email_address_hint');
|
|
|
|
var li = $(html).find("li:first");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(li.text(), 'translated: The email will be forwarded to this stream');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('emoji_popover', () => {
|
2017-07-19 00:28:56 +02:00
|
|
|
var args = {
|
|
|
|
class: "emoji-info-popover",
|
|
|
|
};
|
2017-09-17 20:55:41 +02:00
|
|
|
var html = "<div>";
|
|
|
|
html += render('emoji_popover', args);
|
|
|
|
html += "</div>";
|
|
|
|
var popover = $(html).find(".popover");
|
|
|
|
assert(popover.hasClass("emoji-info-popover"));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-07-19 00:28:56 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('emoji_popover_content', () => {
|
2017-04-28 22:26:22 +02:00
|
|
|
var args = {
|
|
|
|
search: 'Search',
|
|
|
|
message_id: 1,
|
2017-07-19 00:28:56 +02:00
|
|
|
emoji_categories: [
|
|
|
|
{
|
|
|
|
name: 'Test',
|
|
|
|
emojis: [
|
|
|
|
{
|
|
|
|
has_reacted: false,
|
|
|
|
is_realm_emoji: false,
|
|
|
|
name: '100',
|
2018-07-20 18:38:56 +02:00
|
|
|
emoji_code: '100',
|
2017-07-19 00:28:56 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2017-09-17 20:55:41 +02:00
|
|
|
{
|
|
|
|
name: 'Test1',
|
|
|
|
emojis: [
|
|
|
|
{
|
|
|
|
has_reacted: false,
|
|
|
|
is_realm_emoji: true,
|
|
|
|
name: 'zulip',
|
|
|
|
url: 'zulip',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2017-07-19 00:28:56 +02:00
|
|
|
],
|
2017-04-28 22:26:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
2017-09-29 22:16:36 +02:00
|
|
|
var first_emoji = $(html).find(".emoji-100");
|
|
|
|
assert.equal(first_emoji.length, 1);
|
2017-09-17 20:55:41 +02:00
|
|
|
|
|
|
|
var categories = $(html).find(".emoji-popover-tab-item");
|
|
|
|
assert.equal(categories.length, 2);
|
|
|
|
|
|
|
|
var category_1 = $(html).find(".emoji-popover-tab-item[data-tab-name = 'Test']");
|
|
|
|
assert(category_1.hasClass("active"));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-04-28 22:26:22 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('emoji_popover_search_results', () => {
|
2017-07-19 00:28:56 +02:00
|
|
|
var args = {
|
|
|
|
message_id: 1,
|
|
|
|
search_results: [
|
|
|
|
{
|
|
|
|
has_reacted: false,
|
|
|
|
is_realm_emoji: false,
|
|
|
|
name: 'test-1',
|
2018-07-20 18:38:56 +02:00
|
|
|
emoji_code: 'test-1',
|
2017-07-19 00:28:56 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
has_reacted: true,
|
|
|
|
is_realm_emoji: false,
|
|
|
|
name: 'test-2',
|
2018-07-20 18:38:56 +02:00
|
|
|
emoji_code: 'test-2',
|
2017-07-19 00:28:56 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
var html = "<div>";
|
|
|
|
html += render("emoji_popover_search_results", args);
|
|
|
|
html += "</div>";
|
|
|
|
var used_emoji = $(html).find(".emoji-test-2").parent();
|
|
|
|
assert(used_emoji.hasClass("reaction"));
|
|
|
|
assert(used_emoji.hasClass("reacted"));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-07-19 00:28:56 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('emoji_showcase', () => {
|
2017-08-27 22:15:02 +02:00
|
|
|
var args = {
|
|
|
|
emoji_dict: {
|
|
|
|
name: "thumbs_up",
|
|
|
|
is_realm_emoji: false,
|
2018-07-20 18:38:56 +02:00
|
|
|
emoji_code: "1f44d",
|
2017-08-27 22:15:02 +02:00
|
|
|
has_reacted: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
var html = render("emoji_showcase", args);
|
|
|
|
var emoji_div = $(html).find(".emoji");
|
|
|
|
var canonical_name = $(html).find(".emoji-canonical-name");
|
|
|
|
|
|
|
|
assert.equal(emoji_div.length, 1);
|
|
|
|
assert(emoji_div.hasClass("emoji-1f44d"));
|
|
|
|
assert.equal(canonical_name.text(), "thumbs_up");
|
|
|
|
assert.equal(canonical_name.attr("title"), "thumbs_up");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-08-27 22:15:02 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('group_pms', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
var a = $(html).find("a:first");
|
|
|
|
assert.equal(a.text(), 'Alice and Bob');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('hotspot_overlay', () => {
|
2017-07-14 03:15:19 +02:00
|
|
|
var args = {
|
|
|
|
title: 'Start a new conversation',
|
2017-08-30 02:15:32 +02:00
|
|
|
name: 'intro_compose',
|
2017-07-14 03:15:19 +02:00
|
|
|
description: 'Click the "New topic" button to start a new conversation.',
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('hotspot_overlay', args);
|
|
|
|
|
2017-08-30 02:15:32 +02:00
|
|
|
assert.equal($(html).attr('id'), 'hotspot_intro_compose_overlay');
|
2017-07-14 03:15:19 +02:00
|
|
|
assert.equal($(html).find('.hotspot-title').text(), 'Start a new conversation');
|
|
|
|
assert.equal(
|
|
|
|
$(html).find('.hotspot-description').text(),
|
|
|
|
'Click the "New topic" button to start a new conversation.'
|
|
|
|
);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-07-14 03:15:19 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('input_pill', () => {
|
2018-03-31 13:22:29 +02:00
|
|
|
var args = {
|
|
|
|
id: 22,
|
|
|
|
display_value: 'King Hamlet',
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('input_pill', args);
|
|
|
|
|
|
|
|
assert($(html).hasClass('pill'));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-03-31 13:22:29 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('intro_reply_hotspot', () => {
|
2018-05-15 23:21:12 +02:00
|
|
|
var html = render('intro_reply_hotspot', {});
|
|
|
|
|
|
|
|
assert($(html).hasClass('hotspot-message'));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-05-15 23:21:12 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('invite_subscription', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
var input = $(html).find("label:first");
|
|
|
|
assert.equal(input.text().trim(), "devel");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('single_message', () => {
|
2014-02-18 16:37:13 +01:00
|
|
|
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',
|
|
|
|
is_stream: true,
|
|
|
|
content: 'This is message one.',
|
|
|
|
last_edit_timestr: '11:00',
|
2016-12-03 23:17:57 +01:00
|
|
|
starred: true,
|
2017-06-29 08:37:35 +02:00
|
|
|
starred_status: "Unstar",
|
2016-12-03 23:17:57 +01:00
|
|
|
},
|
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
|
|
|
|
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");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(starred_title, "translated: Unstar this message (*)");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('message_edit_form', () => {
|
2016-07-30 06:07:53 +02:00
|
|
|
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);
|
|
|
|
|
|
|
|
var textarea = $(html).find("textarea.message_edit_content");
|
|
|
|
assert.equal(textarea.text(), "Let's go to lunch!");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-07-30 06:07:53 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('message_group', () => {
|
2014-02-18 16:37:13 +01:00
|
|
|
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,
|
2019-02-08 20:11:21 +01:00
|
|
|
group_date_divider_html: '"<span class="timerender82">Jan 07</span>"',
|
2019-02-08 20:24:01 +01:00
|
|
|
show_group_date_divider: true,
|
2018-11-15 16:59:41 +01:00
|
|
|
match_topic: '<span class="highlight">two</span> messages',
|
2016-12-03 23:17:57 +01:00
|
|
|
},
|
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>.');
|
|
|
|
|
2018-12-23 18:20:07 +01:00
|
|
|
var highlighted_topic_word = $(html).find('a.narrows_by_topic .highlight').text();
|
|
|
|
assert.equal(highlighted_topic_word, 'two');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2014-02-18 16:37:13 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('message_edit_history', () => {
|
2017-02-20 02:37:58 +01:00
|
|
|
var message = {
|
|
|
|
content: "Let's go to lunch!",
|
|
|
|
edit_history: [
|
|
|
|
{
|
2017-06-06 01:46:41 +02:00
|
|
|
body_to_render: "<p>Let's go to " +
|
|
|
|
"<span class='highlight_text_deleted'>lunch</span>" +
|
|
|
|
"<span class='highlight_text_inserted'>dinner</span>" +
|
|
|
|
"!</p>",
|
2017-02-20 02:37:58 +01:00
|
|
|
timestamp: 1468132659,
|
|
|
|
edited_by: 'Alice',
|
|
|
|
posted_or_edited: "Edited by",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2019-02-14 01:36:12 +01:00
|
|
|
var html = "<div>" + render('message_edit_history', {
|
2018-05-07 03:30:13 +02:00
|
|
|
edited_messages: message.edit_history,
|
2019-02-14 01:36:12 +01:00
|
|
|
}) + "</div>";
|
2017-02-20 02:37:58 +01:00
|
|
|
var edited_message = $(html).find("div.messagebox-content");
|
|
|
|
assert.equal(edited_message.text().trim(),
|
2019-02-14 01:36:12 +01:00
|
|
|
"1468132659\n Let\'s go to lunchdinner!\n Edited by Alice");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-02-20 02:37:58 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('message_reaction', () => {
|
2016-12-02 13:23:23 +01:00
|
|
|
var args = {
|
2017-10-31 22:33:28 +01:00
|
|
|
class: 'message_reaction',
|
2016-12-02 13:23:23 +01:00
|
|
|
emoji_name: 'smile',
|
2017-10-31 22:33:28 +01:00
|
|
|
emoji_code: '1f604',
|
|
|
|
local_id: 'unicode_emoji,smile,1f604',
|
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>';
|
|
|
|
|
2017-10-31 22:33:28 +01:00
|
|
|
var reaction = $(html).find(".message_reaction");
|
|
|
|
assert.equal(reaction.data("reaction-id"), "unicode_emoji,smile,1f604");
|
|
|
|
assert(reaction.find(".emoji").hasClass("emoji-1f604"));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-12-02 13:23:23 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('more_topics', () => {
|
2017-09-21 20:44:31 +02:00
|
|
|
var html = render('more_topics');
|
|
|
|
|
|
|
|
assert($(html).hasClass('show-more-topics'));
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-09-21 20:44:31 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('new_stream_users', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
var label = $(html).find("label:first");
|
|
|
|
assert.equal(label.text().trim(), 'King Lear (lear@zulip.com)');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('non_editable_user_group', () => {
|
2018-04-05 23:22:49 +02:00
|
|
|
var args = {
|
|
|
|
user_group: {
|
|
|
|
id: "9",
|
|
|
|
name: "uranohoshi",
|
|
|
|
description: "Students at Uranohoshi Academy",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<div id="user-groups">';
|
|
|
|
html += render('non_editable_user_group', args);
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
var group_id = $(html).find('.user-group:first').prop('id');
|
2018-03-27 22:08:50 +02:00
|
|
|
var group_pills_id = $(html).find('.user-group:first .pill-container').attr('data-group-pills');
|
2018-04-05 23:22:49 +02:00
|
|
|
var group_name_display = $(html).find('.user-group:first .name').text().trim().replace(/\s+/g, ' ');
|
|
|
|
var group_description = $(html).find('.user-group:first .description').text().trim().replace(/\s+/g, ' ');
|
|
|
|
|
|
|
|
assert.equal(group_id, '9');
|
2018-03-27 22:08:50 +02:00
|
|
|
assert.equal(group_pills_id, '9');
|
2018-04-05 23:22:49 +02:00
|
|
|
assert.equal(group_name_display, 'uranohoshi');
|
|
|
|
assert.equal(group_description, 'Students at Uranohoshi Academy');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-04-05 23:22:49 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('notification', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
var title = $(html).find(".title");
|
|
|
|
assert.equal(title.text().trim(), 'You have a notification');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('propagate_notification_change', () => {
|
2016-07-30 06:09:32 +02:00
|
|
|
var html = render('propagate_notification_change');
|
|
|
|
|
|
|
|
var button_area = $(html).find(".propagate-notifications-controls");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(button_area.find(".yes_propagate_notifications").text().trim(), 'translated: Yes');
|
|
|
|
assert.equal(button_area.find(".no_propagate_notifications").text().trim(), 'translated: No');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-07-30 06:09:32 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('reminder_popover_content', () => {
|
2018-01-15 03:02:23 +01:00
|
|
|
var args = {
|
|
|
|
message: {
|
|
|
|
is_stream: true,
|
|
|
|
id: "420",
|
|
|
|
stream: "devel",
|
|
|
|
sender_full_name: "Iago",
|
|
|
|
},
|
|
|
|
can_edit_message: true,
|
|
|
|
can_mute_topic: true,
|
|
|
|
narrowed: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<div style="height: 250px">';
|
|
|
|
html += render('remind_me_popover_content', args);
|
|
|
|
html += "</div>";
|
|
|
|
var link = $(html).find("a.remind.custom");
|
|
|
|
assert.equal(link.text().trim(), 'translated: Select date and time');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-01-15 03:02:23 +01:00
|
|
|
|
2019-02-15 19:09:25 +01:00
|
|
|
run_test('revoke_invite_modal', () => {
|
|
|
|
var args = {
|
|
|
|
is_multiuse: false,
|
|
|
|
email: "iago@zulip.com",
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = "<div>";
|
|
|
|
html += render('revoke-invite-modal', args);
|
|
|
|
html += "</div>";
|
|
|
|
assert.equal($(html).find("p strong").text(), "iago@zulip.com");
|
|
|
|
});
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('settings_tab', () => {
|
2016-07-30 06:10:30 +02:00
|
|
|
var page_param_checkbox_options = {
|
2017-04-29 07:01:46 +02:00
|
|
|
enable_stream_desktop_notifications: true,
|
2017-08-17 16:55:32 +02:00
|
|
|
enable_stream_push_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,
|
2018-01-06 23:30:43 +01:00
|
|
|
realm_name_in_notifications: true,
|
2018-08-30 22:45:59 +02:00
|
|
|
realm_push_notifications_enabled: 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",
|
2017-08-17 16:55:32 +02:00
|
|
|
"enable_stream_push_notifications",
|
2016-07-30 06:10:30 +02:00
|
|
|
"enable_stream_sounds", "enable_desktop_notifications",
|
|
|
|
"enable_sounds", "enable_offline_push_notifications",
|
2016-09-19 22:55:18 +02:00
|
|
|
"enable_online_push_notifications",
|
2017-12-27 13:17:58 +01:00
|
|
|
"enable_digest_emails",
|
2018-01-06 23:30:43 +01:00
|
|
|
"realm_name_in_notifications"];
|
2016-07-30 06:10:30 +02:00
|
|
|
|
|
|
|
// Render with all booleans set to true.
|
|
|
|
var html = render('settings_tab', {page_params: page_params});
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
});
|
|
|
|
|
2017-07-21 08:19:37 +02:00
|
|
|
// Check if enable_desktop_notifications setting disables subsetting too.
|
|
|
|
var parent_elem = $('#pm_content_in_desktop_notifications_label').wrap("<div></div>");
|
|
|
|
|
|
|
|
$('#enable_desktop_notifications').prop('checked', false).triggerHandler('change');
|
|
|
|
$('#enable_desktop_notifications').change(function () {
|
|
|
|
assert(parent_elem.hasClass('control-label-disabled'));
|
|
|
|
assert.equal($('#pm_content_in_desktop_notifications').attr('disabled'), 'disabled');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#enable_desktop_notifications').prop('checked', true).triggerHandler('change');
|
|
|
|
$('#enable_desktop_notifications').change(function () {
|
|
|
|
assert(!parent_elem.hasClass('control-label-disabled'));
|
|
|
|
assert.equal($('#pm_content_in_desktop_notifications').attr('disabled'), undefined);
|
|
|
|
});
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-07-30 06:10:30 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('sidebar_private_message_list', () => {
|
2016-08-25 03:57:29 +02:00
|
|
|
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');
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(conversations[1].trim(), '(translated: more conversations)');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-08-25 03:57:29 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('stream_member_list_entry', () => {
|
2014-02-01 17:12:28 +01:00
|
|
|
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);
|
|
|
|
});
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2014-02-01 17:12:28 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('stream_sidebar_actions', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
var li = $(html).find("li:first");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(li.text().trim(), 'translated: Stream settings');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('stream_sidebar_row', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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>';
|
|
|
|
|
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");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('subscription_invites_warning_modal', () => {
|
2017-06-02 15:06:33 +02:00
|
|
|
var html = render('subscription_invites_warning_modal');
|
|
|
|
|
|
|
|
var button = $(html).find(".close-invites-warning-modal").last();
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(button.text(), 'translated: Go back');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('subscription_settings', () => {
|
2017-05-10 20:02:21 +02:00
|
|
|
var sub = {
|
|
|
|
name: 'devel',
|
|
|
|
subscribed: true,
|
|
|
|
notifications: true,
|
|
|
|
is_admin: true,
|
|
|
|
render_subscribers: true,
|
|
|
|
color: 'purple',
|
|
|
|
invite_only: true,
|
2018-05-22 01:14:18 +02:00
|
|
|
can_change_stream_permissions: true,
|
2017-05-10 20:02:21 +02:00
|
|
|
email_address: 'xxxxxxxxxxxxxxx@zulip.com',
|
|
|
|
stream_id: 888,
|
|
|
|
in_home_view: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += render('subscription_settings', sub);
|
|
|
|
|
|
|
|
var div = $(html).find(".subscription-type");
|
2018-06-08 22:05:07 +02:00
|
|
|
assert(div.text().indexOf('private stream') > 0);
|
2017-05-10 20:02:21 +02:00
|
|
|
|
|
|
|
var anchor = $(html).find(".change-stream-privacy:first");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(anchor.text(), "[translated: Change]");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-05-10 20:02:21 +02:00
|
|
|
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('subscription_stream_privacy_modal', () => {
|
2017-02-24 00:46:42 +01:00
|
|
|
var args = {
|
|
|
|
stream_id: 999,
|
|
|
|
is_private: true,
|
2019-01-15 22:20:52 +01:00
|
|
|
is_admin: true,
|
2017-02-24 00:46:42 +01:00
|
|
|
};
|
|
|
|
var html = render('subscription_stream_privacy_modal', args);
|
|
|
|
|
2018-05-03 18:52:39 +02:00
|
|
|
var other_options = $(html).find("input[name=privacy]");
|
|
|
|
assert.equal(other_options[0].value, 'public');
|
2018-05-30 23:16:28 +02:00
|
|
|
assert.equal(other_options[1].value, 'invite-only-public-history');
|
|
|
|
assert.equal(other_options[2].value, 'invite-only');
|
2017-02-24 00:46:42 +01:00
|
|
|
|
2018-05-30 16:02:13 +02:00
|
|
|
var is_announcement_only = $(html).find("input[name=is-announcement-only]");
|
|
|
|
assert.equal(is_announcement_only.prop('checked'), false);
|
|
|
|
|
2017-02-24 00:46:42 +01:00
|
|
|
var button = $(html).find("#change-stream-privacy-button");
|
2018-05-03 18:52:39 +02:00
|
|
|
assert(button.hasClass("btn-danger"));
|
2018-05-30 21:51:55 +02:00
|
|
|
assert.equal(button.text().trim(), "translated: Save changes");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-02-24 00:46:42 +01:00
|
|
|
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('subscription_table_body', () => {
|
2018-07-24 14:27:32 +02:00
|
|
|
// We are mostly deprecating template tests,
|
|
|
|
// but we try to make sure rendering does not
|
|
|
|
// crash.
|
|
|
|
render('subscription_table_body', {});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
run_test('subscriptions', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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,
|
|
|
|
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 = '';
|
2018-07-24 14:27:32 +02:00
|
|
|
html += '<div>';
|
|
|
|
html += render('subscriptions', args);
|
2013-12-11 18:53:05 +01:00
|
|
|
html += '</div>';
|
|
|
|
|
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');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('tab_bar', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
var a = $(html).find("li:first");
|
|
|
|
assert.equal(a.text().trim(), 'Home');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('topic_edit_form', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
var html = render('topic_edit_form');
|
|
|
|
|
|
|
|
var button = $(html).find("button:first");
|
2018-07-04 02:36:22 +02:00
|
|
|
assert.equal(button.find("i").attr("class"), 'fa fa-check');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('topic_list_item', () => {
|
2016-10-29 18:11:01 +02:00
|
|
|
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);
|
|
|
|
|
2017-08-17 01:43:37 +02:00
|
|
|
assert.equal($(html).attr('data-topic-name'), 'lunch');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-10-29 18:11:01 +02:00
|
|
|
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('topic_sidebar_actions', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
var args = {
|
|
|
|
stream_name: 'social',
|
|
|
|
topic_name: 'lunch',
|
2016-12-03 23:17:57 +01:00
|
|
|
can_mute_topic: true,
|
2019-01-18 17:40:54 +01:00
|
|
|
is_admin: false,
|
2013-12-11 18:53:05 +01:00
|
|
|
};
|
|
|
|
var html = render('topic_sidebar_actions', args);
|
|
|
|
|
|
|
|
var a = $(html).find("a.narrow_to_topic");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(a.text().trim(), 'translated: Narrow to topic lunch');
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2019-01-18 17:40:54 +01:00
|
|
|
var delete_topic_option = $(html).find("a.sidebar-popover-delete-topic-messages");
|
|
|
|
assert.equal(delete_topic_option.length, 0);
|
|
|
|
|
|
|
|
args = {
|
|
|
|
is_admin: true,
|
|
|
|
};
|
|
|
|
html = render('topic_sidebar_actions', args);
|
|
|
|
|
|
|
|
delete_topic_option = $(html).find("a.sidebar-popover-delete-topic-messages");
|
|
|
|
assert.equal(delete_topic_option.length, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
run_test('delete_topic_modal', () => {
|
|
|
|
var args = {
|
|
|
|
topic_name: 'lunch',
|
|
|
|
};
|
|
|
|
var html = render('delete_topic_modal', args);
|
|
|
|
|
|
|
|
var modal_body = $(html).find('.modal-body');
|
2019-02-07 03:07:44 +01:00
|
|
|
assert(modal_body.text().indexOf('delete all messages in lunch?') > 0);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('typeahead_list_item', () => {
|
2017-06-12 19:15:57 +02:00
|
|
|
var args = {
|
|
|
|
primary: 'primary-text',
|
|
|
|
secondary: 'secondary-text',
|
|
|
|
img_src: 'https://zulip.org',
|
2017-09-27 19:39:42 +02:00
|
|
|
is_emoji: true,
|
2017-06-12 19:15:57 +02:00
|
|
|
has_image: true,
|
|
|
|
has_secondary: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<div>' + render('typeahead_list_item', args) + '</div>';
|
|
|
|
|
|
|
|
assert.equal($(html).find('.emoji').attr('src'), 'https://zulip.org');
|
|
|
|
assert.equal($(html).find('strong').text().trim(), 'primary-text');
|
|
|
|
assert.equal($(html).find('small').text().trim(), 'secondary-text');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('typing_notifications', () => {
|
2016-10-12 20:57:59 +02:00
|
|
|
var args = {
|
|
|
|
users: [{
|
|
|
|
full_name: 'Hamlet',
|
|
|
|
email: 'hamlet@zulip.com',
|
|
|
|
}],
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
html += '<ul>';
|
|
|
|
html += render('typing_notifications', args);
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
var li = $(html).find('li:first');
|
|
|
|
assert.equal(li.text(), 'Hamlet is typing...');
|
2017-03-03 21:36:37 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-03-03 21:36:37 +01:00
|
|
|
|
2019-01-17 12:05:09 +01:00
|
|
|
run_test('upload_space_stats', () => {
|
|
|
|
var args = {
|
|
|
|
show_upgrade_message: true,
|
|
|
|
percent_used: 50,
|
|
|
|
upload_quota: "1 GB",
|
|
|
|
};
|
|
|
|
var html = render('upload-space-stats', args);
|
|
|
|
assert.equal($(html).text().trim(), "translated: Organization using 50% of 1 GB.\n translated: Upgrade for more space.");
|
|
|
|
|
|
|
|
args = {
|
|
|
|
show_upgrade_message: false,
|
|
|
|
percent_used: 10,
|
|
|
|
upload_quota: "5 GB",
|
|
|
|
};
|
|
|
|
html = render('upload-space-stats', args);
|
|
|
|
assert.equal($(html).text().trim(), "translated: Organization using 10% of 5 GB.");
|
|
|
|
});
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('user_group_info_popover', () => {
|
2018-02-14 05:21:46 +01:00
|
|
|
var html = render('user_group_info_popover');
|
|
|
|
|
|
|
|
$(html).hasClass('popover message-info-popover group-info-popover');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-14 05:21:46 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('user_group_info_popover_content', () => {
|
2018-02-14 05:21:46 +01:00
|
|
|
var args = {
|
|
|
|
group_name: 'groupName',
|
|
|
|
group_description: 'groupDescription',
|
|
|
|
members: [
|
|
|
|
{
|
|
|
|
full_name: 'Active Alice',
|
|
|
|
user_last_seen_time_status: 'time',
|
|
|
|
is_bot: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
full_name: 'Bot Bob',
|
|
|
|
user_last_seen_time_status: 'time',
|
|
|
|
is_bot: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
full_name: 'Inactive Imogen',
|
|
|
|
user_last_seen_time_status: 'time',
|
|
|
|
is_bot: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('user_group_info_popover_content', args);
|
|
|
|
|
|
|
|
var allUsers = $(html).find("li");
|
|
|
|
assert.equal($(allUsers[0]).text().trim(), 'Active Alice');
|
|
|
|
assert.equal($(allUsers[1]).text().trim(), 'Bot Bob');
|
|
|
|
assert.equal($(allUsers[2]).text().trim(), 'Inactive Imogen');
|
|
|
|
|
|
|
|
assert.equal($(html).find('.group-name').text().trim(), 'groupName');
|
|
|
|
assert.equal($(html).find('.group-description').text().trim(), 'groupDescription');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-14 05:21:46 +01:00
|
|
|
|
2019-02-14 15:01:39 +01:00
|
|
|
run_test('no_arrow_popover', () => {
|
|
|
|
var html = render('no_arrow_popover', {class: 'message-info-popover'});
|
2017-03-03 21:36:37 +01:00
|
|
|
|
|
|
|
$(html).hasClass('popover message-info-popover');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-10-12 20:57:59 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('user_info_popover_content', () => {
|
2017-03-04 13:26:46 +01:00
|
|
|
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);
|
|
|
|
|
2017-10-14 00:33:36 +02:00
|
|
|
var a = $(html).find("a.narrow_to_private_messages");
|
2017-11-08 19:17:57 +01:00
|
|
|
assert.equal(a.text().trim(), 'translated: View private messages');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-03-04 13:26:46 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('user_info_popover_title', () => {
|
2017-03-04 13:26:46 +01:00
|
|
|
var html = render('user_info_popover_title', {user_avatar: 'avatar/hamlet@zulip.com'});
|
|
|
|
|
|
|
|
html = '<div>' + html + '</div>';
|
2017-09-17 01:19:11 +02:00
|
|
|
assert.equal($(html).find('.popover-avatar').css('background-image'), "url(avatar/hamlet@zulip.com)");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-09-17 01:19:11 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('uploaded_files_list_popover', () => {
|
2017-09-17 01:20:11 +02:00
|
|
|
var args = {
|
|
|
|
attachment: {
|
|
|
|
name: "file_name.txt",
|
|
|
|
create_time: "Apr 12 04:18 AM",
|
|
|
|
messages: [
|
|
|
|
{
|
|
|
|
id: "1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "2",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
size: 1234,
|
|
|
|
path_id: "2/65/6wITdgsd63hdskjuFqEeEy7_r/file_name.txt",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('uploaded_files_list', args);
|
|
|
|
assert.equal($(html).find('.ind-message').attr("href"), "/#narrow/id/1");
|
|
|
|
assert.equal($(html).find('#download_attachment').attr("href"),
|
|
|
|
"/user_uploads/2/65/6wITdgsd63hdskjuFqEeEy7_r/file_name.txt");
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2017-03-04 13:26:46 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('user_presence_rows', () => {
|
2013-12-11 18:53:05 +01:00
|
|
|
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>';
|
|
|
|
|
2017-02-25 19:25:56 +01:00
|
|
|
var a = $(html).find("a:first");
|
2018-06-27 00:08:28 +02:00
|
|
|
assert.equal(a.text().trim(), 'King Lear');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2013-12-11 18:53:05 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('user_profile_modal', () => {
|
2018-04-23 20:41:35 +02:00
|
|
|
var args = {
|
|
|
|
full_name: "Iago",
|
|
|
|
email: "iago@zulip.com",
|
|
|
|
profile_data: {
|
|
|
|
author: "Shakespeare",
|
|
|
|
book: "Othello",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var html = render('user_profile_modal', args);
|
2018-10-05 05:29:44 +02:00
|
|
|
var div = $(html).find("#email .value");
|
2018-04-23 20:41:35 +02:00
|
|
|
assert.equal(div.text().trim(), 'iago@zulip.com');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-04-23 20:41:35 +02:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('muted_topic_ui_row', () => {
|
2016-11-26 04:39:53 +01:00
|
|
|
var args = {
|
|
|
|
stream: 'Verona',
|
2018-12-14 17:52:01 +01:00
|
|
|
stream_id: 99,
|
|
|
|
topic: 'pizza',
|
2016-11-26 04:39:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var html = '<table id="muted-topics-table">';
|
|
|
|
html += '<tbody>';
|
|
|
|
html += render('muted_topic_ui_row', args);
|
|
|
|
html += '</tbody>';
|
|
|
|
html += '</table>';
|
|
|
|
|
2018-12-14 17:52:01 +01:00
|
|
|
assert.equal($(html).find("tr").attr("data-stream-id"), 99);
|
|
|
|
assert.equal($(html).find("tr").attr("data-topic"), "pizza");
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2016-11-26 04:39:53 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('embedded_bot_config_item', () => {
|
2018-01-07 19:24:14 +01:00
|
|
|
var args = {
|
|
|
|
botname: 'giphy',
|
|
|
|
key: 'api_key',
|
|
|
|
value: '12345678',
|
|
|
|
};
|
|
|
|
var html = render('embedded_bot_config_item', args);
|
|
|
|
assert.equal($(html).attr('name'), args.botname);
|
2018-06-04 21:13:07 +02:00
|
|
|
assert.equal($(html).attr('id'), args.botname + '_' + args.key);
|
2018-01-07 19:24:14 +01:00
|
|
|
assert.equal($(html).find('label').text(), args.key);
|
|
|
|
assert.equal($(html).find('input').attr('placeholder'), args.value);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-01-07 19:24:14 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('edit_bot', () => {
|
2018-02-07 10:34:52 +01:00
|
|
|
render('edit_bot');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-07 10:34:52 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('edit_outgoing_webhook_service', () => {
|
2018-02-07 15:14:18 +01:00
|
|
|
var args = {
|
|
|
|
service: {base_url: "http://www.foo.bar",
|
|
|
|
interface: "1"},
|
|
|
|
};
|
|
|
|
var html = render('edit-outgoing-webhook-service', args);
|
2018-05-18 14:39:02 +02:00
|
|
|
assert.equal($(html).find('#edit_service_base_url').val(), args.service.base_url);
|
|
|
|
assert.equal($(html).find('#edit_service_interface').val(), args.service.interface);
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-07 15:14:18 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('edit_embedded_bot_service', () => {
|
2018-02-01 13:57:24 +01:00
|
|
|
var args = {
|
|
|
|
service: {service_name: "giphy",
|
|
|
|
config_data: {key: "abcd1234"}},
|
|
|
|
};
|
|
|
|
var html = render('edit-embedded-bot-service', args);
|
|
|
|
assert.equal($(html).find('#embedded_bot_key_edit').attr('name'), 'key');
|
|
|
|
assert.equal($(html).find('#embedded_bot_key_edit').val(), 'abcd1234');
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|
2018-02-01 13:57:24 +01:00
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
run_test('archive_message_group', () => {
|
2018-02-03 12:57:38 +01:00
|
|
|
// The messages list below doesn't represent the actual HTML which would be
|
|
|
|
// feed to these handlebar templates but since the actual one is a lot bigger
|
|
|
|
// to be included in a test case and really comes pre rendered from the backend
|
|
|
|
// we just kinda test out the template part which is rendered on frontend with
|
|
|
|
// some self made html for messages to insert into the handlebars.
|
|
|
|
var messages = [
|
|
|
|
'<p>This is message one.</p>',
|
|
|
|
'<p>This is message two.</p>',
|
|
|
|
];
|
|
|
|
|
|
|
|
var groups = [
|
|
|
|
{
|
|
|
|
display_recipient: "support",
|
|
|
|
message_containers: messages,
|
2019-02-08 20:11:21 +01:00
|
|
|
group_date_divider_html: '"<span class="timerender82">Jan 07</span>"',
|
2019-02-08 20:24:01 +01:00
|
|
|
show_group_date_divider: true,
|
2018-02-03 12:57:38 +01:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
var html = render('archive_message_group', {message_groups: groups});
|
|
|
|
|
|
|
|
var first_message_text = $(html).next('.recipient_row').find('p').first().text().trim();
|
|
|
|
assert.equal(first_message_text, "This is message one.");
|
|
|
|
|
|
|
|
var last_message_text = $(html).next('.recipient_row').find('p').last().text().trim();
|
|
|
|
assert.equal(last_message_text, 'This is message two.');
|
|
|
|
|
2018-06-02 09:45:07 +02:00
|
|
|
});
|