mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
js: Normalize strings to double quotes.
Prettier would do this anyway, but it’s separated out for a more reviewable diff. Generated by ESLint. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
06691e1e45
commit
f3726db89a
@@ -112,6 +112,11 @@
|
||||
}
|
||||
],
|
||||
"quote-props": [ "error", "as-needed" ],
|
||||
"quotes": [
|
||||
"error",
|
||||
"double",
|
||||
{ "avoidEscape": true, "allowTemplateLiterals": false }
|
||||
],
|
||||
"radix": "error",
|
||||
"semi": "error",
|
||||
"semi-spacing": "error",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var util = require("util");
|
||||
|
||||
var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
|
||||
var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
|
||||
|
||||
casper.options.clientScripts.push("frontend_tests/casper_lib/polyfill.js");
|
||||
|
||||
@@ -14,7 +14,7 @@ var last_send_or_update = -1;
|
||||
function log_in() {
|
||||
var credentials = test_credentials.default_user;
|
||||
|
||||
casper.test.info('Logging in');
|
||||
casper.test.info("Logging in");
|
||||
casper.fill('form[action^="/accounts/login/"]', {
|
||||
username: credentials.username,
|
||||
password: credentials.password,
|
||||
@@ -55,16 +55,16 @@ exports.initialize_casper = function () {
|
||||
// set this at the PhantomJS level.
|
||||
casper.page.onError = function (msg, trace) {
|
||||
casper.test.error(msg);
|
||||
casper.echo('Traceback:');
|
||||
casper.echo("Traceback:");
|
||||
trace.forEach(function (item) {
|
||||
casper.echo(' ' + item.file + ':' + item.line);
|
||||
casper.echo(" " + item.file + ":" + item.line);
|
||||
});
|
||||
casper.exit(1);
|
||||
};
|
||||
|
||||
// Capture screens from all failures
|
||||
var casper_failure_count = 1;
|
||||
casper.test.on('fail', function failure() {
|
||||
casper.test.on("fail", function failure() {
|
||||
if (casper_failure_count <= 10) {
|
||||
casper.capture("var/casper/casper-failure" + casper_failure_count + ".png");
|
||||
casper_failure_count += 1;
|
||||
@@ -72,14 +72,14 @@ exports.initialize_casper = function () {
|
||||
});
|
||||
|
||||
// Update last_send_or_update whenever get_events returns.
|
||||
casper.on('resource.received', function (resource) {
|
||||
casper.on("resource.received", function (resource) {
|
||||
if (/\/json\/get_events/.test(resource.url)) {
|
||||
last_send_or_update = timestamp();
|
||||
}
|
||||
});
|
||||
|
||||
casper.on('load.finished', function () {
|
||||
casper.test.info('page load finished');
|
||||
casper.on("load.finished", function () {
|
||||
casper.test.info("page load finished");
|
||||
});
|
||||
|
||||
casper.evaluate(function () {
|
||||
@@ -87,7 +87,7 @@ exports.initialize_casper = function () {
|
||||
});
|
||||
|
||||
// This captures console messages from the app.
|
||||
casper.on('remote.message', function (msg) {
|
||||
casper.on("remote.message", function (msg) {
|
||||
casper.echo("app console: " + msg);
|
||||
});
|
||||
};
|
||||
@@ -116,14 +116,14 @@ exports.then_log_in = function () {
|
||||
};
|
||||
|
||||
exports.then_log_out = function () {
|
||||
var menu_selector = '#settings-dropdown';
|
||||
var menu_selector = "#settings-dropdown";
|
||||
var logout_selector = 'a[href="#logout"]';
|
||||
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
|
||||
casper.waitUntilVisible(logout_selector, function () {
|
||||
casper.test.info('Logging out');
|
||||
casper.test.info("Logging out");
|
||||
casper.click(logout_selector);
|
||||
|
||||
});
|
||||
@@ -139,7 +139,7 @@ exports.then_log_out = function () {
|
||||
// select the menu item matching item by typing str.
|
||||
exports.select_item_via_typeahead = function (field_selector, str, item) {
|
||||
casper.then(function () {
|
||||
casper.test.info('Looking in ' + field_selector + ' to select ' + str + ', ' + item);
|
||||
casper.test.info("Looking in " + field_selector + " to select " + str + ", " + item);
|
||||
|
||||
casper.evaluate(function (field_selector, str, item) {
|
||||
// Set the value and then send a bogus keyup event to trigger
|
||||
@@ -147,7 +147,7 @@ exports.select_item_via_typeahead = function (field_selector, str, item) {
|
||||
$(field_selector)
|
||||
.focus()
|
||||
.val(str)
|
||||
.trigger($.Event('keyup', { which: 0 }));
|
||||
.trigger($.Event("keyup", { which: 0 }));
|
||||
|
||||
// You might think these steps should be split by casper.then,
|
||||
// but apparently that's enough to make the typeahead close (??),
|
||||
@@ -227,13 +227,13 @@ exports.wait_for_message_fully_processed = function (content) {
|
||||
don't add the star icon until the server
|
||||
responds.
|
||||
*/
|
||||
return row.find('.star').length === 1;
|
||||
return row.find(".star").length === 1;
|
||||
}, { content: content});
|
||||
});
|
||||
};
|
||||
|
||||
exports.turn_off_press_enter_to_send = function () {
|
||||
var enter_send_selector = '#enter_sends';
|
||||
var enter_send_selector = "#enter_sends";
|
||||
casper.waitForSelector(enter_send_selector);
|
||||
|
||||
var is_checked = casper.evaluate(function (enter_send_selector) {
|
||||
@@ -269,15 +269,15 @@ exports.then_send_message = function (type, params) {
|
||||
delete params.outside_view;
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitForSelector('#compose-send-button:enabled');
|
||||
casper.waitForSelector('#compose-textarea');
|
||||
casper.waitForSelector("#compose-send-button:enabled");
|
||||
casper.waitForSelector("#compose-textarea");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
if (type === "stream") {
|
||||
casper.page.sendEvent('keypress', "c");
|
||||
casper.page.sendEvent("keypress", "c");
|
||||
} else if (type === "private") {
|
||||
casper.page.sendEvent('keypress', "x");
|
||||
casper.page.sendEvent("keypress", "x");
|
||||
} else {
|
||||
casper.test.assertTrue(false, "send_message got valid message type");
|
||||
}
|
||||
@@ -300,13 +300,13 @@ exports.then_send_message = function (type, params) {
|
||||
exports.turn_off_press_enter_to_send();
|
||||
|
||||
casper.then(function () {
|
||||
casper.click('#compose-send-button');
|
||||
casper.click("#compose-send-button");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitFor(function emptyComposeBox() {
|
||||
return casper.getFormValues('form[action^="/json/messages"]').content === '';
|
||||
return casper.getFormValues('form[action^="/json/messages"]').content === "";
|
||||
});
|
||||
if (!outside_view) {
|
||||
exports.wait_for_message_fully_processed(params.content);
|
||||
@@ -328,16 +328,16 @@ exports.then_send_message = function (type, params) {
|
||||
// 'table' here).
|
||||
exports.get_rendered_messages = function (table) {
|
||||
return casper.evaluate(function (table) {
|
||||
var tbl = $('#' + table);
|
||||
var tbl = $("#" + table);
|
||||
return {
|
||||
headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) {
|
||||
headings: $.map(tbl.find(".recipient_row .message-header-contents"), function (elem) {
|
||||
var $clone = $(elem).clone(true);
|
||||
$clone.find(".recipient_row_date").remove();
|
||||
|
||||
return $clone.text().trim().replace(/\s+/g, ' ');
|
||||
return $clone.text().trim().replace(/\s+/g, " ");
|
||||
}),
|
||||
|
||||
bodies: $.map(tbl.find('.message_content'), function (elem) {
|
||||
bodies: $.map(tbl.find(".message_content"), function (elem) {
|
||||
return elem.innerHTML;
|
||||
}),
|
||||
};
|
||||
@@ -373,7 +373,7 @@ exports.get_stream_id = function (stream_name) {
|
||||
// presses by code, only strings of printable characters.
|
||||
exports.keypress = function (code) {
|
||||
casper.evaluate(function (code) {
|
||||
$('body').trigger($.Event('keydown', { which: code }));
|
||||
$("body").trigger($.Event("keydown", { which: code }));
|
||||
}, {
|
||||
code: code,
|
||||
});
|
||||
@@ -382,7 +382,7 @@ exports.keypress = function (code) {
|
||||
exports.then_send_many = function (msgs) {
|
||||
msgs.forEach(function (msg) {
|
||||
exports.then_send_message(
|
||||
msg.stream !== undefined ? 'stream' : 'private',
|
||||
msg.stream !== undefined ? "stream" : "private",
|
||||
msg);
|
||||
});
|
||||
};
|
||||
@@ -397,21 +397,21 @@ exports.wait_for_receive = function (step) {
|
||||
|
||||
// Wait until the loading spinner goes away (helpful just after logging in).
|
||||
exports.wait_for_load = function (step) {
|
||||
casper.waitWhileVisible('#page_loading_indicator', step);
|
||||
casper.waitWhileVisible("#page_loading_indicator", step);
|
||||
};
|
||||
|
||||
// innerText sometimes gives us non-breaking space characters, and occasionally
|
||||
// a different number of spaces than we expect.
|
||||
exports.normalize_spaces = function (str) {
|
||||
return str.replace(/\s+/g, ' ');
|
||||
return str.replace(/\s+/g, " ");
|
||||
};
|
||||
|
||||
exports.ltrim = function (str) {
|
||||
return str.replace(/^\s+/g, '');
|
||||
return str.replace(/^\s+/g, "");
|
||||
};
|
||||
|
||||
exports.rtrim = function (str) {
|
||||
return str.replace(/\s+$/g, '');
|
||||
return str.replace(/\s+$/g, "");
|
||||
};
|
||||
|
||||
exports.trim = function (str) {
|
||||
@@ -421,24 +421,24 @@ exports.trim = function (str) {
|
||||
// Call get_rendered_messages and then check that the last few headings and
|
||||
// bodies match the specified arrays.
|
||||
exports.expected_messages = function (table, headings, bodies) {
|
||||
casper.test.assertVisible('#' + table, table + ' is visible');
|
||||
casper.test.assertVisible("#" + table, table + " is visible");
|
||||
|
||||
var msg = exports.get_rendered_messages(table);
|
||||
|
||||
casper.test.assertEquals(
|
||||
msg.headings.slice(-headings.length),
|
||||
headings.map(exports.trim),
|
||||
'Got expected message headings');
|
||||
"Got expected message headings");
|
||||
|
||||
casper.test.assertEquals(
|
||||
msg.bodies.slice(-bodies.length),
|
||||
bodies,
|
||||
'Got expected message bodies');
|
||||
"Got expected message bodies");
|
||||
};
|
||||
|
||||
exports.un_narrow = function () {
|
||||
casper.test.info('Un-narrowing');
|
||||
if (casper.visible('.message_comp')) {
|
||||
casper.test.info("Un-narrowing");
|
||||
if (casper.visible(".message_comp")) {
|
||||
// close the compose box
|
||||
common.keypress(27); // Esc
|
||||
}
|
||||
@@ -447,20 +447,20 @@ exports.un_narrow = function () {
|
||||
|
||||
exports.manage_organization = function () {
|
||||
casper.then(function () {
|
||||
var menu_selector = '#settings-dropdown';
|
||||
var menu_selector = "#settings-dropdown";
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Organization page');
|
||||
casper.test.info("Organization page");
|
||||
casper.click('a[href^="#organization"]');
|
||||
});
|
||||
|
||||
casper.waitForSelector('#settings_overlay_container.show', function () {
|
||||
casper.test.info('Organization page is active');
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, 'URL suggests we are on organization page');
|
||||
casper.waitForSelector("#settings_overlay_container.show", function () {
|
||||
casper.test.info("Organization page is active");
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, "URL suggests we are on organization page");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
var email = 'alice@test.example.com';
|
||||
var subdomain = 'testsubdomain';
|
||||
var organization_name = 'Awesome Organization';
|
||||
var email = "alice@test.example.com";
|
||||
var subdomain = "testsubdomain";
|
||||
var organization_name = "Awesome Organization";
|
||||
var host = "zulipdev.com:9981";
|
||||
var realm_host = "testsubdomain" + '.' + host;
|
||||
var realm_host = "testsubdomain" + "." + host;
|
||||
|
||||
casper.start('http://' + host + '/new/');
|
||||
casper.start("http://" + host + "/new/");
|
||||
|
||||
casper.then(function () {
|
||||
// Submit the email for realm creation
|
||||
@@ -17,58 +17,58 @@ casper.then(function () {
|
||||
});
|
||||
// Make sure confirmation email is send
|
||||
this.waitWhileVisible('form[name="email_form"]', function () {
|
||||
var regex = new RegExp('^http://[^/]+/accounts/new/send_confirm/' + email);
|
||||
this.test.assertUrlMatch(regex, 'Confirmation mail send');
|
||||
var regex = new RegExp("^http://[^/]+/accounts/new/send_confirm/" + email);
|
||||
this.test.assertUrlMatch(regex, "Confirmation mail send");
|
||||
});
|
||||
});
|
||||
|
||||
// Special endpoint enabled only during tests for extracting confirmation key
|
||||
casper.thenOpen('http://' + host + '/confirmation_key/');
|
||||
casper.thenOpen("http://" + host + "/confirmation_key/");
|
||||
|
||||
// Open the confirmation URL
|
||||
casper.then(function () {
|
||||
var confirmation_key = JSON.parse(this.getPageContent()).confirmation_key;
|
||||
var confirmation_url = 'http://' + host + '/accounts/do_confirm/' + confirmation_key;
|
||||
var confirmation_url = "http://" + host + "/accounts/do_confirm/" + confirmation_key;
|
||||
this.thenOpen(confirmation_url);
|
||||
});
|
||||
|
||||
// Make sure the realm creation page is loaded correctly
|
||||
casper.then(function () {
|
||||
this.waitUntilVisible('.pitch', function () {
|
||||
this.test.assertSelectorContains('.pitch', "We just need you to do one last thing.");
|
||||
this.waitUntilVisible(".pitch", function () {
|
||||
this.test.assertSelectorContains(".pitch", "We just need you to do one last thing.");
|
||||
});
|
||||
|
||||
this.waitUntilVisible('#id_email', function () {
|
||||
this.waitUntilVisible("#id_email", function () {
|
||||
this.test.assertEvalEquals(function () {
|
||||
return $('#id_email').attr('placeholder');
|
||||
return $("#id_email").attr("placeholder");
|
||||
}, email);
|
||||
});
|
||||
|
||||
this.waitUntilVisible('label[for=id_team_name]', function () {
|
||||
this.test.assertSelectorHasText('label[for=id_team_name]', 'Organization name');
|
||||
this.waitUntilVisible("label[for=id_team_name]", function () {
|
||||
this.test.assertSelectorHasText("label[for=id_team_name]", "Organization name");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
|
||||
this.fill('form[action^="/accounts/register/"]', {
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
realm_name: organization_name,
|
||||
realm_subdomain: subdomain,
|
||||
password: 'passwordwhichisreallyreallyreallycomplexandnotguessable',
|
||||
password: "passwordwhichisreallyreallyreallycomplexandnotguessable",
|
||||
terms: true,
|
||||
realm_in_root_domain: false,
|
||||
}, true);
|
||||
});
|
||||
|
||||
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
|
||||
casper.test.assertUrlMatch(realm_host + '/', 'Home page loaded');
|
||||
casper.test.assertUrlMatch(realm_host + "/", "Home page loaded");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
// The user is logged in to the newly created realm and the app is loaded
|
||||
casper.waitUntilVisible('.message_row', function () {
|
||||
casper.waitUntilVisible(".message_row", function () {
|
||||
this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
|
||||
}, null, 20000);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
var realm_url = "http://zulip.zulipdev.com:9981/";
|
||||
|
||||
// Start of test script.
|
||||
@@ -6,7 +6,7 @@ common.init_viewport();
|
||||
casper.start(realm_url, common.initialize_casper);
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, 'Redirected to /login/');
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, "Redirected to /login/");
|
||||
});
|
||||
|
||||
common.then_log_in();
|
||||
|
||||
@@ -8,69 +8,69 @@
|
||||
// Provides a few utility functions.
|
||||
// See https://web.archive.org/web/20200110122733if_/https://docs.casperjs.org/en/latest/modules/utils.html
|
||||
// For example, utils.dump() prints an Object with nice formatting.
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Sanity-checking existing messages');
|
||||
casper.test.info("Sanity-checking existing messages");
|
||||
|
||||
var msg = common.get_rendered_messages('zhome');
|
||||
var msg = common.get_rendered_messages("zhome");
|
||||
|
||||
msg.headings.forEach(function (heading) {
|
||||
casper.test.assertMatch(common.normalize_spaces(heading),
|
||||
/(^You and )|( )/,
|
||||
'Heading is well-formed');
|
||||
"Heading is well-formed");
|
||||
});
|
||||
|
||||
casper.test.info('Sending messages');
|
||||
casper.test.info("Sending messages");
|
||||
});
|
||||
|
||||
// Send some messages.
|
||||
|
||||
common.then_send_many([
|
||||
{ stream: 'Verona', subject: 'frontend test',
|
||||
content: 'test verona A' },
|
||||
{ stream: "Verona", subject: "frontend test",
|
||||
content: "test verona A" },
|
||||
|
||||
{ stream: 'Verona', subject: 'frontend test',
|
||||
content: 'test verona B' },
|
||||
{ stream: "Verona", subject: "frontend test",
|
||||
content: "test verona B" },
|
||||
|
||||
{ stream: 'Verona', subject: 'other subject',
|
||||
content: 'test verona C' },
|
||||
{ stream: "Verona", subject: "other subject",
|
||||
content: "test verona C" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
||||
content: 'personal A' },
|
||||
{ recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "personal A" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
||||
content: 'personal B' },
|
||||
{ recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "personal B" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com',
|
||||
content: 'personal C' }]);
|
||||
{ recipient: "cordelia@zulip.com",
|
||||
content: "personal C" }]);
|
||||
|
||||
common.wait_for_receive(function () {
|
||||
common.expected_messages('zhome', [
|
||||
'Verona > frontend test',
|
||||
'Verona > other subject',
|
||||
'You and Cordelia Lear, King Hamlet',
|
||||
'You and Cordelia Lear',
|
||||
common.expected_messages("zhome", [
|
||||
"Verona > frontend test",
|
||||
"Verona > other subject",
|
||||
"You and Cordelia Lear, King Hamlet",
|
||||
"You and Cordelia Lear",
|
||||
], [
|
||||
'<p>test verona A</p>',
|
||||
'<p>test verona B</p>',
|
||||
'<p>test verona C</p>',
|
||||
'<p>personal A</p>',
|
||||
'<p>personal B</p>',
|
||||
'<p>personal C</p>',
|
||||
"<p>test verona A</p>",
|
||||
"<p>test verona B</p>",
|
||||
"<p>test verona C</p>",
|
||||
"<p>personal A</p>",
|
||||
"<p>personal B</p>",
|
||||
"<p>personal C</p>",
|
||||
]);
|
||||
|
||||
casper.test.info('Sending more messages');
|
||||
casper.test.info("Sending more messages");
|
||||
});
|
||||
|
||||
common.then_send_many([
|
||||
{ stream: 'Verona', subject: 'frontend test',
|
||||
content: 'test verona D' },
|
||||
{ stream: "Verona", subject: "frontend test",
|
||||
content: "test verona D" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
||||
content: 'personal D' },
|
||||
{ recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "personal D" },
|
||||
]);
|
||||
|
||||
common.then_log_out();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -12,39 +12,39 @@ function get_stream_li(stream_name) {
|
||||
// 'run' script provides for).
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Sending messages');
|
||||
casper.test.info("Sending messages");
|
||||
});
|
||||
|
||||
common.then_send_many([
|
||||
{ stream: 'Verona', subject: 'frontend test',
|
||||
content: 'test message A' },
|
||||
{ stream: "Verona", subject: "frontend test",
|
||||
content: "test message A" },
|
||||
|
||||
{ stream: 'Verona', subject: 'frontend test',
|
||||
content: 'test message B' },
|
||||
{ stream: "Verona", subject: "frontend test",
|
||||
content: "test message B" },
|
||||
|
||||
{ stream: 'Verona', subject: 'other subject',
|
||||
content: 'test message C' },
|
||||
{ stream: "Verona", subject: "other subject",
|
||||
content: "test message C" },
|
||||
|
||||
{ stream: 'Denmark', subject: 'frontend test',
|
||||
content: 'other message' },
|
||||
{ stream: "Denmark", subject: "frontend test",
|
||||
content: "other message" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
||||
content: 'personal A' },
|
||||
{ recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "personal A" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
||||
content: 'personal B' },
|
||||
{ recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "personal B" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com',
|
||||
content: 'personal C' },
|
||||
{ recipient: "cordelia@zulip.com",
|
||||
content: "personal C" },
|
||||
|
||||
{ stream: 'Verona', subject: 'frontend test',
|
||||
content: 'test message D' },
|
||||
{ stream: "Verona", subject: "frontend test",
|
||||
content: "test message D" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
||||
content: 'personal D' },
|
||||
{ recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "personal D" },
|
||||
|
||||
{ recipient: 'cordelia@zulip.com',
|
||||
content: 'personal E' },
|
||||
{ recipient: "cordelia@zulip.com",
|
||||
content: "personal E" },
|
||||
]);
|
||||
|
||||
|
||||
@@ -52,15 +52,15 @@ common.then_send_many([
|
||||
|
||||
function expect_home() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zhome', function () {
|
||||
common.expected_messages('zhome', [
|
||||
'Verona > frontend test',
|
||||
'You and Cordelia Lear, King Hamlet',
|
||||
'You and Cordelia Lear',
|
||||
casper.waitUntilVisible("#zhome", function () {
|
||||
common.expected_messages("zhome", [
|
||||
"Verona > frontend test",
|
||||
"You and Cordelia Lear, King Hamlet",
|
||||
"You and Cordelia Lear",
|
||||
], [
|
||||
'<p>test message D</p>',
|
||||
'<p>personal D</p>',
|
||||
'<p>personal E</p>',
|
||||
"<p>test message D</p>",
|
||||
"<p>personal D</p>",
|
||||
"<p>personal E</p>",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -68,16 +68,16 @@ function expect_home() {
|
||||
|
||||
function expect_stream() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
common.expected_messages('zfilt', [
|
||||
'Verona > frontend test',
|
||||
'Verona > other subject',
|
||||
'Verona > frontend test',
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
common.expected_messages("zfilt", [
|
||||
"Verona > frontend test",
|
||||
"Verona > other subject",
|
||||
"Verona > frontend test",
|
||||
], [
|
||||
'<p>test message A</p>',
|
||||
'<p>test message B</p>',
|
||||
'<p>test message C</p>',
|
||||
'<p>test message D</p>',
|
||||
"<p>test message A</p>",
|
||||
"<p>test message B</p>",
|
||||
"<p>test message C</p>",
|
||||
"<p>test message D</p>",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -85,32 +85,32 @@ function expect_stream() {
|
||||
|
||||
function expect_stream_subject() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
common.expected_messages('zfilt', [
|
||||
'Verona > frontend test',
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
common.expected_messages("zfilt", [
|
||||
"Verona > frontend test",
|
||||
], [
|
||||
'<p>test message A</p>',
|
||||
'<p>test message B</p>',
|
||||
'<p>test message D</p>',
|
||||
"<p>test message A</p>",
|
||||
"<p>test message B</p>",
|
||||
"<p>test message D</p>",
|
||||
]);
|
||||
|
||||
casper.test.assertEquals(casper.fetchText('#left_bar_compose_stream_button_big'), 'New topic');
|
||||
casper.test.assertEquals(casper.fetchText("#left_bar_compose_stream_button_big"), "New topic");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function expect_subject() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
common.expected_messages('zfilt', [
|
||||
'Verona > frontend test',
|
||||
'Denmark > frontend test',
|
||||
'Verona > frontend test',
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
common.expected_messages("zfilt", [
|
||||
"Verona > frontend test",
|
||||
"Denmark > frontend test",
|
||||
"Verona > frontend test",
|
||||
], [
|
||||
'<p>test message A</p>',
|
||||
'<p>test message B</p>',
|
||||
'<p>other message</p>',
|
||||
'<p>test message D</p>',
|
||||
"<p>test message A</p>",
|
||||
"<p>test message B</p>",
|
||||
"<p>other message</p>",
|
||||
"<p>test message D</p>",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -118,13 +118,13 @@ function expect_subject() {
|
||||
|
||||
function expect_huddle() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
common.expected_messages('zfilt', [
|
||||
'You and Cordelia Lear, King Hamlet',
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
common.expected_messages("zfilt", [
|
||||
"You and Cordelia Lear, King Hamlet",
|
||||
], [
|
||||
'<p>personal A</p>',
|
||||
'<p>personal B</p>',
|
||||
'<p>personal D</p>',
|
||||
"<p>personal A</p>",
|
||||
"<p>personal B</p>",
|
||||
"<p>personal D</p>",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -132,12 +132,12 @@ function expect_huddle() {
|
||||
|
||||
function expect_1on1() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
common.expected_messages('zfilt', [
|
||||
'You and Cordelia Lear',
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
common.expected_messages("zfilt", [
|
||||
"You and Cordelia Lear",
|
||||
], [
|
||||
'<p>personal C</p>',
|
||||
'<p>personal E</p>',
|
||||
"<p>personal C</p>",
|
||||
"<p>personal E</p>",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -145,41 +145,41 @@ function expect_1on1() {
|
||||
|
||||
function expect_all_pm() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
common.expected_messages('zfilt', [
|
||||
'You and Cordelia Lear, King Hamlet',
|
||||
'You and Cordelia Lear',
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
common.expected_messages("zfilt", [
|
||||
"You and Cordelia Lear, King Hamlet",
|
||||
"You and Cordelia Lear",
|
||||
], [
|
||||
'<p>personal A</p>',
|
||||
'<p>personal B</p>',
|
||||
'<p>personal C</p>',
|
||||
'<p>personal D</p>',
|
||||
'<p>personal E</p>',
|
||||
"<p>personal A</p>",
|
||||
"<p>personal B</p>",
|
||||
"<p>personal C</p>",
|
||||
"<p>personal D</p>",
|
||||
"<p>personal E</p>",
|
||||
]);
|
||||
|
||||
casper.test.assertEquals(casper.fetchText('#left_bar_compose_stream_button_big'), 'New stream message');
|
||||
casper.test.assertEquals(casper.fetchText("#left_bar_compose_stream_button_big"), "New stream message");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function expect_non_existing_user() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#non_existing_user', function () {
|
||||
casper.waitUntilVisible("#non_existing_user", function () {
|
||||
casper.test.info("Empty feed for non existing user visible.");
|
||||
var expected_message = "\n This user does not exist!" +
|
||||
"\n ";
|
||||
this.test.assertEquals(casper.fetchText('#non_existing_user'), expected_message);
|
||||
this.test.assertEquals(casper.fetchText("#non_existing_user"), expected_message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function expect_non_existing_users() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#non_existing_users', function () {
|
||||
casper.waitUntilVisible("#non_existing_users", function () {
|
||||
casper.test.info("Empty feed for non existing user visible.");
|
||||
var expected_message = "\n One or more of these users do not exist!" +
|
||||
"\n ";
|
||||
this.test.assertEquals(casper.fetchText('#non_existing_users'), expected_message);
|
||||
this.test.assertEquals(casper.fetchText("#non_existing_users"), expected_message);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -188,38 +188,38 @@ function check_narrow_title(title) {
|
||||
return function () {
|
||||
// need to get title tag from HTML
|
||||
// test if it's equal to some string passed in to function
|
||||
casper.test.assertSelectorHasText('title', title, 'Got expected narrow title');
|
||||
casper.test.assertSelectorHasText("title", title, "Got expected narrow title");
|
||||
};
|
||||
}
|
||||
|
||||
function un_narrow() {
|
||||
casper.then(common.un_narrow);
|
||||
expect_home();
|
||||
casper.then(check_narrow_title('home - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("home - Zulip Dev - Zulip"));
|
||||
}
|
||||
|
||||
function search_and_check(str, item, check, narrow_title) {
|
||||
common.select_item_via_typeahead('#search_query', str, item);
|
||||
common.select_item_via_typeahead("#search_query", str, item);
|
||||
check();
|
||||
casper.then(check_narrow_title(narrow_title));
|
||||
un_narrow();
|
||||
}
|
||||
|
||||
function search_silent_user(str, item) {
|
||||
common.select_item_via_typeahead('#search_query', str, item);
|
||||
common.select_item_via_typeahead("#search_query", str, item);
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#silent_user', function () {
|
||||
casper.waitUntilVisible("#silent_user", function () {
|
||||
casper.test.info("Empty feed for silent user visible.");
|
||||
var expected_message = "\n You haven't received any messages sent by this user yet!" +
|
||||
"\n ";
|
||||
this.test.assertEquals(casper.fetchText('#silent_user'), expected_message);
|
||||
this.test.assertEquals(casper.fetchText("#silent_user"), expected_message);
|
||||
});
|
||||
});
|
||||
un_narrow();
|
||||
}
|
||||
|
||||
function search_non_existing_user(str, item) {
|
||||
common.select_item_via_typeahead('#search_query', str, item);
|
||||
common.select_item_via_typeahead("#search_query", str, item);
|
||||
expect_non_existing_user();
|
||||
un_narrow();
|
||||
}
|
||||
@@ -228,248 +228,248 @@ function search_non_existing_user(str, item) {
|
||||
|
||||
casper.then(function () {
|
||||
common.wait_for_receive(function () {
|
||||
casper.test.info('Narrowing by clicking stream');
|
||||
casper.test.info("Narrowing by clicking stream");
|
||||
casper.click('*[title="Narrow to stream \\"Verona\\""]');
|
||||
});
|
||||
});
|
||||
|
||||
expect_stream();
|
||||
|
||||
casper.then(check_narrow_title('Verona - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("Verona - Zulip Dev - Zulip"));
|
||||
|
||||
un_narrow();
|
||||
|
||||
expect_home();
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Narrowing by clicking subject');
|
||||
casper.test.info("Narrowing by clicking subject");
|
||||
casper.click('*[title="Narrow to stream \\"Verona\\", topic \\"frontend test\\""]');
|
||||
});
|
||||
|
||||
expect_stream_subject();
|
||||
|
||||
casper.then(check_narrow_title('frontend test - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("frontend test - Zulip Dev - Zulip"));
|
||||
|
||||
casper.then(function () {
|
||||
// Un-narrow by clicking "Zulip"
|
||||
casper.test.info('Un-narrowing');
|
||||
casper.click('.brand');
|
||||
casper.test.info("Un-narrowing");
|
||||
casper.click(".brand");
|
||||
});
|
||||
|
||||
expect_home();
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Narrowing by clicking personal');
|
||||
casper.test.info("Narrowing by clicking personal");
|
||||
casper.click('*[title="Narrow to your private messages with Cordelia Lear, King Hamlet"]');
|
||||
});
|
||||
|
||||
expect_huddle();
|
||||
|
||||
casper.then(check_narrow_title('Cordelia Lear, King Hamlet - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("Cordelia Lear, King Hamlet - Zulip Dev - Zulip"));
|
||||
|
||||
casper.then(function () {
|
||||
// Un-narrow by clicking "Zulip"
|
||||
casper.test.info('Un-narrowing');
|
||||
casper.click('.brand');
|
||||
casper.test.info("Un-narrowing");
|
||||
casper.click(".brand");
|
||||
});
|
||||
|
||||
expect_home();
|
||||
|
||||
// Narrow by typing in search strings or operators.
|
||||
// Test stream / recipient autocomplete in the search bar
|
||||
search_and_check('Verona', 'Stream', expect_stream,
|
||||
'Verona - Zulip Dev - Zulip');
|
||||
search_and_check("Verona", "Stream", expect_stream,
|
||||
"Verona - Zulip Dev - Zulip");
|
||||
|
||||
search_and_check('Cordelia', 'Private', expect_1on1,
|
||||
'Cordelia Lear - Zulip Dev - Zulip');
|
||||
search_and_check("Cordelia", "Private", expect_1on1,
|
||||
"Cordelia Lear - Zulip Dev - Zulip");
|
||||
|
||||
// Test operators
|
||||
search_and_check('stream:Verona', '', expect_stream,
|
||||
'Verona - Zulip Dev - Zulip');
|
||||
search_and_check("stream:Verona", "", expect_stream,
|
||||
"Verona - Zulip Dev - Zulip");
|
||||
|
||||
search_and_check('stream:Verona subject:frontend+test', '', expect_stream_subject,
|
||||
'frontend test - Zulip Dev - Zulip');
|
||||
search_and_check("stream:Verona subject:frontend+test", "", expect_stream_subject,
|
||||
"frontend test - Zulip Dev - Zulip");
|
||||
|
||||
search_and_check('stream:Verona topic:frontend+test', '', expect_stream_subject,
|
||||
'frontend test - Zulip Dev - Zulip');
|
||||
search_and_check("stream:Verona topic:frontend+test", "", expect_stream_subject,
|
||||
"frontend test - Zulip Dev - Zulip");
|
||||
|
||||
search_and_check('subject:frontend+test', '', expect_subject,
|
||||
'home - Zulip Dev - Zulip');
|
||||
search_and_check("subject:frontend+test", "", expect_subject,
|
||||
"home - Zulip Dev - Zulip");
|
||||
|
||||
search_silent_user('sender:emailgateway@zulip.com', '');
|
||||
search_silent_user("sender:emailgateway@zulip.com", "");
|
||||
|
||||
search_non_existing_user('sender:dummyuser@zulip.com', '');
|
||||
search_non_existing_user("sender:dummyuser@zulip.com", "");
|
||||
|
||||
search_and_check('pm-with:dummyuser@zulip.com', '', expect_non_existing_user, 'Invalid user');
|
||||
search_and_check("pm-with:dummyuser@zulip.com", "", expect_non_existing_user, "Invalid user");
|
||||
|
||||
search_and_check('pm-with:dummyuser@zulip.com,dummyuser2@zulip.com', '', expect_non_existing_users,
|
||||
'Invalid users');
|
||||
search_and_check("pm-with:dummyuser@zulip.com,dummyuser2@zulip.com", "", expect_non_existing_users,
|
||||
"Invalid users");
|
||||
|
||||
// Narrow by clicking the left sidebar.
|
||||
casper.then(function () {
|
||||
casper.test.info('Narrowing with left sidebar');
|
||||
casper.click(get_stream_li("Verona") + ' a');
|
||||
casper.test.info("Narrowing with left sidebar");
|
||||
casper.click(get_stream_li("Verona") + " a");
|
||||
});
|
||||
|
||||
expect_stream();
|
||||
|
||||
casper.then(check_narrow_title('Verona - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("Verona - Zulip Dev - Zulip"));
|
||||
|
||||
casper.thenClick('.top_left_all_messages a');
|
||||
casper.thenClick(".top_left_all_messages a");
|
||||
|
||||
expect_home();
|
||||
|
||||
casper.then(check_narrow_title('home - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("home - Zulip Dev - Zulip"));
|
||||
|
||||
casper.thenClick('.top_left_private_messages a');
|
||||
casper.thenClick(".top_left_private_messages a");
|
||||
|
||||
expect_all_pm();
|
||||
|
||||
casper.then(check_narrow_title('Private messages - Zulip Dev - Zulip'));
|
||||
casper.then(check_narrow_title("Private messages - Zulip Dev - Zulip"));
|
||||
|
||||
un_narrow();
|
||||
|
||||
// Make sure stream search filters the stream list
|
||||
casper.then(function () {
|
||||
casper.test.info('Search streams using left sidebar');
|
||||
casper.test.assertExists('.input-append.notdisplayed', 'Stream filter box not visible initially');
|
||||
casper.click('#streams_header .sidebar-title');
|
||||
casper.test.info("Search streams using left sidebar");
|
||||
casper.test.assertExists(".input-append.notdisplayed", "Stream filter box not visible initially");
|
||||
casper.click("#streams_header .sidebar-title");
|
||||
});
|
||||
|
||||
casper.waitWhileSelector('#streams_list .input-append.notdisplayed', function () {
|
||||
casper.waitWhileSelector("#streams_list .input-append.notdisplayed", function () {
|
||||
casper.test.assertExists(get_stream_li("Denmark"),
|
||||
'Original stream list contains Denmark');
|
||||
"Original stream list contains Denmark");
|
||||
casper.test.assertExists(get_stream_li("Scotland"),
|
||||
'Original stream list contains Scotland');
|
||||
"Original stream list contains Scotland");
|
||||
casper.test.assertExists(get_stream_li("Verona"),
|
||||
'Original stream list contains Verona');
|
||||
"Original stream list contains Verona");
|
||||
});
|
||||
|
||||
// Enter the search box and test highlighted suggestion navigation
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
$('.stream-list-filter').expectOne()
|
||||
$(".stream-list-filter").expectOne()
|
||||
.focus()
|
||||
.trigger($.Event('click'));
|
||||
.trigger($.Event("click"));
|
||||
});
|
||||
});
|
||||
|
||||
casper.waitForSelector('#stream_filters .highlighted_stream', function () {
|
||||
casper.test.info('Suggestion highlighting - initial situation');
|
||||
casper.test.assertExist(get_stream_li("Denmark") + '.highlighted_stream',
|
||||
'Stream Denmark is highlighted');
|
||||
casper.test.assertDoesntExist(get_stream_li("Scotland") + '.highlighted_stream',
|
||||
'Stream Scotland is not highlighted');
|
||||
casper.test.assertDoesntExist(get_stream_li("Verona") + '.highlighted_stream',
|
||||
'Stream Verona is not highlighted');
|
||||
casper.waitForSelector("#stream_filters .highlighted_stream", function () {
|
||||
casper.test.info("Suggestion highlighting - initial situation");
|
||||
casper.test.assertExist(get_stream_li("Denmark") + ".highlighted_stream",
|
||||
"Stream Denmark is highlighted");
|
||||
casper.test.assertDoesntExist(get_stream_li("Scotland") + ".highlighted_stream",
|
||||
"Stream Scotland is not highlighted");
|
||||
casper.test.assertDoesntExist(get_stream_li("Verona") + ".highlighted_stream",
|
||||
"Stream Verona is not highlighted");
|
||||
});
|
||||
|
||||
// Use arrow keys to navigate through suggestions
|
||||
casper.then(function () {
|
||||
function arrow(key) {
|
||||
casper.sendKeys('.stream-list-filter',
|
||||
casper.sendKeys(".stream-list-filter",
|
||||
casper.page.event.key[key],
|
||||
{keepFocus: true});
|
||||
}
|
||||
arrow('Down'); // Denmark -> Scotland
|
||||
arrow('Up'); // Scotland -> Denmark
|
||||
arrow('Up'); // Denmark -> Denmark
|
||||
arrow('Down'); // Denmark -> Scotland
|
||||
arrow("Down"); // Denmark -> Scotland
|
||||
arrow("Up"); // Scotland -> Denmark
|
||||
arrow("Up"); // Denmark -> Denmark
|
||||
arrow("Down"); // Denmark -> Scotland
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitForSelector(get_stream_li("Scotland") + '.highlighted_stream', function () {
|
||||
casper.test.info('Suggestion highlighting - after arrow key navigation');
|
||||
casper.waitForSelector(get_stream_li("Scotland") + ".highlighted_stream", function () {
|
||||
casper.test.info("Suggestion highlighting - after arrow key navigation");
|
||||
casper.test.assertDoesntExist(
|
||||
get_stream_li("Denmark") + '.highlighted_stream',
|
||||
'Stream Denmark is not highlighted');
|
||||
get_stream_li("Denmark") + ".highlighted_stream",
|
||||
"Stream Denmark is not highlighted");
|
||||
casper.test.assertExist(
|
||||
get_stream_li("Scotland") + '.highlighted_stream',
|
||||
'Stream Scotland is highlighted');
|
||||
get_stream_li("Scotland") + ".highlighted_stream",
|
||||
"Stream Scotland is highlighted");
|
||||
casper.test.assertDoesntExist(
|
||||
get_stream_li("Verona") + '.highlighted_stream',
|
||||
'Stream Verona is not highlighted');
|
||||
get_stream_li("Verona") + ".highlighted_stream",
|
||||
"Stream Verona is not highlighted");
|
||||
});
|
||||
});
|
||||
|
||||
// We search for the beginning of "Scotland", not case sensitive
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
$('.stream-list-filter').expectOne()
|
||||
$(".stream-list-filter").expectOne()
|
||||
.focus()
|
||||
.val('sCoT')
|
||||
.trigger($.Event('input'))
|
||||
.trigger($.Event('click'));
|
||||
.val("sCoT")
|
||||
.trigger($.Event("input"))
|
||||
.trigger($.Event("click"));
|
||||
});
|
||||
});
|
||||
|
||||
// There will be no race condition between these two waits because we
|
||||
// expect them to happen in parallel.
|
||||
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
|
||||
casper.test.info('Search term entered');
|
||||
casper.test.info("Search term entered");
|
||||
casper.test.assertDoesntExist(get_stream_li("Denmark"),
|
||||
'Filtered stream list does not contain Denmark');
|
||||
"Filtered stream list does not contain Denmark");
|
||||
});
|
||||
casper.waitWhileVisible(get_stream_li("Verona"), function () {
|
||||
casper.test.assertDoesntExist(get_stream_li("Verona"),
|
||||
'Filtered stream list does not contain Verona');
|
||||
"Filtered stream list does not contain Verona");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.assertExists(get_stream_li("Scotland"),
|
||||
'Filtered stream list does contain Scotland');
|
||||
casper.test.assertExists(get_stream_li("Scotland") + '.highlighted_stream',
|
||||
'Stream Scotland is highlighted');
|
||||
"Filtered stream list does contain Scotland");
|
||||
casper.test.assertExists(get_stream_li("Scotland") + ".highlighted_stream",
|
||||
"Stream Scotland is highlighted");
|
||||
});
|
||||
|
||||
// Clearing the list should give us back all the streams in the list
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
$('.stream-list-filter').expectOne()
|
||||
$(".stream-list-filter").expectOne()
|
||||
.focus()
|
||||
.val('')
|
||||
.trigger($.Event('input'));
|
||||
.val("")
|
||||
.trigger($.Event("input"));
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(get_stream_li("Denmark"), function () {
|
||||
casper.test.assertExists(get_stream_li("Denmark"),
|
||||
'Restored stream list contains Denmark');
|
||||
"Restored stream list contains Denmark");
|
||||
});
|
||||
casper.waitUntilVisible(get_stream_li("Scotland"), function () {
|
||||
casper.test.assertExists(get_stream_li("Denmark"),
|
||||
'Restored stream list contains Scotland');
|
||||
"Restored stream list contains Scotland");
|
||||
});
|
||||
casper.waitUntilVisible(get_stream_li("Verona"), function () {
|
||||
casper.test.assertExists(get_stream_li("Denmark"),
|
||||
'Restored stream list contains Verona');
|
||||
"Restored stream list contains Verona");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
casper.thenClick('#streams_header .sidebar-title');
|
||||
casper.thenClick("#streams_header .sidebar-title");
|
||||
|
||||
casper.waitForSelector('.input-append.notdisplayed', function () {
|
||||
casper.test.assertExists('.input-append.notdisplayed',
|
||||
'Stream filter box not visible after second click');
|
||||
casper.waitForSelector(".input-append.notdisplayed", function () {
|
||||
casper.test.assertExists(".input-append.notdisplayed",
|
||||
"Stream filter box not visible after second click");
|
||||
});
|
||||
|
||||
// We search for the beginning of "Verona", not case sensitive
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
$('.stream-list-filter').expectOne()
|
||||
$(".stream-list-filter").expectOne()
|
||||
.focus()
|
||||
.val('ver')
|
||||
.trigger($.Event('input'));
|
||||
.val("ver")
|
||||
.trigger($.Event("input"));
|
||||
});
|
||||
});
|
||||
|
||||
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
|
||||
// Clicking the narrowed list should clear the search
|
||||
casper.click(get_stream_li("Verona") + ' a');
|
||||
casper.click(get_stream_li("Verona") + " a");
|
||||
expect_stream();
|
||||
casper.test.assertEquals(casper.fetchText('.stream-list-filter'), '', 'Clicking on a stream clears the search');
|
||||
casper.test.assertEquals(casper.fetchText(".stream-list-filter"), "", "Clicking on a stream clears the search");
|
||||
});
|
||||
|
||||
un_narrow();
|
||||
@@ -477,14 +477,14 @@ un_narrow();
|
||||
function assert_in_list(name) {
|
||||
casper.test.assertExists(
|
||||
'#user_presences li [data-name="' + name + '"]',
|
||||
'User ' + name + ' is IN buddy list'
|
||||
"User " + name + " is IN buddy list"
|
||||
);
|
||||
}
|
||||
|
||||
function assert_selected(name) {
|
||||
casper.test.assertExists(
|
||||
'#user_presences li.highlighted_user [data-name="' + name + '"]',
|
||||
'User ' + name + ' is SELECTED IN buddy list'
|
||||
"User " + name + " is SELECTED IN buddy list"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -492,42 +492,42 @@ function assert_not_selected(name) {
|
||||
assert_in_list(name);
|
||||
casper.test.assertDoesntExist(
|
||||
'#user_presences li.highlighted_user [data-name="' + name + '"]',
|
||||
'User ' + name + ' is NOT SELECTED buddy list'
|
||||
"User " + name + " is NOT SELECTED buddy list"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// User search at the right sidebar
|
||||
casper.then(function () {
|
||||
casper.test.info('Search users using right sidebar');
|
||||
assert_in_list('Iago');
|
||||
assert_in_list('Cordelia Lear');
|
||||
assert_in_list('King Hamlet');
|
||||
assert_in_list('aaron');
|
||||
casper.test.info("Search users using right sidebar");
|
||||
assert_in_list("Iago");
|
||||
assert_in_list("Cordelia Lear");
|
||||
assert_in_list("King Hamlet");
|
||||
assert_in_list("aaron");
|
||||
});
|
||||
|
||||
// Enter the search box and test selected suggestion navigation
|
||||
// Click on search icon
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
$('#user_filter_icon').expectOne()
|
||||
$("#user_filter_icon").expectOne()
|
||||
.focus()
|
||||
.trigger($.Event('click'));
|
||||
.trigger($.Event("click"));
|
||||
});
|
||||
});
|
||||
|
||||
casper.waitForSelector('#user_presences .highlighted_user', function () {
|
||||
casper.test.info('Suggestion highlighting - initial situation');
|
||||
assert_selected('Iago');
|
||||
assert_not_selected('Cordelia Lear');
|
||||
assert_not_selected('King Hamlet');
|
||||
assert_not_selected('aaron');
|
||||
casper.waitForSelector("#user_presences .highlighted_user", function () {
|
||||
casper.test.info("Suggestion highlighting - initial situation");
|
||||
assert_selected("Iago");
|
||||
assert_not_selected("Cordelia Lear");
|
||||
assert_not_selected("King Hamlet");
|
||||
assert_not_selected("aaron");
|
||||
});
|
||||
|
||||
// Use arrow keys to navigate through suggestions
|
||||
casper.then(function () {
|
||||
function arrow(key) {
|
||||
casper.sendKeys('.user-list-filter',
|
||||
casper.sendKeys(".user-list-filter",
|
||||
casper.page.event.key[key],
|
||||
{keepFocus: true});
|
||||
}
|
||||
@@ -537,21 +537,21 @@ casper.then(function () {
|
||||
// Cordelia
|
||||
// Desdemona
|
||||
// Hamlet
|
||||
arrow('Down');
|
||||
arrow('Down');
|
||||
arrow('Up');
|
||||
arrow('Up');
|
||||
arrow('Up'); // does nothing
|
||||
arrow('Down');
|
||||
arrow('Down');
|
||||
arrow('Down');
|
||||
arrow("Down");
|
||||
arrow("Down");
|
||||
arrow("Up");
|
||||
arrow("Up");
|
||||
arrow("Up"); // does nothing
|
||||
arrow("Down");
|
||||
arrow("Down");
|
||||
arrow("Down");
|
||||
});
|
||||
|
||||
casper.waitForSelector('#user_presences li.highlighted_user [data-name="King Hamlet"]', function () {
|
||||
casper.test.info('Suggestion highlighting - after arrow key navigation');
|
||||
assert_not_selected('Iago');
|
||||
assert_not_selected('Cordelia Lear');
|
||||
assert_selected('King Hamlet');
|
||||
casper.test.info("Suggestion highlighting - after arrow key navigation");
|
||||
assert_not_selected("Iago");
|
||||
assert_not_selected("Cordelia Lear");
|
||||
assert_selected("King Hamlet");
|
||||
});
|
||||
|
||||
common.then_log_out();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -10,14 +10,14 @@ casper.then(function () {
|
||||
|
||||
casper.then(function () {
|
||||
msgs_qty = this.evaluate(function () {
|
||||
return $('#zhome .message_row').length;
|
||||
return $("#zhome .message_row").length;
|
||||
});
|
||||
});
|
||||
|
||||
// Send a message to try replying to
|
||||
common.then_send_many([
|
||||
{ stream: 'Verona',
|
||||
subject: 'Reply test',
|
||||
{ stream: "Verona",
|
||||
subject: "Reply test",
|
||||
content: "We reply to this message",
|
||||
},
|
||||
{ recipient: "cordelia@zulip.com",
|
||||
@@ -28,65 +28,65 @@ common.then_send_many([
|
||||
casper.then(function () {
|
||||
casper.waitFor(function check_length() {
|
||||
return casper.evaluate(function (expected_length) {
|
||||
return $('#zhome .message_row').length === expected_length;
|
||||
return $("#zhome .message_row").length === expected_length;
|
||||
}, msgs_qty + 2);
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
// TODO: Test opening the compose box from the left side buttons
|
||||
casper.click('body');
|
||||
casper.page.sendEvent('keypress', "c");
|
||||
casper.click("body");
|
||||
casper.page.sendEvent("keypress", "c");
|
||||
});
|
||||
|
||||
|
||||
function check_compose_is_cleared() {
|
||||
common.check_form(
|
||||
'#send_message_form',
|
||||
"#send_message_form",
|
||||
{
|
||||
stream_message_recipient_stream: '',
|
||||
stream_message_recipient_topic: '',
|
||||
stream_message_recipient_stream: "",
|
||||
stream_message_recipient_topic: "",
|
||||
},
|
||||
"Stream empty on new compose"
|
||||
);
|
||||
}
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#compose', function () {
|
||||
casper.test.assertVisible('#stream-message', 'Stream input box visible');
|
||||
casper.waitUntilVisible("#compose", function () {
|
||||
casper.test.assertVisible("#stream-message", "Stream input box visible");
|
||||
check_compose_is_cleared();
|
||||
casper.click('body');
|
||||
casper.page.sendEvent('keypress', "x");
|
||||
casper.click("body");
|
||||
casper.page.sendEvent("keypress", "x");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#private_message_recipient', function () {
|
||||
casper.waitUntilVisible("#private_message_recipient", function () {
|
||||
common.pm_recipient.expect("");
|
||||
casper.click('body');
|
||||
casper.page.sendEvent('keypress', 'c');
|
||||
casper.click("body");
|
||||
casper.page.sendEvent("keypress", "c");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#stream-message', function () {
|
||||
casper.waitUntilVisible("#stream-message", function () {
|
||||
check_compose_is_cleared();
|
||||
|
||||
// Check that when you reply to a message it pre-populates the stream and subject fields
|
||||
casper.click('body');
|
||||
casper.click("body");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible('#stream-message', function () {
|
||||
casper.waitWhileVisible("#stream-message", function () {
|
||||
casper.clickLabel("We reply to this message");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#stream-message', function () {
|
||||
casper.waitUntilVisible("#stream-message", function () {
|
||||
common.check_form(
|
||||
'#send_message_form',
|
||||
"#send_message_form",
|
||||
{
|
||||
stream_message_recipient_stream: "Verona",
|
||||
stream_message_recipient_topic: "Reply test",
|
||||
@@ -94,25 +94,25 @@ casper.then(function () {
|
||||
"Stream populated after reply by click"
|
||||
);
|
||||
// Or recipient field
|
||||
casper.click('body');
|
||||
casper.click("body");
|
||||
casper.clickLabel("And reply to this message");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#private_message_recipient', function () {
|
||||
casper.waitUntilVisible("#private_message_recipient", function () {
|
||||
common.pm_recipient.expect("cordelia@zulip.com");
|
||||
|
||||
common.keypress(27); //escape
|
||||
casper.page.sendEvent('keypress', 'k');
|
||||
casper.page.sendEvent('keypress', 'r');
|
||||
casper.page.sendEvent("keypress", "k");
|
||||
casper.page.sendEvent("keypress", "r");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#stream-message', function () {
|
||||
casper.waitUntilVisible("#stream-message", function () {
|
||||
common.check_form(
|
||||
'#send_message_form',
|
||||
"#send_message_form",
|
||||
{
|
||||
stream_message_recipient_stream: "Verona",
|
||||
stream_message_recipient_topic: "Reply test",
|
||||
@@ -121,21 +121,21 @@ casper.then(function () {
|
||||
);
|
||||
|
||||
// Test "closing" the compose box
|
||||
casper.click('body');
|
||||
casper.click("body");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible('#stream-message', function () {
|
||||
casper.test.assertNotVisible('#stream-message', 'Close stream compose box');
|
||||
casper.page.sendEvent('keypress', "x");
|
||||
casper.click('body');
|
||||
casper.waitWhileVisible("#stream-message", function () {
|
||||
casper.test.assertNotVisible("#stream-message", "Close stream compose box");
|
||||
casper.page.sendEvent("keypress", "x");
|
||||
casper.click("body");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible('#private-message', function () {
|
||||
casper.test.assertNotVisible('#private-message', 'Close PM compose box');
|
||||
casper.waitWhileVisible("#private-message", function () {
|
||||
casper.test.assertNotVisible("#private-message", "Close PM compose box");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -145,32 +145,32 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
var cordelia_user_id = common.get_user_id('cordelia@zulip.com');
|
||||
var cordelia_user_id = common.get_user_id("cordelia@zulip.com");
|
||||
var pm_li = 'li[data-user-ids-string="' + cordelia_user_id + '"].expanded_private_message.active-sub-filter';
|
||||
|
||||
casper.waitUntilVisible(pm_li, function () {
|
||||
casper.page.sendEvent('keypress', 'c');
|
||||
casper.page.sendEvent("keypress", "c");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#compose', function () {
|
||||
casper.waitUntilVisible("#compose", function () {
|
||||
casper.test.assertEval(function () {
|
||||
return document.activeElement === $('.compose_table #stream_message_recipient_stream')[0];
|
||||
}, 'Stream box focused after narrowing to PMs with a user and pressing `c`');
|
||||
return document.activeElement === $(".compose_table #stream_message_recipient_stream")[0];
|
||||
}, "Stream box focused after narrowing to PMs with a user and pressing `c`");
|
||||
});
|
||||
});
|
||||
|
||||
// Make sure multiple PM recipients display properly.
|
||||
var recipients = ['cordelia@zulip.com', 'othello@zulip.com'];
|
||||
var recipients = ["cordelia@zulip.com", "othello@zulip.com"];
|
||||
casper.then(function () {
|
||||
common.keypress(27); // escape to dismiss compose box
|
||||
});
|
||||
casper.waitWhileVisible('.message_comp');
|
||||
common.then_send_message('private', {
|
||||
recipient: recipients.join(','),
|
||||
casper.waitWhileVisible(".message_comp");
|
||||
common.then_send_message("private", {
|
||||
recipient: recipients.join(","),
|
||||
outside_view: true,
|
||||
content: 'A huddle to check spaces',
|
||||
content: "A huddle to check spaces",
|
||||
});
|
||||
|
||||
|
||||
@@ -180,39 +180,39 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
common.un_narrow();
|
||||
});
|
||||
casper.waitUntilVisible('#zhome', function () {
|
||||
casper.clickLabel('A huddle to check spaces');
|
||||
casper.waitUntilVisible("#zhome", function () {
|
||||
casper.clickLabel("A huddle to check spaces");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#compose', function () {
|
||||
common.pm_recipient.expect(recipients.join(','));
|
||||
casper.waitUntilVisible("#compose", function () {
|
||||
common.pm_recipient.expect(recipients.join(","));
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#markdown_preview', function () {
|
||||
casper.test.assertNotVisible('#undo_markdown_preview', 'Write button is hidden');
|
||||
casper.waitUntilVisible("#markdown_preview", function () {
|
||||
casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden");
|
||||
casper.click("#markdown_preview");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible("#markdown_preview", function () {
|
||||
casper.test.assertVisible('#undo_markdown_preview', 'Write button is visible');
|
||||
casper.test.assertEquals(casper.getHTML('#preview_content'), "Nothing to preview", "Nothing to preview");
|
||||
casper.test.assertVisible("#undo_markdown_preview", "Write button is visible");
|
||||
casper.test.assertEquals(casper.getHTML("#preview_content"), "Nothing to preview", "Nothing to preview");
|
||||
casper.click("#undo_markdown_preview");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible("#undo_markdown_preview", function () {
|
||||
casper.test.assertVisible('#markdown_preview', 'Preview button is visible.');
|
||||
casper.test.assertNotVisible('#undo_markdown_preview', 'Write button is hidden.');
|
||||
casper.test.assertEquals(casper.getHTML('#preview_content'), "", "Markdown preview area is empty");
|
||||
casper.test.assertVisible("#markdown_preview", "Preview button is visible.");
|
||||
casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden.");
|
||||
casper.test.assertEquals(casper.getHTML("#preview_content"), "", "Markdown preview area is empty");
|
||||
|
||||
casper.fill('form[action^="/json/messages"]', {
|
||||
content: '**Markdown Preview** >> Test for markdown preview',
|
||||
content: "**Markdown Preview** >> Test for markdown preview",
|
||||
}, false);
|
||||
|
||||
casper.click("#markdown_preview");
|
||||
@@ -221,7 +221,7 @@ casper.then(function () {
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitForSelectorTextChange("#preview_content", function () {
|
||||
casper.test.assertEquals(casper.getHTML('#preview_content'), "<p><strong>Markdown Preview</strong> >> Test for markdown preview</p>", "Check markdown is previewed properly");
|
||||
casper.test.assertEquals(casper.getHTML("#preview_content"), "<p><strong>Markdown Preview</strong> >> Test for markdown preview</p>", "Check markdown is previewed properly");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
function stream_checkbox(stream_name) {
|
||||
const stream_id = common.get_stream_id(stream_name);
|
||||
@@ -6,7 +6,7 @@ function stream_checkbox(stream_name) {
|
||||
}
|
||||
|
||||
function stream_span(stream_name) {
|
||||
return stream_checkbox(stream_name) + ' input ~ span';
|
||||
return stream_checkbox(stream_name) + " input ~ span";
|
||||
}
|
||||
|
||||
function user_checkbox(email) {
|
||||
@@ -15,13 +15,13 @@ function user_checkbox(email) {
|
||||
}
|
||||
|
||||
function user_span(email) {
|
||||
return user_checkbox(email) + ' input ~ span';
|
||||
return user_checkbox(email) + " input ~ span";
|
||||
}
|
||||
|
||||
function is_checked(email) {
|
||||
var sel = user_checkbox(email);
|
||||
return casper.evaluate(function (sel) {
|
||||
return $(sel).find('input')[0].checked;
|
||||
return $(sel).find("input")[0].checked;
|
||||
}, {
|
||||
sel: sel,
|
||||
});
|
||||
@@ -30,9 +30,9 @@ function is_checked(email) {
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.then(function () {
|
||||
var menu_selector = '#settings-dropdown';
|
||||
var menu_selector = "#settings-dropdown";
|
||||
|
||||
casper.test.info('Streams page');
|
||||
casper.test.info("Streams page");
|
||||
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
@@ -40,156 +40,156 @@ casper.then(function () {
|
||||
casper.click('a[href^="#streams"]');
|
||||
casper.test.assertUrlMatch(
|
||||
/^http:\/\/[^/]+\/#streams/,
|
||||
'URL suggests we are on streams page');
|
||||
casper.waitUntilVisible('#subscription_overlay.new-style', function () {
|
||||
casper.test.assertExists('#subscription_overlay.new-style', 'Streams page is active');
|
||||
"URL suggests we are on streams page");
|
||||
casper.waitUntilVisible("#subscription_overlay.new-style", function () {
|
||||
casper.test.assertExists("#subscription_overlay.new-style", "Streams page is active");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
casper.waitUntilVisible('.sub_unsub_button.checked', function () {
|
||||
casper.test.assertExists('.sub_unsub_button.checked', 'Initial subscriptions loaded');
|
||||
casper.click('#add_new_subscription .create_stream_button');
|
||||
casper.waitUntilVisible(".sub_unsub_button.checked", function () {
|
||||
casper.test.assertExists(".sub_unsub_button.checked", "Initial subscriptions loaded");
|
||||
casper.click("#add_new_subscription .create_stream_button");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.assertExists(user_checkbox('cordelia@zulip.com'), 'Original user list contains Cordelia');
|
||||
casper.test.assertExists(user_checkbox('othello@zulip.com'), 'Original user list contains Othello');
|
||||
casper.test.assertExists(user_checkbox("cordelia@zulip.com"), "Original user list contains Cordelia");
|
||||
casper.test.assertExists(user_checkbox("othello@zulip.com"), "Original user list contains Othello");
|
||||
});
|
||||
|
||||
casper.waitUntilVisible("#copy-from-stream-expand-collapse", function () {
|
||||
casper.click('#copy-from-stream-expand-collapse');
|
||||
casper.click("#copy-from-stream-expand-collapse");
|
||||
});
|
||||
|
||||
casper.waitUntilVisible("#stream-checkboxes", function () {
|
||||
casper.test.assertExists(stream_checkbox('Scotland'), 'Original stream list contains Scotland');
|
||||
casper.test.assertExists(stream_checkbox('Rome'), 'Original stream list contains Rome');
|
||||
casper.test.assertExists(stream_checkbox("Scotland"), "Original stream list contains Scotland");
|
||||
casper.test.assertExists(stream_checkbox("Rome"), "Original stream list contains Rome");
|
||||
});
|
||||
|
||||
casper.waitUntilVisible("form#stream_creation_form", function () {
|
||||
casper.test.info("Filtering with keyword 'ot'");
|
||||
casper.fill('form#stream_creation_form', {user_list_filter: 'ot'});
|
||||
casper.fill("form#stream_creation_form", {user_list_filter: "ot"});
|
||||
});
|
||||
casper.waitUntilVisible("#user-checkboxes", function () {
|
||||
casper.test.assertEquals(casper.visible(user_checkbox('cordelia@zulip.com')),
|
||||
casper.test.assertEquals(casper.visible(user_checkbox("cordelia@zulip.com")),
|
||||
false,
|
||||
"Cordelia is not visible");
|
||||
casper.test.assertEquals(casper.visible(user_checkbox('othello@zulip.com')),
|
||||
casper.test.assertEquals(casper.visible(user_checkbox("othello@zulip.com")),
|
||||
true,
|
||||
"Othello is visible");
|
||||
|
||||
/* The filter should not impact streams */
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox('Scotland')),
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox("Scotland")),
|
||||
true,
|
||||
"Scotland is visible");
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox('Rome')),
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox("Rome")),
|
||||
true,
|
||||
"Rome is visible");
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.test.info("Check Uncheck only visible users for new stream");
|
||||
casper.click('.subs_set_all_users');
|
||||
casper.click(".subs_set_all_users");
|
||||
casper.wait(100, function () {
|
||||
casper.test.assert(
|
||||
!is_checked('cordelia@zulip.com'),
|
||||
!is_checked("cordelia@zulip.com"),
|
||||
"Cordelia is unchecked");
|
||||
casper.test.assert(
|
||||
is_checked('othello@zulip.com'),
|
||||
is_checked("othello@zulip.com"),
|
||||
"Othello is checked");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.test.info("Check Uncheck only visible users for new stream");
|
||||
casper.click('.subs_unset_all_users');
|
||||
casper.click(".subs_unset_all_users");
|
||||
casper.wait(100, function () {
|
||||
casper.test.assert(
|
||||
!is_checked('othello@zulip.com'),
|
||||
!is_checked("othello@zulip.com"),
|
||||
"Othello is unchecked");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.test.info("Clearing user filter search box");
|
||||
casper.fill('form#stream_creation_form', {user_list_filter: ''});
|
||||
casper.fill("form#stream_creation_form", {user_list_filter: ""});
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.test.assertEquals(casper.visible(user_checkbox('cordelia@zulip.com')),
|
||||
casper.test.assertEquals(casper.visible(user_checkbox("cordelia@zulip.com")),
|
||||
true,
|
||||
"Cordelia is visible again");
|
||||
casper.test.assertEquals(casper.visible(user_checkbox('othello@zulip.com')),
|
||||
casper.test.assertEquals(casper.visible(user_checkbox("othello@zulip.com")),
|
||||
true,
|
||||
"Othello is visible again");
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox('Scotland')),
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox("Scotland")),
|
||||
true,
|
||||
"Scotland is visible again");
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox('Rome')),
|
||||
casper.test.assertEquals(casper.visible(stream_checkbox("Rome")),
|
||||
true,
|
||||
"Rome is visible again");
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#stream_creation_form', function () {
|
||||
casper.test.assertTextExists('Create stream', 'New stream creation panel');
|
||||
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio', stream_description: 'Oimeesaw'});
|
||||
casper.click(stream_span('Scotland'));
|
||||
casper.click(user_span('cordelia@zulip.com'));
|
||||
casper.click(user_span('othello@zulip.com'));
|
||||
casper.click('form#stream_creation_form button.button.sea-green');
|
||||
casper.waitUntilVisible("#stream_creation_form", function () {
|
||||
casper.test.assertTextExists("Create stream", "New stream creation panel");
|
||||
casper.fill("form#stream_creation_form", {stream_name: "Waseemio", stream_description: "Oimeesaw"});
|
||||
casper.click(stream_span("Scotland"));
|
||||
casper.click(user_span("cordelia@zulip.com"));
|
||||
casper.click(user_span("othello@zulip.com"));
|
||||
casper.click("form#stream_creation_form button.button.sea-green");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitFor(function () {
|
||||
return casper.evaluate(function () {
|
||||
return $('.stream-name').is(':contains("Waseemio")');
|
||||
return $(".stream-name").is(':contains("Waseemio")');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info("User should be subscribed to stream Waseemio");
|
||||
casper.test.assertSelectorHasText('.stream-name', 'Waseemio');
|
||||
casper.test.assertSelectorHasText('.description', 'Oimeesaw');
|
||||
casper.test.assertSelectorHasText(".stream-name", "Waseemio");
|
||||
casper.test.assertSelectorHasText(".description", "Oimeesaw");
|
||||
// Based on the selected checkboxes while creating stream,
|
||||
// 4 users from Scotland are added.
|
||||
// 1 user, Cordelia, is added. Othello (subscribed to Scotland) is removed.
|
||||
// FIXME: This assertion may pick up the count from a random other stream.
|
||||
casper.test.assertSelectorHasText('.subscriber-count-text', '4');
|
||||
casper.fill('form#stream_creation_form', {stream_name: ' '});
|
||||
casper.click('form#stream_creation_form button.button.sea-green');
|
||||
casper.test.assertSelectorHasText(".subscriber-count-text", "4");
|
||||
casper.fill("form#stream_creation_form", {stream_name: " "});
|
||||
casper.click("form#stream_creation_form button.button.sea-green");
|
||||
});
|
||||
casper.then(function () {
|
||||
common.wait_for_text('#stream_name_error', 'A stream needs to have a name', function () {
|
||||
casper.test.assertTextExists('A stream needs to have a name', "Can't create a stream with an empty name");
|
||||
casper.click('form#stream_creation_form button.button.white');
|
||||
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio'});
|
||||
casper.click('form#stream_creation_form button.button.sea-green');
|
||||
common.wait_for_text("#stream_name_error", "A stream needs to have a name", function () {
|
||||
casper.test.assertTextExists("A stream needs to have a name", "Can't create a stream with an empty name");
|
||||
casper.click("form#stream_creation_form button.button.white");
|
||||
casper.fill("form#stream_creation_form", {stream_name: "Waseemio"});
|
||||
casper.click("form#stream_creation_form button.button.sea-green");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
common.wait_for_text('#stream_name_error', 'A stream with this name already exists', function () {
|
||||
casper.test.assertTextExists('A stream with this name already exists', "Can't create a stream with a duplicate name");
|
||||
casper.test.info('Streams should be filtered when typing in the create box');
|
||||
casper.click('form#stream_creation_form button.button.white');
|
||||
common.wait_for_text("#stream_name_error", "A stream with this name already exists", function () {
|
||||
casper.test.assertTextExists("A stream with this name already exists", "Can't create a stream with a duplicate name");
|
||||
casper.test.info("Streams should be filtered when typing in the create box");
|
||||
casper.click("form#stream_creation_form button.button.white");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
common.wait_for_text('#search_stream_name', '', function () {
|
||||
casper.test.assertSelectorHasText('.stream-row[data-stream-name="Verona"] .stream-name', 'Verona', 'Verona stream exists before filtering');
|
||||
casper.test.assertSelectorDoesntHaveText('.stream-row.notdisplayed .stream-name', 'Verona', 'Verona stream shown before filtering');
|
||||
common.wait_for_text("#search_stream_name", "", function () {
|
||||
casper.test.assertSelectorHasText('.stream-row[data-stream-name="Verona"] .stream-name', "Verona", "Verona stream exists before filtering");
|
||||
casper.test.assertSelectorDoesntHaveText(".stream-row.notdisplayed .stream-name", "Verona", "Verona stream shown before filtering");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
$('#stream_filter input[type="text"]')
|
||||
.expectOne()
|
||||
.val('waseem')
|
||||
.trigger($.Event('input'));
|
||||
.val("waseem")
|
||||
.trigger($.Event("input"));
|
||||
});
|
||||
});
|
||||
casper.waitForSelectorTextChange('.streams-list', function () {
|
||||
casper.test.assertSelectorHasText('.stream-row .stream-name', 'Waseemio', 'Waseemio stream exists after filtering');
|
||||
casper.test.assertSelectorHasText('.stream-row.notdisplayed .stream-name', 'Verona', 'Verona stream not shown after filtering');
|
||||
casper.test.assertSelectorDoesntHaveText('.stream-row.notdisplayed .stream-name', 'Waseemio', 'Waseemio stream shown after filtering');
|
||||
casper.waitForSelectorTextChange(".streams-list", function () {
|
||||
casper.test.assertSelectorHasText(".stream-row .stream-name", "Waseemio", "Waseemio stream exists after filtering");
|
||||
casper.test.assertSelectorHasText(".stream-row.notdisplayed .stream-name", "Verona", "Verona stream not shown after filtering");
|
||||
casper.test.assertSelectorDoesntHaveText(".stream-row.notdisplayed .stream-name", "Waseemio", "Waseemio stream shown after filtering");
|
||||
});
|
||||
|
||||
common.then_log_out();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
|
||||
var OUTGOING_WEBHOOK_BOT_TYPE = '3';
|
||||
var GENERIC_BOT_TYPE = '1';
|
||||
var common = require("../casper_lib/common.js");
|
||||
var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
|
||||
var OUTGOING_WEBHOOK_BOT_TYPE = "3";
|
||||
var GENERIC_BOT_TYPE = "1";
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -13,7 +13,7 @@ var regex_outgoing_webhook_zuliprc = /^data:application\/octet-stream;charset=ut
|
||||
var regex_botserverrc = /^data:application\/octet-stream;charset=utf-8,\[\]\nemail=.+\nkey=.+\nsite=.+\ntoken=.+\n$/;
|
||||
|
||||
casper.then(function () {
|
||||
var menu_selector = '#settings-dropdown';
|
||||
var menu_selector = "#settings-dropdown";
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
});
|
||||
@@ -21,20 +21,20 @@ casper.then(function () {
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('a[href^="#settings"]', function () {
|
||||
casper.test.info('Settings page');
|
||||
casper.test.info("Settings page");
|
||||
casper.click('a[href^="#settings"]');
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible("#settings_content .account-settings-form", function () {
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#settings/, 'URL suggests we are on settings page');
|
||||
casper.test.assertVisible('.account-settings-form', 'Settings page is active');
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#settings/, "URL suggests we are on settings page");
|
||||
casper.test.assertVisible(".account-settings-form", "Settings page is active");
|
||||
|
||||
casper.test.assertNotVisible("#pw_change_controls");
|
||||
|
||||
// casper.click(".change_password_button");
|
||||
casper.click('#api_key_button');
|
||||
casper.click("#api_key_button");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,15 +67,15 @@ casper.then(function () {
|
||||
*/
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#get_api_key_button', function () {
|
||||
casper.fill('#api_key_form', {password: test_credentials.default_user.password});
|
||||
casper.click('#get_api_key_button');
|
||||
casper.waitUntilVisible("#get_api_key_button", function () {
|
||||
casper.fill("#api_key_form", {password: test_credentials.default_user.password});
|
||||
casper.click("#get_api_key_button");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#show_api_key', function () {
|
||||
casper.test.assertMatch(casper.fetchText('#api_key_value'), /[a-zA-Z0-9]{32}/, "Looks like an API key");
|
||||
casper.waitUntilVisible("#show_api_key", function () {
|
||||
casper.test.assertMatch(casper.fetchText("#api_key_value"), /[a-zA-Z0-9]{32}/, "Looks like an API key");
|
||||
|
||||
/*
|
||||
// Change it all back so the next test can still log in
|
||||
@@ -90,23 +90,23 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#show_api_key', function () {
|
||||
casper.test.assertExists('#download_zuliprc', '~/.zuliprc button exists');
|
||||
casper.click('#download_zuliprc');
|
||||
casper.waitUntilVisible("#show_api_key", function () {
|
||||
casper.test.assertExists("#download_zuliprc", "~/.zuliprc button exists");
|
||||
casper.click("#download_zuliprc");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#download_zuliprc[href^="data:application"]', function () {
|
||||
casper.test.assertMatch(
|
||||
decodeURIComponent(casper.getElementsAttribute('#download_zuliprc', 'href')),
|
||||
decodeURIComponent(casper.getElementsAttribute("#download_zuliprc", "href")),
|
||||
regex_zuliprc,
|
||||
'Looks like a zuliprc file');
|
||||
"Looks like a zuliprc file");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.click('#api_key_modal .close');
|
||||
casper.click("#api_key_modal .close");
|
||||
|
||||
// casper.waitUntilVisible('#account-settings-status', function () {
|
||||
casper.click('[data-section="your-bots"]');
|
||||
@@ -114,20 +114,20 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function create_bot() {
|
||||
casper.test.info('Filling out the create bot form for an outgoing webhook bot');
|
||||
casper.test.info("Filling out the create bot form for an outgoing webhook bot");
|
||||
|
||||
casper.fill('#create_bot_form', {
|
||||
bot_name: 'Bot 1',
|
||||
bot_short_name: '1',
|
||||
casper.fill("#create_bot_form", {
|
||||
bot_name: "Bot 1",
|
||||
bot_short_name: "1",
|
||||
bot_type: OUTGOING_WEBHOOK_BOT_TYPE,
|
||||
payload_url: 'http://hostname.example.com/bots/followup',
|
||||
payload_url: "http://hostname.example.com/bots/followup",
|
||||
});
|
||||
|
||||
casper.test.info('Submitting the create bot form');
|
||||
casper.click('#create_bot_button');
|
||||
casper.test.info("Submitting the create bot form");
|
||||
casper.click("#create_bot_button");
|
||||
});
|
||||
|
||||
var bot_email = '1-bot@zulip.testserver';
|
||||
var bot_email = "1-bot@zulip.testserver";
|
||||
var button_sel = '.download_bot_zuliprc[data-email="' + bot_email + '"]';
|
||||
|
||||
casper.then(function () {
|
||||
@@ -139,26 +139,26 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(button_sel + '[href^="data:application"]', function () {
|
||||
casper.test.assertMatch(
|
||||
decodeURIComponent(casper.getElementsAttribute(button_sel, 'href')),
|
||||
decodeURIComponent(casper.getElementsAttribute(button_sel, "href")),
|
||||
regex_outgoing_webhook_zuliprc,
|
||||
'Looks like an outgoing webhook bot ~/.zuliprc file');
|
||||
"Looks like an outgoing webhook bot ~/.zuliprc file");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function create_bot() {
|
||||
casper.test.info('Filling out the create bot form for a normal bot');
|
||||
casper.test.info("Filling out the create bot form for a normal bot");
|
||||
|
||||
casper.fill('#create_bot_form', {
|
||||
bot_name: 'Bot 2',
|
||||
bot_short_name: '2',
|
||||
casper.fill("#create_bot_form", {
|
||||
bot_name: "Bot 2",
|
||||
bot_short_name: "2",
|
||||
bot_type: GENERIC_BOT_TYPE,
|
||||
});
|
||||
|
||||
casper.test.info('Submitting the create bot form');
|
||||
casper.click('#create_bot_button');
|
||||
casper.test.info("Submitting the create bot form");
|
||||
casper.click("#create_bot_button");
|
||||
});
|
||||
|
||||
var second_bot_email = '2-bot@zulip.testserver';
|
||||
var second_bot_email = "2-bot@zulip.testserver";
|
||||
var second_button_sel = '.download_bot_zuliprc[data-email="' + second_bot_email + '"]';
|
||||
|
||||
casper.then(function () {
|
||||
@@ -170,28 +170,28 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(second_button_sel + '[href^="data:application"]', function () {
|
||||
casper.test.assertMatch(
|
||||
decodeURIComponent(casper.getElementsAttribute(second_button_sel, 'href')),
|
||||
decodeURIComponent(casper.getElementsAttribute(second_button_sel, "href")),
|
||||
regex_zuliprc,
|
||||
'Looks like a bot ~/.zuliprc file');
|
||||
"Looks like a bot ~/.zuliprc file");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#download_botserverrc', function () {
|
||||
casper.waitUntilVisible("#download_botserverrc", function () {
|
||||
casper.click("#download_botserverrc");
|
||||
|
||||
casper.waitUntilVisible('#download_botserverrc[href^="data:application"]', function () {
|
||||
casper.test.assertMatch(
|
||||
decodeURIComponent(casper.getElementsAttribute('#download_botserverrc', 'href')),
|
||||
decodeURIComponent(casper.getElementsAttribute("#download_botserverrc", "href")),
|
||||
regex_botserverrc,
|
||||
'Looks like a botserverrc file');
|
||||
"Looks like a botserverrc file");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.open_edit_bot_form[data-email="' + bot_email + '"]', function open_edit_bot_form() {
|
||||
casper.test.info('Opening edit bot form');
|
||||
casper.test.info("Opening edit bot form");
|
||||
casper.click('.open_edit_bot_form[data-email="' + bot_email + '"]');
|
||||
});
|
||||
});
|
||||
@@ -199,7 +199,7 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.edit_bot_form[data-email="' + bot_email + '"]', function test_edit_bot_form_values() {
|
||||
var form_sel = '.edit_bot_form[data-email="' + bot_email + '"]';
|
||||
casper.test.info('Testing edit bot form values');
|
||||
casper.test.info("Testing edit bot form values");
|
||||
|
||||
// casper.test.assertEqual(
|
||||
// common.get_form_field_value(form_sel + ' [name=bot_name]'),
|
||||
@@ -211,95 +211,95 @@ casper.then(function () {
|
||||
// common.get_form_field_value(form_sel + ' [name=bot_default_events_register_stream]'),
|
||||
// 'Rome');
|
||||
casper.test.assertEqual(
|
||||
common.get_form_field_value(form_sel + ' [name=bot_name]'),
|
||||
'Bot 1');
|
||||
common.get_form_field_value(form_sel + " [name=bot_name]"),
|
||||
"Bot 1");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.click('[data-section="alert-words"]');
|
||||
casper.waitUntilVisible('#create_alert_word_form', function () {
|
||||
casper.test.info('Attempting to submit an empty alert word');
|
||||
casper.click('#create_alert_word_button');
|
||||
casper.waitUntilVisible('#alert_word_status', function () {
|
||||
casper.test.info('Checking that an error is displayed');
|
||||
casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word can\'t be empty!');
|
||||
casper.test.info('Closing the error message');
|
||||
casper.click('.close-alert-word-status');
|
||||
casper.test.info('Checking the error is hidden');
|
||||
casper.test.assertNotVisible('#alert_word_status');
|
||||
casper.waitUntilVisible("#create_alert_word_form", function () {
|
||||
casper.test.info("Attempting to submit an empty alert word");
|
||||
casper.click("#create_alert_word_button");
|
||||
casper.waitUntilVisible("#alert_word_status", function () {
|
||||
casper.test.info("Checking that an error is displayed");
|
||||
casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word can't be empty!");
|
||||
casper.test.info("Closing the error message");
|
||||
casper.click(".close-alert-word-status");
|
||||
casper.test.info("Checking the error is hidden");
|
||||
casper.test.assertNotVisible("#alert_word_status");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Filling out the alert word input');
|
||||
casper.sendKeys('#create_alert_word_name', 'some phrase');
|
||||
casper.click('#create_alert_word_button');
|
||||
casper.test.info('Checking that a success message is displayed');
|
||||
casper.waitUntilVisible('#alert_word_status', function () {
|
||||
casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word "some phrase" added successfully!');
|
||||
casper.test.info('Closing the status message');
|
||||
casper.click('.close-alert-word-status');
|
||||
casper.test.info('Checking the status message is hidden');
|
||||
casper.test.assertNotVisible('#alert_word_status');
|
||||
casper.test.info("Filling out the alert word input");
|
||||
casper.sendKeys("#create_alert_word_name", "some phrase");
|
||||
casper.click("#create_alert_word_button");
|
||||
casper.test.info("Checking that a success message is displayed");
|
||||
casper.waitUntilVisible("#alert_word_status", function () {
|
||||
casper.test.assertSelectorHasText(".alert_word_status_text", 'Alert word "some phrase" added successfully!');
|
||||
casper.test.info("Closing the status message");
|
||||
casper.click(".close-alert-word-status");
|
||||
casper.test.info("Checking the status message is hidden");
|
||||
casper.test.assertNotVisible("#alert_word_status");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Checking that an element was created');
|
||||
casper.test.info("Checking that an element was created");
|
||||
casper.waitUntilVisible(".alert-word-item[data-word='some phrase']", function () {
|
||||
casper.test.assertExists('div.alert-word-information-box');
|
||||
casper.test.assertSelectorHasText('span.value', 'some phrase');
|
||||
casper.test.assertExists("div.alert-word-information-box");
|
||||
casper.test.assertSelectorHasText("span.value", "some phrase");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Trying to create a duplicate alert word');
|
||||
casper.sendKeys('#create_alert_word_name', 'some phrase');
|
||||
casper.click('#create_alert_word_button');
|
||||
casper.test.info('Checking that an error message is displayed');
|
||||
casper.waitUntilVisible('#alert_word_status', function () {
|
||||
casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word already exists!');
|
||||
casper.test.info('Closing the status message');
|
||||
casper.click('.close-alert-word-status');
|
||||
casper.test.info('Checking the status message is hidden');
|
||||
casper.test.assertNotVisible('#alert_word_status');
|
||||
casper.test.info("Trying to create a duplicate alert word");
|
||||
casper.sendKeys("#create_alert_word_name", "some phrase");
|
||||
casper.click("#create_alert_word_button");
|
||||
casper.test.info("Checking that an error message is displayed");
|
||||
casper.waitUntilVisible("#alert_word_status", function () {
|
||||
casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word already exists!");
|
||||
casper.test.info("Closing the status message");
|
||||
casper.click(".close-alert-word-status");
|
||||
casper.test.info("Checking the status message is hidden");
|
||||
casper.test.assertNotVisible("#alert_word_status");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Deleting alert word');
|
||||
casper.click('button.remove-alert-word');
|
||||
casper.test.info('Checking that a success message is displayed');
|
||||
casper.waitUntilVisible('#alert_word_status', function () {
|
||||
casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word removed successfully!');
|
||||
casper.test.info('Closing the status message');
|
||||
casper.click('.close-alert-word-status');
|
||||
casper.test.info('Checking the status message is hidden');
|
||||
casper.test.assertNotVisible('#alert_word_status');
|
||||
casper.test.info("Deleting alert word");
|
||||
casper.click("button.remove-alert-word");
|
||||
casper.test.info("Checking that a success message is displayed");
|
||||
casper.waitUntilVisible("#alert_word_status", function () {
|
||||
casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word removed successfully!");
|
||||
casper.test.info("Closing the status message");
|
||||
casper.click(".close-alert-word-status");
|
||||
casper.test.info("Checking the status message is hidden");
|
||||
casper.test.assertNotVisible("#alert_word_status");
|
||||
});
|
||||
casper.test.info('Checking that the element was deleted');
|
||||
casper.test.info("Checking that the element was deleted");
|
||||
casper.waitWhileVisible(".alert-word-item[data-word='some phrase']", function () {
|
||||
casper.test.assertDoesntExist('div.alert-word-information-box');
|
||||
casper.test.info('Element deleted successfully');
|
||||
casper.test.assertDoesntExist("div.alert-word-information-box");
|
||||
casper.test.info("Element deleted successfully");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function change_default_language() {
|
||||
casper.test.info('Changing the default language');
|
||||
casper.test.info("Changing the default language");
|
||||
casper.click('[data-section="display-settings"]');
|
||||
casper.waitUntilVisible('#default_language');
|
||||
casper.waitUntilVisible("#default_language");
|
||||
});
|
||||
|
||||
casper.thenClick('#default_language');
|
||||
casper.thenClick("#default_language");
|
||||
|
||||
casper.waitUntilVisible('#default_language_modal');
|
||||
casper.waitUntilVisible("#default_language_modal");
|
||||
|
||||
casper.thenClick('a[data-code="zh-hans"]');
|
||||
|
||||
casper.waitUntilVisible('#language-settings-status a', function () {
|
||||
casper.test.assertSelectorHasText('#language-settings-status', 'Saved. Please reload for the change to take effect.');
|
||||
casper.waitUntilVisible("#language-settings-status a", function () {
|
||||
casper.test.assertSelectorHasText("#language-settings-status", "Saved. Please reload for the change to take effect.");
|
||||
casper.test.info("Reloading the page.");
|
||||
casper.reload();
|
||||
});
|
||||
@@ -308,13 +308,13 @@ casper.then(function () {
|
||||
casper.waitUntilVisible("#default_language", function () {
|
||||
casper.test.info("Checking if we are on Chinese page.");
|
||||
casper.test.assertEvalEquals(function () {
|
||||
return $('#default_language_name').text().trim();
|
||||
}, '简体中文');
|
||||
return $("#default_language_name").text().trim();
|
||||
}, "简体中文");
|
||||
casper.test.info("Opening German page through i18n url.");
|
||||
});
|
||||
});
|
||||
|
||||
var settings_url = 'http://zulip.zulipdev.com:9981/de/#settings';
|
||||
var settings_url = "http://zulip.zulipdev.com:9981/de/#settings";
|
||||
|
||||
casper.thenOpen(settings_url);
|
||||
|
||||
@@ -322,27 +322,27 @@ casper.waitUntilVisible("#settings-change-box", function check_url_preference()
|
||||
casper.test.info("Checking the i18n url language precedence.");
|
||||
casper.test.assertEvalEquals(function () {
|
||||
return document.documentElement.lang;
|
||||
}, 'de');
|
||||
}, "de");
|
||||
casper.test.info("English is now the default language");
|
||||
casper.click('[data-section="display-settings"]');
|
||||
});
|
||||
|
||||
casper.thenClick('#default_language');
|
||||
casper.thenClick("#default_language");
|
||||
|
||||
casper.waitUntilVisible('#default_language_modal');
|
||||
casper.waitUntilVisible("#default_language_modal");
|
||||
|
||||
casper.thenClick('a[data-code="en"]');
|
||||
|
||||
/*
|
||||
* Changing the language back to English so that subsequent tests pass.
|
||||
*/
|
||||
casper.waitUntilVisible('#language-settings-status a', function () {
|
||||
casper.test.assertSelectorHasText('#language-settings-status', 'Gespeichert. Bitte lade die Seite neu um die Änderungen zu aktivieren.');
|
||||
casper.waitUntilVisible("#language-settings-status a", function () {
|
||||
casper.test.assertSelectorHasText("#language-settings-status", "Gespeichert. Bitte lade die Seite neu um die Änderungen zu aktivieren.");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('[data-section="notifications"]', function () {
|
||||
casper.test.info('Testing disabled/enabled behavior for Notification sound');
|
||||
casper.test.info("Testing disabled/enabled behavior for Notification sound");
|
||||
casper.click('[data-section="notifications"]');
|
||||
});
|
||||
});
|
||||
@@ -352,13 +352,13 @@ casper.then(function () {
|
||||
// will be off by default.
|
||||
casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
|
||||
|
||||
casper.click('#enable_stream_audible_notifications');
|
||||
casper.click("#enable_stream_audible_notifications");
|
||||
casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
|
||||
|
||||
casper.click('#enable_sounds');
|
||||
casper.click("#enable_sounds");
|
||||
casper.test.assertVisible("#notification_sound:enabled", "Notification sound selector is enabled");
|
||||
|
||||
casper.click('#enable_stream_audible_notifications');
|
||||
casper.click("#enable_stream_audible_notifications");
|
||||
casper.test.assertVisible("#notification_sound:disabled", "Notification sound selector is disabled");
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
function star_count() {
|
||||
return casper.evaluate(function () {
|
||||
@@ -11,22 +11,22 @@ function toggle_test_star_message() {
|
||||
var msg = $('.message_content:contains("test star"):visible').last();
|
||||
|
||||
if (msg.length !== 1) {
|
||||
return 'cannot find test star message';
|
||||
return "cannot find test star message";
|
||||
}
|
||||
|
||||
var star_icon = msg
|
||||
.closest('.messagebox')
|
||||
.find('.star');
|
||||
.closest(".messagebox")
|
||||
.find(".star");
|
||||
|
||||
if (star_icon.length !== 1) {
|
||||
return 'cannot find star icon';
|
||||
return "cannot find star icon";
|
||||
}
|
||||
|
||||
star_icon.click();
|
||||
});
|
||||
|
||||
if (error) {
|
||||
casper.test.info('\n\nERROR: ' + error);
|
||||
casper.test.info("\n\nERROR: " + error);
|
||||
}
|
||||
|
||||
casper.test.assert(!error);
|
||||
@@ -38,10 +38,10 @@ casper.then(function () {
|
||||
casper.test.info("Sending test message");
|
||||
});
|
||||
|
||||
common.then_send_message('stream', {
|
||||
stream: 'Verona',
|
||||
subject: 'stars',
|
||||
content: 'test star',
|
||||
common.then_send_message("stream", {
|
||||
stream: "Verona",
|
||||
subject: "stars",
|
||||
content: "test star",
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
@@ -60,7 +60,7 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zhome .fa-star', function () {
|
||||
casper.waitUntilVisible("#zhome .fa-star", function () {
|
||||
casper.test.assertEquals(star_count(), 1,
|
||||
"Got expected single star count.");
|
||||
|
||||
@@ -68,9 +68,9 @@ casper.then(function () {
|
||||
});
|
||||
});
|
||||
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
// You can narrow to your starred messages.
|
||||
common.expected_messages('zfilt', ['Verona > stars'], ['<p>test star</p>']);
|
||||
common.expected_messages("zfilt", ["Verona > stars"], ["<p>test star</p>"]);
|
||||
common.un_narrow();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
casper.options.verbose = true;
|
||||
casper.options.logLevel = "debug";
|
||||
@@ -8,9 +8,9 @@ common.start_and_log_in();
|
||||
function then_edit_last_message() {
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
var msg = $('#zhome .message_row').last();
|
||||
msg.find('.info').click();
|
||||
$('.popover_edit_message').click();
|
||||
var msg = $("#zhome .message_row").last();
|
||||
msg.find(".info").click();
|
||||
$(".popover_edit_message").click();
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
@@ -20,20 +20,20 @@ function then_edit_last_message() {
|
||||
|
||||
// Send and edit a stream message
|
||||
|
||||
common.then_send_message('stream', {
|
||||
stream: 'Verona',
|
||||
subject: 'edits',
|
||||
content: 'test editing',
|
||||
common.then_send_message("stream", {
|
||||
stream: "Verona",
|
||||
subject: "edits",
|
||||
content: "test editing",
|
||||
});
|
||||
|
||||
then_edit_last_message();
|
||||
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
var msg = $('#zhome .message_row').last();
|
||||
msg.find('.message_edit_topic').val("edited");
|
||||
msg.find('.message_edit_content').val("test edited");
|
||||
msg.find('.message_edit_save').click();
|
||||
var msg = $("#zhome .message_row").last();
|
||||
msg.find(".message_edit_topic").val("edited");
|
||||
msg.find(".message_edit_content").val("test edited");
|
||||
msg.find(".message_edit_save").click();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,20 +41,20 @@ casper.waitWhileVisible("textarea.message_edit_content", function () {
|
||||
casper.test.assertSelectorHasText(".last_message .message_content", "test edited");
|
||||
});
|
||||
|
||||
common.then_send_message('stream', {
|
||||
stream: 'Verona',
|
||||
subject: 'edits',
|
||||
content: '/me test editing one line with me',
|
||||
common.then_send_message("stream", {
|
||||
stream: "Verona",
|
||||
subject: "edits",
|
||||
content: "/me test editing one line with me",
|
||||
});
|
||||
|
||||
then_edit_last_message();
|
||||
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
var msg = $('#zhome .message_row').last();
|
||||
msg.find('.message_edit_topic').val("edited");
|
||||
msg.find('.message_edit_content').val("/me test edited one line with me");
|
||||
msg.find('.message_edit_save').click();
|
||||
var msg = $("#zhome .message_row").last();
|
||||
msg.find(".message_edit_topic").val("edited");
|
||||
msg.find(".message_edit_content").val("/me test edited one line with me");
|
||||
msg.find(".message_edit_save").click();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,7 +62,7 @@ casper.waitWhileVisible("textarea.message_edit_content", function () {
|
||||
casper.test.assertSelectorHasText(".last_message .sender-status", "test edited one line with me");
|
||||
});
|
||||
|
||||
common.then_send_message('private', {
|
||||
common.then_send_message("private", {
|
||||
recipient: "cordelia@zulip.com",
|
||||
content: "test editing pm",
|
||||
});
|
||||
@@ -71,9 +71,9 @@ then_edit_last_message();
|
||||
|
||||
casper.then(function () {
|
||||
casper.evaluate(function () {
|
||||
var msg = $('#zhome .message_row').last();
|
||||
msg.find('.message_edit_content').val("test edited pm");
|
||||
msg.find('.message_edit_save').click();
|
||||
var msg = $("#zhome .message_row").last();
|
||||
msg.find(".message_edit_content").val("test edited pm");
|
||||
msg.find(".message_edit_save").click();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
// Test basic tab navigation.
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Testing navigation');
|
||||
casper.test.info("Testing navigation");
|
||||
});
|
||||
|
||||
function wait_for_tab(tab) {
|
||||
casper.waitForSelector('#' + tab + '.tab-pane.active', function () {
|
||||
casper.test.assertExists('#' + tab + '.tab-pane.active', tab + ' page is active');
|
||||
casper.waitForSelector("#" + tab + ".tab-pane.active", function () {
|
||||
casper.test.assertExists("#" + tab + ".tab-pane.active", tab + " page is active");
|
||||
});
|
||||
}
|
||||
|
||||
function then_navigate_to(click_target, tab) {
|
||||
casper.then(function () {
|
||||
casper.test.info('Visiting #' + click_target);
|
||||
casper.test.info("Visiting #" + click_target);
|
||||
casper.click("a[href='#" + click_target + "']");
|
||||
wait_for_tab(tab);
|
||||
});
|
||||
@@ -24,15 +24,15 @@ function then_navigate_to(click_target, tab) {
|
||||
|
||||
function then_navigate_to_settings() {
|
||||
casper.then(function () {
|
||||
casper.test.info('Navigate to settings');
|
||||
var menu_selector = '#settings-dropdown';
|
||||
casper.test.info("Navigate to settings");
|
||||
var menu_selector = "#settings-dropdown";
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
casper.waitUntilVisible('a[href^="#settings"]', function () {
|
||||
casper.click('a[href^="#settings"]');
|
||||
casper.waitUntilVisible('#settings_page', function () {
|
||||
casper.test.assertExists('#settings_page', "Settings page is active");
|
||||
casper.click('#settings_page .exit');
|
||||
casper.waitUntilVisible("#settings_page", function () {
|
||||
casper.test.assertExists("#settings_page", "Settings page is active");
|
||||
casper.click("#settings_page .exit");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -41,15 +41,15 @@ function then_navigate_to_settings() {
|
||||
|
||||
function then_navigate_to_subscriptions() {
|
||||
casper.then(function () {
|
||||
casper.test.info('Navigate to subscriptions');
|
||||
casper.test.info("Navigate to subscriptions");
|
||||
|
||||
var menu_selector = '#settings-dropdown';
|
||||
var menu_selector = "#settings-dropdown";
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
casper.click('a[href^="#streams"]');
|
||||
casper.waitUntilVisible("#subscription_overlay", function () {
|
||||
casper.test.assertExists('#subscriptions_table', "#subscriptions page is active");
|
||||
casper.click('#subscription_overlay .exit');
|
||||
casper.test.assertExists("#subscriptions_table", "#subscriptions page is active");
|
||||
casper.click("#subscription_overlay .exit");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -62,19 +62,19 @@ then_navigate_to_settings();
|
||||
var verona_narrow;
|
||||
casper.then(function () {
|
||||
var verona_id = casper.evaluate(function () {
|
||||
return stream_data.get_stream_id('Verona');
|
||||
return stream_data.get_stream_id("Verona");
|
||||
});
|
||||
verona_narrow = 'narrow/stream/' + verona_id + '-Verona';
|
||||
verona_narrow = "narrow/stream/" + verona_id + "-Verona";
|
||||
casper.test.info(verona_narrow);
|
||||
|
||||
then_navigate_to(verona_narrow, 'home');
|
||||
then_navigate_to('home', 'home');
|
||||
then_navigate_to(verona_narrow, "home");
|
||||
then_navigate_to("home", "home");
|
||||
then_navigate_to_subscriptions();
|
||||
then_navigate_to('', 'home');
|
||||
then_navigate_to("", "home");
|
||||
then_navigate_to_settings();
|
||||
then_navigate_to('narrow/is/private', 'home');
|
||||
then_navigate_to("narrow/is/private", "home");
|
||||
then_navigate_to_subscriptions();
|
||||
then_navigate_to(verona_narrow, 'home');
|
||||
then_navigate_to(verona_narrow, "home");
|
||||
});
|
||||
|
||||
var initial_page_load_time;
|
||||
@@ -111,7 +111,7 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
casper.waitUntilVisible("#zfilt", function () {
|
||||
// Verify that we're narrowed to the target stream
|
||||
casper.test.assertEquals(orig_hash, hash);
|
||||
casper.test.assertVisible("#zfilt");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -7,11 +7,11 @@ common.manage_organization();
|
||||
function submit_notifications_stream_settings() {
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="unsaved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Save');
|
||||
casper.test.assertSelectorHasText("#org-submit-notifications", "Save");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
casper.click('#org-submit-notifications');
|
||||
casper.click("#org-submit-notifications");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ function submit_notifications_stream_settings() {
|
||||
casper.then(function () {
|
||||
casper.test.info('Changing notifications stream to Verona by filtering with "verona"');
|
||||
casper.click("#realm_notifications_stream_id_widget button.dropdown-toggle");
|
||||
casper.waitUntilVisible('#realm_notifications_stream_id_widget ul.dropdown-menu', function () {
|
||||
casper.sendKeys('#realm_notifications_stream_id_widget .dropdown-search > input[type=text]', 'verona');
|
||||
casper.waitUntilVisible("#realm_notifications_stream_id_widget ul.dropdown-menu", function () {
|
||||
casper.sendKeys("#realm_notifications_stream_id_widget .dropdown-search > input[type=text]", "verona");
|
||||
casper.click("#realm_notifications_stream_id_widget .dropdown-list-body > li:nth-of-type(1)");
|
||||
});
|
||||
});
|
||||
@@ -29,9 +29,9 @@ submit_notifications_stream_settings();
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
@@ -42,17 +42,17 @@ submit_notifications_stream_settings();
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test changing signup notifications stream
|
||||
casper.then(function () {
|
||||
casper.test.info('Changing signup notifications stream to Verona by filtering with "verona"');
|
||||
casper.click("#id_realm_signup_notifications_stream_id > button.dropdown-toggle");
|
||||
casper.waitUntilVisible('#realm_signup_notifications_stream_id_widget ul.dropdown-menu', function () {
|
||||
casper.sendKeys('#realm_signup_notifications_stream_id_widget .dropdown-search > input[type=text]', 'verona');
|
||||
casper.waitUntilVisible("#realm_signup_notifications_stream_id_widget ul.dropdown-menu", function () {
|
||||
casper.sendKeys("#realm_signup_notifications_stream_id_widget .dropdown-search > input[type=text]", "verona");
|
||||
casper.click("#realm_signup_notifications_stream_id_widget .dropdown-list-body li.list_item");
|
||||
});
|
||||
});
|
||||
@@ -61,9 +61,9 @@ submit_notifications_stream_settings();
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
@@ -74,9 +74,9 @@ submit_notifications_stream_settings();
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#org-submit-notifications[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-notifications', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-notifications", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test permissions setting
|
||||
@@ -85,8 +85,8 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
function submit_permissions_change() {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', "Save");
|
||||
casper.click('#org-submit-other-permissions');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Save");
|
||||
casper.click("#org-submit-other-permissions");
|
||||
}
|
||||
|
||||
// Test setting create streams policy to 'admins only'.
|
||||
@@ -104,9 +104,9 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting create streams policy to 'members and admins'.
|
||||
@@ -124,9 +124,9 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting create streams policy to 'full members'.
|
||||
@@ -144,9 +144,9 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting invite to streams policy to 'admins only'.
|
||||
@@ -164,9 +164,9 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting invite to streams policy to 'members and admins'.
|
||||
@@ -184,9 +184,9 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting invite to streams policy to 'full members'.
|
||||
@@ -204,9 +204,9 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting new user threshold to three days.
|
||||
@@ -223,10 +223,10 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertNotVisible('#id_realm_waiting_period_threshold');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
casper.test.assertNotVisible("#id_realm_waiting_period_threshold");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
// Test setting new user threshold to N days.
|
||||
@@ -243,40 +243,40 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
// Test that save worked.
|
||||
casper.waitUntilVisible('#org-submit-other-permissions[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-other-permissions', 'Saved');
|
||||
casper.test.assertVisible('#id_realm_waiting_period_threshold');
|
||||
casper.test.assertSelectorHasText("#org-submit-other-permissions", "Saved");
|
||||
casper.test.assertVisible("#id_realm_waiting_period_threshold");
|
||||
});
|
||||
casper.waitWhileVisible('#org-submit-notifications');
|
||||
casper.waitWhileVisible("#org-submit-notifications");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
// Test custom realm emoji
|
||||
casper.click("li[data-section='emoji-settings']");
|
||||
casper.waitUntilVisible('.admin-emoji-form', function () {
|
||||
casper.fill('form.admin-emoji-form', {
|
||||
name: 'new mouse face',
|
||||
emoji_file_input: 'static/images/logo/zulip-icon-128x128.png',
|
||||
casper.waitUntilVisible(".admin-emoji-form", function () {
|
||||
casper.fill("form.admin-emoji-form", {
|
||||
name: "new mouse face",
|
||||
emoji_file_input: "static/images/logo/zulip-icon-128x128.png",
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('div#admin-emoji-status', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-emoji-status', 'Custom emoji added!');
|
||||
casper.waitUntilVisible("div#admin-emoji-status", function () {
|
||||
casper.test.assertSelectorHasText("div#admin-emoji-status", "Custom emoji added!");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('tr#emoji_new_mouse_face', function () {
|
||||
casper.test.assertSelectorHasText('tr#emoji_new_mouse_face .emoji_name', 'new mouse face');
|
||||
casper.test.assertExists('tr#emoji_new_mouse_face img');
|
||||
casper.click('tr#emoji_new_mouse_face button.delete');
|
||||
casper.waitUntilVisible("tr#emoji_new_mouse_face", function () {
|
||||
casper.test.assertSelectorHasText("tr#emoji_new_mouse_face .emoji_name", "new mouse face");
|
||||
casper.test.assertExists("tr#emoji_new_mouse_face img");
|
||||
casper.click("tr#emoji_new_mouse_face button.delete");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible('tr#emoji_new_mouse_face', function () {
|
||||
casper.test.assertDoesntExist('tr#emoji_new_mouse_face');
|
||||
casper.waitWhileVisible("tr#emoji_new_mouse_face", function () {
|
||||
casper.test.assertDoesntExist("tr#emoji_new_mouse_face");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -284,10 +284,10 @@ var stream_name = "Scotland";
|
||||
function get_suggestions(str) {
|
||||
casper.then(function () {
|
||||
casper.evaluate(function (str) {
|
||||
$('.create_default_stream')
|
||||
$(".create_default_stream")
|
||||
.focus()
|
||||
.val(str)
|
||||
.trigger($.Event('keyup', { which: 0 }));
|
||||
.trigger($.Event("keyup", { which: 0 }));
|
||||
}, str);
|
||||
});
|
||||
}
|
||||
@@ -295,7 +295,7 @@ function get_suggestions(str) {
|
||||
function select_from_suggestions(item) {
|
||||
casper.then(function () {
|
||||
casper.evaluate(function (item) {
|
||||
var tah = $('.create_default_stream').data().typeahead;
|
||||
var tah = $(".create_default_stream").data().typeahead;
|
||||
tah.mouseenter({
|
||||
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
|
||||
});
|
||||
@@ -322,8 +322,8 @@ casper.then(function () {
|
||||
var stream_id = common.get_stream_id(stream_name);
|
||||
var row = ".default_stream_row[data-stream-id='" + stream_id + "']";
|
||||
casper.waitUntilVisible(row, function () {
|
||||
casper.test.assertSelectorHasText(row + ' .default_stream_name', stream_name);
|
||||
casper.click(row + ' button.remove-default-stream');
|
||||
casper.test.assertSelectorHasText(row + " .default_stream_name", stream_name);
|
||||
casper.click(row + " button.remove-default-stream");
|
||||
casper.waitWhileVisible(row, function () {
|
||||
casper.test.assertDoesntExist(row);
|
||||
});
|
||||
@@ -337,16 +337,16 @@ casper.then(function () {
|
||||
casper.click("li[data-section='organization-profile']");
|
||||
var selector = '#realm-icon-upload-widget .image-block[src^="https://secure.gravatar.com/avatar/"]';
|
||||
casper.waitUntilVisible(selector, function () {
|
||||
casper.test.assertEqual(casper.visible('#realm-icon-upload-widget .settings-page-delete-button'), false);
|
||||
casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), false);
|
||||
// Hack: Rather than submitting the form, we just fill the
|
||||
// form and then trigger a click event by clicking the button.
|
||||
casper.fill('form.admin-realm-form', {
|
||||
file_input: 'static/images/logo/zulip-icon-128x128.png',
|
||||
casper.fill("form.admin-realm-form", {
|
||||
file_input: "static/images/logo/zulip-icon-128x128.png",
|
||||
}, false);
|
||||
casper.click("#realm-icon-upload-widget .image_upload_button");
|
||||
casper.waitWhileVisible("#realm-icon-upload-widget .upload-spinner-background", function () {
|
||||
casper.test.assertExists('#realm-icon-upload-widget .image-block[src^="/user_avatars/2/realm/icon.png?version=2"]');
|
||||
casper.test.assertEqual(casper.visible('#realm-icon-upload-widget .settings-page-delete-button'), true);
|
||||
casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -355,30 +355,30 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
casper.click("li[data-section='organization-profile']");
|
||||
casper.click("#realm-icon-upload-widget .settings-page-delete-button");
|
||||
casper.test.assertEqual(casper.visible('#realm-icon-upload-widget .settings-page-delete-button'), true);
|
||||
casper.waitWhileVisible('#realm-icon-upload-widget .settings-page-delete-button', function () {
|
||||
casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), true);
|
||||
casper.waitWhileVisible("#realm-icon-upload-widget .settings-page-delete-button", function () {
|
||||
casper.test.assertExists('#realm-icon-upload-widget .image-block[src^="https://secure.gravatar.com/avatar/"]');
|
||||
casper.test.assertEqual(casper.visible('#realm-icon-upload-widget .settings-page-delete-button'), false);
|
||||
casper.test.assertEqual(casper.visible("#realm-icon-upload-widget .settings-page-delete-button"), false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
casper.then(function () {
|
||||
casper.click("li[data-section='organization-settings']");
|
||||
casper.waitUntilVisible('#id_realm_default_language', function () {
|
||||
casper.waitUntilVisible("#id_realm_default_language", function () {
|
||||
casper.test.info("Changing realm default language");
|
||||
casper.evaluate(function () {
|
||||
$('#id_realm_default_language').val('de').change();
|
||||
$("#id_realm_default_language").val("de").change();
|
||||
});
|
||||
casper.test.assertSelectorHasText('#org-submit-user-defaults', "Save");
|
||||
casper.click('#org-submit-user-defaults');
|
||||
casper.test.assertSelectorHasText("#org-submit-user-defaults", "Save");
|
||||
casper.click("#org-submit-user-defaults");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#org-submit-user-defaults[data-status="saved"]', function () {
|
||||
casper.test.assertSelectorHasText('#org-submit-user-defaults',
|
||||
'Saved');
|
||||
casper.test.assertSelectorHasText("#org-submit-user-defaults",
|
||||
"Saved");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -387,16 +387,16 @@ casper.then(function () {
|
||||
casper.click("li[data-section='auth-methods']");
|
||||
casper.waitUntilVisible(".method_row[data-method='Google'] input[type='checkbox'] + span", function () {
|
||||
casper.click(".method_row[data-method='Google'] input[type='checkbox'] + span");
|
||||
casper.test.assertSelectorHasText('#org-submit-auth_settings', "Save");
|
||||
casper.click('#org-submit-auth_settings');
|
||||
casper.test.assertSelectorHasText("#org-submit-auth_settings", "Save");
|
||||
casper.click("#org-submit-auth_settings");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
// Leave the page and return
|
||||
casper.click('#settings-dropdown');
|
||||
casper.click("#settings-dropdown");
|
||||
casper.click('a[href^="#streams"]');
|
||||
casper.click('#settings-dropdown');
|
||||
casper.click("#settings-dropdown");
|
||||
casper.click('a[href^="#organization"]');
|
||||
casper.click("li[data-section='auth-methods']");
|
||||
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.waitUntilVisible('#zhome', function () {
|
||||
casper.test.info('compose box visible');
|
||||
casper.page.sendEvent('keypress', "c"); // brings up the compose box
|
||||
casper.waitUntilVisible("#zhome", function () {
|
||||
casper.test.info("compose box visible");
|
||||
casper.page.sendEvent("keypress", "c"); // brings up the compose box
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.fill('form[action^="/json/messages"]', {
|
||||
stream_message_recipient_stream: 'Verona',
|
||||
stream_message_recipient_topic: 'Test mention all',
|
||||
stream_message_recipient_stream: "Verona",
|
||||
stream_message_recipient_topic: "Test mention all",
|
||||
});
|
||||
});
|
||||
common.select_item_via_typeahead('#compose-textarea', '@**all**', 'all');
|
||||
common.select_item_via_typeahead("#compose-textarea", "@**all**", "all");
|
||||
|
||||
casper.then(function () {
|
||||
common.turn_off_press_enter_to_send();
|
||||
casper.test.info("Checking for all everyone warning");
|
||||
var stream_size = this.evaluate(function () {
|
||||
return stream_data.get_sub('Verona').subscribers.size;
|
||||
return stream_data.get_sub("Verona").subscribers.size;
|
||||
});
|
||||
casper.test.info(stream_size);
|
||||
var threshold = this.evaluate(function () {
|
||||
@@ -27,26 +27,26 @@ casper.then(function () {
|
||||
return compose.all_everyone_warn_threshold;
|
||||
});
|
||||
casper.test.assertTrue(stream_size > threshold);
|
||||
casper.test.info('Click Send Button');
|
||||
casper.click('#compose-send-button');
|
||||
casper.test.info("Click Send Button");
|
||||
casper.click("#compose-send-button");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
common.wait_for_text(".compose-all-everyone-msg", "Are you sure you want to mention all", function () {
|
||||
casper.test.info('Warning message appears when mentioning @**all**');
|
||||
casper.test.assertSelectorHasText('.compose-all-everyone-msg', 'Are you sure you want to mention all');
|
||||
casper.click('.compose-all-everyone-confirm');
|
||||
casper.test.info("Warning message appears when mentioning @**all**");
|
||||
casper.test.assertSelectorHasText(".compose-all-everyone-msg", "Are you sure you want to mention all");
|
||||
casper.click(".compose-all-everyone-confirm");
|
||||
});
|
||||
|
||||
casper.waitWhileVisible('.compose-all-everyone-confirm', function () {
|
||||
casper.test.info('Check that error messages are gone.');
|
||||
casper.test.assertNotVisible('.compose-all-everyone-msg');
|
||||
casper.test.assertNotVisible('#compose-send-status');
|
||||
casper.waitWhileVisible(".compose-all-everyone-confirm", function () {
|
||||
casper.test.info("Check that error messages are gone.");
|
||||
casper.test.assertNotVisible(".compose-all-everyone-msg");
|
||||
casper.test.assertNotVisible("#compose-send-status");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
common.expected_messages('zhome', ['Verona > Test mention all'],
|
||||
common.expected_messages("zhome", ["Verona > Test mention all"],
|
||||
["<p><span class=\"user-mention user-mention-me\" " +
|
||||
"data-user-id=\"*\">@all</span></p>"]);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -8,49 +8,49 @@ common.manage_organization();
|
||||
casper.test.info("Testing custom profile fields");
|
||||
casper.thenClick("li[data-section='profile-field-settings']");
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.admin-profile-field-form', function () {
|
||||
casper.fill('form.admin-profile-field-form', {
|
||||
name: 'Teams',
|
||||
field_type: '1',
|
||||
casper.waitUntilVisible(".admin-profile-field-form", function () {
|
||||
casper.fill("form.admin-profile-field-form", {
|
||||
name: "Teams",
|
||||
field_type: "1",
|
||||
});
|
||||
casper.click("form.admin-profile-field-form button[type='submit']");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#admin-add-profile-field-status img', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-add-profile-field-status', 'Saved');
|
||||
common.wait_for_text('.profile-field-row span.profile_field_name', 'Teams', function () {
|
||||
casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'Teams');
|
||||
casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short text');
|
||||
casper.click('.profile-field-row button.open-edit-form');
|
||||
casper.waitUntilVisible("#admin-add-profile-field-status img", function () {
|
||||
casper.test.assertSelectorHasText("div#admin-add-profile-field-status", "Saved");
|
||||
common.wait_for_text(".profile-field-row span.profile_field_name", "Teams", function () {
|
||||
casper.test.assertSelectorHasText(".profile-field-row span.profile_field_name", "Teams");
|
||||
casper.test.assertSelectorHasText(".profile-field-row span.profile_field_type", "Short text");
|
||||
casper.click(".profile-field-row button.open-edit-form");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('tr.profile-field-form form', function () {
|
||||
casper.fill('tr.profile-field-form form.name-setting', {
|
||||
name: 'team',
|
||||
casper.waitUntilVisible("tr.profile-field-form form", function () {
|
||||
casper.fill("tr.profile-field-form form.name-setting", {
|
||||
name: "team",
|
||||
});
|
||||
casper.click('tr.profile-field-form button.submit');
|
||||
casper.click("tr.profile-field-form button.submit");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#admin-profile-field-status img', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-profile-field-status', 'Saved');
|
||||
casper.waitUntilVisible("#admin-profile-field-status img", function () {
|
||||
casper.test.assertSelectorHasText("div#admin-profile-field-status", "Saved");
|
||||
});
|
||||
casper.waitForSelectorTextChange('.profile-field-row span.profile_field_name', function () {
|
||||
casper.test.assertSelectorHasText('.profile-field-row span.profile_field_name', 'team');
|
||||
casper.test.assertSelectorHasText('.profile-field-row span.profile_field_type', 'Short text');
|
||||
casper.click('.profile-field-row button.delete');
|
||||
casper.waitForSelectorTextChange(".profile-field-row span.profile_field_name", function () {
|
||||
casper.test.assertSelectorHasText(".profile-field-row span.profile_field_name", "team");
|
||||
casper.test.assertSelectorHasText(".profile-field-row span.profile_field_type", "Short text");
|
||||
casper.click(".profile-field-row button.delete");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#admin-profile-field-status img', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-profile-field-status', 'Saved');
|
||||
casper.waitUntilVisible("#admin-profile-field-status img", function () {
|
||||
casper.test.assertSelectorHasText("div#admin-profile-field-status", "Saved");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
function user_row(name) {
|
||||
var email = name + '@zulip.com';
|
||||
var email = name + "@zulip.com";
|
||||
var user_id = common.get_user_id(email);
|
||||
return '.user_row[data-user-id="' + user_id + '"]';
|
||||
}
|
||||
@@ -9,7 +9,7 @@ function user_row(name) {
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.then(function () {
|
||||
var menu_selector = '#settings-dropdown';
|
||||
var menu_selector = "#settings-dropdown";
|
||||
casper.waitUntilVisible(menu_selector, function () {
|
||||
casper.click(menu_selector);
|
||||
casper.click('a[href^="#organization"]');
|
||||
@@ -17,43 +17,43 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#settings_overlay_container.show', function () {
|
||||
casper.waitUntilVisible("#settings_overlay_container.show", function () {
|
||||
casper.click("li[data-section='user-list-admin']");
|
||||
});
|
||||
});
|
||||
|
||||
// Test user deactivation and reactivation
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(user_row('cordelia'), function () {
|
||||
casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
|
||||
casper.click(user_row('cordelia') + ' .deactivate');
|
||||
casper.test.assertTextExists('Deactivate cordelia@zulip.com', 'Deactivate modal has right user');
|
||||
casper.test.assertTextExists('Deactivate now', 'Deactivate now button available');
|
||||
casper.click('#deactivation_user_modal .do_deactivate_button');
|
||||
casper.waitUntilVisible(user_row("cordelia"), function () {
|
||||
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
||||
casper.click(user_row("cordelia") + " .deactivate");
|
||||
casper.test.assertTextExists("Deactivate cordelia@zulip.com", "Deactivate modal has right user");
|
||||
casper.test.assertTextExists("Deactivate now", "Deactivate now button available");
|
||||
casper.click("#deactivation_user_modal .do_deactivate_button");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(user_row('cordelia') + '.deactivated_user', function () {
|
||||
casper.test.assertExists('.fa-user-plus', 'Reactivate icon available');
|
||||
casper.click(user_row('cordelia') + ' .reactivate');
|
||||
casper.waitUntilVisible(user_row("cordelia") + ".deactivated_user", function () {
|
||||
casper.test.assertExists(".fa-user-plus", "Reactivate icon available");
|
||||
casper.click(user_row("cordelia") + " .reactivate");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(user_row('cordelia') + ':not(.deactivated_user)', function () {
|
||||
casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
|
||||
casper.waitUntilVisible(user_row("cordelia") + ":not(.deactivated_user)", function () {
|
||||
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
// Test Deactivated users section of admin page
|
||||
casper.waitUntilVisible(user_row('cordelia'), function () {
|
||||
casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
|
||||
casper.click(user_row('cordelia') + ' .deactivate');
|
||||
casper.test.assertTextExists('Deactivate cordelia@zulip.com', 'Deactivate modal has right user');
|
||||
casper.test.assertTextExists('Deactivate now', 'Deactivate now button available');
|
||||
casper.click('#deactivation_user_modal .do_deactivate_button');
|
||||
casper.waitUntilVisible(user_row("cordelia"), function () {
|
||||
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
||||
casper.click(user_row("cordelia") + " .deactivate");
|
||||
casper.test.assertTextExists("Deactivate cordelia@zulip.com", "Deactivate modal has right user");
|
||||
casper.test.assertTextExists("Deactivate now", "Deactivate now button available");
|
||||
casper.click("#deactivation_user_modal .do_deactivate_button");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,15 +65,15 @@ casper.then(function () {
|
||||
casper.click("li[data-section='deactivated-users-admin']");
|
||||
|
||||
|
||||
casper.waitUntilVisible('#admin_deactivated_users_table ' + user_row('cordelia') + ' .reactivate', function () {
|
||||
casper.test.assertExists('.fa-user-plus', 'Reactive icon available');
|
||||
casper.click('#admin_deactivated_users_table ' + user_row('cordelia') + ' .reactivate');
|
||||
casper.waitUntilVisible("#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate", function () {
|
||||
casper.test.assertExists(".fa-user-plus", "Reactive icon available");
|
||||
casper.click("#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#admin_deactivated_users_table ' + user_row('cordelia') + ' button:not(.reactivate)', function () {
|
||||
casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
|
||||
casper.waitUntilVisible("#admin_deactivated_users_table " + user_row("cordelia") + " button:not(.reactivate)", function () {
|
||||
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -84,22 +84,22 @@ casper.then(function () {
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(user_row('default-bot'), function () {
|
||||
casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
|
||||
casper.click(user_row('default-bot') + ' .deactivate');
|
||||
casper.waitUntilVisible(user_row("default-bot"), function () {
|
||||
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
||||
casper.click(user_row("default-bot") + " .deactivate");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(user_row('default-bot') + '.deactivated_user', function () {
|
||||
casper.test.assertExists('.fa-user-plus', 'Reactivate icon available');
|
||||
casper.click(user_row('default-bot') + ' .reactivate');
|
||||
casper.waitUntilVisible(user_row("default-bot") + ".deactivated_user", function () {
|
||||
casper.test.assertExists(".fa-user-plus", "Reactivate icon available");
|
||||
casper.click(user_row("default-bot") + " .reactivate");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible(user_row('default-bot') + ':not(.deactivated_user)', function () {
|
||||
casper.test.assertExists('.fa-user-times', 'Deactivate icon available');
|
||||
casper.waitUntilVisible(user_row("default-bot") + ":not(.deactivated_user)", function () {
|
||||
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
function waitWhileDraftsVisible(then) {
|
||||
casper.waitFor(function () {
|
||||
@@ -21,211 +21,211 @@ function waitUntilDraftsVisible(then) {
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Drafts page');
|
||||
casper.test.info("Drafts page");
|
||||
|
||||
casper.waitUntilVisible('.drafts-link', function () {
|
||||
casper.click('.drafts-link');
|
||||
casper.waitUntilVisible(".drafts-link", function () {
|
||||
casper.click(".drafts-link");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#drafts/,
|
||||
'URL suggests we are on drafts page');
|
||||
"URL suggests we are on drafts page");
|
||||
waitUntilDraftsVisible(function () {
|
||||
casper.test.assertExists('#draft_overlay', 'Drafts page is active');
|
||||
casper.test.assertSelectorHasText('.no-drafts', 'No drafts.');
|
||||
casper.test.assertExists("#draft_overlay", "Drafts page is active");
|
||||
casper.test.assertSelectorHasText(".no-drafts", "No drafts.");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
casper.then(function () {
|
||||
casper.click('#draft_overlay .exit');
|
||||
casper.click("#draft_overlay .exit");
|
||||
waitWhileDraftsVisible();
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Creating Stream Message Draft');
|
||||
casper.click('body');
|
||||
casper.page.sendEvent('keypress', "c");
|
||||
casper.waitUntilVisible('#stream-message', function () {
|
||||
casper.fill('form#send_message_form', {
|
||||
stream_message_recipient_stream: 'all',
|
||||
stream_message_recipient_topic: 'tests',
|
||||
content: 'Test Stream Message',
|
||||
casper.test.info("Creating Stream Message Draft");
|
||||
casper.click("body");
|
||||
casper.page.sendEvent("keypress", "c");
|
||||
casper.waitUntilVisible("#stream-message", function () {
|
||||
casper.fill("form#send_message_form", {
|
||||
stream_message_recipient_stream: "all",
|
||||
stream_message_recipient_topic: "tests",
|
||||
content: "Test Stream Message",
|
||||
}, false);
|
||||
casper.click("#compose_close");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Creating Private Message Draft');
|
||||
casper.click('body');
|
||||
casper.page.sendEvent('keypress', "x");
|
||||
casper.waitUntilVisible('#private-message', function () {
|
||||
casper.fill('form#send_message_form', {
|
||||
content: 'Test Private Message',
|
||||
casper.test.info("Creating Private Message Draft");
|
||||
casper.click("body");
|
||||
casper.page.sendEvent("keypress", "x");
|
||||
casper.waitUntilVisible("#private-message", function () {
|
||||
casper.fill("form#send_message_form", {
|
||||
content: "Test Private Message",
|
||||
}, false);
|
||||
common.pm_recipient.set('cordelia@zulip.com, hamlet@zulip.com');
|
||||
common.pm_recipient.set("cordelia@zulip.com, hamlet@zulip.com");
|
||||
casper.click("#compose_close");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Opening Markdown Preview');
|
||||
casper.waitUntilVisible('#left_bar_compose_stream_button_big', function () {
|
||||
casper.click('#left_bar_compose_stream_button_big');
|
||||
casper.test.info("Opening Markdown Preview");
|
||||
casper.waitUntilVisible("#left_bar_compose_stream_button_big", function () {
|
||||
casper.click("#left_bar_compose_stream_button_big");
|
||||
});
|
||||
casper.waitUntilVisible('#markdown_preview', function () {
|
||||
casper.click('#markdown_preview');
|
||||
casper.waitUntilVisible("#markdown_preview", function () {
|
||||
casper.click("#markdown_preview");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.drafts-link', function () {
|
||||
casper.click('.drafts-link');
|
||||
casper.waitUntilVisible(".drafts-link", function () {
|
||||
casper.click(".drafts-link");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
waitUntilDraftsVisible(function () {
|
||||
casper.test.assertElementCount('.draft-row', 2, 'Drafts loaded');
|
||||
casper.test.assertElementCount(".draft-row", 2, "Drafts loaded");
|
||||
|
||||
casper.test.assertSelectorHasText('.draft-row .message_header_stream .stream_label', 'all');
|
||||
casper.test.assertSelectorHasText('.draft-row .message_header_stream .stream_topic', 'tests');
|
||||
casper.test.assertTextExists('Test Stream Message', 'Stream draft contains message content');
|
||||
casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_label", "all");
|
||||
casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_topic", "tests");
|
||||
casper.test.assertTextExists("Test Stream Message", "Stream draft contains message content");
|
||||
|
||||
casper.test.assertSelectorHasText('.draft-row .message_header_private_message .stream_label',
|
||||
'You and Cordelia Lear, King Hamlet');
|
||||
casper.test.assertTextExists('Test Private Message', 'Private draft contains message content');
|
||||
casper.test.assertSelectorHasText(".draft-row .message_header_private_message .stream_label",
|
||||
"You and Cordelia Lear, King Hamlet");
|
||||
casper.test.assertTextExists("Test Private Message", "Private draft contains message content");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Restoring Stream Message Draft');
|
||||
casper.test.info("Restoring Stream Message Draft");
|
||||
casper.click("#drafts_table .message_row:not(.private-message) .restore-draft");
|
||||
waitWhileDraftsVisible(function () {
|
||||
casper.test.assertVisible('#stream-message', 'Stream Message Box Restored');
|
||||
casper.test.assertNotVisible('#preview_message_area', 'Preview Was Hidden');
|
||||
common.check_form('form#send_message_form', {
|
||||
stream_message_recipient_stream: 'all',
|
||||
stream_message_recipient_topic: 'tests',
|
||||
content: 'Test Stream Message',
|
||||
casper.test.assertVisible("#stream-message", "Stream Message Box Restored");
|
||||
casper.test.assertNotVisible("#preview_message_area", "Preview Was Hidden");
|
||||
common.check_form("form#send_message_form", {
|
||||
stream_message_recipient_stream: "all",
|
||||
stream_message_recipient_topic: "tests",
|
||||
content: "Test Stream Message",
|
||||
}, "Stream message box filled with draft content");
|
||||
casper.test.assertSelectorHasText('title', 'tests - Zulip Dev - Zulip', 'Narrowed to topic');
|
||||
casper.test.assertSelectorHasText("title", "tests - Zulip Dev - Zulip", "Narrowed to topic");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Editing Stream Message Draft');
|
||||
casper.fill('form#send_message_form', {
|
||||
stream_message_recipient_stream: 'all',
|
||||
stream_message_recipient_topic: 'tests',
|
||||
content: 'Updated Stream Message',
|
||||
casper.test.info("Editing Stream Message Draft");
|
||||
casper.fill("form#send_message_form", {
|
||||
stream_message_recipient_stream: "all",
|
||||
stream_message_recipient_topic: "tests",
|
||||
content: "Updated Stream Message",
|
||||
}, false);
|
||||
casper.click("#compose_close");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.drafts-link', function () {
|
||||
casper.click('.drafts-link');
|
||||
casper.waitUntilVisible(".drafts-link", function () {
|
||||
casper.click(".drafts-link");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
waitUntilDraftsVisible(function () {
|
||||
casper.test.assertSelectorHasText('.draft-row .message_header_stream .stream_label', 'all');
|
||||
casper.test.assertSelectorHasText('.draft-row .message_header_stream .stream_topic', 'tests');
|
||||
casper.test.assertTextExists('Updated Stream Message', 'Stream draft contains message content');
|
||||
casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_label", "all");
|
||||
casper.test.assertSelectorHasText(".draft-row .message_header_stream .stream_topic", "tests");
|
||||
casper.test.assertTextExists("Updated Stream Message", "Stream draft contains message content");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Restoring Private Message Draft');
|
||||
casper.test.info("Restoring Private Message Draft");
|
||||
casper.click("#drafts_table .message_row.private-message .restore-draft");
|
||||
waitWhileDraftsVisible(function () {
|
||||
casper.test.assertVisible('#private-message', 'Private Message Box Restored');
|
||||
common.check_form('form#send_message_form', {
|
||||
content: 'Test Private Message',
|
||||
casper.test.assertVisible("#private-message", "Private Message Box Restored");
|
||||
common.check_form("form#send_message_form", {
|
||||
content: "Test Private Message",
|
||||
}, "Private message box filled with draft content");
|
||||
common.pm_recipient.expect('cordelia@zulip.com,hamlet@zulip.com');
|
||||
casper.test.assertSelectorHasText('title', 'Cordelia Lear, King Hamlet - Zulip Dev - Zulip', 'Narrowed to huddle');
|
||||
common.pm_recipient.expect("cordelia@zulip.com,hamlet@zulip.com");
|
||||
casper.test.assertSelectorHasText("title", "Cordelia Lear, King Hamlet - Zulip Dev - Zulip", "Narrowed to huddle");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.click("#compose_close");
|
||||
casper.waitUntilVisible('.drafts-link', function () {
|
||||
casper.click('.drafts-link');
|
||||
casper.waitUntilVisible(".drafts-link", function () {
|
||||
casper.click(".drafts-link");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Deleting Draft');
|
||||
casper.test.info("Deleting Draft");
|
||||
casper.click("#drafts_table .message_row.private-message .delete-draft");
|
||||
casper.test.assertElementCount('.draft-row', 1, 'Draft deleted');
|
||||
casper.test.assertElementCount(".draft-row", 1, "Draft deleted");
|
||||
casper.test.assertDoesntExist("#drafts_table .message_row.private-message");
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Saving Draft by Reloading');
|
||||
casper.click('#draft_overlay .exit');
|
||||
casper.test.info("Saving Draft by Reloading");
|
||||
casper.click("#draft_overlay .exit");
|
||||
waitWhileDraftsVisible(function () {
|
||||
casper.click('body');
|
||||
casper.page.sendEvent('keypress', "x");
|
||||
casper.click("body");
|
||||
casper.page.sendEvent("keypress", "x");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('#private-message', function () {
|
||||
casper.fill('form#send_message_form', {
|
||||
content: 'Test Private Message',
|
||||
casper.waitUntilVisible("#private-message", function () {
|
||||
casper.fill("form#send_message_form", {
|
||||
content: "Test Private Message",
|
||||
}, false);
|
||||
common.pm_recipient.set('cordelia@zulip.com');
|
||||
common.pm_recipient.set("cordelia@zulip.com");
|
||||
});
|
||||
casper.reload();
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Finished reloading; now opening drafts again');
|
||||
casper.test.info("Finished reloading; now opening drafts again");
|
||||
// Reloading into a narrow opens compose box automatically
|
||||
|
||||
casper.waitUntilVisible("#compose_close", function () {
|
||||
casper.click("#compose_close");
|
||||
});
|
||||
casper.waitUntilVisible('.drafts-link', function () {
|
||||
casper.click('.drafts-link');
|
||||
casper.waitUntilVisible(".drafts-link", function () {
|
||||
casper.click(".drafts-link");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Checking drafts survived the reload');
|
||||
casper.test.info("Checking drafts survived the reload");
|
||||
waitUntilDraftsVisible(function () {
|
||||
casper.test.assertElementCount('.draft-row', 2, 'Drafts loaded');
|
||||
casper.test.assertSelectorHasText('.draft-row .message_header_private_message .stream_label',
|
||||
'You and Cordelia Lear');
|
||||
casper.test.assertTextExists('Test Private Message');
|
||||
casper.test.assertElementCount(".draft-row", 2, "Drafts loaded");
|
||||
casper.test.assertSelectorHasText(".draft-row .message_header_private_message .stream_label",
|
||||
"You and Cordelia Lear");
|
||||
casper.test.assertTextExists("Test Private Message");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Deleting Draft after Sending Message');
|
||||
casper.test.info("Deleting Draft after Sending Message");
|
||||
casper.click("#drafts_table .message_row.private-message .restore-draft");
|
||||
waitWhileDraftsVisible(function () {
|
||||
casper.test.assertVisible('#private-message');
|
||||
casper.test.assertVisible("#private-message");
|
||||
casper.click("#enter_sends");
|
||||
casper.waitUntilVisible('#compose-send-button', function () {
|
||||
casper.click('#compose-send-button');
|
||||
casper.waitUntilVisible("#compose-send-button", function () {
|
||||
casper.click("#compose-send-button");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
// This tests the second drafts link in the compose area
|
||||
casper.waitUntilVisible('.compose_table .drafts-link', function () {
|
||||
casper.click('.compose_table .drafts-link');
|
||||
casper.waitUntilVisible(".compose_table .drafts-link", function () {
|
||||
casper.click(".compose_table .drafts-link");
|
||||
});
|
||||
waitUntilDraftsVisible(function () {
|
||||
casper.test.assertElementCount('.draft-row', 1, 'Drafts loaded');
|
||||
casper.test.assertElementCount(".draft-row", 1, "Drafts loaded");
|
||||
casper.test.assertDoesntExist("#drafts_table .message_row.private-message");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -12,19 +12,19 @@ casper.then(function () {
|
||||
|
||||
casper.then(function () {
|
||||
msgs_qty = this.evaluate(function () {
|
||||
return $('#zhome .message_row').length;
|
||||
return $("#zhome .message_row").length;
|
||||
});
|
||||
last_message_id = this.evaluate(function () {
|
||||
var msg = $('#zhome .message_row').last();
|
||||
msg.find('.info').click();
|
||||
$('.delete_message').click();
|
||||
return msg.attr('id');
|
||||
var msg = $("#zhome .message_row").last();
|
||||
msg.find(".info").click();
|
||||
$(".delete_message").click();
|
||||
return msg.attr("id");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible("#delete_message_modal", function () {
|
||||
casper.click('#do_delete_message_button');
|
||||
casper.click("#do_delete_message_button");
|
||||
});
|
||||
});
|
||||
casper.then(function () {
|
||||
@@ -35,7 +35,7 @@ casper.then(function () {
|
||||
casper.then(function () {
|
||||
casper.waitFor(function check_length() {
|
||||
return casper.evaluate(function (expected_length) {
|
||||
return $('#zhome .message_row').length === expected_length;
|
||||
return $("#zhome .message_row").length === expected_length;
|
||||
}, msgs_qty - 1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Sending messages');
|
||||
casper.test.info("Sending messages");
|
||||
});
|
||||
|
||||
// setup environment: several messages to different topics
|
||||
common.then_send_many([
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #1',
|
||||
content: 'copy paste test A' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #1",
|
||||
content: "copy paste test A" },
|
||||
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #1',
|
||||
content: 'copy paste test B' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #1",
|
||||
content: "copy paste test B" },
|
||||
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #2',
|
||||
content: 'copy paste test C' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #2",
|
||||
content: "copy paste test C" },
|
||||
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #2',
|
||||
content: 'copy paste test D' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #2",
|
||||
content: "copy paste test D" },
|
||||
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #2',
|
||||
content: 'copy paste test E' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #2",
|
||||
content: "copy paste test E" },
|
||||
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #3',
|
||||
content: 'copy paste test F' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #3",
|
||||
content: "copy paste test F" },
|
||||
|
||||
{ stream: 'Verona', subject: 'copy-paste-subject #3',
|
||||
content: 'copy paste test G' },
|
||||
{ stream: "Verona", subject: "copy-paste-subject #3",
|
||||
content: "copy paste test G" },
|
||||
]);
|
||||
|
||||
common.wait_for_receive(function () {
|
||||
common.expected_messages('zhome', [
|
||||
'Verona > copy-paste-subject #1',
|
||||
'Verona > copy-paste-subject #2',
|
||||
'Verona > copy-paste-subject #3',
|
||||
common.expected_messages("zhome", [
|
||||
"Verona > copy-paste-subject #1",
|
||||
"Verona > copy-paste-subject #2",
|
||||
"Verona > copy-paste-subject #3",
|
||||
], [
|
||||
'<p>copy paste test A</p>',
|
||||
'<p>copy paste test B</p>',
|
||||
'<p>copy paste test C</p>',
|
||||
'<p>copy paste test D</p>',
|
||||
'<p>copy paste test E</p>',
|
||||
'<p>copy paste test F</p>',
|
||||
'<p>copy paste test G</p>',
|
||||
"<p>copy paste test A</p>",
|
||||
"<p>copy paste test B</p>",
|
||||
"<p>copy paste test C</p>",
|
||||
"<p>copy paste test D</p>",
|
||||
"<p>copy paste test E</p>",
|
||||
"<p>copy paste test F</p>",
|
||||
"<p>copy paste test G</p>",
|
||||
]);
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.test.info('Messages were sent successfully');
|
||||
casper.test.info("Messages were sent successfully");
|
||||
});
|
||||
|
||||
function get_message_node(message) {
|
||||
@@ -66,14 +66,14 @@ function copy_messages(start_message, end_message) {
|
||||
// Remove existing copy/paste divs, which may linger from the previous
|
||||
// example. (The code clears these out with a zero-second timeout, which
|
||||
// is probably sufficient for human users, but which causes problems here.)
|
||||
$('#copytempdiv').remove();
|
||||
$("#copytempdiv").remove();
|
||||
|
||||
// emulate copy event
|
||||
$('body').trigger($.Event('keydown', { which: 67, ctrlKey: true }));
|
||||
$("body").trigger($.Event("keydown", { which: 67, ctrlKey: true }));
|
||||
|
||||
// find temp div with copied text
|
||||
var temp_div = $('#copytempdiv');
|
||||
return temp_div.children('p').get().map(function (p) { return p.textContent; });
|
||||
var temp_div = $("#copytempdiv");
|
||||
return temp_div.children("p").get().map(function (p) { return p.textContent; });
|
||||
}, {
|
||||
get_message_node: get_message_node,
|
||||
start_message: start_message,
|
||||
@@ -83,85 +83,85 @@ function copy_messages(start_message, end_message) {
|
||||
|
||||
// test copying first message from topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test C', 'copy paste test C');
|
||||
var actual_copied_lines = copy_messages("copy paste test C", "copy paste test C");
|
||||
var expected_copied_lines = [];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by browser');
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by browser");
|
||||
});
|
||||
|
||||
// test copying last message from topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test E', 'copy paste test E');
|
||||
var actual_copied_lines = copy_messages("copy paste test E", "copy paste test E");
|
||||
var expected_copied_lines = [];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by browser');
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by browser");
|
||||
});
|
||||
|
||||
// test copying two first messages from topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test C', 'copy paste test D');
|
||||
var expected_copied_lines = ['Iago: copy paste test C', 'Iago: copy paste test D'];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by custom handler');
|
||||
var actual_copied_lines = copy_messages("copy paste test C", "copy paste test D");
|
||||
var expected_copied_lines = ["Iago: copy paste test C", "Iago: copy paste test D"];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
|
||||
});
|
||||
|
||||
// test copying all messages from topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test C', 'copy paste test E');
|
||||
var expected_copied_lines = ['Iago: copy paste test C', 'Iago: copy paste test D', 'Iago: copy paste test E'];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by custom handler');
|
||||
var actual_copied_lines = copy_messages("copy paste test C", "copy paste test E");
|
||||
var expected_copied_lines = ["Iago: copy paste test C", "Iago: copy paste test D", "Iago: copy paste test E"];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
|
||||
});
|
||||
|
||||
// test copying last message from previous topic and first message from next topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test B', 'copy paste test C');
|
||||
var actual_copied_lines = copy_messages("copy paste test B", "copy paste test C");
|
||||
var expected_copied_lines = [
|
||||
'Verona > copy-paste-subject #1 Today',
|
||||
'Iago: copy paste test B',
|
||||
'Verona > copy-paste-subject #2 Today',
|
||||
'Iago: copy paste test C',
|
||||
"Verona > copy-paste-subject #1 Today",
|
||||
"Iago: copy paste test B",
|
||||
"Verona > copy-paste-subject #2 Today",
|
||||
"Iago: copy paste test C",
|
||||
];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by custom handler');
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
|
||||
});
|
||||
|
||||
// test copying last message from previous topic and all messages from next topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test B', 'copy paste test E');
|
||||
var actual_copied_lines = copy_messages("copy paste test B", "copy paste test E");
|
||||
var expected_copied_lines = [
|
||||
'Verona > copy-paste-subject #1 Today',
|
||||
'Iago: copy paste test B',
|
||||
'Verona > copy-paste-subject #2 Today',
|
||||
'Iago: copy paste test C',
|
||||
'Iago: copy paste test D',
|
||||
'Iago: copy paste test E',
|
||||
"Verona > copy-paste-subject #1 Today",
|
||||
"Iago: copy paste test B",
|
||||
"Verona > copy-paste-subject #2 Today",
|
||||
"Iago: copy paste test C",
|
||||
"Iago: copy paste test D",
|
||||
"Iago: copy paste test E",
|
||||
];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by custom handler');
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
|
||||
});
|
||||
|
||||
// test copying all messages from previous topic and first message from next topic
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test A', 'copy paste test C');
|
||||
var actual_copied_lines = copy_messages("copy paste test A", "copy paste test C");
|
||||
var expected_copied_lines = [
|
||||
'Verona > copy-paste-subject #1 Today',
|
||||
'Iago: copy paste test A',
|
||||
'Iago: copy paste test B',
|
||||
'Verona > copy-paste-subject #2 Today',
|
||||
'Iago: copy paste test C',
|
||||
"Verona > copy-paste-subject #1 Today",
|
||||
"Iago: copy paste test A",
|
||||
"Iago: copy paste test B",
|
||||
"Verona > copy-paste-subject #2 Today",
|
||||
"Iago: copy paste test C",
|
||||
];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by custom handler');
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
|
||||
});
|
||||
|
||||
// test copying message from several topics
|
||||
casper.then(function () {
|
||||
var actual_copied_lines = copy_messages('copy paste test B', 'copy paste test F');
|
||||
var actual_copied_lines = copy_messages("copy paste test B", "copy paste test F");
|
||||
var expected_copied_lines = [
|
||||
'Verona > copy-paste-subject #1 Today',
|
||||
'Iago: copy paste test B',
|
||||
'Verona > copy-paste-subject #2 Today',
|
||||
'Iago: copy paste test C',
|
||||
'Iago: copy paste test D',
|
||||
'Iago: copy paste test E',
|
||||
'Verona > copy-paste-subject #3 Today',
|
||||
'Iago: copy paste test F',
|
||||
"Verona > copy-paste-subject #1 Today",
|
||||
"Iago: copy paste test B",
|
||||
"Verona > copy-paste-subject #2 Today",
|
||||
"Iago: copy paste test C",
|
||||
"Iago: copy paste test D",
|
||||
"Iago: copy paste test E",
|
||||
"Verona > copy-paste-subject #3 Today",
|
||||
"Iago: copy paste test F",
|
||||
];
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, 'Copying was handled by custom handler');
|
||||
casper.test.assertEquals(actual_copied_lines, expected_copied_lines, "Copying was handled by custom handler");
|
||||
});
|
||||
|
||||
// Run the above queued actions.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var common = require('../casper_lib/common.js');
|
||||
var common = require("../casper_lib/common.js");
|
||||
|
||||
common.start_and_log_in();
|
||||
|
||||
@@ -7,48 +7,48 @@ common.manage_organization();
|
||||
// Test custom realm filters
|
||||
casper.then(function () {
|
||||
casper.click("li[data-section='filter-settings']");
|
||||
casper.waitUntilVisible('.admin-filter-form', function () {
|
||||
casper.fill('form.admin-filter-form', {
|
||||
pattern: '#(?P<id>[0-9]+)',
|
||||
url_format_string: 'https://trac.example.com/ticket/%(id)s',
|
||||
casper.waitUntilVisible(".admin-filter-form", function () {
|
||||
casper.fill("form.admin-filter-form", {
|
||||
pattern: "#(?P<id>[0-9]+)",
|
||||
url_format_string: "https://trac.example.com/ticket/%(id)s",
|
||||
});
|
||||
casper.click('form.admin-filter-form button.button');
|
||||
casper.click("form.admin-filter-form button.button");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('div#admin-filter-status', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-filter-status', 'Custom filter added!');
|
||||
casper.waitUntilVisible("div#admin-filter-status", function () {
|
||||
casper.test.assertSelectorHasText("div#admin-filter-status", "Custom filter added!");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.filter_row', function () {
|
||||
casper.test.assertSelectorHasText('.filter_row span.filter_pattern', '#(?P<id>[0-9]+)');
|
||||
casper.test.assertSelectorHasText('.filter_row span.filter_url_format_string', 'https://trac.example.com/ticket/%(id)s');
|
||||
casper.click('.filter_row button');
|
||||
casper.waitUntilVisible(".filter_row", function () {
|
||||
casper.test.assertSelectorHasText(".filter_row span.filter_pattern", "#(?P<id>[0-9]+)");
|
||||
casper.test.assertSelectorHasText(".filter_row span.filter_url_format_string", "https://trac.example.com/ticket/%(id)s");
|
||||
casper.click(".filter_row button");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitWhileVisible('.filter_row', function () {
|
||||
casper.test.assertDoesntExist('.filter_row');
|
||||
casper.waitWhileVisible(".filter_row", function () {
|
||||
casper.test.assertDoesntExist(".filter_row");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('.admin-filter-form', function () {
|
||||
casper.fill('form.admin-filter-form', {
|
||||
pattern: 'a$',
|
||||
url_format_string: 'https://trac.example.com/ticket/%(id)s',
|
||||
casper.waitUntilVisible(".admin-filter-form", function () {
|
||||
casper.fill("form.admin-filter-form", {
|
||||
pattern: "a$",
|
||||
url_format_string: "https://trac.example.com/ticket/%(id)s",
|
||||
});
|
||||
casper.click('form.admin-filter-form button.button');
|
||||
casper.click("form.admin-filter-form button.button");
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.waitUntilVisible('div#admin-filter-pattern-status', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-filter-pattern-status', 'Failed: Invalid filter pattern');
|
||||
casper.waitUntilVisible("div#admin-filter-pattern-status", function () {
|
||||
casper.test.assertSelectorHasText("div#admin-filter-pattern-status", "Failed: Invalid filter pattern");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
let filter_key_handlers;
|
||||
|
||||
const huddle_data = zrequire('huddle_data');
|
||||
const huddle_data = zrequire("huddle_data");
|
||||
|
||||
const _page_params = {
|
||||
realm_users: [],
|
||||
@@ -41,13 +41,13 @@ const _popovers = {
|
||||
hide_all_except_sidebars: function () {},
|
||||
hide_all: function () {},
|
||||
show_userlist_sidebar: function () {
|
||||
$('.column-right').addClass('expanded');
|
||||
$(".column-right").addClass("expanded");
|
||||
},
|
||||
};
|
||||
|
||||
const _stream_popover = {
|
||||
show_streamlist_sidebar: function () {
|
||||
$('.column-left').addClass('expanded');
|
||||
$(".column-left").addClass("expanded");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -56,71 +56,71 @@ const _resize = {
|
||||
resize_page_components: () => {},
|
||||
};
|
||||
|
||||
set_global('padded_widget', {
|
||||
set_global("padded_widget", {
|
||||
update_padding: () => {},
|
||||
});
|
||||
set_global('channel', _channel);
|
||||
set_global('compose_state', _compose_state);
|
||||
set_global('document', _document);
|
||||
set_global('keydown_util', _keydown_util);
|
||||
set_global('page_params', _page_params);
|
||||
set_global('pm_list', _pm_list);
|
||||
set_global('popovers', _popovers);
|
||||
set_global('resize', _resize);
|
||||
set_global('scroll_util', _scroll_util);
|
||||
set_global('stream_popover', _stream_popover);
|
||||
set_global('ui', _ui);
|
||||
set_global("channel", _channel);
|
||||
set_global("compose_state", _compose_state);
|
||||
set_global("document", _document);
|
||||
set_global("keydown_util", _keydown_util);
|
||||
set_global("page_params", _page_params);
|
||||
set_global("pm_list", _pm_list);
|
||||
set_global("popovers", _popovers);
|
||||
set_global("resize", _resize);
|
||||
set_global("scroll_util", _scroll_util);
|
||||
set_global("stream_popover", _stream_popover);
|
||||
set_global("ui", _ui);
|
||||
|
||||
zrequire('compose_fade');
|
||||
set_global('Handlebars', global.make_handlebars());
|
||||
zrequire('unread');
|
||||
zrequire('hash_util');
|
||||
zrequire('narrow');
|
||||
zrequire('presence');
|
||||
zrequire('people');
|
||||
zrequire('buddy_data');
|
||||
zrequire('buddy_list');
|
||||
zrequire('user_search');
|
||||
zrequire('user_status');
|
||||
zrequire('list_cursor');
|
||||
zrequire('activity');
|
||||
zrequire("compose_fade");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("unread");
|
||||
zrequire("hash_util");
|
||||
zrequire("narrow");
|
||||
zrequire("presence");
|
||||
zrequire("people");
|
||||
zrequire("buddy_data");
|
||||
zrequire("buddy_list");
|
||||
zrequire("user_search");
|
||||
zrequire("user_status");
|
||||
zrequire("list_cursor");
|
||||
zrequire("activity");
|
||||
|
||||
const me = {
|
||||
email: 'me@zulip.com',
|
||||
email: "me@zulip.com",
|
||||
user_id: 999,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@zulip.com',
|
||||
email: "alice@zulip.com",
|
||||
user_id: 1,
|
||||
full_name: 'Alice Smith',
|
||||
full_name: "Alice Smith",
|
||||
};
|
||||
const fred = {
|
||||
email: 'fred@zulip.com',
|
||||
email: "fred@zulip.com",
|
||||
user_id: 2,
|
||||
full_name: "Fred Flintstone",
|
||||
};
|
||||
const jill = {
|
||||
email: 'jill@zulip.com',
|
||||
email: "jill@zulip.com",
|
||||
user_id: 3,
|
||||
full_name: 'Jill Hill',
|
||||
full_name: "Jill Hill",
|
||||
};
|
||||
const mark = {
|
||||
email: 'mark@zulip.com',
|
||||
email: "mark@zulip.com",
|
||||
user_id: 4,
|
||||
full_name: 'Marky Mark',
|
||||
full_name: "Marky Mark",
|
||||
};
|
||||
const norbert = {
|
||||
email: 'norbert@zulip.com',
|
||||
email: "norbert@zulip.com",
|
||||
user_id: 5,
|
||||
full_name: 'Norbert Oswald',
|
||||
full_name: "Norbert Oswald",
|
||||
};
|
||||
|
||||
const zoe = {
|
||||
email: 'zoe@example.com',
|
||||
email: "zoe@example.com",
|
||||
user_id: 6,
|
||||
full_name: 'Zoe Yang',
|
||||
full_name: "Zoe Yang",
|
||||
};
|
||||
|
||||
people.add_active_user(alice);
|
||||
@@ -133,9 +133,9 @@ people.add_active_user(me);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
const presence_info = new Map();
|
||||
presence_info.set(alice.user_id, { status: 'inactive' });
|
||||
presence_info.set(fred.user_id, { status: 'active' });
|
||||
presence_info.set(jill.user_id, { status: 'active' });
|
||||
presence_info.set(alice.user_id, { status: "inactive" });
|
||||
presence_info.set(fred.user_id, { status: "active" });
|
||||
presence_info.set(jill.user_id, { status: "active" });
|
||||
|
||||
presence.presence_info = presence_info;
|
||||
|
||||
@@ -149,19 +149,19 @@ buddy_list.fill_screen_with_content = () => {
|
||||
});
|
||||
};
|
||||
|
||||
run_test('get_status', () => {
|
||||
run_test("get_status", () => {
|
||||
assert.equal(presence.get_status(page_params.user_id), "active");
|
||||
assert.equal(presence.get_status(alice.user_id), "inactive");
|
||||
assert.equal(presence.get_status(fred.user_id), "active");
|
||||
assert.equal(presence.get_status(zoe.user_id), "offline");
|
||||
});
|
||||
|
||||
run_test('reload_defaults', () => {
|
||||
blueslip.expect('warn', 'get_filter_text() is called before initialization');
|
||||
assert.equal(activity.get_filter_text(), '');
|
||||
run_test("reload_defaults", () => {
|
||||
blueslip.expect("warn", "get_filter_text() is called before initialization");
|
||||
assert.equal(activity.get_filter_text(), "");
|
||||
});
|
||||
|
||||
run_test('sort_users', () => {
|
||||
run_test("sort_users", () => {
|
||||
const user_ids = [alice.user_id, fred.user_id, jill.user_id];
|
||||
|
||||
buddy_data.sort_users(user_ids);
|
||||
@@ -173,37 +173,37 @@ run_test('sort_users', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('huddle_data.process_loaded_messages', () => {
|
||||
run_test("huddle_data.process_loaded_messages", () => {
|
||||
// TODO: move this to a module for just testing `huddle_data`
|
||||
|
||||
const huddle1 = 'jill@zulip.com,norbert@zulip.com';
|
||||
const huddle1 = "jill@zulip.com,norbert@zulip.com";
|
||||
const timestamp1 = 1382479029; // older
|
||||
|
||||
const huddle2 = 'alice@zulip.com,fred@zulip.com';
|
||||
const huddle2 = "alice@zulip.com,fred@zulip.com";
|
||||
const timestamp2 = 1382479033; // newer
|
||||
|
||||
const old_timestamp = 1382479000;
|
||||
|
||||
const messages = [
|
||||
{
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [{id: jill.user_id}, {id: norbert.user_id}],
|
||||
timestamp: timestamp1,
|
||||
},
|
||||
{
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
},
|
||||
{
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [{id: me.user_id}], // PM to myself
|
||||
},
|
||||
{
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [{id: alice.user_id}, {id: fred.user_id}],
|
||||
timestamp: timestamp2,
|
||||
},
|
||||
{
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [{id: fred.user_id}, {id: alice.user_id}],
|
||||
timestamp: old_timestamp,
|
||||
},
|
||||
@@ -235,7 +235,7 @@ function reset_setup() {
|
||||
$.clear_all_elements();
|
||||
activity.set_cursor_and_filter();
|
||||
|
||||
buddy_list.container = $('#user_presences');
|
||||
buddy_list.container = $("#user_presences");
|
||||
|
||||
buddy_list.container.append = () => {};
|
||||
clear_buddy_list();
|
||||
@@ -243,8 +243,8 @@ function reset_setup() {
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('presence_list_full_update', () => {
|
||||
$('.user-list-filter').focus();
|
||||
run_test("presence_list_full_update", () => {
|
||||
$(".user-list-filter").focus();
|
||||
compose_state.private_message_recipient = () => fred.email;
|
||||
compose_fade.set_focused_recipient("private");
|
||||
|
||||
@@ -262,54 +262,54 @@ run_test('presence_list_full_update', () => {
|
||||
});
|
||||
|
||||
function simulate_right_column_buddy_list() {
|
||||
$('.user-list-filter').closest = function (selector) {
|
||||
$(".user-list-filter").closest = function (selector) {
|
||||
assert.equal(selector, ".app-main [class^='column-']");
|
||||
return $.create('right-sidebar').addClass('column-right');
|
||||
return $.create("right-sidebar").addClass("column-right");
|
||||
};
|
||||
}
|
||||
|
||||
function simulate_left_column_buddy_list() {
|
||||
$('.user-list-filter').closest = function (selector) {
|
||||
$(".user-list-filter").closest = function (selector) {
|
||||
assert.equal(selector, ".app-main [class^='column-']");
|
||||
return $.create('left-sidebar').addClass('column-left');
|
||||
return $.create("left-sidebar").addClass("column-left");
|
||||
};
|
||||
}
|
||||
|
||||
function buddy_list_add(user_id, stub) {
|
||||
if (stub.attr) {
|
||||
stub.attr('data-user-id', user_id);
|
||||
stub.attr("data-user-id", user_id);
|
||||
}
|
||||
stub.length = 1;
|
||||
const sel = `li.user_sidebar_entry[data-user-id='${user_id}']`;
|
||||
$('#user_presences').set_find_results(sel, stub);
|
||||
$("#user_presences").set_find_results(sel, stub);
|
||||
}
|
||||
|
||||
run_test('PM_update_dom_counts', () => {
|
||||
const value = $.create('alice-value');
|
||||
const count = $.create('alice-count');
|
||||
run_test("PM_update_dom_counts", () => {
|
||||
const value = $.create("alice-value");
|
||||
const count = $.create("alice-count");
|
||||
const pm_key = alice.user_id.toString();
|
||||
const li = $.create('alice stub');
|
||||
const li = $.create("alice stub");
|
||||
buddy_list_add(pm_key, li);
|
||||
count.set_find_results('.value', value);
|
||||
li.set_find_results('.count', count);
|
||||
count.set_parents_result('li', li);
|
||||
count.set_find_results(".value", value);
|
||||
li.set_find_results(".count", count);
|
||||
count.set_parents_result("li", li);
|
||||
|
||||
const counts = new Map();
|
||||
counts.set(pm_key, 5);
|
||||
li.addClass('user_sidebar_entry');
|
||||
li.addClass("user_sidebar_entry");
|
||||
|
||||
activity.update_dom_with_unread_counts({pm_count: counts});
|
||||
assert(li.hasClass('user-with-count'));
|
||||
assert(li.hasClass("user-with-count"));
|
||||
assert.equal(value.text(), "5");
|
||||
|
||||
counts.set(pm_key, 0);
|
||||
|
||||
activity.update_dom_with_unread_counts({pm_count: counts});
|
||||
assert(!li.hasClass('user-with-count'));
|
||||
assert.equal(value.text(), '');
|
||||
assert(!li.hasClass("user-with-count"));
|
||||
assert.equal(value.text(), "");
|
||||
});
|
||||
|
||||
run_test('handlers', () => {
|
||||
run_test("handlers", () => {
|
||||
// This is kind of weak coverage; we are mostly making sure that
|
||||
// keys and clicks got mapped to functions that don't crash.
|
||||
let me_li;
|
||||
@@ -322,9 +322,9 @@ run_test('handlers', () => {
|
||||
keys: [me.user_id, alice.user_id, fred.user_id],
|
||||
});
|
||||
|
||||
me_li = $.create('me stub');
|
||||
alice_li = $.create('alice stub');
|
||||
fred_li = $.create('fred stub');
|
||||
me_li = $.create("me stub");
|
||||
alice_li = $.create("alice stub");
|
||||
fred_li = $.create("fred stub");
|
||||
|
||||
buddy_list_add(me.user_id, me_li);
|
||||
buddy_list_add(alice.user_id, alice_li);
|
||||
@@ -344,14 +344,14 @@ run_test('handlers', () => {
|
||||
stopPropagation: () => {},
|
||||
};
|
||||
|
||||
const handler = $('.user-list-filter').get_on_handler('focus');
|
||||
const handler = $(".user-list-filter").get_on_handler("focus");
|
||||
handler(e);
|
||||
}());
|
||||
|
||||
(function test_click_header_filter() {
|
||||
init();
|
||||
const e = {};
|
||||
const handler = $('#userlist-header').get_on_handler('click');
|
||||
const handler = $("#userlist-header").get_on_handler("click");
|
||||
|
||||
simulate_right_column_buddy_list();
|
||||
|
||||
@@ -365,11 +365,11 @@ run_test('handlers', () => {
|
||||
let narrowed;
|
||||
|
||||
narrow.by = (method, email) => {
|
||||
assert.equal(email, 'alice@zulip.com');
|
||||
assert.equal(email, "alice@zulip.com");
|
||||
narrowed = true;
|
||||
};
|
||||
|
||||
$('.user-list-filter').val('al');
|
||||
$(".user-list-filter").val("al");
|
||||
activity.user_cursor.go_to(alice.user_id);
|
||||
|
||||
filter_key_handlers.enter_key();
|
||||
@@ -387,7 +387,7 @@ run_test('handlers', () => {
|
||||
let narrowed;
|
||||
|
||||
narrow.by = (method, email) => {
|
||||
assert.equal(email, 'alice@zulip.com');
|
||||
assert.equal(email, "alice@zulip.com");
|
||||
narrowed = true;
|
||||
};
|
||||
|
||||
@@ -398,7 +398,7 @@ run_test('handlers', () => {
|
||||
(function test_blur_filter() {
|
||||
init();
|
||||
const e = {};
|
||||
const handler = $('.user-list-filter').get_on_handler('blur');
|
||||
const handler = $(".user-list-filter").get_on_handler("blur");
|
||||
handler(e);
|
||||
}());
|
||||
});
|
||||
@@ -413,7 +413,7 @@ presence.presence_info.set(zoe.user_id, { status: activity.ACTIVE });
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('first/prev/next', () => {
|
||||
run_test("first/prev/next", () => {
|
||||
clear_buddy_list();
|
||||
|
||||
assert.equal(buddy_list.first_key(), undefined);
|
||||
@@ -435,9 +435,9 @@ run_test('first/prev/next', () => {
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('filter_user_ids', () => {
|
||||
const user_filter = $('.user-list-filter');
|
||||
user_filter.val(''); // no search filter
|
||||
run_test("filter_user_ids", () => {
|
||||
const user_filter = $(".user-list-filter");
|
||||
user_filter.val(""); // no search filter
|
||||
|
||||
function get_user_ids() {
|
||||
const filter_text = activity.get_filter_text();
|
||||
@@ -455,83 +455,83 @@ run_test('filter_user_ids', () => {
|
||||
mark.user_id,
|
||||
]);
|
||||
|
||||
user_filter.val('abc'); // no match
|
||||
user_filter.val("abc"); // no match
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, []);
|
||||
|
||||
user_filter.val('fred'); // match fred
|
||||
user_filter.val("fred"); // match fred
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, [fred.user_id]);
|
||||
|
||||
user_filter.val('fred,alice'); // match fred and alice
|
||||
user_filter.val("fred,alice"); // match fred and alice
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
|
||||
|
||||
user_filter.val('fr,al'); // match fred and alice partials
|
||||
user_filter.val("fr,al"); // match fred and alice partials
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
|
||||
|
||||
user_filter.val('fr|al'); // test | as OR-operator
|
||||
user_filter.val("fr|al"); // test | as OR-operator
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
|
||||
|
||||
presence.presence_info.set(alice.user_id, { status: activity.IDLE });
|
||||
user_filter.val('fr,al'); // match fred and alice partials and idle user
|
||||
user_filter.val("fr,al"); // match fred and alice partials and idle user
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, [fred.user_id, alice.user_id]);
|
||||
|
||||
$.stub_selector('.user-list-filter', []);
|
||||
$.stub_selector(".user-list-filter", []);
|
||||
presence.presence_info.set(alice.user_id, { status: activity.ACTIVE });
|
||||
user_ids = get_user_ids();
|
||||
assert.deepEqual(user_ids, [alice.user_id, fred.user_id]);
|
||||
});
|
||||
|
||||
run_test('insert_one_user_into_empty_list', () => {
|
||||
run_test("insert_one_user_into_empty_list", () => {
|
||||
let appended_html;
|
||||
$('#user_presences').append = function (html) {
|
||||
$("#user_presences").append = function (html) {
|
||||
appended_html = html;
|
||||
};
|
||||
|
||||
clear_buddy_list();
|
||||
activity.redraw_user(alice.user_id);
|
||||
assert(appended_html.indexOf('data-user-id="1"') > 0);
|
||||
assert(appended_html.indexOf('user_circle_green') > 0);
|
||||
assert(appended_html.indexOf("user_circle_green") > 0);
|
||||
});
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('insert_alice_then_fred', () => {
|
||||
run_test("insert_alice_then_fred", () => {
|
||||
clear_buddy_list();
|
||||
|
||||
let appended_html;
|
||||
$('#user_presences').append = function (html) {
|
||||
$("#user_presences").append = function (html) {
|
||||
appended_html = html;
|
||||
};
|
||||
|
||||
activity.redraw_user(alice.user_id);
|
||||
assert(appended_html.indexOf('data-user-id="1"') > 0);
|
||||
assert(appended_html.indexOf('user_circle_green') > 0);
|
||||
assert(appended_html.indexOf("user_circle_green") > 0);
|
||||
|
||||
activity.redraw_user(fred.user_id);
|
||||
assert(appended_html.indexOf('data-user-id="2"') > 0);
|
||||
assert(appended_html.indexOf('user_circle_green') > 0);
|
||||
assert(appended_html.indexOf("user_circle_green") > 0);
|
||||
});
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('insert_fred_then_alice_then_rename', () => {
|
||||
run_test("insert_fred_then_alice_then_rename", () => {
|
||||
clear_buddy_list();
|
||||
|
||||
let appended_html;
|
||||
$('#user_presences').append = function (html) {
|
||||
$("#user_presences").append = function (html) {
|
||||
appended_html = html;
|
||||
};
|
||||
|
||||
activity.redraw_user(fred.user_id);
|
||||
assert(appended_html.indexOf('data-user-id="2"') > 0);
|
||||
assert(appended_html.indexOf('user_circle_green') > 0);
|
||||
assert(appended_html.indexOf("user_circle_green") > 0);
|
||||
|
||||
const fred_stub = $.create('fred-first');
|
||||
const fred_stub = $.create("fred-first");
|
||||
buddy_list_add(fred.user_id, fred_stub);
|
||||
|
||||
let inserted_html;
|
||||
@@ -541,7 +541,7 @@ run_test('insert_fred_then_alice_then_rename', () => {
|
||||
|
||||
activity.redraw_user(alice.user_id);
|
||||
assert(inserted_html.indexOf('data-user-id="1"') > 0);
|
||||
assert(inserted_html.indexOf('user_circle_green') > 0);
|
||||
assert(inserted_html.indexOf("user_circle_green") > 0);
|
||||
|
||||
// Next rename fred to Aaron.
|
||||
const fred_with_new_name = {
|
||||
@@ -551,7 +551,7 @@ run_test('insert_fred_then_alice_then_rename', () => {
|
||||
};
|
||||
people.add_active_user(fred_with_new_name);
|
||||
|
||||
const alice_stub = $.create('alice-first');
|
||||
const alice_stub = $.create("alice-first");
|
||||
buddy_list_add(alice.user_id, alice_stub);
|
||||
|
||||
alice_stub.before = (html) => {
|
||||
@@ -568,75 +568,75 @@ run_test('insert_fred_then_alice_then_rename', () => {
|
||||
// Reset jquery here.
|
||||
reset_setup();
|
||||
|
||||
run_test('insert_unfiltered_user_with_filter', () => {
|
||||
run_test("insert_unfiltered_user_with_filter", () => {
|
||||
// This test only tests that we do not explode when
|
||||
// try to insert Fred into a list where he does not
|
||||
// match the search filter.
|
||||
const user_filter = $('.user-list-filter');
|
||||
user_filter.val('do-not-match-filter');
|
||||
const user_filter = $(".user-list-filter");
|
||||
user_filter.val("do-not-match-filter");
|
||||
activity.redraw_user(fred.user_id);
|
||||
});
|
||||
|
||||
run_test('realm_presence_disabled', () => {
|
||||
run_test("realm_presence_disabled", () => {
|
||||
page_params.realm_presence_disabled = true;
|
||||
|
||||
activity.redraw_user();
|
||||
activity.build_user_sidebar();
|
||||
});
|
||||
|
||||
run_test('clear_search', () => {
|
||||
$('.user-list-filter').val('somevalue');
|
||||
run_test("clear_search", () => {
|
||||
$(".user-list-filter").val("somevalue");
|
||||
activity.user_filter.clear_search();
|
||||
assert.equal($('.user-list-filter').val(), '');
|
||||
assert.equal($(".user-list-filter").val(), "");
|
||||
activity.user_filter.clear_search();
|
||||
assert($('#user_search_section').hasClass('notdisplayed'));
|
||||
assert($("#user_search_section").hasClass("notdisplayed"));
|
||||
});
|
||||
|
||||
run_test('escape_search', () => {
|
||||
run_test("escape_search", () => {
|
||||
clear_buddy_list();
|
||||
$('.user-list-filter').val('somevalue');
|
||||
$(".user-list-filter").val("somevalue");
|
||||
activity.escape_search();
|
||||
assert.equal($('.user-list-filter').val(), '');
|
||||
assert.equal($(".user-list-filter").val(), "");
|
||||
activity.escape_search();
|
||||
assert($('#user_search_section').hasClass('notdisplayed'));
|
||||
assert($("#user_search_section").hasClass("notdisplayed"));
|
||||
});
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('initiate_search', () => {
|
||||
$('.user-list-filter').blur();
|
||||
run_test("initiate_search", () => {
|
||||
$(".user-list-filter").blur();
|
||||
simulate_right_column_buddy_list();
|
||||
activity.initiate_search();
|
||||
assert.equal($('.column-right').hasClass('expanded'), true);
|
||||
assert.equal($('.user-list-filter').is_focused(), true);
|
||||
assert.equal($(".column-right").hasClass("expanded"), true);
|
||||
assert.equal($(".user-list-filter").is_focused(), true);
|
||||
|
||||
simulate_left_column_buddy_list();
|
||||
activity.initiate_search();
|
||||
assert.equal($('.column-left').hasClass('expanded'), true);
|
||||
assert.equal($('.user-list-filter').is_focused(), true);
|
||||
assert.equal($(".column-left").hasClass("expanded"), true);
|
||||
assert.equal($(".user-list-filter").is_focused(), true);
|
||||
});
|
||||
|
||||
run_test('toggle_filter_display', () => {
|
||||
run_test("toggle_filter_display", () => {
|
||||
activity.user_filter.toggle_filter_displayed();
|
||||
assert($('#user_search_section').hasClass('notdisplayed'));
|
||||
$('.user-list-filter').closest = function (selector) {
|
||||
assert($("#user_search_section").hasClass("notdisplayed"));
|
||||
$(".user-list-filter").closest = function (selector) {
|
||||
assert.equal(selector, ".app-main [class^='column-']");
|
||||
return $.create('sidebar').addClass('column-right');
|
||||
return $.create("sidebar").addClass("column-right");
|
||||
};
|
||||
activity.user_filter.toggle_filter_displayed();
|
||||
assert.equal($('#user_search_section').hasClass('notdisplayed'), false);
|
||||
assert.equal($("#user_search_section").hasClass("notdisplayed"), false);
|
||||
});
|
||||
|
||||
run_test('searching', () => {
|
||||
$('.user-list-filter').focus();
|
||||
run_test("searching", () => {
|
||||
$(".user-list-filter").focus();
|
||||
assert.equal(activity.searching(), true);
|
||||
$('.user-list-filter').blur();
|
||||
$(".user-list-filter").blur();
|
||||
assert.equal(activity.searching(), false);
|
||||
});
|
||||
|
||||
reset_setup();
|
||||
|
||||
run_test('update_presence_info', () => {
|
||||
run_test("update_presence_info", () => {
|
||||
page_params.realm_presence_disabled = false;
|
||||
|
||||
const server_time = 500;
|
||||
@@ -649,7 +649,7 @@ run_test('update_presence_info', () => {
|
||||
|
||||
buddy_data.matches_filter = () => true;
|
||||
|
||||
const alice_li = $.create('alice stub');
|
||||
const alice_li = $.create("alice stub");
|
||||
buddy_list_add(alice.user_id, alice_li);
|
||||
|
||||
let inserted;
|
||||
@@ -660,20 +660,20 @@ run_test('update_presence_info', () => {
|
||||
presence.presence_info.delete(me.user_id);
|
||||
activity.update_presence_info(me.user_id, info, server_time);
|
||||
assert(inserted);
|
||||
assert.deepEqual(presence.presence_info.get(me.user_id).status, 'active');
|
||||
assert.deepEqual(presence.presence_info.get(me.user_id).status, "active");
|
||||
|
||||
presence.presence_info.delete(alice.user_id);
|
||||
activity.update_presence_info(alice.user_id, info, server_time);
|
||||
assert(inserted);
|
||||
|
||||
const expected = { status: 'active', last_active: 500 };
|
||||
const expected = { status: "active", last_active: 500 };
|
||||
assert.deepEqual(presence.presence_info.get(alice.user_id), expected);
|
||||
});
|
||||
|
||||
run_test('initialize', () => {
|
||||
run_test("initialize", () => {
|
||||
function clear() {
|
||||
$.clear_all_elements();
|
||||
buddy_list.container = $('#user_presences');
|
||||
buddy_list.container = $("#user_presences");
|
||||
buddy_list.container.append = () => {};
|
||||
clear_buddy_list();
|
||||
page_params.presences = {};
|
||||
@@ -681,7 +681,7 @@ run_test('initialize', () => {
|
||||
|
||||
clear();
|
||||
|
||||
$.stub_selector('html', {
|
||||
$.stub_selector("html", {
|
||||
on: function (name, func) {
|
||||
func();
|
||||
},
|
||||
@@ -708,7 +708,7 @@ run_test('initialize', () => {
|
||||
|
||||
assert(scroll_handler_started);
|
||||
assert(!activity.new_user_input);
|
||||
assert(!$('#zephyr-mirror-error').hasClass('show'));
|
||||
assert(!$("#zephyr-mirror-error").hasClass("show"));
|
||||
assert(activity.client_is_active);
|
||||
$(window).idle = function (params) {
|
||||
params.onIdle();
|
||||
@@ -723,14 +723,14 @@ run_test('initialize', () => {
|
||||
|
||||
activity.initialize();
|
||||
|
||||
assert($('#zephyr-mirror-error').hasClass('show'));
|
||||
assert($("#zephyr-mirror-error").hasClass("show"));
|
||||
assert(!activity.new_user_input);
|
||||
assert(!activity.client_is_active);
|
||||
|
||||
clear();
|
||||
});
|
||||
|
||||
run_test('away_status', () => {
|
||||
run_test("away_status", () => {
|
||||
assert(!user_status.is_away(alice.user_id));
|
||||
activity.on_set_away(alice.user_id);
|
||||
assert(user_status.is_away(alice.user_id));
|
||||
@@ -738,7 +738,7 @@ run_test('away_status', () => {
|
||||
assert(!user_status.is_away(alice.user_id));
|
||||
});
|
||||
|
||||
run_test('electron_bridge', () => {
|
||||
run_test("electron_bridge", () => {
|
||||
activity.client_is_active = false;
|
||||
window.electron_bridge = undefined;
|
||||
assert.equal(activity.compute_active_status(), activity.IDLE);
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
const params = {
|
||||
alert_words: ['alertone', 'alerttwo', 'alertthree', 'al*rt.*s', '.+', 'emoji'],
|
||||
alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"],
|
||||
};
|
||||
|
||||
zrequire('people');
|
||||
zrequire('alert_words');
|
||||
zrequire("people");
|
||||
zrequire("alert_words");
|
||||
|
||||
alert_words.initialize(params);
|
||||
|
||||
people.add_active_user({
|
||||
email: 'tester@zulip.com',
|
||||
full_name: 'Tester von Tester',
|
||||
email: "tester@zulip.com",
|
||||
full_name: "Tester von Tester",
|
||||
user_id: 42,
|
||||
});
|
||||
|
||||
people.initialize_current_user(42);
|
||||
|
||||
const regular_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>a message</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>a message</p>",
|
||||
};
|
||||
const own_message = {
|
||||
sender_email: 'tester@zulip.com',
|
||||
content: '<p>hey this message alertone</p>',
|
||||
sender_email: "tester@zulip.com",
|
||||
content: "<p>hey this message alertone</p>",
|
||||
alerted: true,
|
||||
};
|
||||
const other_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>another alertone message</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>another alertone message</p>",
|
||||
alerted: true,
|
||||
};
|
||||
const caps_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>another ALERTtwo message</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>another ALERTtwo message</p>",
|
||||
alerted: true,
|
||||
};
|
||||
const alertwordboundary_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>another alertthreemessage</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>another alertthreemessage</p>",
|
||||
alerted: false,
|
||||
};
|
||||
const multialert_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>another alertthreemessage alertone and then alerttwo</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>another alertthreemessage alertone and then alerttwo</p>",
|
||||
alerted: true,
|
||||
};
|
||||
const unsafe_word_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>gotta al*rt.*s all</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>gotta al*rt.*s all</p>",
|
||||
alerted: true,
|
||||
};
|
||||
const alert_in_url_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>http://www.google.com/alertone/me</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>http://www.google.com/alertone/me</p>",
|
||||
alerted: true,
|
||||
};
|
||||
const question_word_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
content: '<p>still alertone? me</p>',
|
||||
sender_email: "another@zulip.com",
|
||||
content: "<p>still alertone? me</p>",
|
||||
alerted: true,
|
||||
};
|
||||
|
||||
const alert_domain_message = {
|
||||
sender_email: 'another@zulip.com',
|
||||
sender_email: "another@zulip.com",
|
||||
content: '<p>now with link <a href="http://www.alerttwo.us/foo/bar" target="_blank" title="http://www.alerttwo.us/foo/bar">www.alerttwo.us/foo/bar</a></p>',
|
||||
alerted: true,
|
||||
};
|
||||
// This test ensure we are not mucking up rendered HTML content.
|
||||
const message_with_emoji = {
|
||||
sender_email: 'another@zulip.com',
|
||||
sender_email: "another@zulip.com",
|
||||
content: '<p>I <img alt=":heart:" class="emoji" src="/static/generated/emoji/images/emoji/unicode/2764.png" title="heart"> emoji!</p>',
|
||||
alerted: true,
|
||||
};
|
||||
|
||||
run_test('notifications', () => {
|
||||
run_test("notifications", () => {
|
||||
assert(!alert_words.notifies(regular_message));
|
||||
assert(!alert_words.notifies(own_message));
|
||||
assert(alert_words.notifies(other_message));
|
||||
@@ -84,7 +84,7 @@ run_test('notifications', () => {
|
||||
assert(alert_words.notifies(message_with_emoji));
|
||||
});
|
||||
|
||||
run_test('munging', () => {
|
||||
run_test("munging", () => {
|
||||
let saved_content = regular_message.content;
|
||||
alert_words.process_message(regular_message);
|
||||
assert.equal(saved_content, regular_message.content);
|
||||
@@ -111,17 +111,17 @@ run_test('munging', () => {
|
||||
assert.equal(question_word_message.content, "<p>still <span class='alert-word'>alertone</span>? me</p>");
|
||||
|
||||
alert_words.process_message(alert_domain_message);
|
||||
assert.equal(alert_domain_message.content, `<p>now with link <a href="http://www.alerttwo.us/foo/bar" target="_blank" title="http://www.alerttwo.us/foo/bar">www.<span class='alert-word'>alerttwo</span>.us/foo/bar</a></p>`);
|
||||
assert.equal(alert_domain_message.content, "<p>now with link <a href=\"http://www.alerttwo.us/foo/bar\" target=\"_blank\" title=\"http://www.alerttwo.us/foo/bar\">www.<span class='alert-word'>alerttwo</span>.us/foo/bar</a></p>");
|
||||
|
||||
alert_words.process_message(message_with_emoji);
|
||||
assert.equal(message_with_emoji.content, `<p>I <img alt=":heart:" class="emoji" src="/static/generated/emoji/images/emoji/unicode/2764.png" title="heart"> <span class='alert-word'>emoji</span>!</p>`);
|
||||
assert.equal(message_with_emoji.content, "<p>I <img alt=\":heart:\" class=\"emoji\" src=\"/static/generated/emoji/images/emoji/unicode/2764.png\" title=\"heart\"> <span class='alert-word'>emoji</span>!</p>");
|
||||
});
|
||||
|
||||
run_test('basic get/set operations', () => {
|
||||
assert(!alert_words.has_alert_word('breakfast'));
|
||||
assert(!alert_words.has_alert_word('lunch'));
|
||||
alert_words.set_words(['breakfast', 'lunch']);
|
||||
assert(alert_words.has_alert_word('breakfast'));
|
||||
assert(alert_words.has_alert_word('lunch'));
|
||||
assert(!alert_words.has_alert_word('dinner'));
|
||||
run_test("basic get/set operations", () => {
|
||||
assert(!alert_words.has_alert_word("breakfast"));
|
||||
assert(!alert_words.has_alert_word("lunch"));
|
||||
alert_words.set_words(["breakfast", "lunch"]);
|
||||
assert(alert_words.has_alert_word("breakfast"));
|
||||
assert(alert_words.has_alert_word("lunch"));
|
||||
assert(!alert_words.has_alert_word("dinner"));
|
||||
});
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
set_global('channel', {});
|
||||
set_global("channel", {});
|
||||
|
||||
zrequire('alert_words');
|
||||
zrequire('alert_words_ui');
|
||||
zrequire("alert_words");
|
||||
zrequire("alert_words_ui");
|
||||
|
||||
alert_words.initialize({
|
||||
alert_words: ['foo', 'bar'],
|
||||
alert_words: ["foo", "bar"],
|
||||
});
|
||||
|
||||
run_test('render_alert_words_ui', () => {
|
||||
const word_list = $('#alert_words_list');
|
||||
run_test("render_alert_words_ui", () => {
|
||||
const word_list = $("#alert_words_list");
|
||||
const appended = [];
|
||||
word_list.append = (rendered) => {
|
||||
appended.push(rendered);
|
||||
};
|
||||
|
||||
const alert_word_items = $.create('alert_word_items');
|
||||
word_list.set_find_results('.alert-word-item', alert_word_items);
|
||||
const alert_word_items = $.create("alert_word_items");
|
||||
word_list.set_find_results(".alert-word-item", alert_word_items);
|
||||
|
||||
global.stub_templates((name, args) => {
|
||||
assert.equal(name, 'settings/alert_word_settings_item');
|
||||
return 'stub-' + args.word;
|
||||
assert.equal(name, "settings/alert_word_settings_item");
|
||||
return "stub-" + args.word;
|
||||
});
|
||||
|
||||
const new_alert_word = $('#create_alert_word_name');
|
||||
const new_alert_word = $("#create_alert_word_name");
|
||||
assert(!new_alert_word.is_focused());
|
||||
|
||||
alert_words_ui.render_alert_words_ui();
|
||||
|
||||
assert.deepEqual(appended, [
|
||||
'stub-bar',
|
||||
'stub-foo',
|
||||
"stub-bar",
|
||||
"stub-foo",
|
||||
]);
|
||||
assert(new_alert_word.is_focused());
|
||||
});
|
||||
|
||||
run_test('add_alert_word', () => {
|
||||
run_test("add_alert_word", () => {
|
||||
alert_words_ui.render_alert_words_ui = () => {}; // we've already tested this above
|
||||
|
||||
alert_words_ui.set_up_alert_words();
|
||||
|
||||
const create_form = $('#create_alert_word_form');
|
||||
const add_func = create_form.get_on_handler('click', '#create_alert_word_button');
|
||||
const create_form = $("#create_alert_word_form");
|
||||
const add_func = create_form.get_on_handler("click", "#create_alert_word_button");
|
||||
|
||||
const new_alert_word = $('#create_alert_word_name');
|
||||
const alert_word_status = $('#alert_word_status');
|
||||
const alert_word_status_text = $('.alert_word_status_text');
|
||||
alert_word_status.set_find_results('.alert_word_status_text', alert_word_status_text);
|
||||
const new_alert_word = $("#create_alert_word_name");
|
||||
const alert_word_status = $("#alert_word_status");
|
||||
const alert_word_status_text = $(".alert_word_status_text");
|
||||
alert_word_status.set_find_results(".alert_word_status_text", alert_word_status_text);
|
||||
|
||||
// add '' as alert word
|
||||
add_func();
|
||||
assert.equal(new_alert_word.val(), '');
|
||||
assert(alert_word_status.hasClass('alert-danger'));
|
||||
assert.equal(new_alert_word.val(), "");
|
||||
assert(alert_word_status.hasClass("alert-danger"));
|
||||
assert.equal(alert_word_status_text.text(), "translated: Alert word can't be empty!");
|
||||
assert(alert_word_status.visible());
|
||||
|
||||
// add 'foo' as alert word (existing word)
|
||||
new_alert_word.val('foo');
|
||||
new_alert_word.val("foo");
|
||||
|
||||
add_func();
|
||||
assert(alert_word_status.hasClass('alert-danger'));
|
||||
assert(alert_word_status.hasClass("alert-danger"));
|
||||
assert.equal(alert_word_status_text.text(), "translated: Alert word already exists!");
|
||||
assert(alert_word_status.visible());
|
||||
|
||||
// add 'zot' as alert word (new word)
|
||||
new_alert_word.val('zot');
|
||||
new_alert_word.val("zot");
|
||||
|
||||
let success_func;
|
||||
let fail_func;
|
||||
channel.post = (opts) => {
|
||||
assert.equal(opts.url, '/json/users/me/alert_words');
|
||||
assert.equal(opts.url, "/json/users/me/alert_words");
|
||||
assert.deepEqual(opts.data, {alert_words: '["zot"]'});
|
||||
success_func = opts.success;
|
||||
fail_func = opts.error;
|
||||
@@ -80,28 +80,28 @@ run_test('add_alert_word', () => {
|
||||
|
||||
// test failure
|
||||
fail_func();
|
||||
assert(alert_word_status.hasClass('alert-danger'));
|
||||
assert(alert_word_status.hasClass("alert-danger"));
|
||||
assert.equal(alert_word_status_text.text(), "translated: Error adding alert word!");
|
||||
assert(alert_word_status.visible());
|
||||
|
||||
// test success
|
||||
success_func();
|
||||
assert(alert_word_status.hasClass('alert-success'));
|
||||
assert(alert_word_status.hasClass("alert-success"));
|
||||
assert.equal(alert_word_status_text.text(), "translated: Alert word \"zot\" added successfully!");
|
||||
assert(alert_word_status.visible());
|
||||
});
|
||||
|
||||
run_test('add_alert_word_keypress', () => {
|
||||
const create_form = $('#create_alert_word_form');
|
||||
const keypress_func = create_form.get_on_handler('keypress', '#create_alert_word_name');
|
||||
run_test("add_alert_word_keypress", () => {
|
||||
const create_form = $("#create_alert_word_form");
|
||||
const keypress_func = create_form.get_on_handler("keypress", "#create_alert_word_name");
|
||||
|
||||
const new_alert_word = $('#create_alert_word_name');
|
||||
new_alert_word.val('zot');
|
||||
const new_alert_word = $("#create_alert_word_name");
|
||||
new_alert_word.val("zot");
|
||||
|
||||
const event = {
|
||||
preventDefault: () => {},
|
||||
which: 13,
|
||||
target: '#create_alert_word_name',
|
||||
target: "#create_alert_word_name",
|
||||
};
|
||||
|
||||
let called = false;
|
||||
@@ -114,26 +114,26 @@ run_test('add_alert_word_keypress', () => {
|
||||
assert(called);
|
||||
});
|
||||
|
||||
run_test('remove_alert_word', () => {
|
||||
const word_list = $('#alert_words_list');
|
||||
const remove_func = word_list.get_on_handler('click', '.remove-alert-word');
|
||||
run_test("remove_alert_word", () => {
|
||||
const word_list = $("#alert_words_list");
|
||||
const remove_func = word_list.get_on_handler("click", ".remove-alert-word");
|
||||
|
||||
const remove_alert_word = $('.remove-alert-word');
|
||||
const list_item = $('li.alert-word-item');
|
||||
const val_item = $('span.value');
|
||||
val_item.text(i18n.t('zot'));
|
||||
const remove_alert_word = $(".remove-alert-word");
|
||||
const list_item = $("li.alert-word-item");
|
||||
const val_item = $("span.value");
|
||||
val_item.text(i18n.t("zot"));
|
||||
|
||||
remove_alert_word.set_parents_result('li', list_item);
|
||||
list_item.set_find_results('.value', val_item);
|
||||
remove_alert_word.set_parents_result("li", list_item);
|
||||
list_item.set_find_results(".value", val_item);
|
||||
|
||||
const event = {
|
||||
currentTarget: '.remove-alert-word',
|
||||
currentTarget: ".remove-alert-word",
|
||||
};
|
||||
|
||||
let success_func;
|
||||
let fail_func;
|
||||
channel.del = (opts) => {
|
||||
assert.equal(opts.url, '/json/users/me/alert_words');
|
||||
assert.equal(opts.url, "/json/users/me/alert_words");
|
||||
assert.deepEqual(opts.data, {alert_words: '["translated: zot"]'});
|
||||
success_func = opts.success;
|
||||
fail_func = opts.error;
|
||||
@@ -141,36 +141,36 @@ run_test('remove_alert_word', () => {
|
||||
|
||||
remove_func(event);
|
||||
|
||||
const alert_word_status = $('#alert_word_status');
|
||||
const alert_word_status_text = $('.alert_word_status_text');
|
||||
alert_word_status.set_find_results('.alert_word_status_text', alert_word_status_text);
|
||||
const alert_word_status = $("#alert_word_status");
|
||||
const alert_word_status_text = $(".alert_word_status_text");
|
||||
alert_word_status.set_find_results(".alert_word_status_text", alert_word_status_text);
|
||||
|
||||
// test failure
|
||||
fail_func();
|
||||
assert(alert_word_status.hasClass('alert-danger'));
|
||||
assert(alert_word_status.hasClass("alert-danger"));
|
||||
assert.equal(alert_word_status_text.text(), "translated: Error removing alert word!");
|
||||
assert(alert_word_status.visible());
|
||||
|
||||
// test success
|
||||
success_func();
|
||||
assert(alert_word_status.hasClass('alert-success'));
|
||||
assert(alert_word_status.hasClass("alert-success"));
|
||||
assert.equal(alert_word_status_text.text(), "translated: Alert word removed successfully!");
|
||||
assert(alert_word_status.visible());
|
||||
});
|
||||
|
||||
run_test('close_status_message', () => {
|
||||
const alert_word_settings = $('#alert-word-settings');
|
||||
const close = alert_word_settings.get_on_handler('click', '.close-alert-word-status');
|
||||
run_test("close_status_message", () => {
|
||||
const alert_word_settings = $("#alert-word-settings");
|
||||
const close = alert_word_settings.get_on_handler("click", ".close-alert-word-status");
|
||||
|
||||
const alert = $('.alert');
|
||||
const close_btn = $('.close-alert-word-status');
|
||||
close_btn.set_parents_result('.alert', alert);
|
||||
const alert = $(".alert");
|
||||
const close_btn = $(".close-alert-word-status");
|
||||
close_btn.set_parents_result(".alert", alert);
|
||||
|
||||
alert.show();
|
||||
|
||||
const event = {
|
||||
preventDefault: () => {},
|
||||
currentTarget: '.close-alert-word-status',
|
||||
currentTarget: ".close-alert-word-status",
|
||||
};
|
||||
|
||||
assert(alert.visible());
|
||||
|
||||
@@ -8,15 +8,15 @@ const document = dom.window.document;
|
||||
|
||||
let jquery_init;
|
||||
global.$ = (f) => {jquery_init = f;};
|
||||
set_global('helpers', {
|
||||
set_global("helpers", {
|
||||
set_tab: noop,
|
||||
});
|
||||
set_global('StripeCheckout', {
|
||||
set_global("StripeCheckout", {
|
||||
configure: noop,
|
||||
});
|
||||
|
||||
zrequire('billing', "js/billing/billing");
|
||||
set_global('$', global.make_zjquery());
|
||||
zrequire("billing", "js/billing/billing");
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
run_test("initialize", () => {
|
||||
let token_func;
|
||||
@@ -51,9 +51,9 @@ run_test("initialize", () => {
|
||||
|
||||
let stripe_checkout_configure_called = false;
|
||||
StripeCheckout.configure = (config_opts) => {
|
||||
assert.equal(config_opts.image, '/static/images/logo/zulip-icon-128x128.png');
|
||||
assert.equal(config_opts.locale, 'auto');
|
||||
assert.equal(config_opts.key, '{{publishable_key}}');
|
||||
assert.equal(config_opts.image, "/static/images/logo/zulip-icon-128x128.png");
|
||||
assert.equal(config_opts.locale, "auto");
|
||||
assert.equal(config_opts.key, "{{publishable_key}}");
|
||||
token_func = config_opts.token;
|
||||
stripe_checkout_configure_called = true;
|
||||
|
||||
@@ -71,7 +71,7 @@ run_test("initialize", () => {
|
||||
const e = {
|
||||
preventDefault: noop,
|
||||
};
|
||||
const update_card_click_handler = $('#update-card-button').get_on_handler('click');
|
||||
const update_card_click_handler = $("#update-card-button").get_on_handler("click");
|
||||
update_card_click_handler(e);
|
||||
assert(create_ajax_request_called);
|
||||
assert(open_func_called);
|
||||
@@ -85,7 +85,7 @@ run_test("initialize", () => {
|
||||
create_ajax_request_called = true;
|
||||
};
|
||||
|
||||
const change_plan_status_click_handler = $('#change-plan-status').get_on_handler('click');
|
||||
const change_plan_status_click_handler = $("#change-plan-status").get_on_handler("click");
|
||||
change_plan_status_click_handler(e);
|
||||
assert(create_ajax_request_called);
|
||||
});
|
||||
|
||||
@@ -2,24 +2,24 @@ const { JSDOM } = require("jsdom");
|
||||
const fs = require("fs");
|
||||
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8");
|
||||
const dom = new JSDOM(template, { pretendToBeVisual: true });
|
||||
const jquery = require('jquery')(dom.window);
|
||||
const jquery = require("jquery")(dom.window);
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('page_params', {});
|
||||
set_global('loading', {});
|
||||
set_global('history', {});
|
||||
set_global('document', {
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("page_params", {});
|
||||
set_global("loading", {});
|
||||
set_global("history", {});
|
||||
set_global("document", {
|
||||
title: "Zulip",
|
||||
});
|
||||
set_global('location', {
|
||||
set_global("location", {
|
||||
pathname: "/upgrade/",
|
||||
search: "",
|
||||
hash: "#billing",
|
||||
});
|
||||
|
||||
zrequire('helpers', "js/billing/helpers");
|
||||
zrequire("helpers", "js/billing/helpers");
|
||||
|
||||
run_test('create_ajax_request', () => {
|
||||
run_test("create_ajax_request", () => {
|
||||
const form_loading_indicator = "#autopay_loading_indicator";
|
||||
const form_input_section = "#autopay-input-section";
|
||||
const form_success = "#autopay-success";
|
||||
@@ -124,7 +124,7 @@ run_test('create_ajax_request', () => {
|
||||
assert.equal(data.billing_modality, '"charge_automatically"');
|
||||
assert.equal(data.schedule, '"monthly"');
|
||||
assert.equal(data.license_management, '"automatic"');
|
||||
assert.equal(data.licenses, '');
|
||||
assert.equal(data.licenses, "");
|
||||
|
||||
history.pushState = (state_object, title, path) => {
|
||||
state.pushState += 1;
|
||||
@@ -224,8 +224,8 @@ run_test("show_license_section", () => {
|
||||
assert.equal(state.hide_license_manual_section, 1);
|
||||
assert.equal(state.show_license_automatic_section, 1);
|
||||
assert.equal(state.show_license_manual_section, 0);
|
||||
assert.equal($("#automatic_license_count").prop('disabled'), false);
|
||||
assert.equal($("#manual_license_count").prop('disabled'), true);
|
||||
assert.equal($("#automatic_license_count").prop("disabled"), false);
|
||||
assert.equal($("#manual_license_count").prop("disabled"), true);
|
||||
|
||||
helpers.show_license_section("manual");
|
||||
|
||||
@@ -233,8 +233,8 @@ run_test("show_license_section", () => {
|
||||
assert.equal(state.hide_license_manual_section, 2);
|
||||
assert.equal(state.show_license_automatic_section, 1);
|
||||
assert.equal(state.show_license_manual_section, 1);
|
||||
assert.equal($("#automatic_license_count").prop('disabled'), true);
|
||||
assert.equal($("#manual_license_count").prop('disabled'), false);
|
||||
assert.equal($("#automatic_license_count").prop("disabled"), true);
|
||||
assert.equal($("#manual_license_count").prop("disabled"), false);
|
||||
});
|
||||
|
||||
run_test("set_tab", () => {
|
||||
|
||||
@@ -2,20 +2,20 @@ const _settings_bots = {
|
||||
render_bots: () => {},
|
||||
};
|
||||
|
||||
set_global('settings_bots', _settings_bots);
|
||||
set_global("settings_bots", _settings_bots);
|
||||
|
||||
zrequire('bot_data');
|
||||
zrequire('people');
|
||||
zrequire("bot_data");
|
||||
zrequire("people");
|
||||
|
||||
const me = {
|
||||
email: 'me@zulip.com',
|
||||
full_name: 'Me Myself',
|
||||
email: "me@zulip.com",
|
||||
full_name: "Me Myself",
|
||||
user_id: 2,
|
||||
};
|
||||
|
||||
const fred = {
|
||||
email: 'fred@zulip.com',
|
||||
full_name: 'Fred Frederickson',
|
||||
email: "fred@zulip.com",
|
||||
full_name: "Fred Frederickson",
|
||||
user_id: 3,
|
||||
};
|
||||
|
||||
@@ -24,36 +24,36 @@ people.add_active_user(fred);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
const bot_data_params = {
|
||||
realm_bots: [{email: 'bot0@zulip.com', user_id: 42, full_name: 'Bot 0',
|
||||
realm_bots: [{email: "bot0@zulip.com", user_id: 42, full_name: "Bot 0",
|
||||
services: []},
|
||||
{email: 'outgoingwebhook@zulip.com', user_id: 314, full_name: "Outgoing webhook",
|
||||
{email: "outgoingwebhook@zulip.com", user_id: 314, full_name: "Outgoing webhook",
|
||||
services: [{base_url: "http://foo.com", interface: 1}]}],
|
||||
};
|
||||
|
||||
|
||||
bot_data.initialize(bot_data_params);
|
||||
// Our startup logic should have added Bot 0 from page_params.
|
||||
assert.equal(bot_data.get(42).full_name, 'Bot 0');
|
||||
assert.equal(bot_data.get(314).full_name, 'Outgoing webhook');
|
||||
assert.equal(bot_data.get(42).full_name, "Bot 0");
|
||||
assert.equal(bot_data.get(314).full_name, "Outgoing webhook");
|
||||
|
||||
run_test('test_basics', () => {
|
||||
run_test("test_basics", () => {
|
||||
const test_bot = {
|
||||
email: 'bot1@zulip.com',
|
||||
email: "bot1@zulip.com",
|
||||
user_id: 43,
|
||||
avatar_url: '',
|
||||
full_name: 'Bot 1',
|
||||
avatar_url: "",
|
||||
full_name: "Bot 1",
|
||||
services: [{base_url: "http://bar.com", interface: 1}],
|
||||
extra: 'Not in data',
|
||||
extra: "Not in data",
|
||||
};
|
||||
|
||||
const test_embedded_bot = {
|
||||
email: 'embedded-bot@zulip.com',
|
||||
email: "embedded-bot@zulip.com",
|
||||
user_id: 143,
|
||||
avatar_url: '',
|
||||
full_name: 'Embedded bot 1',
|
||||
services: [{config_data: {key: '12345678'},
|
||||
avatar_url: "",
|
||||
full_name: "Embedded bot 1",
|
||||
services: [{config_data: {key: "12345678"},
|
||||
service_name: "giphy"}],
|
||||
owner: 'cordelia@zulip.com',
|
||||
owner: "cordelia@zulip.com",
|
||||
};
|
||||
|
||||
(function test_add() {
|
||||
@@ -61,8 +61,8 @@ run_test('test_basics', () => {
|
||||
|
||||
const bot = bot_data.get(43);
|
||||
const services = bot_data.get_services(43);
|
||||
assert.equal('Bot 1', bot.full_name);
|
||||
assert.equal('http://bar.com', services[0].base_url);
|
||||
assert.equal("Bot 1", bot.full_name);
|
||||
assert.equal("http://bar.com", services[0].base_url);
|
||||
assert.equal(1, services[0].interface);
|
||||
assert.equal(undefined, bot.extra);
|
||||
}());
|
||||
@@ -71,15 +71,15 @@ run_test('test_basics', () => {
|
||||
bot_data.add(test_bot);
|
||||
|
||||
let bot = bot_data.get(43);
|
||||
assert.equal('Bot 1', bot.full_name);
|
||||
bot_data.update(43, {full_name: 'New Bot 1',
|
||||
assert.equal("Bot 1", bot.full_name);
|
||||
bot_data.update(43, {full_name: "New Bot 1",
|
||||
services: [{interface: 2,
|
||||
base_url: 'http://baz.com'}]});
|
||||
base_url: "http://baz.com"}]});
|
||||
bot = bot_data.get(43);
|
||||
const services = bot_data.get_services(43);
|
||||
assert.equal('New Bot 1', bot.full_name);
|
||||
assert.equal("New Bot 1", bot.full_name);
|
||||
assert.equal(2, services[0].interface);
|
||||
assert.equal('http://baz.com', services[0].base_url);
|
||||
assert.equal("http://baz.com", services[0].base_url);
|
||||
|
||||
const change_owner_event = {
|
||||
owner_id: fred.user_id,
|
||||
@@ -94,9 +94,9 @@ run_test('test_basics', () => {
|
||||
bot_data.add(test_embedded_bot);
|
||||
const bot_id = 143;
|
||||
const services = bot_data.get_services(bot_id);
|
||||
assert.equal('12345678', services[0].config_data.key);
|
||||
bot_data.update(bot_id, {services: [{config_data: {key: '87654321'}}]});
|
||||
assert.equal('87654321', services[0].config_data.key);
|
||||
assert.equal("12345678", services[0].config_data.key);
|
||||
bot_data.update(bot_id, {services: [{config_data: {key: "87654321"}}]});
|
||||
assert.equal("87654321", services[0].config_data.key);
|
||||
}());
|
||||
|
||||
(function test_remove() {
|
||||
@@ -105,7 +105,7 @@ run_test('test_basics', () => {
|
||||
bot_data.add({ ...test_bot, is_active: true });
|
||||
|
||||
bot = bot_data.get(43);
|
||||
assert.equal('Bot 1', bot.full_name);
|
||||
assert.equal("Bot 1", bot.full_name);
|
||||
assert(bot.is_active);
|
||||
bot_data.deactivate(43);
|
||||
bot = bot_data.get(43);
|
||||
@@ -124,7 +124,7 @@ run_test('test_basics', () => {
|
||||
bot_data.add({ ...test_bot, is_active: true });
|
||||
|
||||
bot = bot_data.get(43);
|
||||
assert.equal('Bot 1', bot.full_name);
|
||||
assert.equal("Bot 1", bot.full_name);
|
||||
assert(bot.is_active);
|
||||
bot_data.del(43);
|
||||
bot = bot_data.get(43);
|
||||
@@ -134,18 +134,18 @@ run_test('test_basics', () => {
|
||||
(function test_get_editable() {
|
||||
|
||||
bot_data.add({...test_bot, user_id: 44, owner_id: me.user_id, is_active: true});
|
||||
bot_data.add({...test_bot, user_id: 45, email: 'bot2@zulip.com', owner_id: me.user_id, is_active: true});
|
||||
bot_data.add({...test_bot, user_id: 46, email: 'bot3@zulip.com', owner_id: fred.user_id, is_active: true});
|
||||
bot_data.add({...test_bot, user_id: 45, email: "bot2@zulip.com", owner_id: me.user_id, is_active: true});
|
||||
bot_data.add({...test_bot, user_id: 46, email: "bot3@zulip.com", owner_id: fred.user_id, is_active: true});
|
||||
|
||||
const editable_bots = bot_data.get_editable().map((bot) => bot.email);
|
||||
assert.deepEqual(['bot1@zulip.com', 'bot2@zulip.com'], editable_bots);
|
||||
assert.deepEqual(["bot1@zulip.com", "bot2@zulip.com"], editable_bots);
|
||||
}());
|
||||
|
||||
(function test_get_all_bots_for_current_user() {
|
||||
const bots = bot_data.get_all_bots_for_current_user();
|
||||
|
||||
assert.equal(bots.length, 2);
|
||||
assert.equal(bots[0].email, 'bot1@zulip.com');
|
||||
assert.equal(bots[1].email, 'bot2@zulip.com');
|
||||
assert.equal(bots[0].email, "bot1@zulip.com");
|
||||
assert.equal(bots[1].email, "bot2@zulip.com");
|
||||
}());
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const _page_params = {};
|
||||
|
||||
set_global('page_params', _page_params);
|
||||
set_global('$', global.make_zjquery());
|
||||
zrequire('people');
|
||||
zrequire('presence');
|
||||
zrequire('user_status');
|
||||
set_global("page_params", _page_params);
|
||||
set_global("$", global.make_zjquery());
|
||||
zrequire("people");
|
||||
zrequire("presence");
|
||||
zrequire("user_status");
|
||||
|
||||
zrequire('buddy_data');
|
||||
set_global('timerender', {});
|
||||
zrequire("buddy_data");
|
||||
set_global("timerender", {});
|
||||
|
||||
// The buddy_data module is mostly tested indirectly through
|
||||
// activity.js, but we should feel free to add direct tests
|
||||
@@ -15,61 +15,61 @@ set_global('timerender', {});
|
||||
|
||||
const selma = {
|
||||
user_id: 1000,
|
||||
full_name: 'Human Selma',
|
||||
email: 'selma@example.com',
|
||||
full_name: "Human Selma",
|
||||
email: "selma@example.com",
|
||||
};
|
||||
|
||||
const me = {
|
||||
user_id: 1001,
|
||||
full_name: 'Human Myself',
|
||||
email: 'self@example.com',
|
||||
full_name: "Human Myself",
|
||||
email: "self@example.com",
|
||||
};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@zulip.com',
|
||||
email: "alice@zulip.com",
|
||||
user_id: 1002,
|
||||
full_name: 'Alice Smith',
|
||||
full_name: "Alice Smith",
|
||||
};
|
||||
|
||||
const fred = {
|
||||
email: 'fred@zulip.com',
|
||||
email: "fred@zulip.com",
|
||||
user_id: 1003,
|
||||
full_name: "Fred Flintstone",
|
||||
};
|
||||
|
||||
const jill = {
|
||||
email: 'jill@zulip.com',
|
||||
email: "jill@zulip.com",
|
||||
user_id: 1004,
|
||||
full_name: 'Jill Hill',
|
||||
full_name: "Jill Hill",
|
||||
};
|
||||
|
||||
const mark = {
|
||||
email: 'mark@zulip.com',
|
||||
email: "mark@zulip.com",
|
||||
user_id: 1005,
|
||||
full_name: 'Marky Mark',
|
||||
full_name: "Marky Mark",
|
||||
};
|
||||
|
||||
const old_user = {
|
||||
user_id: 9999,
|
||||
full_name: 'Old User',
|
||||
email: 'old_user@example.com',
|
||||
full_name: "Old User",
|
||||
email: "old_user@example.com",
|
||||
};
|
||||
|
||||
const bot = {
|
||||
user_id: 55555,
|
||||
full_name: 'Red Herring Bot',
|
||||
email: 'bot@example.com',
|
||||
full_name: "Red Herring Bot",
|
||||
email: "bot@example.com",
|
||||
is_bot: true,
|
||||
bot_owner_id: null,
|
||||
};
|
||||
|
||||
const bot_with_owner = {
|
||||
user_id: 55556,
|
||||
full_name: 'Blue Herring Bot',
|
||||
email: 'bot_with_owner@example.com',
|
||||
full_name: "Blue Herring Bot",
|
||||
email: "bot_with_owner@example.com",
|
||||
is_bot: true,
|
||||
bot_owner_id: 1001,
|
||||
bot_owner_full_name: 'Human Myself',
|
||||
bot_owner_full_name: "Human Myself",
|
||||
};
|
||||
|
||||
function make_people() {
|
||||
@@ -100,15 +100,15 @@ function make_people() {
|
||||
|
||||
make_people();
|
||||
|
||||
run_test('huddle_fraction_present', () => {
|
||||
let huddle = 'alice@zulip.com,fred@zulip.com,jill@zulip.com,mark@zulip.com';
|
||||
run_test("huddle_fraction_present", () => {
|
||||
let huddle = "alice@zulip.com,fred@zulip.com,jill@zulip.com,mark@zulip.com";
|
||||
huddle = people.emails_strings_to_user_ids_string(huddle);
|
||||
|
||||
let presence_info = new Map();
|
||||
presence_info.set(alice.user_id, { status: 'active' }); // counts as present
|
||||
presence_info.set(fred.user_id, { status: 'idle' }); // does not count as present
|
||||
presence_info.set(alice.user_id, { status: "active" }); // counts as present
|
||||
presence_info.set(fred.user_id, { status: "idle" }); // does not count as present
|
||||
// jill not in list
|
||||
presence_info.set(mark.user_id, { status: 'offline' }); // does not count
|
||||
presence_info.set(mark.user_id, { status: "offline" }); // does not count
|
||||
presence.presence_info = presence_info;
|
||||
|
||||
assert.equal(
|
||||
@@ -117,7 +117,7 @@ run_test('huddle_fraction_present', () => {
|
||||
|
||||
presence_info = new Map();
|
||||
for (const user of [alice, fred, jill, mark]) {
|
||||
presence_info.set(user.user_id, { status: 'active' }); // counts as present
|
||||
presence_info.set(user.user_id, { status: "active" }); // counts as present
|
||||
}
|
||||
presence.presence_info = presence_info;
|
||||
|
||||
@@ -125,13 +125,13 @@ run_test('huddle_fraction_present', () => {
|
||||
buddy_data.huddle_fraction_present(huddle),
|
||||
1);
|
||||
|
||||
huddle = 'alice@zulip.com,fred@zulip.com,jill@zulip.com,mark@zulip.com';
|
||||
huddle = "alice@zulip.com,fred@zulip.com,jill@zulip.com,mark@zulip.com";
|
||||
huddle = people.emails_strings_to_user_ids_string(huddle);
|
||||
presence_info = new Map();
|
||||
presence_info.set(alice.user_id, { status: 'idle' });
|
||||
presence_info.set(fred.user_id, { status: 'idle' }); // does not count as present
|
||||
presence_info.set(alice.user_id, { status: "idle" });
|
||||
presence_info.set(fred.user_id, { status: "idle" }); // does not count as present
|
||||
// jill not in list
|
||||
presence_info.set(mark.user_id, { status: 'offline' }); // does not count
|
||||
presence_info.set(mark.user_id, { status: "offline" }); // does not count
|
||||
presence.presence_info = presence_info;
|
||||
|
||||
assert.equal(
|
||||
@@ -150,108 +150,108 @@ function activate_people() {
|
||||
}
|
||||
|
||||
// Make 400 of the users active
|
||||
set_presence(selma.user_id, 'active');
|
||||
set_presence(me.user_id, 'active');
|
||||
set_presence(selma.user_id, "active");
|
||||
set_presence(me.user_id, "active");
|
||||
|
||||
for (const user_id of _.range(1000, 1400)) {
|
||||
set_presence(user_id, 'active');
|
||||
set_presence(user_id, "active");
|
||||
}
|
||||
|
||||
// And then 300 not active
|
||||
for (const user_id of _.range(1400, 1700)) {
|
||||
set_presence(user_id, 'offline');
|
||||
set_presence(user_id, "offline");
|
||||
}
|
||||
}
|
||||
|
||||
activate_people();
|
||||
|
||||
run_test('user_circle', () => {
|
||||
assert.equal(buddy_data.get_user_circle_class(selma.user_id), 'user_circle_green');
|
||||
run_test("user_circle", () => {
|
||||
assert.equal(buddy_data.get_user_circle_class(selma.user_id), "user_circle_green");
|
||||
user_status.set_away(selma.user_id);
|
||||
assert.equal(buddy_data.get_user_circle_class(selma.user_id), 'user_circle_empty_line');
|
||||
assert.equal(buddy_data.get_user_circle_class(selma.user_id), "user_circle_empty_line");
|
||||
user_status.revoke_away(selma.user_id);
|
||||
assert.equal(buddy_data.get_user_circle_class(selma.user_id), 'user_circle_green');
|
||||
assert.equal(buddy_data.get_user_circle_class(selma.user_id), "user_circle_green");
|
||||
|
||||
assert.equal(buddy_data.get_user_circle_class(me.user_id), 'user_circle_green');
|
||||
assert.equal(buddy_data.get_user_circle_class(me.user_id), "user_circle_green");
|
||||
user_status.set_away(me.user_id);
|
||||
assert.equal(buddy_data.get_user_circle_class(me.user_id), 'user_circle_empty_line');
|
||||
assert.equal(buddy_data.get_user_circle_class(me.user_id), "user_circle_empty_line");
|
||||
user_status.revoke_away(me.user_id);
|
||||
assert.equal(buddy_data.get_user_circle_class(me.user_id), 'user_circle_green');
|
||||
assert.equal(buddy_data.get_user_circle_class(me.user_id), "user_circle_green");
|
||||
});
|
||||
|
||||
run_test('buddy_status', () => {
|
||||
assert.equal(buddy_data.buddy_status(selma.user_id), 'active');
|
||||
run_test("buddy_status", () => {
|
||||
assert.equal(buddy_data.buddy_status(selma.user_id), "active");
|
||||
user_status.set_away(selma.user_id);
|
||||
assert.equal(buddy_data.buddy_status(selma.user_id), 'away_them');
|
||||
assert.equal(buddy_data.buddy_status(selma.user_id), "away_them");
|
||||
user_status.revoke_away(selma.user_id);
|
||||
assert.equal(buddy_data.buddy_status(selma.user_id), 'active');
|
||||
assert.equal(buddy_data.buddy_status(selma.user_id), "active");
|
||||
|
||||
assert.equal(buddy_data.buddy_status(me.user_id), 'active');
|
||||
assert.equal(buddy_data.buddy_status(me.user_id), "active");
|
||||
user_status.set_away(me.user_id);
|
||||
assert.equal(buddy_data.buddy_status(me.user_id), 'away_me');
|
||||
assert.equal(buddy_data.buddy_status(me.user_id), "away_me");
|
||||
user_status.revoke_away(me.user_id);
|
||||
assert.equal(buddy_data.buddy_status(me.user_id), 'active');
|
||||
assert.equal(buddy_data.buddy_status(me.user_id), "active");
|
||||
});
|
||||
|
||||
run_test('title_data', () => {
|
||||
run_test("title_data", () => {
|
||||
// Groups
|
||||
let is_group = true;
|
||||
const user_ids_string = "9999,1000";
|
||||
let expected_group_data = {
|
||||
first_line: 'Human Selma, Old User',
|
||||
second_line: '',
|
||||
third_line: '',
|
||||
first_line: "Human Selma, Old User",
|
||||
second_line: "",
|
||||
third_line: "",
|
||||
};
|
||||
assert.deepEqual(buddy_data.get_title_data(user_ids_string, is_group), expected_group_data);
|
||||
|
||||
is_group = '';
|
||||
is_group = "";
|
||||
|
||||
// Bots with owners.
|
||||
expected_group_data = {
|
||||
first_line: 'Blue Herring Bot',
|
||||
second_line: 'translated: Owner: Human Myself',
|
||||
third_line: '',
|
||||
first_line: "Blue Herring Bot",
|
||||
second_line: "translated: Owner: Human Myself",
|
||||
third_line: "",
|
||||
};
|
||||
assert.deepEqual(buddy_data.get_title_data(bot_with_owner.user_id, is_group),
|
||||
expected_group_data);
|
||||
|
||||
// Bots without owners.
|
||||
expected_group_data = {
|
||||
first_line: 'Red Herring Bot',
|
||||
second_line: '',
|
||||
third_line: '',
|
||||
first_line: "Red Herring Bot",
|
||||
second_line: "",
|
||||
third_line: "",
|
||||
};
|
||||
assert.deepEqual(buddy_data.get_title_data(bot.user_id, is_group), expected_group_data);
|
||||
|
||||
// Individual Users.
|
||||
user_status.set_status_text({
|
||||
user_id: me.user_id,
|
||||
status_text: 'out to lunch',
|
||||
status_text: "out to lunch",
|
||||
});
|
||||
|
||||
let expected_data = {
|
||||
first_line: 'Human Myself',
|
||||
second_line: 'out to lunch',
|
||||
third_line: 'translated: Active now',
|
||||
first_line: "Human Myself",
|
||||
second_line: "out to lunch",
|
||||
third_line: "translated: Active now",
|
||||
|
||||
};
|
||||
assert.deepEqual(buddy_data.get_title_data(me.user_id, is_group), expected_data);
|
||||
|
||||
expected_data = {
|
||||
first_line: 'Old User',
|
||||
second_line: 'translated: Last active: translated: More than 2 weeks ago',
|
||||
third_line: '',
|
||||
first_line: "Old User",
|
||||
second_line: "translated: Last active: translated: More than 2 weeks ago",
|
||||
third_line: "",
|
||||
};
|
||||
assert.deepEqual(buddy_data.get_title_data(old_user.user_id, is_group), expected_data);
|
||||
});
|
||||
|
||||
run_test('simple search', () => {
|
||||
const user_ids = buddy_data.get_filtered_and_sorted_user_ids('sel');
|
||||
run_test("simple search", () => {
|
||||
const user_ids = buddy_data.get_filtered_and_sorted_user_ids("sel");
|
||||
|
||||
assert.deepEqual(user_ids, [selma.user_id]);
|
||||
});
|
||||
|
||||
run_test('bulk_data_hacks', () => {
|
||||
run_test("bulk_data_hacks", () => {
|
||||
let user_ids;
|
||||
|
||||
// Even though we have 1000 users, we only get the 400 active
|
||||
@@ -259,40 +259,40 @@ run_test('bulk_data_hacks', () => {
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids();
|
||||
assert.equal(user_ids.length, 400);
|
||||
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('');
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids("");
|
||||
assert.equal(user_ids.length, 400);
|
||||
|
||||
// We don't match on "so", because it's not at the start of a
|
||||
// word in the name/email.
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('so');
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids("so");
|
||||
assert.equal(user_ids.length, 0);
|
||||
|
||||
// We match on "h" for the first name, and the result limit
|
||||
// is relaxed for searches. (We exclude "me", though.)
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('h');
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids("h");
|
||||
assert.equal(user_ids.length, 996);
|
||||
|
||||
// We match on "p" for the email.
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('p');
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids("p");
|
||||
assert.equal(user_ids.length, 994);
|
||||
|
||||
// Make our shrink limit higher, and go back to an empty search.
|
||||
// We won't get all 1000 users, just the present ones.
|
||||
buddy_data.max_size_before_shrinking = 50000;
|
||||
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('');
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids("");
|
||||
assert.equal(user_ids.length, 700);
|
||||
});
|
||||
|
||||
run_test('level', () => {
|
||||
assert.equal(buddy_data.my_user_status(me.user_id), 'translated: (you)');
|
||||
run_test("level", () => {
|
||||
assert.equal(buddy_data.my_user_status(me.user_id), "translated: (you)");
|
||||
user_status.set_away(me.user_id);
|
||||
assert.equal(buddy_data.my_user_status(me.user_id), 'translated: (unavailable)');
|
||||
assert.equal(buddy_data.my_user_status(me.user_id), "translated: (unavailable)");
|
||||
user_status.revoke_away(me.user_id);
|
||||
assert.equal(buddy_data.my_user_status(me.user_id), 'translated: (you)');
|
||||
assert.equal(buddy_data.my_user_status(me.user_id), "translated: (you)");
|
||||
});
|
||||
|
||||
run_test('level', () => {
|
||||
run_test("level", () => {
|
||||
presence.presence_info.clear();
|
||||
assert.equal(buddy_data.level(me.user_id), 0);
|
||||
assert.equal(buddy_data.level(selma.user_id), 3);
|
||||
@@ -319,38 +319,38 @@ run_test('level', () => {
|
||||
assert.equal(buddy_data.level(selma.user_id), 3);
|
||||
});
|
||||
|
||||
run_test('user_last_seen_time_status', () => {
|
||||
run_test("user_last_seen_time_status", () => {
|
||||
assert.equal(buddy_data.user_last_seen_time_status(selma.user_id),
|
||||
'translated: Active now');
|
||||
"translated: Active now");
|
||||
|
||||
page_params.realm_is_zephyr_mirror_realm = true;
|
||||
assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
|
||||
'translated: Unknown');
|
||||
"translated: Unknown");
|
||||
page_params.realm_is_zephyr_mirror_realm = false;
|
||||
assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
|
||||
'translated: More than 2 weeks ago');
|
||||
"translated: More than 2 weeks ago");
|
||||
|
||||
presence.last_active_date = (user_id) => {
|
||||
assert.equal(user_id, old_user.user_id);
|
||||
|
||||
return {
|
||||
clone: () => 'date-stub',
|
||||
clone: () => "date-stub",
|
||||
};
|
||||
};
|
||||
|
||||
timerender.last_seen_status_from_date = (date) => {
|
||||
assert.equal(date, 'date-stub');
|
||||
return 'May 12';
|
||||
assert.equal(date, "date-stub");
|
||||
return "May 12";
|
||||
};
|
||||
|
||||
assert.equal(buddy_data.user_last_seen_time_status(old_user.user_id),
|
||||
'May 12');
|
||||
"May 12");
|
||||
|
||||
});
|
||||
|
||||
run_test('error handling', () => {
|
||||
run_test("error handling", () => {
|
||||
presence.get_user_ids = () => [42];
|
||||
blueslip.expect('error', 'Unknown user_id in get_by_user_id: 42');
|
||||
blueslip.expect('warn', 'Got user_id in presence but not people: 42');
|
||||
blueslip.expect("error", "Unknown user_id in get_by_user_id: 42");
|
||||
blueslip.expect("warn", "Got user_id in presence but not people: 42");
|
||||
buddy_data.get_filtered_and_sorted_user_ids();
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
zrequire('people');
|
||||
zrequire('buddy_data');
|
||||
zrequire('buddy_list');
|
||||
zrequire('ui');
|
||||
set_global("$", global.make_zjquery());
|
||||
zrequire("people");
|
||||
zrequire("buddy_data");
|
||||
zrequire("buddy_list");
|
||||
zrequire("ui");
|
||||
|
||||
set_global('padded_widget', {
|
||||
set_global("padded_widget", {
|
||||
update_padding: () => {},
|
||||
});
|
||||
|
||||
function init_simulated_scrolling() {
|
||||
set_global('message_viewport', {
|
||||
set_global("message_viewport", {
|
||||
height: () => 550,
|
||||
});
|
||||
|
||||
@@ -19,23 +19,23 @@ function init_simulated_scrolling() {
|
||||
scrollHeight: 0,
|
||||
};
|
||||
|
||||
$('#buddy_list_wrapper')[0] = elem;
|
||||
$("#buddy_list_wrapper")[0] = elem;
|
||||
|
||||
$('#buddy_list_wrapper_padding').height = () => 0;
|
||||
$("#buddy_list_wrapper_padding").height = () => 0;
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
const alice = {
|
||||
email: 'alice@zulip.com',
|
||||
email: "alice@zulip.com",
|
||||
user_id: 10,
|
||||
full_name: 'Alice Smith',
|
||||
full_name: "Alice Smith",
|
||||
};
|
||||
people.add_active_user(alice);
|
||||
|
||||
run_test('get_items', () => {
|
||||
const alice_li = $.create('alice stub');
|
||||
const sel = 'li.user_sidebar_entry';
|
||||
run_test("get_items", () => {
|
||||
const alice_li = $.create("alice stub");
|
||||
const sel = "li.user_sidebar_entry";
|
||||
|
||||
buddy_list.container.set_find_results(sel, {
|
||||
map: (f) => [f(0, alice_li)],
|
||||
@@ -45,26 +45,26 @@ run_test('get_items', () => {
|
||||
assert.deepEqual(items, [alice_li]);
|
||||
});
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
init_simulated_scrolling();
|
||||
|
||||
buddy_list.get_data_from_keys = (opts) => {
|
||||
const keys = opts.keys;
|
||||
assert.deepEqual(keys, [alice.user_id]);
|
||||
return 'data-stub';
|
||||
return "data-stub";
|
||||
};
|
||||
|
||||
buddy_list.items_to_html = (opts) => {
|
||||
const items = opts.items;
|
||||
|
||||
assert.equal(items, 'data-stub');
|
||||
assert.equal(items, "data-stub");
|
||||
|
||||
return 'html-stub';
|
||||
return "html-stub";
|
||||
};
|
||||
|
||||
let appended;
|
||||
buddy_list.container.append = (html) => {
|
||||
assert.equal(html, 'html-stub');
|
||||
assert.equal(html, "html-stub");
|
||||
appended = true;
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ run_test('basics', () => {
|
||||
});
|
||||
assert(appended);
|
||||
|
||||
const alice_li = $.create('alice-li-stub');
|
||||
const alice_li = $.create("alice-li-stub");
|
||||
alice_li.length = 1;
|
||||
|
||||
buddy_list.get_li_from_key = (opts) => {
|
||||
@@ -89,7 +89,7 @@ run_test('basics', () => {
|
||||
assert.equal(li, alice_li);
|
||||
});
|
||||
|
||||
run_test('big_list', () => {
|
||||
run_test("big_list", () => {
|
||||
const elem = init_simulated_scrolling();
|
||||
|
||||
// Don't actually render, but do simulate filling up
|
||||
@@ -108,9 +108,9 @@ run_test('big_list', () => {
|
||||
|
||||
_.times(num_users, (i) => {
|
||||
const person = {
|
||||
email: 'foo' + i + '@zulip.com',
|
||||
email: "foo" + i + "@zulip.com",
|
||||
user_id: 100 + i,
|
||||
full_name: 'Somebody ' + i,
|
||||
full_name: "Somebody " + i,
|
||||
};
|
||||
people.add_active_user(person);
|
||||
user_ids.push(person.user_id);
|
||||
@@ -123,7 +123,7 @@ run_test('big_list', () => {
|
||||
assert.equal(chunks_inserted, 6);
|
||||
});
|
||||
|
||||
run_test('force_render', () => {
|
||||
run_test("force_render", () => {
|
||||
buddy_list.render_count = 50;
|
||||
|
||||
let num_rendered = 0;
|
||||
@@ -138,18 +138,18 @@ run_test('force_render', () => {
|
||||
assert.equal(num_rendered, 60 - 50 + 3);
|
||||
|
||||
// Force a contrived error case for line coverage.
|
||||
blueslip.expect('error', 'cannot show key at this position: 10');
|
||||
blueslip.expect("error", "cannot show key at this position: 10");
|
||||
buddy_list.force_render({
|
||||
pos: 10,
|
||||
});
|
||||
});
|
||||
|
||||
run_test('find_li w/force_render', () => {
|
||||
run_test("find_li w/force_render", () => {
|
||||
// If we call find_li w/force_render set, and the
|
||||
// key is not already rendered in DOM, then the
|
||||
// widget will call show_key to force-render it.
|
||||
const key = '999';
|
||||
const stub_li = $.create('nada');
|
||||
const key = "999";
|
||||
const stub_li = $.create("nada");
|
||||
|
||||
stub_li.length = 0;
|
||||
|
||||
@@ -159,7 +159,7 @@ run_test('find_li w/force_render', () => {
|
||||
};
|
||||
|
||||
buddy_list.keys = [
|
||||
'foo', 'bar', key, 'baz',
|
||||
"foo", "bar", key, "baz",
|
||||
];
|
||||
|
||||
let shown;
|
||||
@@ -186,7 +186,7 @@ run_test('find_li w/force_render', () => {
|
||||
buddy_list.get_li_from_key = () => ({length: 0});
|
||||
|
||||
const undefined_li = buddy_list.find_li({
|
||||
key: 'not-there',
|
||||
key: "not-there",
|
||||
force_render: true,
|
||||
});
|
||||
|
||||
@@ -194,7 +194,7 @@ run_test('find_li w/force_render', () => {
|
||||
assert.equal(undefined_li.length, 0);
|
||||
});
|
||||
|
||||
run_test('scrolling', () => {
|
||||
run_test("scrolling", () => {
|
||||
let scroll_f;
|
||||
|
||||
$(buddy_list.scroll_container_sel).scroll = (f) => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
set_global('$', {});
|
||||
set_global("$", {});
|
||||
|
||||
set_global('reload', {});
|
||||
zrequire('reload_state');
|
||||
zrequire('channel');
|
||||
set_global("reload", {});
|
||||
zrequire("reload_state");
|
||||
zrequire("channel");
|
||||
|
||||
const default_stub_xhr = 'default-stub-xhr';
|
||||
const default_stub_xhr = "default-stub-xhr";
|
||||
|
||||
function test_with_mock_ajax(test_params) {
|
||||
const {
|
||||
@@ -36,15 +36,15 @@ function test_with_mock_ajax(test_params) {
|
||||
check_ajax_options(ajax_options);
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
test_with_mock_ajax({
|
||||
run_code: function () {
|
||||
channel.post({});
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'POST');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "POST");
|
||||
assert.equal(options.dataType, "json");
|
||||
|
||||
// Just make sure these don't explode.
|
||||
options.simulate_success();
|
||||
@@ -58,9 +58,9 @@ run_test('basics', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'POST');
|
||||
assert.equal(options.data.method, 'PATCH');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "POST");
|
||||
assert.equal(options.data.method, "PATCH");
|
||||
assert.equal(options.dataType, "json");
|
||||
|
||||
// Just make sure these don't explode.
|
||||
options.simulate_success();
|
||||
@@ -74,8 +74,8 @@ run_test('basics', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'PUT');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "PUT");
|
||||
assert.equal(options.dataType, "json");
|
||||
|
||||
// Just make sure these don't explode.
|
||||
options.simulate_success();
|
||||
@@ -89,8 +89,8 @@ run_test('basics', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'DELETE');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "DELETE");
|
||||
assert.equal(options.dataType, "json");
|
||||
|
||||
// Just make sure these don't explode.
|
||||
options.simulate_success();
|
||||
@@ -104,8 +104,8 @@ run_test('basics', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'GET');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "GET");
|
||||
assert.equal(options.dataType, "json");
|
||||
|
||||
// Just make sure these don't explode.
|
||||
options.simulate_success();
|
||||
@@ -115,16 +115,16 @@ run_test('basics', () => {
|
||||
|
||||
});
|
||||
|
||||
run_test('normal_post', () => {
|
||||
run_test("normal_post", () => {
|
||||
const data = {
|
||||
s: 'some_string',
|
||||
s: "some_string",
|
||||
num: 7,
|
||||
lst: [1, 2, 4, 8],
|
||||
};
|
||||
|
||||
let orig_success_called;
|
||||
let orig_error_called;
|
||||
const stub_xhr = 'stub-xhr-normal-post';
|
||||
const stub_xhr = "stub-xhr-normal-post";
|
||||
|
||||
test_with_mock_ajax({
|
||||
xhr: stub_xhr,
|
||||
@@ -132,11 +132,11 @@ run_test('normal_post', () => {
|
||||
run_code: function () {
|
||||
channel.post({
|
||||
data: data,
|
||||
url: '/json/endpoint',
|
||||
url: "/json/endpoint",
|
||||
success: function (data, text_status, xhr) {
|
||||
orig_success_called = true;
|
||||
assert.equal(data, 'response data');
|
||||
assert.equal(text_status, 'success');
|
||||
assert.equal(data, "response data");
|
||||
assert.equal(text_status, "success");
|
||||
assert.equal(xhr, stub_xhr);
|
||||
},
|
||||
error: function () {
|
||||
@@ -146,12 +146,12 @@ run_test('normal_post', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'POST');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "POST");
|
||||
assert.equal(options.dataType, "json");
|
||||
assert.deepEqual(options.data, data);
|
||||
assert.equal(options.url, '/json/endpoint');
|
||||
assert.equal(options.url, "/json/endpoint");
|
||||
|
||||
options.simulate_success('response data', 'success');
|
||||
options.simulate_success("response data", "success");
|
||||
assert(orig_success_called);
|
||||
|
||||
options.simulate_error();
|
||||
@@ -160,13 +160,13 @@ run_test('normal_post', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('patch_with_form_data', () => {
|
||||
run_test("patch_with_form_data", () => {
|
||||
let appended;
|
||||
|
||||
const data = {
|
||||
append: function (k, v) {
|
||||
assert.equal(k, 'method');
|
||||
assert.equal(v, 'PATCH');
|
||||
assert.equal(k, "method");
|
||||
assert.equal(v, "PATCH");
|
||||
appended = true;
|
||||
},
|
||||
};
|
||||
@@ -181,8 +181,8 @@ run_test('patch_with_form_data', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
assert.equal(options.type, 'POST');
|
||||
assert.equal(options.dataType, 'json');
|
||||
assert.equal(options.type, "POST");
|
||||
assert.equal(options.dataType, "json");
|
||||
|
||||
// Just make sure these don't explode.
|
||||
options.simulate_success();
|
||||
@@ -191,7 +191,7 @@ run_test('patch_with_form_data', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('reload_on_403_error', () => {
|
||||
run_test("reload_on_403_error", () => {
|
||||
test_with_mock_ajax({
|
||||
xhr: {
|
||||
status: 403,
|
||||
@@ -220,11 +220,11 @@ run_test('reload_on_403_error', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('unexpected_403_response', () => {
|
||||
run_test("unexpected_403_response", () => {
|
||||
test_with_mock_ajax({
|
||||
xhr: {
|
||||
status: 403,
|
||||
responseText: 'unexpected',
|
||||
responseText: "unexpected",
|
||||
},
|
||||
|
||||
run_code: function () {
|
||||
@@ -232,13 +232,13 @@ run_test('unexpected_403_response', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
blueslip.expect('error', 'Unexpected 403 response from server');
|
||||
blueslip.expect("error", "Unexpected 403 response from server");
|
||||
options.simulate_error();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
run_test('retry', () => {
|
||||
run_test("retry", () => {
|
||||
test_with_mock_ajax({
|
||||
run_code: function () {
|
||||
channel.post({
|
||||
@@ -248,12 +248,12 @@ run_test('retry', () => {
|
||||
},
|
||||
|
||||
check_ajax_options: function (options) {
|
||||
global.patch_builtin('setTimeout', (f, delay) => {
|
||||
global.patch_builtin("setTimeout", (f, delay) => {
|
||||
assert.equal(delay, 0);
|
||||
f();
|
||||
});
|
||||
|
||||
blueslip.expect('log', 'Retrying idempotent[object Object]');
|
||||
blueslip.expect("log", "Retrying idempotent[object Object]");
|
||||
test_with_mock_ajax({
|
||||
run_code: function () {
|
||||
options.simulate_success();
|
||||
@@ -267,32 +267,32 @@ run_test('retry', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('too_many_pending', () => {
|
||||
run_test("too_many_pending", () => {
|
||||
$.ajax = function () {
|
||||
const xhr = 'stub';
|
||||
const xhr = "stub";
|
||||
return xhr;
|
||||
};
|
||||
|
||||
blueslip.expect('warn',
|
||||
'The length of pending_requests is over 50. ' +
|
||||
'Most likely they are not being correctly removed.');
|
||||
blueslip.expect("warn",
|
||||
"The length of pending_requests is over 50. " +
|
||||
"Most likely they are not being correctly removed.");
|
||||
_.times(50, () => {
|
||||
channel.post({});
|
||||
});
|
||||
});
|
||||
|
||||
run_test('xhr_error_message', () => {
|
||||
run_test("xhr_error_message", () => {
|
||||
let xhr = {
|
||||
status: '200',
|
||||
responseText: 'does not matter',
|
||||
status: "200",
|
||||
responseText: "does not matter",
|
||||
};
|
||||
let msg = 'data added';
|
||||
assert.equal(channel.xhr_error_message(msg, xhr), 'data added');
|
||||
let msg = "data added";
|
||||
assert.equal(channel.xhr_error_message(msg, xhr), "data added");
|
||||
|
||||
xhr = {
|
||||
status: '404',
|
||||
status: "404",
|
||||
responseText: '{"msg": "file not found"}',
|
||||
};
|
||||
msg = 'some message';
|
||||
assert.equal(channel.xhr_error_message(msg, xhr), 'some message: file not found');
|
||||
msg = "some message";
|
||||
assert.equal(channel.xhr_error_message(msg, xhr), "some message: file not found");
|
||||
});
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
zrequire('color_data');
|
||||
zrequire("color_data");
|
||||
|
||||
run_test('pick_color', () => {
|
||||
run_test("pick_color", () => {
|
||||
color_data.colors = [
|
||||
'blue',
|
||||
'orange',
|
||||
'red',
|
||||
'yellow',
|
||||
"blue",
|
||||
"orange",
|
||||
"red",
|
||||
"yellow",
|
||||
];
|
||||
|
||||
color_data.reset();
|
||||
|
||||
color_data.claim_colors([
|
||||
{ color: 'orange' },
|
||||
{ foo: 'whatever' },
|
||||
{ color: 'yellow' },
|
||||
{ color: 'bogus' },
|
||||
{ color: "orange" },
|
||||
{ foo: "whatever" },
|
||||
{ color: "yellow" },
|
||||
{ color: "bogus" },
|
||||
]);
|
||||
|
||||
const expected_colors = [
|
||||
'blue',
|
||||
'red',
|
||||
"blue",
|
||||
"red",
|
||||
// ok, now we'll cycle through all colors
|
||||
'blue',
|
||||
'orange',
|
||||
'red',
|
||||
'yellow',
|
||||
'blue',
|
||||
'orange',
|
||||
'red',
|
||||
'yellow',
|
||||
'blue',
|
||||
'orange',
|
||||
'red',
|
||||
'yellow',
|
||||
"blue",
|
||||
"orange",
|
||||
"red",
|
||||
"yellow",
|
||||
"blue",
|
||||
"orange",
|
||||
"red",
|
||||
"yellow",
|
||||
"blue",
|
||||
"orange",
|
||||
"red",
|
||||
"yellow",
|
||||
];
|
||||
|
||||
for (const expected_color of expected_colors) {
|
||||
assert.equal(color_data.pick_color(), expected_color);
|
||||
}
|
||||
|
||||
color_data.claim_color('blue');
|
||||
assert.equal(color_data.pick_color(), 'orange');
|
||||
color_data.claim_color("blue");
|
||||
assert.equal(color_data.pick_color(), "orange");
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
zrequire('colorspace');
|
||||
zrequire("colorspace");
|
||||
|
||||
run_test('sRGB_to_linear', () => {
|
||||
run_test("sRGB_to_linear", () => {
|
||||
let srgb_color = 0.0042;
|
||||
let expected_value = 0.0042 / 255.0 / 12.92;
|
||||
let actual_value = colorspace.sRGB_to_linear(srgb_color);
|
||||
@@ -12,14 +12,14 @@ run_test('sRGB_to_linear', () => {
|
||||
assert.equal(actual_value, expected_value);
|
||||
});
|
||||
|
||||
run_test('rgb_luminance', () => {
|
||||
run_test("rgb_luminance", () => {
|
||||
const channel = [1, 1, 1];
|
||||
const expected_value = 1;
|
||||
const actual_value = colorspace.rgb_luminance(channel);
|
||||
assert.equal(actual_value, expected_value);
|
||||
});
|
||||
|
||||
run_test('luminance_to_lightness', () => {
|
||||
run_test("luminance_to_lightness", () => {
|
||||
let luminance = 0;
|
||||
let expected_value = 116 * 4 / 29 - 16;
|
||||
let actual_value = colorspace.luminance_to_lightness(luminance);
|
||||
@@ -31,8 +31,8 @@ run_test('luminance_to_lightness', () => {
|
||||
assert.equal(actual_value, expected_value);
|
||||
});
|
||||
|
||||
run_test('getDecimalColor', () => {
|
||||
const hex_color = '#1f293b';
|
||||
run_test("getDecimalColor", () => {
|
||||
const hex_color = "#1f293b";
|
||||
const expected_value = {
|
||||
r: 31,
|
||||
g: 41,
|
||||
@@ -42,7 +42,7 @@ run_test('getDecimalColor', () => {
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
});
|
||||
|
||||
run_test('getLighterColor', () => {
|
||||
run_test("getLighterColor", () => {
|
||||
const rgb_color = {
|
||||
r: 31,
|
||||
g: 41,
|
||||
@@ -54,13 +54,13 @@ run_test('getLighterColor', () => {
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
});
|
||||
|
||||
run_test('getHexColor', () => {
|
||||
run_test("getHexColor", () => {
|
||||
const rgb_color = {
|
||||
r: 31,
|
||||
g: 41,
|
||||
b: 59,
|
||||
};
|
||||
const expected_value = '#1f293b';
|
||||
const expected_value = "#1f293b";
|
||||
const actual_value = colorspace.getHexColor(rgb_color);
|
||||
assert.equal(actual_value, expected_value);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const noop = () => {};
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
const input = $.create('input');
|
||||
set_global('document', {
|
||||
set_global("$", global.make_zjquery());
|
||||
const input = $.create("input");
|
||||
set_global("document", {
|
||||
createElement: () => input,
|
||||
execCommand: noop,
|
||||
});
|
||||
@@ -15,7 +15,7 @@ $(input).val = (arg) => {
|
||||
};
|
||||
};
|
||||
|
||||
zrequire('common');
|
||||
zrequire("common");
|
||||
|
||||
function get_key_stub_html(key_text, expected_key, obj_name) {
|
||||
const key_stub = $.create(obj_name);
|
||||
@@ -26,23 +26,23 @@ function get_key_stub_html(key_text, expected_key, obj_name) {
|
||||
return key_stub;
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
common.autofocus('#home');
|
||||
assert($('#home').is_focused());
|
||||
run_test("basics", () => {
|
||||
common.autofocus("#home");
|
||||
assert($("#home").is_focused());
|
||||
});
|
||||
|
||||
run_test('phrase_match', () => {
|
||||
assert(common.phrase_match('tes', 'test'));
|
||||
assert(common.phrase_match('Tes', 'test'));
|
||||
assert(common.phrase_match('Tes', 'Test'));
|
||||
assert(common.phrase_match('tes', 'Stream Test'));
|
||||
run_test("phrase_match", () => {
|
||||
assert(common.phrase_match("tes", "test"));
|
||||
assert(common.phrase_match("Tes", "test"));
|
||||
assert(common.phrase_match("Tes", "Test"));
|
||||
assert(common.phrase_match("tes", "Stream Test"));
|
||||
|
||||
assert(!common.phrase_match('tests', 'test'));
|
||||
assert(!common.phrase_match('tes', 'hostess'));
|
||||
assert(!common.phrase_match("tests", "test"));
|
||||
assert(!common.phrase_match("tes", "hostess"));
|
||||
});
|
||||
|
||||
run_test('copy_data_attribute_value', () => {
|
||||
const elem = $.create('.envelope-link');
|
||||
run_test("copy_data_attribute_value", () => {
|
||||
const elem = $.create(".envelope-link");
|
||||
elem.data = (key) => {
|
||||
if (key === "admin-emails") {
|
||||
return "iago@zulip.com";
|
||||
@@ -55,35 +55,35 @@ run_test('copy_data_attribute_value', () => {
|
||||
elem.fadeIn = (val) => {
|
||||
assert.equal(val, 1000);
|
||||
};
|
||||
common.copy_data_attribute_value(elem, 'admin-emails');
|
||||
common.copy_data_attribute_value(elem, "admin-emails");
|
||||
});
|
||||
|
||||
run_test('adjust_mac_shortcuts', () => {
|
||||
run_test("adjust_mac_shortcuts", () => {
|
||||
const keys_to_test_mac = new Map([
|
||||
['Backspace', 'Delete'],
|
||||
['Enter', 'Return'],
|
||||
['Home', 'Fn + ←'],
|
||||
['End', 'Fn + →'],
|
||||
['PgUp', 'Fn + ↑'],
|
||||
['PgDn', 'Fn + ↓'],
|
||||
['X + Shift', 'X + Shift'],
|
||||
['⌘ + Return', '⌘ + Return'],
|
||||
['Enter or Backspace', "Return or Delete"],
|
||||
['Ctrl', '⌘'],
|
||||
['Ctrl + Shift', '⌘ + Shift'],
|
||||
['Ctrl + Backspace + End', '⌘ + Delete + Fn + →'],
|
||||
["Backspace", "Delete"],
|
||||
["Enter", "Return"],
|
||||
["Home", "Fn + ←"],
|
||||
["End", "Fn + →"],
|
||||
["PgUp", "Fn + ↑"],
|
||||
["PgDn", "Fn + ↓"],
|
||||
["X + Shift", "X + Shift"],
|
||||
["⌘ + Return", "⌘ + Return"],
|
||||
["Enter or Backspace", "Return or Delete"],
|
||||
["Ctrl", "⌘"],
|
||||
["Ctrl + Shift", "⌘ + Shift"],
|
||||
["Ctrl + Backspace + End", "⌘ + Delete + Fn + →"],
|
||||
]);
|
||||
const keys_to_test_non_mac = new Map([
|
||||
['Backspace', 'Backspace'],
|
||||
['Enter', 'Enter'],
|
||||
['Home', 'Home'],
|
||||
['End', 'End'],
|
||||
['PgUp', 'PgUp'],
|
||||
['PgDn', 'PgDn'],
|
||||
['X + Shift', 'X + Shift'],
|
||||
['⌘ + Return', '⌘ + Return'],
|
||||
['Ctrl + Shift', 'Ctrl + Shift'],
|
||||
['Ctrl + Backspace + End', 'Ctrl + Backspace + End'],
|
||||
["Backspace", "Backspace"],
|
||||
["Enter", "Enter"],
|
||||
["Home", "Home"],
|
||||
["End", "End"],
|
||||
["PgUp", "PgUp"],
|
||||
["PgDn", "PgDn"],
|
||||
["X + Shift", "X + Shift"],
|
||||
["⌘ + Return", "⌘ + Return"],
|
||||
["Ctrl + Shift", "Ctrl + Shift"],
|
||||
["Ctrl + Backspace + End", "Ctrl + Backspace + End"],
|
||||
]);
|
||||
|
||||
let key_no;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
zrequire('keydown_util');
|
||||
zrequire('components');
|
||||
zrequire("keydown_util");
|
||||
zrequire("components");
|
||||
|
||||
const noop = function () {};
|
||||
|
||||
const LEFT_KEY = { which: 37, preventDefault: noop, stopPropagation: noop };
|
||||
const RIGHT_KEY = { which: 39, preventDefault: noop, stopPropagation: noop };
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
let keydown_f;
|
||||
let click_f;
|
||||
const tabs = [];
|
||||
@@ -23,14 +23,14 @@ run_test('basics', () => {
|
||||
self.class = [];
|
||||
|
||||
self.addClass = function (c) {
|
||||
self.class += ' ' + c;
|
||||
self.class += " " + c;
|
||||
const tokens = self.class.trim().split(/ +/);
|
||||
self.class = _.uniq(tokens).join(' ');
|
||||
self.class = _.uniq(tokens).join(" ");
|
||||
};
|
||||
|
||||
self.removeClass = function (c) {
|
||||
const tokens = self.class.trim().split(/ +/);
|
||||
self.class = _.without(tokens, c).join(' ');
|
||||
self.class = _.without(tokens, c).join(" ");
|
||||
};
|
||||
|
||||
self.hasClass = function (c) {
|
||||
@@ -39,7 +39,7 @@ run_test('basics', () => {
|
||||
};
|
||||
|
||||
self.data = function (name) {
|
||||
assert.equal(name, 'tab-id');
|
||||
assert.equal(name, "tab-id");
|
||||
return i;
|
||||
};
|
||||
|
||||
@@ -101,14 +101,14 @@ run_test('basics', () => {
|
||||
case ".ind-tab":
|
||||
return ind_tab;
|
||||
default:
|
||||
throw Error('unknown selector: ' + sel);
|
||||
throw Error("unknown selector: " + sel);
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
}());
|
||||
|
||||
set_global('$', (sel) => {
|
||||
set_global("$", (sel) => {
|
||||
if (sel.stub) {
|
||||
// The component often redundantly re-wraps objects.
|
||||
return sel;
|
||||
@@ -126,7 +126,7 @@ run_test('basics', () => {
|
||||
case "<div class='ind-tab' data-tab-key='search-operators' data-tab-id='2' tabindex='0'>translated: Search operators</div>":
|
||||
return make_tab(2);
|
||||
default:
|
||||
throw Error('unknown selector: ' + sel);
|
||||
throw Error("unknown selector: " + sel);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -157,69 +157,69 @@ run_test('basics', () => {
|
||||
|
||||
assert.deepEqual(switcher.children, tabs);
|
||||
|
||||
assert.equal(switcher.addedClass, 'stream_sorter_toggle');
|
||||
assert.equal(switcher.addedClass, "stream_sorter_toggle");
|
||||
|
||||
assert.equal(focused_tab, 0);
|
||||
assert.equal(tabs[0].class, 'first selected');
|
||||
assert.equal(tabs[1].class, 'middle');
|
||||
assert.equal(tabs[2].class, 'last');
|
||||
assert.deepEqual(callback_args, ['translated: Keyboard shortcuts', 'keyboard-shortcuts']);
|
||||
assert.equal(widget.value(), 'translated: Keyboard shortcuts');
|
||||
assert.equal(tabs[0].class, "first selected");
|
||||
assert.equal(tabs[1].class, "middle");
|
||||
assert.equal(tabs[2].class, "last");
|
||||
assert.deepEqual(callback_args, ["translated: Keyboard shortcuts", "keyboard-shortcuts"]);
|
||||
assert.equal(widget.value(), "translated: Keyboard shortcuts");
|
||||
|
||||
callback_args = undefined;
|
||||
|
||||
widget.goto('message-formatting');
|
||||
widget.goto("message-formatting");
|
||||
assert.equal(focused_tab, 1);
|
||||
assert.equal(tabs[0].class, 'first');
|
||||
assert.equal(tabs[1].class, 'middle selected');
|
||||
assert.equal(tabs[2].class, 'last');
|
||||
assert.deepEqual(callback_args, ['translated: Message formatting', 'message-formatting']);
|
||||
assert.equal(widget.value(), 'translated: Message formatting');
|
||||
assert.equal(tabs[0].class, "first");
|
||||
assert.equal(tabs[1].class, "middle selected");
|
||||
assert.equal(tabs[2].class, "last");
|
||||
assert.deepEqual(callback_args, ["translated: Message formatting", "message-formatting"]);
|
||||
assert.equal(widget.value(), "translated: Message formatting");
|
||||
|
||||
// Go to same tab twice and make sure we get callback.
|
||||
callback_args = undefined;
|
||||
widget.goto('message-formatting');
|
||||
assert.deepEqual(callback_args, ['translated: Message formatting', 'message-formatting']);
|
||||
widget.goto("message-formatting");
|
||||
assert.deepEqual(callback_args, ["translated: Message formatting", "message-formatting"]);
|
||||
|
||||
callback_args = undefined;
|
||||
keydown_f.call(tabs[focused_tab], RIGHT_KEY);
|
||||
assert.equal(focused_tab, 2);
|
||||
assert.equal(tabs[0].class, 'first');
|
||||
assert.equal(tabs[1].class, 'middle');
|
||||
assert.equal(tabs[2].class, 'last selected');
|
||||
assert.deepEqual(callback_args, ['translated: Search operators', 'search-operators']);
|
||||
assert.equal(widget.value(), 'translated: Search operators');
|
||||
assert.equal(tabs[0].class, "first");
|
||||
assert.equal(tabs[1].class, "middle");
|
||||
assert.equal(tabs[2].class, "last selected");
|
||||
assert.deepEqual(callback_args, ["translated: Search operators", "search-operators"]);
|
||||
assert.equal(widget.value(), "translated: Search operators");
|
||||
assert.equal(widget.value(), callback_value);
|
||||
|
||||
// try to crash the key handler
|
||||
keydown_f.call(tabs[focused_tab], RIGHT_KEY);
|
||||
assert.equal(widget.value(), 'translated: Search operators');
|
||||
assert.equal(widget.value(), "translated: Search operators");
|
||||
|
||||
callback_args = undefined;
|
||||
|
||||
keydown_f.call(tabs[focused_tab], LEFT_KEY);
|
||||
assert.equal(widget.value(), 'translated: Message formatting');
|
||||
assert.equal(widget.value(), "translated: Message formatting");
|
||||
|
||||
callback_args = undefined;
|
||||
|
||||
keydown_f.call(tabs[focused_tab], LEFT_KEY);
|
||||
assert.equal(widget.value(), 'translated: Keyboard shortcuts');
|
||||
assert.equal(widget.value(), "translated: Keyboard shortcuts");
|
||||
|
||||
// try to crash the key handler
|
||||
keydown_f.call(tabs[focused_tab], LEFT_KEY);
|
||||
assert.equal(widget.value(), 'translated: Keyboard shortcuts');
|
||||
assert.equal(widget.value(), "translated: Keyboard shortcuts");
|
||||
|
||||
callback_args = undefined;
|
||||
|
||||
click_f.call(tabs[1]);
|
||||
assert.equal(widget.value(), 'translated: Message formatting');
|
||||
assert.equal(widget.value(), "translated: Message formatting");
|
||||
|
||||
callback_args = undefined;
|
||||
widget.disable_tab("search-operators");
|
||||
assert.equal(tabs[2].hasClass('disabled'), true);
|
||||
assert.equal(tabs[2].hasClass("disabled"), true);
|
||||
assert.equal(tabs[2].class, "last disabled");
|
||||
|
||||
widget.goto('keyboard-shortcuts');
|
||||
widget.goto("keyboard-shortcuts");
|
||||
assert.equal(focused_tab, 0);
|
||||
widget.goto("search-operators");
|
||||
assert.equal(focused_tab, 0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,29 +2,29 @@ const noop = function () {};
|
||||
const return_false = function () { return false; };
|
||||
const return_true = function () { return true; };
|
||||
|
||||
set_global('document', {
|
||||
set_global("document", {
|
||||
location: {}, // we need this to load compose.js
|
||||
});
|
||||
|
||||
set_global('page_params', {});
|
||||
set_global("page_params", {});
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
set_global('compose_pm_pill', {
|
||||
set_global("compose_pm_pill", {
|
||||
});
|
||||
|
||||
set_global('hash_util', {
|
||||
set_global("hash_util", {
|
||||
});
|
||||
|
||||
zrequire('people');
|
||||
zrequire('compose_ui');
|
||||
zrequire('compose');
|
||||
zrequire('compose_state');
|
||||
zrequire('compose_actions');
|
||||
zrequire('fenced_code');
|
||||
zrequire('stream_data');
|
||||
zrequire("people");
|
||||
zrequire("compose_ui");
|
||||
zrequire("compose");
|
||||
zrequire("compose_state");
|
||||
zrequire("compose_actions");
|
||||
zrequire("fenced_code");
|
||||
zrequire("stream_data");
|
||||
|
||||
set_global('document', 'document-stub');
|
||||
set_global("document", "document-stub");
|
||||
|
||||
const start = compose_actions.start;
|
||||
const cancel = compose_actions.cancel;
|
||||
@@ -47,36 +47,36 @@ compose_state.private_message_recipient = (function () {
|
||||
};
|
||||
}());
|
||||
|
||||
set_global('reload_state', {
|
||||
set_global("reload_state", {
|
||||
is_in_progress: return_false,
|
||||
});
|
||||
|
||||
set_global('notifications', {
|
||||
set_global("notifications", {
|
||||
clear_compose_notifications: noop,
|
||||
});
|
||||
|
||||
set_global('compose_fade', {
|
||||
set_global("compose_fade", {
|
||||
clear_compose: noop,
|
||||
});
|
||||
|
||||
set_global('drafts', {
|
||||
set_global("drafts", {
|
||||
update_draft: noop,
|
||||
});
|
||||
|
||||
set_global('narrow_state', {
|
||||
set_global("narrow_state", {
|
||||
set_compose_defaults: noop,
|
||||
});
|
||||
|
||||
set_global('unread_ops', {
|
||||
set_global("unread_ops", {
|
||||
notify_server_message_read: noop,
|
||||
});
|
||||
|
||||
set_global('common', {
|
||||
status_classes: 'status_classes',
|
||||
set_global("common", {
|
||||
status_classes: "status_classes",
|
||||
});
|
||||
|
||||
function stub_selected_message(msg) {
|
||||
set_global('current_msg_list', {
|
||||
set_global("current_msg_list", {
|
||||
selected_message: function () {
|
||||
return msg;
|
||||
},
|
||||
@@ -87,7 +87,7 @@ function stub_selected_message(msg) {
|
||||
}
|
||||
|
||||
function stub_channel_get(success_value) {
|
||||
set_global('channel', {
|
||||
set_global("channel", {
|
||||
get: function (opts) {
|
||||
opts.success(success_value);
|
||||
},
|
||||
@@ -102,13 +102,13 @@ function assert_hidden(sel) {
|
||||
assert(!$(sel).visible());
|
||||
}
|
||||
|
||||
run_test('initial_state', () => {
|
||||
run_test("initial_state", () => {
|
||||
assert.equal(compose_state.composing(), false);
|
||||
assert.equal(compose_state.get_message_type(), false);
|
||||
assert.equal(compose_state.has_message_content(), false);
|
||||
});
|
||||
|
||||
run_test('start', () => {
|
||||
run_test("start", () => {
|
||||
compose_actions.autosize_message_content = noop;
|
||||
compose_actions.expand_compose_box = noop;
|
||||
compose_actions.set_focus = noop;
|
||||
@@ -119,27 +119,27 @@ run_test('start', () => {
|
||||
// Start stream message
|
||||
global.narrow_state.set_compose_defaults = function () {
|
||||
const opts = {};
|
||||
opts.stream = 'stream1';
|
||||
opts.topic = 'topic1';
|
||||
opts.stream = "stream1";
|
||||
opts.topic = "topic1";
|
||||
return opts;
|
||||
};
|
||||
|
||||
let opts = {};
|
||||
start('stream', opts);
|
||||
start("stream", opts);
|
||||
|
||||
assert_visible('#stream-message');
|
||||
assert_hidden('#private-message');
|
||||
assert_visible("#stream-message");
|
||||
assert_hidden("#private-message");
|
||||
|
||||
assert.equal($('#stream_message_recipient_stream').val(), 'stream1');
|
||||
assert.equal($('#stream_message_recipient_topic').val(), 'topic1');
|
||||
assert.equal(compose_state.get_message_type(), 'stream');
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "stream1");
|
||||
assert.equal($("#stream_message_recipient_topic").val(), "topic1");
|
||||
assert.equal(compose_state.get_message_type(), "stream");
|
||||
assert(compose_state.composing());
|
||||
|
||||
// Autofill stream field for single subscription
|
||||
const denmark = {
|
||||
subscribed: true,
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
color: "blue",
|
||||
name: "Denmark",
|
||||
stream_id: 1,
|
||||
};
|
||||
stream_data.add_sub(denmark);
|
||||
@@ -151,9 +151,9 @@ run_test('start', () => {
|
||||
};
|
||||
|
||||
opts = {};
|
||||
start('stream', opts);
|
||||
assert.equal($('#stream_message_recipient_stream').val(), 'Denmark');
|
||||
assert.equal($('#stream_message_recipient_topic').val(), '');
|
||||
start("stream", opts);
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "Denmark");
|
||||
assert.equal($("#stream_message_recipient_topic").val(), "");
|
||||
|
||||
global.narrow_state.set_compose_defaults = function () {
|
||||
const opts = {};
|
||||
@@ -162,45 +162,45 @@ run_test('start', () => {
|
||||
};
|
||||
|
||||
opts = {};
|
||||
start('stream', opts);
|
||||
assert.equal($('#stream_message_recipient_stream').val(), 'Denmark');
|
||||
assert.equal($('#stream_message_recipient_topic').val(), '');
|
||||
start("stream", opts);
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "Denmark");
|
||||
assert.equal($("#stream_message_recipient_topic").val(), "");
|
||||
|
||||
const social = {
|
||||
subscribed: true,
|
||||
color: 'red',
|
||||
name: 'social',
|
||||
color: "red",
|
||||
name: "social",
|
||||
stream_id: 2,
|
||||
};
|
||||
stream_data.add_sub(social);
|
||||
|
||||
// More than 1 subscription, do not autofill
|
||||
opts = {};
|
||||
start('stream', opts);
|
||||
assert.equal($('#stream_message_recipient_stream').val(), '');
|
||||
assert.equal($('#stream_message_recipient_topic').val(), '');
|
||||
start("stream", opts);
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "");
|
||||
assert.equal($("#stream_message_recipient_topic").val(), "");
|
||||
stream_data.clear_subscriptions();
|
||||
|
||||
// Start PM
|
||||
global.narrow_state.set_compose_defaults = function () {
|
||||
const opts = {};
|
||||
opts.private_message_recipient = 'foo@example.com';
|
||||
opts.private_message_recipient = "foo@example.com";
|
||||
return opts;
|
||||
};
|
||||
|
||||
opts = {
|
||||
content: 'hello',
|
||||
content: "hello",
|
||||
};
|
||||
|
||||
$('#compose-textarea').trigger = noop;
|
||||
start('private', opts);
|
||||
$("#compose-textarea").trigger = noop;
|
||||
start("private", opts);
|
||||
|
||||
assert_hidden('#stream-message');
|
||||
assert_visible('#private-message');
|
||||
assert_hidden("#stream-message");
|
||||
assert_visible("#private-message");
|
||||
|
||||
assert.equal(compose_state.private_message_recipient(), 'foo@example.com');
|
||||
assert.equal($('#compose-textarea').val(), 'hello');
|
||||
assert.equal(compose_state.get_message_type(), 'private');
|
||||
assert.equal(compose_state.private_message_recipient(), "foo@example.com");
|
||||
assert.equal($("#compose-textarea").val(), "hello");
|
||||
assert.equal(compose_state.get_message_type(), "private");
|
||||
assert(compose_state.composing());
|
||||
|
||||
// Cancel compose.
|
||||
@@ -214,43 +214,43 @@ run_test('start', () => {
|
||||
abort_xhr_called = true;
|
||||
};
|
||||
|
||||
assert_hidden('#compose_controls');
|
||||
assert_hidden("#compose_controls");
|
||||
cancel();
|
||||
assert(abort_xhr_called);
|
||||
assert(pill_cleared);
|
||||
assert_visible('#compose_controls');
|
||||
assert_hidden('#private-message');
|
||||
assert_visible("#compose_controls");
|
||||
assert_hidden("#private-message");
|
||||
assert(!compose_state.composing());
|
||||
});
|
||||
|
||||
run_test('respond_to_message', () => {
|
||||
run_test("respond_to_message", () => {
|
||||
// Test PM
|
||||
const person = {
|
||||
user_id: 22,
|
||||
email: 'alice@example.com',
|
||||
full_name: 'Alice',
|
||||
email: "alice@example.com",
|
||||
full_name: "Alice",
|
||||
};
|
||||
people.add_active_user(person);
|
||||
|
||||
let msg = {
|
||||
type: 'private',
|
||||
type: "private",
|
||||
sender_id: person.user_id,
|
||||
};
|
||||
stub_selected_message(msg);
|
||||
|
||||
let opts = {
|
||||
reply_type: 'personal',
|
||||
reply_type: "personal",
|
||||
};
|
||||
|
||||
respond_to_message(opts);
|
||||
assert.equal(compose_state.private_message_recipient(), 'alice@example.com');
|
||||
assert.equal(compose_state.private_message_recipient(), "alice@example.com");
|
||||
|
||||
// Test stream
|
||||
msg = {
|
||||
type: 'stream',
|
||||
stream: 'devel',
|
||||
topic: 'python',
|
||||
reply_to: 'bob', // compose.start needs this for dubious reasons
|
||||
type: "stream",
|
||||
stream: "devel",
|
||||
topic: "python",
|
||||
reply_to: "bob", // compose.start needs this for dubious reasons
|
||||
};
|
||||
stub_selected_message(msg);
|
||||
|
||||
@@ -258,16 +258,16 @@ run_test('respond_to_message', () => {
|
||||
};
|
||||
|
||||
respond_to_message(opts);
|
||||
assert.equal($('#stream_message_recipient_stream').val(), 'devel');
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "devel");
|
||||
});
|
||||
|
||||
run_test('reply_with_mention', () => {
|
||||
run_test("reply_with_mention", () => {
|
||||
const msg = {
|
||||
type: 'stream',
|
||||
stream: 'devel',
|
||||
topic: 'python',
|
||||
reply_to: 'bob', // compose.start needs this for dubious reasons
|
||||
sender_full_name: 'Bob Roberts',
|
||||
type: "stream",
|
||||
stream: "devel",
|
||||
topic: "python",
|
||||
reply_to: "bob", // compose.start needs this for dubious reasons
|
||||
sender_full_name: "Bob Roberts",
|
||||
sender_id: 40,
|
||||
};
|
||||
stub_selected_message(msg);
|
||||
@@ -281,43 +281,43 @@ run_test('reply_with_mention', () => {
|
||||
};
|
||||
|
||||
reply_with_mention(opts);
|
||||
assert.equal($('#stream_message_recipient_stream').val(), 'devel');
|
||||
assert.equal(syntax_to_insert, '@**Bob Roberts**');
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "devel");
|
||||
assert.equal(syntax_to_insert, "@**Bob Roberts**");
|
||||
assert(compose_state.has_message_content());
|
||||
|
||||
// Test for extended mention syntax
|
||||
const bob_1 = {
|
||||
user_id: 30,
|
||||
email: 'bob1@example.com',
|
||||
full_name: 'Bob Roberts',
|
||||
email: "bob1@example.com",
|
||||
full_name: "Bob Roberts",
|
||||
};
|
||||
people.add_active_user(bob_1);
|
||||
const bob_2 = {
|
||||
user_id: 40,
|
||||
email: 'bob2@example.com',
|
||||
full_name: 'Bob Roberts',
|
||||
email: "bob2@example.com",
|
||||
full_name: "Bob Roberts",
|
||||
};
|
||||
people.add_active_user(bob_2);
|
||||
|
||||
reply_with_mention(opts);
|
||||
assert.equal($('#stream_message_recipient_stream').val(), 'devel');
|
||||
assert.equal(syntax_to_insert, '@**Bob Roberts|40**');
|
||||
assert.equal($("#stream_message_recipient_stream").val(), "devel");
|
||||
assert.equal(syntax_to_insert, "@**Bob Roberts|40**");
|
||||
assert(compose_state.has_message_content());
|
||||
});
|
||||
|
||||
run_test('quote_and_reply', () => {
|
||||
run_test("quote_and_reply", () => {
|
||||
const msg = {
|
||||
type: 'stream',
|
||||
stream: 'devel',
|
||||
topic: 'python',
|
||||
reply_to: 'bob',
|
||||
sender_full_name: 'Bob Roberts',
|
||||
type: "stream",
|
||||
stream: "devel",
|
||||
topic: "python",
|
||||
reply_to: "bob",
|
||||
sender_full_name: "Bob Roberts",
|
||||
sender_id: 40,
|
||||
};
|
||||
hash_util.by_conversation_and_time_uri = () => 'link_to_message';
|
||||
hash_util.by_conversation_and_time_uri = () => "link_to_message";
|
||||
stub_selected_message(msg);
|
||||
stub_channel_get({
|
||||
raw_content: 'Testing.',
|
||||
raw_content: "Testing.",
|
||||
});
|
||||
|
||||
current_msg_list.selected_id = function () {
|
||||
@@ -325,19 +325,19 @@ run_test('quote_and_reply', () => {
|
||||
};
|
||||
|
||||
compose_ui.insert_syntax_and_focus = function (syntax) {
|
||||
assert.equal(syntax, '[Quoting…]\n');
|
||||
assert.equal(syntax, "[Quoting…]\n");
|
||||
};
|
||||
|
||||
compose_ui.replace_syntax = function (syntax, replacement) {
|
||||
assert.equal(syntax, '[Quoting…]');
|
||||
assert.equal(replacement, '@_**Bob Roberts|40** [said](link_to_message):\n```quote\nTesting.\n```');
|
||||
assert.equal(syntax, "[Quoting…]");
|
||||
assert.equal(replacement, "@_**Bob Roberts|40** [said](link_to_message):\n```quote\nTesting.\n```");
|
||||
};
|
||||
|
||||
const opts = {
|
||||
reply_type: 'personal',
|
||||
reply_type: "personal",
|
||||
};
|
||||
|
||||
$('#compose-textarea').caret = (pos) => {
|
||||
$("#compose-textarea").caret = (pos) => {
|
||||
assert.equal(pos, 0);
|
||||
};
|
||||
|
||||
@@ -345,78 +345,78 @@ run_test('quote_and_reply', () => {
|
||||
|
||||
current_msg_list.selected_message = function () {
|
||||
return {
|
||||
type: 'stream',
|
||||
stream: 'devel',
|
||||
topic: 'test',
|
||||
reply_to: 'bob',
|
||||
sender_full_name: 'Bob Roberts',
|
||||
type: "stream",
|
||||
stream: "devel",
|
||||
topic: "test",
|
||||
reply_to: "bob",
|
||||
sender_full_name: "Bob Roberts",
|
||||
sender_id: 40,
|
||||
raw_content: 'Testing.',
|
||||
raw_content: "Testing.",
|
||||
};
|
||||
};
|
||||
|
||||
channel.get = function () {
|
||||
assert.fail('channel.get should not be used if raw_content is present');
|
||||
assert.fail("channel.get should not be used if raw_content is present");
|
||||
};
|
||||
|
||||
quote_and_reply(opts);
|
||||
|
||||
current_msg_list.selected_message = function () {
|
||||
return {
|
||||
type: 'stream',
|
||||
stream: 'devel',
|
||||
topic: 'test',
|
||||
reply_to: 'bob',
|
||||
sender_full_name: 'Bob Roberts',
|
||||
type: "stream",
|
||||
stream: "devel",
|
||||
topic: "test",
|
||||
reply_to: "bob",
|
||||
sender_full_name: "Bob Roberts",
|
||||
sender_id: 40,
|
||||
raw_content: '```\nmultiline code block\nshoudln\'t mess with quotes\n```',
|
||||
raw_content: "```\nmultiline code block\nshoudln't mess with quotes\n```",
|
||||
};
|
||||
};
|
||||
compose_ui.replace_syntax = function (syntax, replacement) {
|
||||
assert.equal(syntax, '[Quoting…]');
|
||||
assert.equal(replacement, '@_**Bob Roberts|40** [said](link_to_message):\n````quote\n```\nmultiline code block\nshoudln\'t mess with quotes\n```\n````');
|
||||
assert.equal(syntax, "[Quoting…]");
|
||||
assert.equal(replacement, "@_**Bob Roberts|40** [said](link_to_message):\n````quote\n```\nmultiline code block\nshoudln't mess with quotes\n```\n````");
|
||||
};
|
||||
quote_and_reply(opts);
|
||||
});
|
||||
|
||||
run_test('get_focus_area', () => {
|
||||
assert.equal(get_focus_area('private', {}), '#private_message_recipient');
|
||||
assert.equal(get_focus_area('private', {
|
||||
private_message_recipient: 'bob@example.com'}), '#compose-textarea');
|
||||
assert.equal(get_focus_area('stream', {}), '#stream_message_recipient_stream');
|
||||
assert.equal(get_focus_area('stream', {stream: 'fun'}),
|
||||
'#stream_message_recipient_topic');
|
||||
assert.equal(get_focus_area('stream', {stream: 'fun',
|
||||
topic: 'more'}),
|
||||
'#compose-textarea');
|
||||
assert.equal(get_focus_area('stream', {stream: 'fun',
|
||||
topic: 'more',
|
||||
trigger: 'new topic button'}),
|
||||
'#stream_message_recipient_topic');
|
||||
run_test("get_focus_area", () => {
|
||||
assert.equal(get_focus_area("private", {}), "#private_message_recipient");
|
||||
assert.equal(get_focus_area("private", {
|
||||
private_message_recipient: "bob@example.com"}), "#compose-textarea");
|
||||
assert.equal(get_focus_area("stream", {}), "#stream_message_recipient_stream");
|
||||
assert.equal(get_focus_area("stream", {stream: "fun"}),
|
||||
"#stream_message_recipient_topic");
|
||||
assert.equal(get_focus_area("stream", {stream: "fun",
|
||||
topic: "more"}),
|
||||
"#compose-textarea");
|
||||
assert.equal(get_focus_area("stream", {stream: "fun",
|
||||
topic: "more",
|
||||
trigger: "new topic button"}),
|
||||
"#stream_message_recipient_topic");
|
||||
});
|
||||
|
||||
run_test('focus_in_empty_compose', () => {
|
||||
$('#compose-textarea').is = function (attr) {
|
||||
assert.equal(attr, ':focus');
|
||||
return $('#compose-textarea').is_focused;
|
||||
run_test("focus_in_empty_compose", () => {
|
||||
$("#compose-textarea").is = function (attr) {
|
||||
assert.equal(attr, ":focus");
|
||||
return $("#compose-textarea").is_focused;
|
||||
};
|
||||
|
||||
compose_state.composing = return_true;
|
||||
$('#compose-textarea').val('');
|
||||
$('#compose-textarea').focus();
|
||||
$("#compose-textarea").val("");
|
||||
$("#compose-textarea").focus();
|
||||
assert(compose_state.focus_in_empty_compose());
|
||||
|
||||
compose_state.composing = return_false;
|
||||
assert(!compose_state.focus_in_empty_compose());
|
||||
|
||||
$('#compose-textarea').val('foo');
|
||||
$("#compose-textarea").val("foo");
|
||||
assert(!compose_state.focus_in_empty_compose());
|
||||
|
||||
$('#compose-textarea').blur();
|
||||
$("#compose-textarea").blur();
|
||||
assert(!compose_state.focus_in_empty_compose());
|
||||
});
|
||||
|
||||
run_test('on_narrow', () => {
|
||||
run_test("on_narrow", () => {
|
||||
let cancel_called = false;
|
||||
compose_actions.cancel = function () {
|
||||
cancel_called = true;
|
||||
@@ -465,16 +465,16 @@ run_test('on_narrow', () => {
|
||||
};
|
||||
compose_actions.on_narrow({
|
||||
force_close: false,
|
||||
trigger: 'not-search',
|
||||
private_message_recipient: 'not@empty.com',
|
||||
trigger: "not-search",
|
||||
private_message_recipient: "not@empty.com",
|
||||
});
|
||||
assert(start_called);
|
||||
|
||||
start_called = false;
|
||||
compose_actions.on_narrow({
|
||||
force_close: false,
|
||||
trigger: 'search',
|
||||
private_message_recipient: '',
|
||||
trigger: "search",
|
||||
private_message_recipient: "",
|
||||
});
|
||||
assert(!start_called);
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
zrequire('stream_data');
|
||||
zrequire('people');
|
||||
zrequire('compose_fade');
|
||||
zrequire("stream_data");
|
||||
zrequire("people");
|
||||
zrequire("compose_fade");
|
||||
|
||||
const me = {
|
||||
email: 'me@example.com',
|
||||
email: "me@example.com",
|
||||
user_id: 30,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 31,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
|
||||
const bob = {
|
||||
email: 'bob@example.com',
|
||||
email: "bob@example.com",
|
||||
user_id: 32,
|
||||
full_name: 'Bob',
|
||||
full_name: "Bob",
|
||||
};
|
||||
|
||||
people.add_active_user(me);
|
||||
@@ -26,10 +26,10 @@ people.initialize_current_user(me.user_id);
|
||||
people.add_active_user(alice);
|
||||
people.add_active_user(bob);
|
||||
|
||||
run_test('set_focused_recipient', () => {
|
||||
run_test("set_focused_recipient", () => {
|
||||
const sub = {
|
||||
stream_id: 101,
|
||||
name: 'social',
|
||||
name: "social",
|
||||
subscribed: true,
|
||||
can_access_subscribers: true,
|
||||
};
|
||||
@@ -38,36 +38,36 @@ run_test('set_focused_recipient', () => {
|
||||
|
||||
global.$ = function (selector) {
|
||||
switch (selector) {
|
||||
case '#stream_message_recipient_stream':
|
||||
case "#stream_message_recipient_stream":
|
||||
return {
|
||||
val: function () {
|
||||
return 'social';
|
||||
return "social";
|
||||
},
|
||||
};
|
||||
case '#stream_message_recipient_topic':
|
||||
case "#stream_message_recipient_topic":
|
||||
return {
|
||||
val: function () {
|
||||
return 'lunch';
|
||||
return "lunch";
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
compose_fade.set_focused_recipient('stream');
|
||||
compose_fade.set_focused_recipient("stream");
|
||||
|
||||
assert.equal(compose_fade.would_receive_message(me.user_id), true);
|
||||
assert.equal(compose_fade.would_receive_message(alice.user_id), true);
|
||||
assert.equal(compose_fade.would_receive_message(bob.user_id), false);
|
||||
|
||||
const good_msg = {
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: 101,
|
||||
topic: 'lunch',
|
||||
topic: "lunch",
|
||||
};
|
||||
const bad_msg = {
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: 999,
|
||||
topic: 'lunch',
|
||||
topic: "lunch",
|
||||
};
|
||||
assert(!compose_fade.should_fade_message(good_msg));
|
||||
assert(compose_fade.should_fade_message(bad_msg));
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
const _people = {
|
||||
small_avatar_url_for_person: function () {
|
||||
return 'http://example.com/example.png';
|
||||
return "http://example.com/example.png";
|
||||
},
|
||||
};
|
||||
|
||||
set_global('people', _people);
|
||||
set_global("people", _people);
|
||||
|
||||
zrequire('compose_pm_pill');
|
||||
zrequire('input_pill');
|
||||
zrequire('user_pill');
|
||||
zrequire("compose_pm_pill");
|
||||
zrequire("input_pill");
|
||||
zrequire("user_pill");
|
||||
|
||||
let pills = {
|
||||
pill: {},
|
||||
};
|
||||
|
||||
run_test('pills', () => {
|
||||
run_test("pills", () => {
|
||||
const othello = {
|
||||
user_id: 1,
|
||||
email: 'othello@example.com',
|
||||
full_name: 'Othello',
|
||||
email: "othello@example.com",
|
||||
full_name: "Othello",
|
||||
};
|
||||
|
||||
const iago = {
|
||||
email: 'iago@zulip.com',
|
||||
email: "iago@zulip.com",
|
||||
user_id: 2,
|
||||
full_name: 'Iago',
|
||||
full_name: "Iago",
|
||||
};
|
||||
|
||||
const hamlet = {
|
||||
email: 'hamlet@example.com',
|
||||
email: "hamlet@example.com",
|
||||
user_id: 3,
|
||||
full_name: 'Hamlet',
|
||||
full_name: "Hamlet",
|
||||
};
|
||||
|
||||
people.get_realm_users = function () {
|
||||
@@ -72,7 +72,7 @@ run_test('pills', () => {
|
||||
let appendValue_called;
|
||||
pills.appendValue = function (value) {
|
||||
appendValue_called = true;
|
||||
assert.equal(value, 'othello@example.com');
|
||||
assert.equal(value, "othello@example.com");
|
||||
this.appendValidatedData(othello);
|
||||
};
|
||||
|
||||
@@ -108,7 +108,7 @@ run_test('pills', () => {
|
||||
get_by_email_called = false;
|
||||
const res = handler(iago.email, pills.items());
|
||||
assert(get_by_email_called);
|
||||
assert.equal(typeof res, 'object');
|
||||
assert.equal(typeof res, "object");
|
||||
assert.equal(res.user_id, iago.user_id);
|
||||
assert.equal(res.display_value, iago.full_name);
|
||||
}());
|
||||
@@ -133,18 +133,18 @@ run_test('pills', () => {
|
||||
assert.deepEqual(user_ids, [othello.user_id, hamlet.user_id]);
|
||||
|
||||
const user_ids_string = compose_pm_pill.get_user_ids_string();
|
||||
assert.equal(user_ids_string, '1,3');
|
||||
assert.equal(user_ids_string, "1,3");
|
||||
|
||||
const emails = compose_pm_pill.get_emails();
|
||||
assert.equal(emails, 'othello@example.com,hamlet@example.com');
|
||||
assert.equal(emails, "othello@example.com,hamlet@example.com");
|
||||
|
||||
const persons = [othello, iago, hamlet];
|
||||
const items = compose_pm_pill.filter_taken_users(persons);
|
||||
assert.deepEqual(items, [{email: 'iago@zulip.com', user_id: 2, full_name: 'Iago'}]);
|
||||
assert.deepEqual(items, [{email: "iago@zulip.com", user_id: 2, full_name: "Iago"}]);
|
||||
|
||||
test_create_item(create_item_handler);
|
||||
|
||||
compose_pm_pill.set_from_emails('othello@example.com');
|
||||
compose_pm_pill.set_from_emails("othello@example.com");
|
||||
assert(compose_pm_pill.widget);
|
||||
|
||||
assert(get_by_user_id_called);
|
||||
@@ -153,7 +153,7 @@ run_test('pills', () => {
|
||||
assert(text_cleared);
|
||||
});
|
||||
|
||||
run_test('has_unconverted_data', () => {
|
||||
run_test("has_unconverted_data", () => {
|
||||
compose_pm_pill.widget = {
|
||||
is_pending: () => true,
|
||||
};
|
||||
@@ -173,7 +173,7 @@ run_test('has_unconverted_data', () => {
|
||||
|
||||
compose_pm_pill.widget = {
|
||||
is_pending: () => false,
|
||||
items: () => [{user_id: 99}, {email: 'random@mit.edu'}],
|
||||
items: () => [{user_id: 99}, {email: "random@mit.edu"}],
|
||||
};
|
||||
|
||||
// One of our items only knows email (as in a bridge-with-zephyr
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
zrequire('compose_ui');
|
||||
zrequire('people');
|
||||
zrequire('user_status');
|
||||
zrequire("compose_ui");
|
||||
zrequire("people");
|
||||
zrequire("user_status");
|
||||
|
||||
set_global('document', {
|
||||
set_global("document", {
|
||||
execCommand: function () { return false; },
|
||||
});
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
const alice = {
|
||||
email: 'alice@zulip.com',
|
||||
email: "alice@zulip.com",
|
||||
user_id: 101,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
const bob = {
|
||||
email: 'bob@zulip.com',
|
||||
email: "bob@zulip.com",
|
||||
user_id: 102,
|
||||
full_name: 'Bob',
|
||||
full_name: "Bob",
|
||||
};
|
||||
|
||||
people.add_active_user(alice);
|
||||
@@ -30,7 +30,7 @@ function make_textbox(s) {
|
||||
widget.focused = false;
|
||||
|
||||
widget.caret = function (arg) {
|
||||
if (typeof arg === 'number') {
|
||||
if (typeof arg === "number") {
|
||||
widget.pos = arg;
|
||||
return;
|
||||
}
|
||||
@@ -71,75 +71,75 @@ function make_textbox(s) {
|
||||
return widget;
|
||||
}
|
||||
|
||||
run_test('insert_syntax_and_focus', () => {
|
||||
$('#compose-textarea').val("xyz ");
|
||||
$('#compose-textarea').caret = function (syntax) {
|
||||
run_test("insert_syntax_and_focus", () => {
|
||||
$("#compose-textarea").val("xyz ");
|
||||
$("#compose-textarea").caret = function (syntax) {
|
||||
if (syntax !== undefined) {
|
||||
$('#compose-textarea').val($('#compose-textarea').val() + syntax);
|
||||
$("#compose-textarea").val($("#compose-textarea").val() + syntax);
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
compose_ui.insert_syntax_and_focus(':octopus:');
|
||||
assert.equal($('#compose-textarea').caret(), 4);
|
||||
assert.equal($('#compose-textarea').val(), 'xyz :octopus: ');
|
||||
compose_ui.insert_syntax_and_focus(":octopus:");
|
||||
assert.equal($("#compose-textarea").caret(), 4);
|
||||
assert.equal($("#compose-textarea").val(), "xyz :octopus: ");
|
||||
assert($("#compose-textarea").is_focused());
|
||||
|
||||
});
|
||||
|
||||
run_test('smart_insert', () => {
|
||||
let textbox = make_textbox('abc');
|
||||
run_test("smart_insert", () => {
|
||||
let textbox = make_textbox("abc");
|
||||
textbox.caret(4);
|
||||
|
||||
compose_ui.smart_insert(textbox, ':smile:');
|
||||
compose_ui.smart_insert(textbox, ":smile:");
|
||||
assert.equal(textbox.insert_pos, 4);
|
||||
assert.equal(textbox.insert_text, ' :smile: ');
|
||||
assert.equal(textbox.val(), 'abc :smile: ');
|
||||
assert.equal(textbox.insert_text, " :smile: ");
|
||||
assert.equal(textbox.val(), "abc :smile: ");
|
||||
assert(textbox.focused);
|
||||
|
||||
textbox.blur();
|
||||
compose_ui.smart_insert(textbox, ':airplane:');
|
||||
assert.equal(textbox.insert_text, ':airplane: ');
|
||||
assert.equal(textbox.val(), 'abc :smile: :airplane: ');
|
||||
compose_ui.smart_insert(textbox, ":airplane:");
|
||||
assert.equal(textbox.insert_text, ":airplane: ");
|
||||
assert.equal(textbox.val(), "abc :smile: :airplane: ");
|
||||
assert(textbox.focused);
|
||||
|
||||
textbox.caret(0);
|
||||
textbox.blur();
|
||||
compose_ui.smart_insert(textbox, ':octopus:');
|
||||
assert.equal(textbox.insert_text, ':octopus: ');
|
||||
assert.equal(textbox.val(), ':octopus: abc :smile: :airplane: ');
|
||||
compose_ui.smart_insert(textbox, ":octopus:");
|
||||
assert.equal(textbox.insert_text, ":octopus: ");
|
||||
assert.equal(textbox.val(), ":octopus: abc :smile: :airplane: ");
|
||||
assert(textbox.focused);
|
||||
|
||||
textbox.caret(textbox.val().length);
|
||||
textbox.blur();
|
||||
compose_ui.smart_insert(textbox, ':heart:');
|
||||
assert.equal(textbox.insert_text, ':heart: ');
|
||||
assert.equal(textbox.val(), ':octopus: abc :smile: :airplane: :heart: ');
|
||||
compose_ui.smart_insert(textbox, ":heart:");
|
||||
assert.equal(textbox.insert_text, ":heart: ");
|
||||
assert.equal(textbox.val(), ":octopus: abc :smile: :airplane: :heart: ");
|
||||
assert(textbox.focused);
|
||||
|
||||
// Test handling of spaces for ```quote
|
||||
textbox = make_textbox('');
|
||||
textbox = make_textbox("");
|
||||
textbox.caret(0);
|
||||
textbox.blur();
|
||||
compose_ui.smart_insert(textbox, '```quote\nquoted message\n```\n');
|
||||
assert.equal(textbox.insert_text, '```quote\nquoted message\n```\n');
|
||||
assert.equal(textbox.val(), '```quote\nquoted message\n```\n');
|
||||
compose_ui.smart_insert(textbox, "```quote\nquoted message\n```\n");
|
||||
assert.equal(textbox.insert_text, "```quote\nquoted message\n```\n");
|
||||
assert.equal(textbox.val(), "```quote\nquoted message\n```\n");
|
||||
assert(textbox.focused);
|
||||
|
||||
textbox = make_textbox('');
|
||||
textbox = make_textbox("");
|
||||
textbox.caret(0);
|
||||
textbox.blur();
|
||||
compose_ui.smart_insert(textbox, "[Quoting…]\n");
|
||||
assert.equal(textbox.insert_text, '[Quoting…]\n');
|
||||
assert.equal(textbox.val(), '[Quoting…]\n');
|
||||
assert.equal(textbox.insert_text, "[Quoting…]\n");
|
||||
assert.equal(textbox.val(), "[Quoting…]\n");
|
||||
assert(textbox.focused);
|
||||
|
||||
textbox = make_textbox('abc');
|
||||
textbox = make_textbox("abc");
|
||||
textbox.caret(3);
|
||||
textbox.blur();
|
||||
compose_ui.smart_insert(textbox, " test with space");
|
||||
assert.equal(textbox.insert_text, ' test with space ');
|
||||
assert.equal(textbox.val(), 'abc test with space ');
|
||||
assert.equal(textbox.insert_text, " test with space ");
|
||||
assert.equal(textbox.val(), "abc test with space ");
|
||||
assert(textbox.focused);
|
||||
|
||||
// Note that we don't have any special logic for strings that are
|
||||
@@ -147,26 +147,26 @@ run_test('smart_insert', () => {
|
||||
// like emojis and file links.
|
||||
});
|
||||
|
||||
run_test('replace_syntax', () => {
|
||||
$('#compose-textarea').val('abcabc');
|
||||
run_test("replace_syntax", () => {
|
||||
$("#compose-textarea").val("abcabc");
|
||||
|
||||
compose_ui.replace_syntax('a', 'A');
|
||||
assert.equal($('#compose-textarea').val(), 'Abcabc');
|
||||
compose_ui.replace_syntax("a", "A");
|
||||
assert.equal($("#compose-textarea").val(), "Abcabc");
|
||||
|
||||
compose_ui.replace_syntax(/b/g, 'B');
|
||||
assert.equal($('#compose-textarea').val(), 'ABcaBc');
|
||||
compose_ui.replace_syntax(/b/g, "B");
|
||||
assert.equal($("#compose-textarea").val(), "ABcaBc");
|
||||
|
||||
// Verify we correctly handle `$`s in the replacement syntax
|
||||
compose_ui.replace_syntax('Bca', '$$\\pi$$');
|
||||
assert.equal($('#compose-textarea').val(), 'A$$\\pi$$Bc');
|
||||
compose_ui.replace_syntax("Bca", "$$\\pi$$");
|
||||
assert.equal($("#compose-textarea").val(), "A$$\\pi$$Bc");
|
||||
});
|
||||
|
||||
run_test('compute_placeholder_text', () => {
|
||||
run_test("compute_placeholder_text", () => {
|
||||
let opts = {
|
||||
message_type: 'stream',
|
||||
stream: '',
|
||||
topic: '',
|
||||
private_message_recipient: '',
|
||||
message_type: "stream",
|
||||
stream: "",
|
||||
topic: "",
|
||||
private_message_recipient: "",
|
||||
};
|
||||
|
||||
// Stream narrows
|
||||
@@ -180,28 +180,28 @@ run_test('compute_placeholder_text', () => {
|
||||
|
||||
// PM Narrows
|
||||
opts = {
|
||||
message_type: 'private',
|
||||
stream: '',
|
||||
topic: '',
|
||||
private_message_recipient: '',
|
||||
message_type: "private",
|
||||
stream: "",
|
||||
topic: "",
|
||||
private_message_recipient: "",
|
||||
};
|
||||
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Compose your message here"));
|
||||
|
||||
opts.private_message_recipient = 'bob@zulip.com';
|
||||
opts.private_message_recipient = "bob@zulip.com";
|
||||
user_status.set_status_text({
|
||||
user_id: bob.user_id,
|
||||
status_text: 'out to lunch',
|
||||
status_text: "out to lunch",
|
||||
});
|
||||
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Message Bob (out to lunch)"));
|
||||
|
||||
opts.private_message_recipient = 'alice@zulip.com';
|
||||
opts.private_message_recipient = "alice@zulip.com";
|
||||
user_status.set_status_text({
|
||||
user_id: alice.user_id,
|
||||
status_text: '',
|
||||
status_text: "",
|
||||
});
|
||||
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Message Alice"));
|
||||
|
||||
// Group PM
|
||||
opts.private_message_recipient = 'alice@zulip.com,bob@zulip.com';
|
||||
opts.private_message_recipient = "alice@zulip.com,bob@zulip.com";
|
||||
assert.equal(compose_ui.compute_placeholder_text(opts), i18n.t("Message Alice, Bob"));
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,18 @@
|
||||
global.stub_out_jquery();
|
||||
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
development_environment: true,
|
||||
});
|
||||
set_global('compose_ui', {});
|
||||
set_global("compose_ui", {});
|
||||
|
||||
const { JSDOM } = require("jsdom");
|
||||
const { window } = new JSDOM('<!DOCTYPE html><p>Hello world</p>');
|
||||
const { window } = new JSDOM("<!DOCTYPE html><p>Hello world</p>");
|
||||
const { DOMParser, document } = window;
|
||||
set_global('$', require('jquery')(window));
|
||||
set_global('DOMParser', DOMParser);
|
||||
set_global('document', document);
|
||||
set_global("$", require("jquery")(window));
|
||||
set_global("DOMParser", DOMParser);
|
||||
set_global("document", document);
|
||||
|
||||
const copy_and_paste = zrequire('copy_and_paste');
|
||||
const copy_and_paste = zrequire("copy_and_paste");
|
||||
|
||||
// Super stripped down version of the code in the drag-mock library
|
||||
// https://github.com/andywer/drag-mock/blob/6d46c7c0ffd6a4d685e6612a90cd58cda80f30fc/src/DataTransfer.js
|
||||
@@ -28,52 +28,52 @@ DataTransfer.prototype.setData = function (dataFormat, data) {
|
||||
|
||||
const createPasteEvent = function () {
|
||||
const clipboardData = new DataTransfer();
|
||||
const pasteEvent = new window.Event('paste');
|
||||
const pasteEvent = new window.Event("paste");
|
||||
pasteEvent.clipboardData = clipboardData;
|
||||
return $.Event(pasteEvent);
|
||||
};
|
||||
|
||||
run_test('paste_handler', () => {
|
||||
run_test("paste_handler", () => {
|
||||
|
||||
let input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;"><span> </span>love the<span> </span><b>Zulip</b><b> </b></span><b style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">Organization</b><span style="color: hsl(0, 0%, 13%); font-family: arial, sans-serif; font-size: 12.8px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">.</span>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
' love the **Zulip** **Organization**.');
|
||||
" love the **Zulip** **Organization**.");
|
||||
|
||||
input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">The<span> </span></span><code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0.4em; margin: 0px; background-color: hsla(210, 13%, 12%, 0.05); border-radius: 3px; color: hsl(210, 12%, 16%); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">JSDOM</code><span style="color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>constructor</span>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'The `JSDOM` constructor');
|
||||
"The `JSDOM` constructor");
|
||||
|
||||
input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://zulip.readthedocs.io/en/latest/subsystems/logging.html" target="_blank" title="https://zulip.readthedocs.io/en/latest/subsystems/logging.html" style="color: hsl(200, 100%, 40%); text-decoration: none; cursor: pointer; font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%);">https://zulip.readthedocs.io/en/latest/subsystems/logging.html</a>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'https://zulip.readthedocs.io/en/latest/subsystems/logging.html');
|
||||
"https://zulip.readthedocs.io/en/latest/subsystems/logging.html");
|
||||
|
||||
input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><a class="reference external" href="https://zulip.readthedocs.io/en/latest/overview/contributing.html" style="box-sizing: border-box; color: hsl(283, 39%, 53%); text-decoration: none; cursor: pointer; outline: 0px; font-family: Lato, proxima-nova, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 99%);">Contributing to Zulip</a>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'[Contributing to Zulip](https://zulip.readthedocs.io/en/latest/overview/contributing.html)');
|
||||
"[Contributing to Zulip](https://zulip.readthedocs.io/en/latest/overview/contributing.html)");
|
||||
|
||||
input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: hsl(0, 0%, 0%); font-family: "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">1. text</span>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'1. text');
|
||||
"1. text");
|
||||
|
||||
input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><h1 style="box-sizing: border-box; font-size: 2em; margin-top: 0px !important; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; font-weight: 600; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid hsl(216, 14%, 93%); color: hsl(210, 12%, 16%); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">Zulip overview</h1>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'Zulip overview');
|
||||
"Zulip overview");
|
||||
|
||||
input = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><i style="box-sizing: inherit; color: hsl(0, 0%, 0%); font-family: Verdana, sans-serif; font-size: 15px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: hsl(0, 0%, 100%); text-decoration-style: initial; text-decoration-color: initial;">This text is italic</i>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'*This text is italic*');
|
||||
"*This text is italic*");
|
||||
|
||||
input = '<div class="preview-content"><div class="comment"><div class="comment-body markdown-body js-preview-body" style="min-height: 131px;"><p>Test List:</p><ul><li>Item 1</li><li>Item 2</li></ul></div></div></div>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'Test List:\n* Item 1\n* Item 2');
|
||||
"Test List:\n* Item 1\n* Item 2");
|
||||
|
||||
input = '<div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z ace-ltr focused-line" dir="auto" id="editor-3-ace-line-41"><span>Test List:</span></div><div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z line-list-type-bullet ace-ltr" dir="auto" id="editor-3-ace-line-42"><ul class="listtype-bullet listindent1 list-bullet1"><li><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="end"></span><span class="ace-line-pocket" data-faketext="" contenteditable="false"></span><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="start"></span><span>Item 1</span></li></ul></div><div class="ace-line gutter-author-d-iz88z86z86za0dz67zz78zz78zz74zz68zjz80zz71z9iz90za3z66zs0z65zz65zq8z75zlaz81zcz66zj6g2mz78zz76zmz66z22z75zfcz69zz66z line-list-type-bullet ace-ltr" dir="auto" id="editor-3-ace-line-43"><ul class="listtype-bullet listindent1 list-bullet1"><li><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="end"></span><span class="ace-line-pocket" data-faketext="" contenteditable="false"></span><span class="ace-line-pocket-zws" data-faketext="" data-contentcollector-ignore-space-at="start"></span><span>Item 2</span></li></ul></div>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input),
|
||||
'Test List:\n* Item 1\n* Item 2');
|
||||
"Test List:\n* Item 1\n* Item 2");
|
||||
|
||||
let data = '<p>text</p>';
|
||||
let data = "<p>text</p>";
|
||||
let event = createPasteEvent();
|
||||
event.originalEvent.clipboardData.setData('text/html', data);
|
||||
event.originalEvent.clipboardData.setData("text/html", data);
|
||||
let insert_syntax_and_focus_called = false;
|
||||
compose_ui.insert_syntax_and_focus = function () {
|
||||
insert_syntax_and_focus_called = true;
|
||||
@@ -83,7 +83,7 @@ run_test('paste_handler', () => {
|
||||
|
||||
data = '<meta http-equiv="content-type" content="text/html; charset=utf-8"><img src="http://localhost:9991/thumbnail?url=user_uploads%2F1%2Fe2%2FHPMCcGWOG9rS2M4ybHN8sEzh%2Fpasted_image.png&size=full"/>';
|
||||
event = createPasteEvent();
|
||||
event.originalEvent.clipboardData.setData('text/html', data);
|
||||
event.originalEvent.clipboardData.setData("text/html", data);
|
||||
insert_syntax_and_focus_called = false;
|
||||
copy_and_paste.paste_handler(event);
|
||||
assert(!insert_syntax_and_focus_called);
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
const noop = function () {};
|
||||
|
||||
const events = require('./lib/events.js');
|
||||
const events = require("./lib/events.js");
|
||||
|
||||
const event_fixtures = events.fixtures;
|
||||
const test_message = events.test_message;
|
||||
const test_user = events.test_user;
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
global.patch_builtin('setTimeout', (func) => func());
|
||||
global.patch_builtin("setTimeout", (func) => func());
|
||||
|
||||
// These dependencies are closer to the dispatcher, and they
|
||||
// apply to all tests.
|
||||
set_global('home_msg_list', {
|
||||
set_global("home_msg_list", {
|
||||
rerender: noop,
|
||||
select_id: noop,
|
||||
selected_id: function () {return 1;},
|
||||
});
|
||||
|
||||
set_global('markdown', {
|
||||
set_global("markdown", {
|
||||
update_realm_filter_rules: noop,
|
||||
});
|
||||
|
||||
set_global('notifications', {
|
||||
set_global("notifications", {
|
||||
redraw_title: noop,
|
||||
});
|
||||
|
||||
set_global('settings_emoji', {
|
||||
set_global("settings_emoji", {
|
||||
update_custom_emoji_ui: noop,
|
||||
});
|
||||
|
||||
set_global('settings_account', {
|
||||
set_global("settings_account", {
|
||||
update_email_change_display: noop,
|
||||
update_name_change_display: noop,
|
||||
add_custom_profile_fields_to_settings: noop,
|
||||
});
|
||||
set_global('settings_display', {
|
||||
set_global("settings_display", {
|
||||
update_page: noop,
|
||||
});
|
||||
|
||||
set_global('settings_notifications', {
|
||||
set_global("settings_notifications", {
|
||||
update_page: noop,
|
||||
});
|
||||
|
||||
set_global('settings_org', {
|
||||
set_global("settings_org", {
|
||||
sync_realm_settings: noop,
|
||||
});
|
||||
|
||||
set_global('message_edit', {
|
||||
set_global("message_edit", {
|
||||
update_message_topic_editing_pencil: noop,
|
||||
});
|
||||
|
||||
set_global('settings_bots', {
|
||||
set_global("settings_bots", {
|
||||
update_bot_permissions_ui: noop,
|
||||
});
|
||||
|
||||
set_global('compose', {
|
||||
set_global("compose", {
|
||||
update_video_chat_button_display: noop,
|
||||
});
|
||||
|
||||
set_global('settings_exports', {
|
||||
set_global("settings_exports", {
|
||||
populate_exports_table: function (exports) {
|
||||
return exports;
|
||||
},
|
||||
@@ -67,18 +67,18 @@ set_global('settings_exports', {
|
||||
});
|
||||
|
||||
// page_params is highly coupled to dispatching now
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
test_suite: false,
|
||||
is_admin: true,
|
||||
realm_description: 'already set description',
|
||||
realm_description: "already set description",
|
||||
});
|
||||
const page_params = global.page_params;
|
||||
|
||||
// We access various msg_list object to rerender them
|
||||
set_global('current_msg_list', {rerender: noop});
|
||||
set_global("current_msg_list", {rerender: noop});
|
||||
|
||||
// We use blueslip to print the traceback
|
||||
set_global('blueslip', {
|
||||
set_global("blueslip", {
|
||||
info: noop,
|
||||
error: function (msg, more_info, stack) {
|
||||
console.log("\nFailed to process an event:\n", more_info.event, "\n");
|
||||
@@ -91,25 +91,25 @@ set_global('blueslip', {
|
||||
},
|
||||
});
|
||||
|
||||
set_global('overlays', {
|
||||
set_global("overlays", {
|
||||
streams_open: () => true,
|
||||
});
|
||||
|
||||
// For data-oriented modules, just use them, don't stub them.
|
||||
zrequire('alert_words');
|
||||
zrequire('unread');
|
||||
zrequire('stream_topic_history');
|
||||
zrequire('stream_list');
|
||||
zrequire('message_flags');
|
||||
zrequire('message_store');
|
||||
zrequire('people');
|
||||
zrequire('starred_messages');
|
||||
zrequire('user_status');
|
||||
zrequire('subs');
|
||||
zrequire('stream_ui_updates');
|
||||
zrequire("alert_words");
|
||||
zrequire("unread");
|
||||
zrequire("stream_topic_history");
|
||||
zrequire("stream_list");
|
||||
zrequire("message_flags");
|
||||
zrequire("message_store");
|
||||
zrequire("people");
|
||||
zrequire("starred_messages");
|
||||
zrequire("user_status");
|
||||
zrequire("subs");
|
||||
zrequire("stream_ui_updates");
|
||||
|
||||
zrequire('server_events_dispatch');
|
||||
zrequire('panels');
|
||||
zrequire("server_events_dispatch");
|
||||
zrequire("panels");
|
||||
|
||||
function dispatch(ev) {
|
||||
server_events_dispatch.dispatch_normal_event(ev);
|
||||
@@ -131,65 +131,65 @@ const with_overrides = global.with_overrides; // make lint happy
|
||||
|
||||
with_overrides((override) => {
|
||||
// alert_words
|
||||
assert(!alert_words.has_alert_word('fire'));
|
||||
assert(!alert_words.has_alert_word('lunch'));
|
||||
assert(!alert_words.has_alert_word("fire"));
|
||||
assert(!alert_words.has_alert_word("lunch"));
|
||||
|
||||
override('alert_words_ui.render_alert_words_ui', noop);
|
||||
override("alert_words_ui.render_alert_words_ui", noop);
|
||||
const event = event_fixtures.alert_words;
|
||||
dispatch(event);
|
||||
|
||||
assert.deepEqual(
|
||||
alert_words.get_word_list(),
|
||||
['fire', 'lunch'],
|
||||
["fire", "lunch"],
|
||||
);
|
||||
assert(alert_words.has_alert_word('fire'));
|
||||
assert(alert_words.has_alert_word('lunch'));
|
||||
assert(alert_words.has_alert_word("fire"));
|
||||
assert(alert_words.has_alert_word("lunch"));
|
||||
});
|
||||
|
||||
with_overrides((override) => {
|
||||
// attachments
|
||||
const event = event_fixtures.attachment;
|
||||
global.with_stub((stub) => {
|
||||
override('attachments_ui.update_attachments', stub.f);
|
||||
override("attachments_ui.update_attachments", stub.f);
|
||||
dispatch(event);
|
||||
assert_same(stub.get_args('event').event, event);
|
||||
assert_same(stub.get_args("event").event, event);
|
||||
});
|
||||
});
|
||||
|
||||
with_overrides((override) => {
|
||||
// User groups
|
||||
let event = event_fixtures.user_group__add;
|
||||
override('settings_user_groups.reload', noop);
|
||||
override("settings_user_groups.reload", noop);
|
||||
global.with_stub((stub) => {
|
||||
override('user_groups.add', stub.f);
|
||||
override("user_groups.add", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('group');
|
||||
const args = stub.get_args("group");
|
||||
assert_same(args.group, event.group);
|
||||
});
|
||||
|
||||
event = event_fixtures.user_group__add_members;
|
||||
global.with_stub((stub) => {
|
||||
override('user_groups.add_members', stub.f);
|
||||
override("user_groups.add_members", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('group_id', 'user_ids');
|
||||
const args = stub.get_args("group_id", "user_ids");
|
||||
assert_same(args.group_id, event.group_id);
|
||||
assert_same(args.user_ids, event.user_ids);
|
||||
});
|
||||
|
||||
event = event_fixtures.user_group__remove_members;
|
||||
global.with_stub((stub) => {
|
||||
override('user_groups.remove_members', stub.f);
|
||||
override("user_groups.remove_members", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('group_id', 'user_ids');
|
||||
const args = stub.get_args("group_id", "user_ids");
|
||||
assert_same(args.group_id, event.group_id);
|
||||
assert_same(args.user_ids, event.user_ids);
|
||||
});
|
||||
|
||||
event = event_fixtures.user_group__update;
|
||||
global.with_stub((stub) => {
|
||||
override('user_groups.update', stub.f);
|
||||
override("user_groups.update", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('event');
|
||||
const args = stub.get_args("event");
|
||||
assert_same(args.event.group_id, event.group_id);
|
||||
assert_same(args.event.data.name, event.data.name);
|
||||
assert_same(args.event.data.description, event.data.description);
|
||||
@@ -199,8 +199,8 @@ with_overrides((override) => {
|
||||
with_overrides((override) => {
|
||||
// custom profile fields
|
||||
const event = event_fixtures.custom_profile_fields;
|
||||
override('settings_profile_fields.populate_profile_fields', noop);
|
||||
override('settings_profile_fields.report_success', noop);
|
||||
override("settings_profile_fields.populate_profile_fields", noop);
|
||||
override("settings_profile_fields.report_success", noop);
|
||||
dispatch(event);
|
||||
assert_same(global.page_params.custom_profile_fields, event.fields);
|
||||
|
||||
@@ -209,11 +209,11 @@ with_overrides((override) => {
|
||||
with_overrides((override) => {
|
||||
// default_streams
|
||||
const event = event_fixtures.default_streams;
|
||||
override('settings_streams.update_default_streams_table', noop);
|
||||
override("settings_streams.update_default_streams_table", noop);
|
||||
global.with_stub((stub) => {
|
||||
override('stream_data.set_realm_default_streams', stub.f);
|
||||
override("stream_data.set_realm_default_streams", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('realm_default_streams');
|
||||
const args = stub.get_args("realm_default_streams");
|
||||
assert_same(args.realm_default_streams, event.default_streams);
|
||||
});
|
||||
|
||||
@@ -222,7 +222,7 @@ with_overrides((override) => {
|
||||
with_overrides((override) => {
|
||||
// hotspots
|
||||
const event = event_fixtures.hotspots;
|
||||
override('hotspots.load_new', noop);
|
||||
override("hotspots.load_new", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.hotspots, event.hotspots);
|
||||
});
|
||||
@@ -230,9 +230,9 @@ with_overrides((override) => {
|
||||
with_overrides((override) => {
|
||||
// invites_changed
|
||||
const event = event_fixtures.invites_changed;
|
||||
$('#admin-invites-list').length = 1;
|
||||
$("#admin-invites-list").length = 1;
|
||||
global.with_stub((stub) => {
|
||||
override('settings_invites.set_up', stub.f);
|
||||
override("settings_invites.set_up", stub.f);
|
||||
dispatch(event); // stub automatically checks if stub.f is called once
|
||||
});
|
||||
});
|
||||
@@ -242,9 +242,9 @@ with_overrides((override) => {
|
||||
const event = event_fixtures.muted_topics;
|
||||
|
||||
global.with_stub((stub) => {
|
||||
override('muting_ui.handle_updates', stub.f);
|
||||
override("muting_ui.handle_updates", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('muted_topics');
|
||||
const args = stub.get_args("muted_topics");
|
||||
assert_same(args.muted_topics, event.muted_topics);
|
||||
});
|
||||
});
|
||||
@@ -254,9 +254,9 @@ with_overrides((override) => {
|
||||
const event = event_fixtures.presence;
|
||||
|
||||
global.with_stub((stub) => {
|
||||
override('activity.update_presence_info', stub.f);
|
||||
override("activity.update_presence_info", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('user_id', 'presence', 'server_time');
|
||||
const args = stub.get_args("user_id", "presence", "server_time");
|
||||
assert_same(args.user_id, event.user_id);
|
||||
assert_same(args.presence, event.presence);
|
||||
assert_same(args.server_time, event.server_timestamp);
|
||||
@@ -267,18 +267,18 @@ with_overrides((override) => {
|
||||
// reaction
|
||||
let event = event_fixtures.reaction__add;
|
||||
global.with_stub((stub) => {
|
||||
override('reactions.add_reaction', stub.f);
|
||||
override("reactions.add_reaction", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('event');
|
||||
const args = stub.get_args("event");
|
||||
assert_same(args.event.emoji_name, event.emoji_name);
|
||||
assert_same(args.event.message_id, event.message_id);
|
||||
});
|
||||
|
||||
event = event_fixtures.reaction__remove;
|
||||
global.with_stub((stub) => {
|
||||
override('reactions.remove_reaction', stub.f);
|
||||
override("reactions.remove_reaction", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('event');
|
||||
const args = stub.get_args("event");
|
||||
assert_same(args.event.emoji_name, event.emoji_name);
|
||||
assert_same(args.event.message_id, event.message_id);
|
||||
});
|
||||
@@ -317,26 +317,26 @@ with_overrides((override) => {
|
||||
}
|
||||
|
||||
let event = event_fixtures.realm__update__create_stream_policy;
|
||||
test_realm_integer(event, 'realm_create_stream_policy');
|
||||
test_realm_integer(event, "realm_create_stream_policy");
|
||||
|
||||
event = event_fixtures.realm__update__invite_to_stream_policy;
|
||||
test_realm_integer(event, 'realm_invite_to_stream_policy');
|
||||
test_realm_integer(event, "realm_invite_to_stream_policy");
|
||||
|
||||
event = event_fixtures.realm__update__bot_creation_policy;
|
||||
test_realm_integer(event, 'realm_bot_creation_policy');
|
||||
test_realm_integer(event, "realm_bot_creation_policy");
|
||||
|
||||
event = event_fixtures.realm__update__invite_required;
|
||||
test_realm_boolean(event, 'realm_invite_required');
|
||||
test_realm_boolean(event, "realm_invite_required");
|
||||
|
||||
event = event_fixtures.realm__update__name;
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_name, 'new_realm_name');
|
||||
assert_same(page_params.realm_name, "new_realm_name");
|
||||
|
||||
let called = false;
|
||||
set_global('electron_bridge', {
|
||||
set_global("electron_bridge", {
|
||||
send_event: (key, val) => {
|
||||
assert_same(key, 'realm_name');
|
||||
assert_same(val, 'new_realm_name');
|
||||
assert_same(key, "realm_name");
|
||||
assert_same(val, "new_realm_name");
|
||||
called = true;
|
||||
},
|
||||
});
|
||||
@@ -345,16 +345,16 @@ with_overrides((override) => {
|
||||
assert_same(called, true);
|
||||
|
||||
event = event_fixtures.realm__update__emails_restricted_to_domains;
|
||||
test_realm_boolean(event, 'realm_emails_restricted_to_domains');
|
||||
test_realm_boolean(event, "realm_emails_restricted_to_domains");
|
||||
|
||||
event = event_fixtures.realm__update__disallow_disposable_email_addresses;
|
||||
test_realm_boolean(event, 'realm_disallow_disposable_email_addresses');
|
||||
test_realm_boolean(event, "realm_disallow_disposable_email_addresses");
|
||||
|
||||
event = event_fixtures.realm__update_default_twenty_four_hour_time;
|
||||
test_realm_boolean(event, 'realm_default_twenty_four_hour_time');
|
||||
test_realm_boolean(event, "realm_default_twenty_four_hour_time");
|
||||
|
||||
event = event_fixtures.realm__update__email_addresses_visibility;
|
||||
override('stream_ui_updates.update_subscribers_list', noop);
|
||||
override("stream_ui_updates.update_subscribers_list", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_email_address_visibility, 3);
|
||||
|
||||
@@ -370,25 +370,25 @@ with_overrides((override) => {
|
||||
|
||||
event = event_fixtures.realm__update_default_code_block_language;
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_default_code_block_language, 'javascript');
|
||||
assert_same(page_params.realm_default_code_block_language, "javascript");
|
||||
|
||||
event = event_fixtures.realm__update_dict__default;
|
||||
page_params.realm_allow_message_editing = false;
|
||||
page_params.realm_message_content_edit_limit_seconds = 0;
|
||||
override('settings_org.populate_auth_methods', noop);
|
||||
override("settings_org.populate_auth_methods", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_allow_message_editing, true);
|
||||
assert_same(page_params.realm_message_content_edit_limit_seconds, 5);
|
||||
assert_same(page_params.realm_authentication_methods, {Google: true});
|
||||
|
||||
event = event_fixtures.realm__update_dict__icon;
|
||||
override('realm_icon.rerender', noop);
|
||||
override("realm_icon.rerender", noop);
|
||||
|
||||
called = false;
|
||||
set_global('electron_bridge', {
|
||||
set_global("electron_bridge", {
|
||||
send_event: (key, val) => {
|
||||
assert_same(key, 'realm_icon_url');
|
||||
assert_same(val, 'icon.png');
|
||||
assert_same(key, "realm_icon_url");
|
||||
assert_same(val, "icon.png");
|
||||
called = true;
|
||||
},
|
||||
});
|
||||
@@ -396,23 +396,23 @@ with_overrides((override) => {
|
||||
dispatch(event);
|
||||
|
||||
assert_same(called, true);
|
||||
assert_same(page_params.realm_icon_url, 'icon.png');
|
||||
assert_same(page_params.realm_icon_source, 'U');
|
||||
assert_same(page_params.realm_icon_url, "icon.png");
|
||||
assert_same(page_params.realm_icon_source, "U");
|
||||
|
||||
event = event_fixtures.realm__update_dict__logo;
|
||||
override('realm_logo.rerender', noop);
|
||||
override("realm_logo.rerender", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_logo_url, 'logo.png');
|
||||
assert_same(page_params.realm_logo_source, 'U');
|
||||
assert_same(page_params.realm_logo_url, "logo.png");
|
||||
assert_same(page_params.realm_logo_source, "U");
|
||||
|
||||
event = event_fixtures.realm__update_dict__night_logo;
|
||||
override('realm_logo.rerender', noop);
|
||||
override("realm_logo.rerender", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_night_logo_url, 'night_logo.png');
|
||||
assert_same(page_params.realm_night_logo_source, 'U');
|
||||
assert_same(page_params.realm_night_logo_url, "night_logo.png");
|
||||
assert_same(page_params.realm_night_logo_source, "U");
|
||||
|
||||
event = event_fixtures.realm__deactivated;
|
||||
set_global('location', {});
|
||||
set_global("location", {});
|
||||
dispatch(event);
|
||||
assert_same(window.location.href, "/accounts/deactivated/");
|
||||
});
|
||||
@@ -422,26 +422,26 @@ with_overrides((override) => {
|
||||
let event = event_fixtures.realm_bot__add;
|
||||
global.with_stub((bot_stub) => {
|
||||
global.with_stub((admin_stub) => {
|
||||
override('bot_data.add', bot_stub.f);
|
||||
override('settings_users.update_bot_data', admin_stub.f);
|
||||
override("bot_data.add", bot_stub.f);
|
||||
override("settings_users.update_bot_data", admin_stub.f);
|
||||
dispatch(event);
|
||||
const args = bot_stub.get_args('bot');
|
||||
const args = bot_stub.get_args("bot");
|
||||
assert_same(args.bot, event.bot);
|
||||
|
||||
admin_stub.get_args('update_user_id', 'update_bot_data');
|
||||
admin_stub.get_args("update_user_id", "update_bot_data");
|
||||
});
|
||||
});
|
||||
|
||||
event = event_fixtures.realm_bot__remove;
|
||||
global.with_stub((bot_stub) => {
|
||||
global.with_stub((admin_stub) => {
|
||||
override('bot_data.deactivate', bot_stub.f);
|
||||
override('settings_users.update_bot_data', admin_stub.f);
|
||||
override("bot_data.deactivate", bot_stub.f);
|
||||
override("settings_users.update_bot_data", admin_stub.f);
|
||||
dispatch(event);
|
||||
const args = bot_stub.get_args('user_id');
|
||||
const args = bot_stub.get_args("user_id");
|
||||
assert_same(args.user_id, event.bot.user_id);
|
||||
|
||||
admin_stub.get_args('update_user_id', 'update_bot_data');
|
||||
admin_stub.get_args("update_user_id", "update_bot_data");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -452,16 +452,16 @@ with_overrides((override) => {
|
||||
event = event_fixtures.realm_bot__update;
|
||||
global.with_stub((bot_stub) => {
|
||||
global.with_stub((admin_stub) => {
|
||||
override('bot_data.update', bot_stub.f);
|
||||
override('settings_users.update_bot_data', admin_stub.f);
|
||||
override("bot_data.update", bot_stub.f);
|
||||
override("settings_users.update_bot_data", admin_stub.f);
|
||||
|
||||
dispatch(event);
|
||||
|
||||
let args = bot_stub.get_args('user_id', 'bot');
|
||||
let args = bot_stub.get_args("user_id", "bot");
|
||||
assert_same(args.user_id, event.bot.user_id);
|
||||
assert_same(args.bot, event.bot);
|
||||
|
||||
args = admin_stub.get_args('update_user_id', 'update_bot_data');
|
||||
args = admin_stub.get_args("update_user_id", "update_bot_data");
|
||||
assert_same(args.update_user_id, event.bot.user_id);
|
||||
});
|
||||
});
|
||||
@@ -472,12 +472,12 @@ with_overrides((override) => {
|
||||
const event = event_fixtures.realm_emoji;
|
||||
|
||||
global.with_stub((stub) => {
|
||||
override('emoji.update_emojis', stub.f);
|
||||
override('settings_emoji.populate_emoji', noop);
|
||||
override('emoji_picker.generate_emoji_picker_data', noop);
|
||||
override('composebox_typeahead.update_emoji_data', noop);
|
||||
override("emoji.update_emojis", stub.f);
|
||||
override("settings_emoji.populate_emoji", noop);
|
||||
override("emoji_picker.generate_emoji_picker_data", noop);
|
||||
override("composebox_typeahead.update_emoji_data", noop);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('realm_emoji');
|
||||
const args = stub.get_args("realm_emoji");
|
||||
assert_same(args.realm_emoji, event.realm_emoji);
|
||||
});
|
||||
});
|
||||
@@ -486,7 +486,7 @@ with_overrides((override) => {
|
||||
// realm_filters
|
||||
const event = event_fixtures.realm_filters;
|
||||
page_params.realm_filters = [];
|
||||
override('settings_linkifiers.populate_filters', noop);
|
||||
override("settings_linkifiers.populate_filters", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_filters, event.realm_filters);
|
||||
|
||||
@@ -496,7 +496,7 @@ with_overrides((override) => {
|
||||
// realm_domains
|
||||
let event = event_fixtures.realm_domains__add;
|
||||
page_params.realm_domains = [];
|
||||
override('settings_org.populate_realm_domains', noop);
|
||||
override("settings_org.populate_realm_domains", noop);
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_domains, [event.realm_domain]);
|
||||
|
||||
@@ -514,23 +514,23 @@ with_overrides((override) => {
|
||||
let event = event_fixtures.realm_user__add;
|
||||
dispatch(event);
|
||||
const added_person = people.get_by_user_id(event.person.user_id);
|
||||
assert.equal(added_person.full_name, 'Added Person');
|
||||
assert.equal(added_person.full_name, "Added Person");
|
||||
assert(people.is_active_user_for_popover(event.person.user_id));
|
||||
|
||||
event = event_fixtures.realm_user__remove;
|
||||
override('stream_events.remove_deactivated_user_from_all_streams', noop);
|
||||
override("stream_events.remove_deactivated_user_from_all_streams", noop);
|
||||
dispatch(event);
|
||||
|
||||
// We don't actually remove the person, we just deactivate them.
|
||||
const removed_person = people.get_by_user_id(event.person.user_id);
|
||||
assert.equal(removed_person.full_name, 'Added Person');
|
||||
assert.equal(removed_person.full_name, "Added Person");
|
||||
assert(!people.is_active_user_for_popover(event.person.user_id));
|
||||
|
||||
event = event_fixtures.realm_user__update;
|
||||
global.with_stub((stub) => {
|
||||
override('user_events.update_person', stub.f);
|
||||
override("user_events.update_person", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('person');
|
||||
const args = stub.get_args("person");
|
||||
assert_same(args.person, event.person);
|
||||
});
|
||||
});
|
||||
@@ -539,9 +539,9 @@ with_overrides((override) => {
|
||||
// restart
|
||||
const event = event_fixtures.restart;
|
||||
global.with_stub((stub) => {
|
||||
override('reload.initiate', stub.f);
|
||||
override("reload.initiate", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('options');
|
||||
const args = stub.get_args("options");
|
||||
assert.equal(args.options.save_pointer, true);
|
||||
assert.equal(args.options.immediate, true);
|
||||
});
|
||||
@@ -552,10 +552,10 @@ with_overrides((override) => {
|
||||
let event = event_fixtures.stream__update;
|
||||
|
||||
global.with_stub((stub) => {
|
||||
override('stream_events.update_property', stub.f);
|
||||
override('settings_streams.update_default_streams_table', noop);
|
||||
override("stream_events.update_property", stub.f);
|
||||
override("settings_streams.update_default_streams_table", noop);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('stream_id', 'property', 'value');
|
||||
const args = stub.get_args("stream_id", "property", "value");
|
||||
assert_same(args.stream_id, event.stream_id);
|
||||
assert_same(args.property, event.property);
|
||||
assert_same(args.value, event.value);
|
||||
@@ -564,30 +564,30 @@ with_overrides((override) => {
|
||||
// stream create
|
||||
event = event_fixtures.stream__create;
|
||||
global.with_stub((stub) => {
|
||||
override('stream_data.create_streams', stub.f);
|
||||
override('stream_data.get_sub_by_id', noop);
|
||||
override('stream_data.update_calculated_fields', noop);
|
||||
override('subs.add_sub_to_table', noop);
|
||||
override("stream_data.create_streams", stub.f);
|
||||
override("stream_data.get_sub_by_id", noop);
|
||||
override("stream_data.update_calculated_fields", noop);
|
||||
override("subs.add_sub_to_table", noop);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('streams');
|
||||
const args = stub.get_args("streams");
|
||||
assert_same(args.streams.map((stream) => stream.stream_id), [42, 99]);
|
||||
});
|
||||
|
||||
// stream delete
|
||||
event = event_fixtures.stream__delete;
|
||||
global.with_stub((stub) => {
|
||||
override('subs.remove_stream', noop);
|
||||
override('stream_data.delete_sub', noop);
|
||||
override('settings_streams.update_default_streams_table', noop);
|
||||
override('stream_data.remove_default_stream', noop);
|
||||
override("subs.remove_stream", noop);
|
||||
override("stream_data.delete_sub", noop);
|
||||
override("settings_streams.update_default_streams_table", noop);
|
||||
override("stream_data.remove_default_stream", noop);
|
||||
|
||||
override('stream_data.get_sub_by_id', (id) => id === 42 ? {subscribed: true} : {subscribed: false});
|
||||
override('stream_list.remove_sidebar_row', stub.f);
|
||||
override("stream_data.get_sub_by_id", (id) => id === 42 ? {subscribed: true} : {subscribed: false});
|
||||
override("stream_list.remove_sidebar_row", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('stream_id');
|
||||
const args = stub.get_args("stream_id");
|
||||
assert_same(args.stream_id, 42);
|
||||
|
||||
override('stream_list.remove_sidebar_row', noop);
|
||||
override("stream_list.remove_sidebar_row", noop);
|
||||
page_params.realm_notifications_stream_id = 42;
|
||||
dispatch(event);
|
||||
assert_same(page_params.realm_notifications_stream_id, -1);
|
||||
@@ -602,15 +602,15 @@ with_overrides((override) => {
|
||||
// submessage
|
||||
const event = event_fixtures.submessage;
|
||||
global.with_stub((stub) => {
|
||||
override('submessage.handle_event', stub.f);
|
||||
override("submessage.handle_event", stub.f);
|
||||
dispatch(event);
|
||||
const submsg = stub.get_args('submsg').submsg;
|
||||
const submsg = stub.get_args("submsg").submsg;
|
||||
assert_same(submsg, {
|
||||
id: 99,
|
||||
sender_id: 42,
|
||||
msg_type: 'stream',
|
||||
msg_type: "stream",
|
||||
message_id: 56,
|
||||
content: 'test',
|
||||
content: "test",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -621,17 +621,17 @@ with_overrides((override) => {
|
||||
// typing
|
||||
let event = event_fixtures.typing__start;
|
||||
global.with_stub((stub) => {
|
||||
override('typing_events.display_notification', stub.f);
|
||||
override("typing_events.display_notification", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('event');
|
||||
const args = stub.get_args("event");
|
||||
assert_same(args.event.sender.user_id, 4);
|
||||
});
|
||||
|
||||
event = event_fixtures.typing__stop;
|
||||
global.with_stub((stub) => {
|
||||
override('typing_events.hide_notification', stub.f);
|
||||
override("typing_events.hide_notification", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('event');
|
||||
const args = stub.get_args("event");
|
||||
assert_same(args.event.sender.user_id, 6);
|
||||
});
|
||||
|
||||
@@ -643,9 +643,9 @@ with_overrides((override) => {
|
||||
with_overrides((override) => {
|
||||
// update_display_settings
|
||||
let event = event_fixtures.update_display_settings__default_language;
|
||||
page_params.default_language = 'en';
|
||||
page_params.default_language = "en";
|
||||
dispatch(event);
|
||||
assert_same(page_params.default_language, 'fr');
|
||||
assert_same(page_params.default_language, "fr");
|
||||
|
||||
event = event_fixtures.update_display_settings__left_side_userlist;
|
||||
page_params.left_side_userlist = false;
|
||||
@@ -657,7 +657,7 @@ with_overrides((override) => {
|
||||
called = true;
|
||||
};
|
||||
|
||||
override('message_list.narrowed', current_msg_list);
|
||||
override("message_list.narrowed", current_msg_list);
|
||||
event = event_fixtures.update_display_settings__twenty_four_hour_time;
|
||||
page_params.twenty_four_hour_time = false;
|
||||
dispatch(event);
|
||||
@@ -677,14 +677,14 @@ with_overrides((override) => {
|
||||
};
|
||||
dispatch(event);
|
||||
assert_same(page_params.high_contrast_mode, true);
|
||||
assert_same(toggled, ['high-contrast']);
|
||||
assert_same(toggled, ["high-contrast"]);
|
||||
|
||||
event = event_fixtures.update_display_settings__dense_mode;
|
||||
page_params.dense_mode = false;
|
||||
toggled = [];
|
||||
dispatch(event);
|
||||
assert_same(page_params.dense_mode, true);
|
||||
assert_same(toggled, ['less_dense_mode', 'more_dense_mode']);
|
||||
assert_same(toggled, ["less_dense_mode", "more_dense_mode"]);
|
||||
|
||||
$("body").fadeOut = (secs) => { assert_same(secs, 300); };
|
||||
$("body").fadeIn = (secs) => { assert_same(secs, 300); };
|
||||
@@ -692,8 +692,8 @@ with_overrides((override) => {
|
||||
global.with_stub((stub) => {
|
||||
event = event_fixtures.update_display_settings__color_scheme_dark;
|
||||
page_params.color_scheme = 1;
|
||||
override('night_mode.enable', stub.f); // automatically checks if called
|
||||
override('realm_logo.rerender', noop);
|
||||
override("night_mode.enable", stub.f); // automatically checks if called
|
||||
override("realm_logo.rerender", noop);
|
||||
dispatch(event);
|
||||
assert(page_params.color_scheme, 2);
|
||||
});
|
||||
@@ -701,8 +701,8 @@ with_overrides((override) => {
|
||||
global.with_stub((stub) => {
|
||||
event = event_fixtures.update_display_settings__color_scheme_light;
|
||||
page_params.color_scheme = 1;
|
||||
override('night_mode.disable', stub.f); // automatically checks if called
|
||||
override('realm_logo.rerender', noop);
|
||||
override("night_mode.disable", stub.f); // automatically checks if called
|
||||
override("realm_logo.rerender", noop);
|
||||
dispatch(event);
|
||||
assert(page_params.color_scheme, 3);
|
||||
});
|
||||
@@ -710,8 +710,8 @@ with_overrides((override) => {
|
||||
global.with_stub((stub) => {
|
||||
event = event_fixtures.update_display_settings__color_scheme_automatic;
|
||||
page_params.color_scheme = 2;
|
||||
override('night_mode.default_preference_checker', stub.f); // automatically checks if called
|
||||
override('realm_logo.rerender', noop);
|
||||
override("night_mode.default_preference_checker", stub.f); // automatically checks if called
|
||||
override("realm_logo.rerender", noop);
|
||||
dispatch(event);
|
||||
assert(page_params.color_scheme, 1);
|
||||
});
|
||||
@@ -719,20 +719,20 @@ with_overrides((override) => {
|
||||
global.with_stub((stub) => {
|
||||
event = event_fixtures.update_display_settings__emojiset;
|
||||
called = false;
|
||||
override('settings_display.report_emojiset_change', stub.f);
|
||||
page_params.emojiset = 'text';
|
||||
override("settings_display.report_emojiset_change", stub.f);
|
||||
page_params.emojiset = "text";
|
||||
dispatch(event);
|
||||
assert_same(called, true);
|
||||
assert_same(page_params.emojiset, 'google');
|
||||
assert_same(page_params.emojiset, "google");
|
||||
});
|
||||
|
||||
override('starred_messages.rerender_ui', noop);
|
||||
override("starred_messages.rerender_ui", noop);
|
||||
event = event_fixtures.update_display_settings__starred_message_counts;
|
||||
page_params.starred_message_counts = false;
|
||||
dispatch(event);
|
||||
assert_same(page_params.starred_message_counts, true);
|
||||
|
||||
override('scroll_bar.set_layout_width', noop);
|
||||
override("scroll_bar.set_layout_width", noop);
|
||||
event = event_fixtures.update_display_settings__fluid_layout_width;
|
||||
page_params.fluid_layout_width = false;
|
||||
dispatch(event);
|
||||
@@ -740,8 +740,8 @@ with_overrides((override) => {
|
||||
|
||||
global.with_stub((stub) => {
|
||||
event = event_fixtures.update_display_settings__demote_inactive_streams;
|
||||
override('stream_data.set_filter_out_inactives', noop);
|
||||
override('stream_list.update_streams_sidebar', stub.f);
|
||||
override("stream_data.set_filter_out_inactives", noop);
|
||||
override("stream_list.update_streams_sidebar", stub.f);
|
||||
page_params.demote_inactive_streams = 1;
|
||||
dispatch(event);
|
||||
assert_same(page_params.demote_inactive_streams, 2);
|
||||
@@ -752,9 +752,9 @@ with_overrides((override) => {
|
||||
// update_global_notifications
|
||||
const event = event_fixtures.update_global_notifications;
|
||||
global.with_stub((stub) => {
|
||||
override('notifications.handle_global_notification_updates', stub.f);
|
||||
override("notifications.handle_global_notification_updates", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('name', 'setting');
|
||||
const args = stub.get_args("name", "setting");
|
||||
assert_same(args.name, event.notification_name);
|
||||
assert_same(args.setting, event.setting);
|
||||
});
|
||||
@@ -765,9 +765,9 @@ with_overrides((override) => {
|
||||
const event = event_fixtures.update_message_flags__read;
|
||||
|
||||
global.with_stub((stub) => {
|
||||
override('unread_ops.process_read_messages_event', stub.f);
|
||||
override("unread_ops.process_read_messages_event", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('message_ids');
|
||||
const args = stub.get_args("message_ids");
|
||||
assert_same(args.message_ids, [999]);
|
||||
});
|
||||
});
|
||||
@@ -775,13 +775,13 @@ with_overrides((override) => {
|
||||
with_overrides((override) => {
|
||||
// update_message_flags__starred
|
||||
|
||||
override('starred_messages.rerender_ui', noop);
|
||||
override("starred_messages.rerender_ui", noop);
|
||||
|
||||
let event = event_fixtures.update_message_flags__starred_add;
|
||||
global.with_stub((stub) => {
|
||||
override('ui.update_starred_view', stub.f);
|
||||
override("ui.update_starred_view", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('message_id', 'new_value');
|
||||
const args = stub.get_args("message_id", "new_value");
|
||||
assert_same(args.message_id, test_message.id);
|
||||
assert_same(args.new_value, true); // for 'add'
|
||||
const msg = message_store.get(test_message.id);
|
||||
@@ -790,9 +790,9 @@ with_overrides((override) => {
|
||||
|
||||
event = event_fixtures.update_message_flags__starred_remove;
|
||||
global.with_stub((stub) => {
|
||||
override('ui.update_starred_view', stub.f);
|
||||
override("ui.update_starred_view", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('message_id', 'new_value');
|
||||
const args = stub.get_args("message_id", "new_value");
|
||||
assert_same(args.message_id, test_message.id);
|
||||
assert_same(args.new_value, false);
|
||||
const msg = message_store.get(test_message.id);
|
||||
@@ -804,26 +804,26 @@ with_overrides((override) => {
|
||||
// delete_message
|
||||
const event = event_fixtures.delete_message;
|
||||
|
||||
override('stream_list.update_streams_sidebar', noop);
|
||||
override("stream_list.update_streams_sidebar", noop);
|
||||
global.with_stub((stub) => {
|
||||
override('unread_ops.process_read_messages_event', noop);
|
||||
override('ui.remove_messages', stub.f);
|
||||
override("unread_ops.process_read_messages_event", noop);
|
||||
override("ui.remove_messages", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('message_ids');
|
||||
const args = stub.get_args("message_ids");
|
||||
assert_same(args.message_ids, [1337]);
|
||||
});
|
||||
global.with_stub((stub) => {
|
||||
override('unread_ops.process_read_messages_event', stub.f);
|
||||
override("unread_ops.process_read_messages_event", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('message_ids');
|
||||
const args = stub.get_args("message_ids");
|
||||
assert_same(args.message_ids, [1337]);
|
||||
});
|
||||
global.with_stub((stub) => {
|
||||
override('stream_topic_history.remove_messages', stub.f);
|
||||
override("stream_topic_history.remove_messages", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('opts');
|
||||
const args = stub.get_args("opts");
|
||||
assert_same(args.opts.stream_id, 99);
|
||||
assert_same(args.opts.topic_name, 'topic1');
|
||||
assert_same(args.opts.topic_name, "topic1");
|
||||
assert_same(args.opts.num_messages, 1);
|
||||
});
|
||||
});
|
||||
@@ -832,42 +832,42 @@ with_overrides((override) => {
|
||||
// attachments
|
||||
let event = event_fixtures.user_status__set_away;
|
||||
global.with_stub((stub) => {
|
||||
override('activity.on_set_away', stub.f);
|
||||
override("activity.on_set_away", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('user_id');
|
||||
const args = stub.get_args("user_id");
|
||||
assert_same(args.user_id, 55);
|
||||
});
|
||||
|
||||
event = event_fixtures.user_status__revoke_away;
|
||||
global.with_stub((stub) => {
|
||||
override('activity.on_revoke_away', stub.f);
|
||||
override("activity.on_revoke_away", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('user_id');
|
||||
const args = stub.get_args("user_id");
|
||||
assert_same(args.user_id, 63);
|
||||
});
|
||||
|
||||
event = event_fixtures.user_status__set_status_text;
|
||||
global.with_stub((stub) => {
|
||||
override('activity.redraw_user', stub.f);
|
||||
override("activity.redraw_user", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('user_id');
|
||||
const args = stub.get_args("user_id");
|
||||
assert_same(args.user_id, test_user.user_id);
|
||||
const status_text = user_status.get_status_text(test_user.user_id);
|
||||
assert.equal(status_text, 'out to lunch');
|
||||
assert.equal(status_text, "out to lunch");
|
||||
});
|
||||
});
|
||||
|
||||
with_overrides((override) => {
|
||||
const event = event_fixtures.realm_export;
|
||||
override('settings_exports.populate_exports_table', noop);
|
||||
override("settings_exports.populate_exports_table", noop);
|
||||
dispatch(event);
|
||||
global.with_stub((stub) => {
|
||||
override('settings_exports.populate_exports_table', stub.f);
|
||||
override("settings_exports.populate_exports_table", stub.f);
|
||||
dispatch(event);
|
||||
|
||||
const args = stub.get_args('exports');
|
||||
const args = stub.get_args("exports");
|
||||
assert.equal(args.exports.acting_user_id, 55);
|
||||
assert.equal(args.exports.event_time, 'noon');
|
||||
assert.equal(args.exports.path, 'some_path');
|
||||
assert.equal(args.exports.event_time, "noon");
|
||||
assert.equal(args.exports.path, "some_path");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
const events = require('./lib/events.js');
|
||||
const events = require("./lib/events.js");
|
||||
const event_fixtures = events.fixtures;
|
||||
const test_user = events.test_user;
|
||||
|
||||
const noop = function () {};
|
||||
|
||||
zrequire('people');
|
||||
zrequire('stream_data');
|
||||
zrequire('server_events_dispatch');
|
||||
zrequire("people");
|
||||
zrequire("stream_data");
|
||||
zrequire("server_events_dispatch");
|
||||
|
||||
people.add_active_user(test_user);
|
||||
|
||||
@@ -21,7 +21,7 @@ function test(label, f) {
|
||||
});
|
||||
}
|
||||
|
||||
test('add', (override) => {
|
||||
test("add", (override) => {
|
||||
const event = event_fixtures.subscription__add;
|
||||
|
||||
const sub = event.subscriptions[0];
|
||||
@@ -33,27 +33,27 @@ test('add', (override) => {
|
||||
});
|
||||
|
||||
global.with_stub((subscription_stub) => {
|
||||
override('stream_events.mark_subscribed', subscription_stub.f);
|
||||
override("stream_events.mark_subscribed", subscription_stub.f);
|
||||
dispatch(event);
|
||||
const args = subscription_stub.get_args('sub', 'subscribers');
|
||||
const args = subscription_stub.get_args("sub", "subscribers");
|
||||
assert.deepEqual(args.sub.stream_id, stream_id);
|
||||
assert.deepEqual(args.subscribers, event.subscriptions[0].subscribers);
|
||||
});
|
||||
});
|
||||
|
||||
test('peer add/remove', (override) => {
|
||||
test("peer add/remove", (override) => {
|
||||
let event = event_fixtures.subscription__peer_add;
|
||||
|
||||
stream_data.add_sub({
|
||||
name: 'devel',
|
||||
name: "devel",
|
||||
stream_id: event.stream_id,
|
||||
});
|
||||
|
||||
const subs_stub = global.make_stub();
|
||||
override('subs.update_subscribers_ui', subs_stub.f);
|
||||
override("subs.update_subscribers_ui", subs_stub.f);
|
||||
|
||||
const compose_fade_stub = global.make_stub();
|
||||
override('compose_fade.update_faded_users', compose_fade_stub.f);
|
||||
override("compose_fade.update_faded_users", compose_fade_stub.f);
|
||||
|
||||
dispatch(event);
|
||||
assert.equal(compose_fade_stub.num_calls, 1);
|
||||
@@ -65,7 +65,7 @@ test('peer add/remove', (override) => {
|
||||
assert.equal(subs_stub.num_calls, 2);
|
||||
});
|
||||
|
||||
test('remove', (override) => {
|
||||
test("remove", (override) => {
|
||||
const event = event_fixtures.subscription__remove;
|
||||
const event_sub = event.subscriptions[0];
|
||||
const stream_id = event_sub.stream_id;
|
||||
@@ -78,88 +78,88 @@ test('remove', (override) => {
|
||||
stream_data.add_sub(sub);
|
||||
|
||||
global.with_stub((stub) => {
|
||||
override('stream_events.mark_unsubscribed', stub.f);
|
||||
override("stream_events.mark_unsubscribed", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('sub');
|
||||
const args = stub.get_args("sub");
|
||||
assert.deepEqual(args.sub, sub);
|
||||
});
|
||||
});
|
||||
|
||||
test('update', (override) => {
|
||||
test("update", (override) => {
|
||||
const event = event_fixtures.subscription__update;
|
||||
global.with_stub((stub) => {
|
||||
override('stream_events.update_property', stub.f);
|
||||
override("stream_events.update_property", stub.f);
|
||||
dispatch(event);
|
||||
const args = stub.get_args('stream_id', 'property', 'value');
|
||||
const args = stub.get_args("stream_id", "property", "value");
|
||||
assert.deepEqual(args.stream_id, event.stream_id);
|
||||
assert.deepEqual(args.property, event.property);
|
||||
assert.deepEqual(args.value, event.value);
|
||||
});
|
||||
});
|
||||
|
||||
test('add error handling', (override) => {
|
||||
test("add error handling", (override) => {
|
||||
// test blueslip errors/warns
|
||||
const event = event_fixtures.subscription__add;
|
||||
global.with_stub((stub) => {
|
||||
override('blueslip.error', stub.f);
|
||||
override("blueslip.error", stub.f);
|
||||
dispatch(event);
|
||||
assert.deepEqual(stub.get_args('param').param, 'Subscribing to unknown stream with ID 42');
|
||||
assert.deepEqual(stub.get_args("param").param, "Subscribing to unknown stream with ID 42");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('peer event error handling (bad stream_ids)', (override) => {
|
||||
override('compose_fade.update_faded_users', noop);
|
||||
test("peer event error handling (bad stream_ids)", (override) => {
|
||||
override("compose_fade.update_faded_users", noop);
|
||||
|
||||
const add_event = {
|
||||
type: 'subscription',
|
||||
op: 'peer_add',
|
||||
type: "subscription",
|
||||
op: "peer_add",
|
||||
stream_id: 99999,
|
||||
};
|
||||
|
||||
blueslip.expect('warn', 'Cannot find stream for peer_add: 99999');
|
||||
blueslip.expect("warn", "Cannot find stream for peer_add: 99999");
|
||||
dispatch(add_event);
|
||||
blueslip.reset();
|
||||
|
||||
const remove_event = {
|
||||
type: 'subscription',
|
||||
op: 'peer_remove',
|
||||
type: "subscription",
|
||||
op: "peer_remove",
|
||||
stream_id: 99999,
|
||||
};
|
||||
|
||||
blueslip.expect('warn', 'Cannot find stream for peer_remove: 99999');
|
||||
blueslip.expect("warn", "Cannot find stream for peer_remove: 99999");
|
||||
dispatch(remove_event);
|
||||
});
|
||||
|
||||
test('peer event error handling (add_subscriber)', (override) => {
|
||||
test("peer event error handling (add_subscriber)", (override) => {
|
||||
stream_data.add_sub({
|
||||
name: 'devel',
|
||||
name: "devel",
|
||||
stream_id: 1,
|
||||
});
|
||||
|
||||
override('stream_data.add_subscriber', () => false);
|
||||
override("stream_data.add_subscriber", () => false);
|
||||
|
||||
const add_event = {
|
||||
type: 'subscription',
|
||||
op: 'peer_add',
|
||||
type: "subscription",
|
||||
op: "peer_add",
|
||||
stream_id: 1,
|
||||
user_id: 99999, // id is irrelevant
|
||||
};
|
||||
|
||||
blueslip.expect('warn', 'Cannot process peer_add event');
|
||||
blueslip.expect("warn", "Cannot process peer_add event");
|
||||
dispatch(add_event);
|
||||
blueslip.reset();
|
||||
|
||||
override('stream_data.remove_subscriber', () => false);
|
||||
override("stream_data.remove_subscriber", () => false);
|
||||
|
||||
const remove_event = {
|
||||
type: 'subscription',
|
||||
op: 'peer_remove',
|
||||
type: "subscription",
|
||||
op: "peer_remove",
|
||||
stream_id: 1,
|
||||
user_id: 99999, // id is irrelevant
|
||||
};
|
||||
|
||||
blueslip.expect('warn', 'Cannot process peer_remove event.');
|
||||
blueslip.expect("warn", "Cannot process peer_remove event.");
|
||||
dispatch(remove_event);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
zrequire('localstorage');
|
||||
zrequire('drafts');
|
||||
set_global('XDate', zrequire('XDate', 'xdate'));
|
||||
zrequire('timerender');
|
||||
set_global('Handlebars', global.make_handlebars());
|
||||
zrequire('stream_color');
|
||||
zrequire('colorspace');
|
||||
zrequire("localstorage");
|
||||
zrequire("drafts");
|
||||
set_global("XDate", zrequire("XDate", "xdate"));
|
||||
zrequire("timerender");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("stream_color");
|
||||
zrequire("colorspace");
|
||||
|
||||
const ls_container = new Map();
|
||||
const noop = function () { return; };
|
||||
|
||||
set_global('localStorage', {
|
||||
set_global("localStorage", {
|
||||
getItem: function (key) {
|
||||
return ls_container.get(key);
|
||||
},
|
||||
@@ -25,26 +25,26 @@ set_global('localStorage', {
|
||||
ls_container.clear();
|
||||
},
|
||||
});
|
||||
set_global('compose', {});
|
||||
set_global('compose_state', {});
|
||||
set_global('stream_data', {
|
||||
set_global("compose", {});
|
||||
set_global("compose_state", {});
|
||||
set_global("stream_data", {
|
||||
get_color: function () {
|
||||
return '#FFFFFF';
|
||||
return "#FFFFFF";
|
||||
},
|
||||
});
|
||||
set_global('people', {
|
||||
set_global("people", {
|
||||
// Mocking get_by_email function, here we are
|
||||
// just returning string before `@` in email
|
||||
get_by_email: function (email) {
|
||||
return {
|
||||
full_name: email.split('@')[0],
|
||||
full_name: email.split("@")[0],
|
||||
};
|
||||
},
|
||||
});
|
||||
set_global('markdown', {
|
||||
set_global("markdown", {
|
||||
apply_markdown: noop,
|
||||
});
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
twenty_four_hour_time: false,
|
||||
});
|
||||
|
||||
@@ -90,14 +90,14 @@ const short_msg = {
|
||||
content: "a",
|
||||
};
|
||||
|
||||
run_test('legacy', () => {
|
||||
run_test("legacy", () => {
|
||||
assert.deepEqual(
|
||||
drafts.restore_message(legacy_draft),
|
||||
compose_args_for_legacy_draft,
|
||||
);
|
||||
});
|
||||
|
||||
run_test('draft_model', () => {
|
||||
run_test("draft_model", () => {
|
||||
const draft_model = drafts.draft_model;
|
||||
const ls = localstorage();
|
||||
|
||||
@@ -149,7 +149,7 @@ run_test('draft_model', () => {
|
||||
}());
|
||||
});
|
||||
|
||||
run_test('snapshot_message', () => {
|
||||
run_test("snapshot_message", () => {
|
||||
function stub_draft(draft) {
|
||||
global.compose_state.get_message_type = function () {
|
||||
return draft.type;
|
||||
@@ -184,7 +184,7 @@ run_test('snapshot_message', () => {
|
||||
assert.equal(drafts.snapshot_message(), undefined);
|
||||
});
|
||||
|
||||
run_test('initialize', () => {
|
||||
run_test("initialize", () => {
|
||||
const message_content = $("#compose-textarea");
|
||||
message_content.focusout = function (f) {
|
||||
assert.equal(f, drafts.update_draft);
|
||||
@@ -202,7 +202,7 @@ run_test('initialize', () => {
|
||||
drafts.initialize();
|
||||
});
|
||||
|
||||
run_test('remove_old_drafts', () => {
|
||||
run_test("remove_old_drafts", () => {
|
||||
const draft_3 = {
|
||||
stream: "stream",
|
||||
subject: "topic",
|
||||
@@ -228,7 +228,7 @@ run_test('remove_old_drafts', () => {
|
||||
assert.deepEqual(draft_model.get(), {id3: draft_3});
|
||||
});
|
||||
|
||||
run_test('format_drafts', () => {
|
||||
run_test("format_drafts", () => {
|
||||
drafts.remove_old_drafts = noop;
|
||||
|
||||
draft_1.updatedAt = new Date(1549958107000).getTime(); // 2/12/2019 07:55:07 AM (UTC+0)
|
||||
@@ -257,49 +257,49 @@ run_test('format_drafts', () => {
|
||||
|
||||
const expected = [
|
||||
{
|
||||
draft_id: 'id1',
|
||||
draft_id: "id1",
|
||||
is_stream: true,
|
||||
stream: 'stream',
|
||||
stream_color: '#FFFFFF',
|
||||
dark_background: '',
|
||||
topic: 'topic',
|
||||
raw_content: 'Test Stream Message',
|
||||
time_stamp: '7:55 AM',
|
||||
stream: "stream",
|
||||
stream_color: "#FFFFFF",
|
||||
dark_background: "",
|
||||
topic: "topic",
|
||||
raw_content: "Test Stream Message",
|
||||
time_stamp: "7:55 AM",
|
||||
},
|
||||
{
|
||||
draft_id: 'id2',
|
||||
draft_id: "id2",
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message',
|
||||
time_stamp: 'Jan 30',
|
||||
recipients: "aaron",
|
||||
raw_content: "Test Private Message",
|
||||
time_stamp: "Jan 30",
|
||||
},
|
||||
{
|
||||
draft_id: 'id5',
|
||||
draft_id: "id5",
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message 3',
|
||||
time_stamp: 'Jan 29',
|
||||
recipients: "aaron",
|
||||
raw_content: "Test Private Message 3",
|
||||
time_stamp: "Jan 29",
|
||||
},
|
||||
{
|
||||
draft_id: 'id4',
|
||||
draft_id: "id4",
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message 2',
|
||||
time_stamp: 'Jan 26',
|
||||
recipients: "aaron",
|
||||
raw_content: "Test Private Message 2",
|
||||
time_stamp: "Jan 26",
|
||||
},
|
||||
{
|
||||
draft_id: 'id3',
|
||||
draft_id: "id3",
|
||||
is_stream: true,
|
||||
stream: 'stream 2',
|
||||
stream_color: '#FFFFFF',
|
||||
dark_background: '',
|
||||
topic: 'topic',
|
||||
raw_content: 'Test Stream Message 2',
|
||||
time_stamp: 'Jan 21',
|
||||
stream: "stream 2",
|
||||
stream_color: "#FFFFFF",
|
||||
dark_background: "",
|
||||
topic: "topic",
|
||||
raw_content: "Test Stream Message 2",
|
||||
time_stamp: "Jan 21",
|
||||
},
|
||||
];
|
||||
|
||||
$('#drafts_table').append = noop;
|
||||
$("#drafts_table").append = noop;
|
||||
|
||||
const draft_model = drafts.draft_model;
|
||||
const ls = localstorage();
|
||||
@@ -314,10 +314,10 @@ run_test('format_drafts', () => {
|
||||
};
|
||||
|
||||
global.stub_templates((template_name, data) => {
|
||||
assert.equal(template_name, 'draft_table_body');
|
||||
assert.equal(template_name, "draft_table_body");
|
||||
// Tests formatting and sorting of drafts
|
||||
assert.deepEqual(data.drafts, expected);
|
||||
return '<draft table stub>';
|
||||
return "<draft table stub>";
|
||||
});
|
||||
|
||||
drafts.open_overlay = noop;
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
zrequire('dropdown_list_widget');
|
||||
zrequire('scroll_util');
|
||||
set_global('$', global.make_zjquery());
|
||||
zrequire("dropdown_list_widget");
|
||||
zrequire("scroll_util");
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
const noop = () => {};
|
||||
const _list_render = {
|
||||
create: () => ({ init: noop }),
|
||||
};
|
||||
set_global('list_render', _list_render);
|
||||
set_global("list_render", _list_render);
|
||||
|
||||
const setup_zjquery_data = (name) => {
|
||||
$.clear_all_elements();
|
||||
const input_group = $(".input_group");
|
||||
const reset_button = $('.dropdown_list_reset_button');
|
||||
input_group.set_find_results('.dropdown_list_reset_button:not([disabled])', reset_button);
|
||||
const reset_button = $(".dropdown_list_reset_button");
|
||||
input_group.set_find_results(".dropdown_list_reset_button:not([disabled])", reset_button);
|
||||
$(`#${name}_widget #${name}_name`).closest = () => input_group;
|
||||
const $widget = $(`#${name}_widget #${name}_name`);
|
||||
return {reset_button, $widget};
|
||||
};
|
||||
|
||||
run_test('basic_functions', () => {
|
||||
run_test("basic_functions", () => {
|
||||
let updated_value;
|
||||
const opts = {
|
||||
widget_name: 'my_setting',
|
||||
data: ['one', 'two', 'three'].map((x) => ({name: x, value: x})),
|
||||
value: 'one',
|
||||
widget_name: "my_setting",
|
||||
data: ["one", "two", "three"].map((x) => ({name: x, value: x})),
|
||||
value: "one",
|
||||
on_update: (val) => { updated_value = val; },
|
||||
default_text: i18n.t("not set"),
|
||||
render_text: (text) => `rendered: ${text}`,
|
||||
@@ -33,34 +33,34 @@ run_test('basic_functions', () => {
|
||||
|
||||
const widget = dropdown_list_widget(opts);
|
||||
|
||||
assert.equal(widget.value(), 'one');
|
||||
assert.equal(widget.value(), "one");
|
||||
assert.equal(updated_value, undefined); // We haven't 'updated' the widget yet.
|
||||
assert(reset_button.visible());
|
||||
|
||||
widget.update('two');
|
||||
assert.equal($widget.text(), 'rendered: two');
|
||||
assert.equal(widget.value(), 'two');
|
||||
assert.equal(updated_value, 'two');
|
||||
widget.update("two");
|
||||
assert.equal($widget.text(), "rendered: two");
|
||||
assert.equal(widget.value(), "two");
|
||||
assert.equal(updated_value, "two");
|
||||
assert(reset_button.visible());
|
||||
|
||||
widget.update(null);
|
||||
assert.equal($widget.text(), 'translated: not set');
|
||||
assert.equal(widget.value(), '');
|
||||
assert.equal($widget.text(), "translated: not set");
|
||||
assert.equal(widget.value(), "");
|
||||
assert.equal(updated_value, null);
|
||||
assert(!reset_button.visible());
|
||||
});
|
||||
|
||||
run_test('no_default_value', () => {
|
||||
run_test("no_default_value", () => {
|
||||
const opts = {
|
||||
widget_name: 'my_setting',
|
||||
data: ['one', 'two', 'three'].map((x) => ({name: x, value: x})),
|
||||
widget_name: "my_setting",
|
||||
data: ["one", "two", "three"].map((x) => ({name: x, value: x})),
|
||||
default_text: i18n.t("not set"),
|
||||
render_text: (text) => `rendered: ${text}`,
|
||||
null_value: 'null-value',
|
||||
null_value: "null-value",
|
||||
};
|
||||
|
||||
blueslip.expect('warn', 'dropdown-list-widget: Called without a default value; using null value');
|
||||
blueslip.expect("warn", "dropdown-list-widget: Called without a default value; using null value");
|
||||
setup_zjquery_data(opts.widget_name);
|
||||
const widget = dropdown_list_widget(opts);
|
||||
assert.equal(widget.value(), 'null-value');
|
||||
assert.equal(widget.value(), "null-value");
|
||||
});
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('markdown', {});
|
||||
set_global('local_message', {
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("markdown", {});
|
||||
set_global("local_message", {
|
||||
now: () => "timestamp",
|
||||
});
|
||||
set_global('page_params', {});
|
||||
set_global("page_params", {});
|
||||
|
||||
zrequire('echo');
|
||||
zrequire('people');
|
||||
zrequire("echo");
|
||||
zrequire("people");
|
||||
|
||||
let disparities = [];
|
||||
let messages_to_rerender = [];
|
||||
|
||||
set_global('ui', {
|
||||
set_global("ui", {
|
||||
show_failed_message_success: () => {},
|
||||
});
|
||||
|
||||
set_global('sent_messages', {
|
||||
set_global("sent_messages", {
|
||||
mark_disparity: (local_id) => {
|
||||
disparities.push(local_id);
|
||||
},
|
||||
});
|
||||
|
||||
set_global('message_store', {
|
||||
set_global("message_store", {
|
||||
get: () => ({ failed_request: true }),
|
||||
update_booleans: () => {},
|
||||
});
|
||||
|
||||
set_global('alert_words', {
|
||||
set_global("alert_words", {
|
||||
process_message: () => {},
|
||||
});
|
||||
|
||||
set_global('home_msg_list', {
|
||||
set_global("home_msg_list", {
|
||||
view: {
|
||||
rerender_messages: (msgs) => {
|
||||
messages_to_rerender = msgs;
|
||||
@@ -38,11 +38,11 @@ set_global('home_msg_list', {
|
||||
},
|
||||
});
|
||||
|
||||
set_global('message_list', {});
|
||||
set_global("message_list", {});
|
||||
|
||||
set_global('current_msg_list', '');
|
||||
set_global("current_msg_list", "");
|
||||
|
||||
run_test('process_from_server for un-echoed messages', () => {
|
||||
run_test("process_from_server for un-echoed messages", () => {
|
||||
const waiting_for_ack = new Map();
|
||||
const server_messages = [
|
||||
{
|
||||
@@ -54,11 +54,11 @@ run_test('process_from_server for un-echoed messages', () => {
|
||||
assert.deepEqual(non_echo_messages, server_messages);
|
||||
});
|
||||
|
||||
run_test('process_from_server for differently rendered messages', () => {
|
||||
run_test("process_from_server for differently rendered messages", () => {
|
||||
// Test that we update all the booleans and the content of the message
|
||||
// in local echo.
|
||||
const old_value = 'old_value';
|
||||
const new_value = 'new_value';
|
||||
const old_value = "old_value";
|
||||
const new_value = "new_value";
|
||||
const waiting_for_ack = new Map([
|
||||
["100.1", {
|
||||
content: "<p>A client rendered message</p>",
|
||||
@@ -93,7 +93,7 @@ run_test('process_from_server for differently rendered messages', () => {
|
||||
}]);
|
||||
});
|
||||
|
||||
run_test('build_display_recipient', () => {
|
||||
run_test("build_display_recipient", () => {
|
||||
page_params.user_id = 123;
|
||||
|
||||
const params = {};
|
||||
@@ -162,7 +162,7 @@ run_test('build_display_recipient', () => {
|
||||
|
||||
});
|
||||
|
||||
run_test('insert_local_message', () => {
|
||||
run_test("insert_local_message", () => {
|
||||
const local_id_float = 1;
|
||||
|
||||
page_params.user_id = 123;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('page_params', {
|
||||
emojiset: 'google',
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("page_params", {
|
||||
emojiset: "google",
|
||||
realm_emoji: {},
|
||||
});
|
||||
set_global('upload_widget', {});
|
||||
set_global("upload_widget", {});
|
||||
|
||||
zrequire('emoji');
|
||||
zrequire('settings_emoji');
|
||||
zrequire("emoji");
|
||||
zrequire("settings_emoji");
|
||||
|
||||
run_test('build_emoji_upload_widget', () => {
|
||||
run_test("build_emoji_upload_widget", () => {
|
||||
let build_widget_stub = false;
|
||||
upload_widget.build_widget = function (
|
||||
get_file_input,
|
||||
@@ -17,59 +17,59 @@ run_test('build_emoji_upload_widget', () => {
|
||||
clear_button,
|
||||
upload_button,
|
||||
) {
|
||||
assert.deepEqual(get_file_input(), $('#emoji_file_input'));
|
||||
assert.deepEqual(file_name_field, $('#emoji-file-name'));
|
||||
assert.deepEqual(input_error, $('#emoji_file_input_error'));
|
||||
assert.deepEqual(clear_button, $('#emoji_image_clear_button'));
|
||||
assert.deepEqual(upload_button, $('#emoji_upload_button'));
|
||||
assert.deepEqual(get_file_input(), $("#emoji_file_input"));
|
||||
assert.deepEqual(file_name_field, $("#emoji-file-name"));
|
||||
assert.deepEqual(input_error, $("#emoji_file_input_error"));
|
||||
assert.deepEqual(clear_button, $("#emoji_image_clear_button"));
|
||||
assert.deepEqual(upload_button, $("#emoji_upload_button"));
|
||||
build_widget_stub = true;
|
||||
};
|
||||
settings_emoji.build_emoji_upload_widget();
|
||||
assert(build_widget_stub);
|
||||
});
|
||||
|
||||
run_test('get_canonical_name', () => {
|
||||
run_test("get_canonical_name", () => {
|
||||
emoji.active_realm_emojis = new Map(Object.entries({
|
||||
realm_emoji: 'TBD',
|
||||
realm_emoji: "TBD",
|
||||
}));
|
||||
let canonical_name = emoji.get_canonical_name('realm_emoji');
|
||||
assert.equal(canonical_name, 'realm_emoji');
|
||||
let canonical_name = emoji.get_canonical_name("realm_emoji");
|
||||
assert.equal(canonical_name, "realm_emoji");
|
||||
|
||||
canonical_name = emoji.get_canonical_name('thumbs_up');
|
||||
assert.equal(canonical_name, '+1');
|
||||
canonical_name = emoji.get_canonical_name("thumbs_up");
|
||||
assert.equal(canonical_name, "+1");
|
||||
|
||||
canonical_name = emoji.get_canonical_name('+1');
|
||||
assert.equal(canonical_name, '+1');
|
||||
canonical_name = emoji.get_canonical_name("+1");
|
||||
assert.equal(canonical_name, "+1");
|
||||
|
||||
canonical_name = emoji.get_canonical_name('airplane');
|
||||
assert.equal(canonical_name, 'airplane');
|
||||
canonical_name = emoji.get_canonical_name("airplane");
|
||||
assert.equal(canonical_name, "airplane");
|
||||
|
||||
blueslip.expect('error', 'Invalid emoji name: non_existent');
|
||||
emoji.get_canonical_name('non_existent');
|
||||
blueslip.expect("error", "Invalid emoji name: non_existent");
|
||||
emoji.get_canonical_name("non_existent");
|
||||
});
|
||||
|
||||
function set_up_spain_realm_emoji_for_test() {
|
||||
const realm_emojis = {
|
||||
101: {
|
||||
id: 101,
|
||||
name: 'spain',
|
||||
source_url: '/some/path/to/spain.png',
|
||||
name: "spain",
|
||||
source_url: "/some/path/to/spain.png",
|
||||
deactivated: false,
|
||||
},
|
||||
};
|
||||
emoji.update_emojis(realm_emojis);
|
||||
}
|
||||
|
||||
run_test('get_emoji_* API', () => {
|
||||
assert.equal(emoji.get_emoji_name('1f384'), 'holiday_tree');
|
||||
assert.equal(emoji.get_emoji_name('1f951'), 'avocado');
|
||||
assert.equal(emoji.get_emoji_name('bogus'), undefined);
|
||||
run_test("get_emoji_* API", () => {
|
||||
assert.equal(emoji.get_emoji_name("1f384"), "holiday_tree");
|
||||
assert.equal(emoji.get_emoji_name("1f951"), "avocado");
|
||||
assert.equal(emoji.get_emoji_name("bogus"), undefined);
|
||||
|
||||
assert.equal(emoji.get_emoji_codepoint('avocado'), '1f951');
|
||||
assert.equal(emoji.get_emoji_codepoint('holiday_tree'), '1f384');
|
||||
assert.equal(emoji.get_emoji_codepoint('bogus'), undefined);
|
||||
assert.equal(emoji.get_emoji_codepoint("avocado"), "1f951");
|
||||
assert.equal(emoji.get_emoji_codepoint("holiday_tree"), "1f384");
|
||||
assert.equal(emoji.get_emoji_codepoint("bogus"), undefined);
|
||||
|
||||
assert.equal(emoji.get_realm_emoji_url('spain'), undefined);
|
||||
assert.equal(emoji.get_realm_emoji_url("spain"), undefined);
|
||||
set_up_spain_realm_emoji_for_test();
|
||||
assert.equal(emoji.get_realm_emoji_url('spain'), '/some/path/to/spain.png');
|
||||
assert.equal(emoji.get_realm_emoji_url("spain"), "/some/path/to/spain.png");
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
zrequire('emoji');
|
||||
zrequire('emoji_picker');
|
||||
zrequire("emoji");
|
||||
zrequire("emoji_picker");
|
||||
|
||||
run_test('initialize', () => {
|
||||
run_test("initialize", () => {
|
||||
emoji.update_emojis({});
|
||||
emoji_picker.initialize();
|
||||
|
||||
const complete_emoji_catalog = _.sortBy(emoji_picker.complete_emoji_catalog, 'name');
|
||||
const complete_emoji_catalog = _.sortBy(emoji_picker.complete_emoji_catalog, "name");
|
||||
assert.equal(complete_emoji_catalog.length, 11);
|
||||
assert.equal(emoji.emojis_by_name.size, 1037);
|
||||
|
||||
@@ -19,7 +19,7 @@ run_test('initialize', () => {
|
||||
assert.equal(this_emoji.is_realm_emoji, val);
|
||||
}
|
||||
}
|
||||
if (ele.name === 'Custom') {
|
||||
if (ele.name === "Custom") {
|
||||
check_emojis(true);
|
||||
} else {
|
||||
check_emojis(false);
|
||||
@@ -28,17 +28,17 @@ run_test('initialize', () => {
|
||||
}
|
||||
const popular_emoji_count = 6;
|
||||
const zulip_emoji_count = 1;
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-car', 170);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-hashtag', 180);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-smile-o', 129);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-star-o', popular_emoji_count);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-thumbs-o-up', 102);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-lightbulb-o', 191);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-cutlery', 92);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-flag', 5);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-cog', 1);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-leaf', 104);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), 'fa-soccer-ball-o', 63);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-car", 170);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-hashtag", 180);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-smile-o", 129);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-star-o", popular_emoji_count);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-thumbs-o-up", 102);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-lightbulb-o", 191);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-cutlery", 92);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-flag", 5);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-cog", 1);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-leaf", 104);
|
||||
assert_emoji_category(complete_emoji_catalog.pop(), "fa-soccer-ball-o", 63);
|
||||
|
||||
// The popular emoji appear twice in the picker, and the zulip emoji is special
|
||||
assert.equal(emoji.emojis_by_name.size,
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
zrequire('fenced_code');
|
||||
zrequire("fenced_code");
|
||||
|
||||
run_test('get_unused_fence', () => {
|
||||
assert.equal(fenced_code.get_unused_fence('```js\nsomething\n```'), '`'.repeat(4));
|
||||
assert.equal(fenced_code.get_unused_fence('````\nsomething\n````'), '`'.repeat(5));
|
||||
assert.equal(fenced_code.get_unused_fence('```\n````\n``````'), '`'.repeat(7));
|
||||
assert.equal(fenced_code.get_unused_fence('~~~\nsomething\n~~~'), '`'.repeat(3));
|
||||
assert.equal(fenced_code.get_unused_fence('```code\nterminating fence is indented and longer\n ````'), '`'.repeat(5));
|
||||
assert.equal(fenced_code.get_unused_fence('```code\nterminating fence is extra indented\n ````'), '`'.repeat(4));
|
||||
let large_testcase = '';
|
||||
run_test("get_unused_fence", () => {
|
||||
assert.equal(fenced_code.get_unused_fence("```js\nsomething\n```"), "`".repeat(4));
|
||||
assert.equal(fenced_code.get_unused_fence("````\nsomething\n````"), "`".repeat(5));
|
||||
assert.equal(fenced_code.get_unused_fence("```\n````\n``````"), "`".repeat(7));
|
||||
assert.equal(fenced_code.get_unused_fence("~~~\nsomething\n~~~"), "`".repeat(3));
|
||||
assert.equal(fenced_code.get_unused_fence("```code\nterminating fence is indented and longer\n ````"), "`".repeat(5));
|
||||
assert.equal(fenced_code.get_unused_fence("```code\nterminating fence is extra indented\n ````"), "`".repeat(4));
|
||||
let large_testcase = "";
|
||||
// ```
|
||||
// ````
|
||||
// `````
|
||||
// ... up to N chars
|
||||
// We insert a N + 1 character fence.
|
||||
for (let i = 3; i <= 20; i += 1) {
|
||||
large_testcase += '`'.repeat(i) + '\n';
|
||||
large_testcase += "`".repeat(i) + "\n";
|
||||
}
|
||||
assert.equal(fenced_code.get_unused_fence(large_testcase), '`'.repeat(21));
|
||||
assert.equal(fenced_code.get_unused_fence(large_testcase), "`".repeat(21));
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const FetchStatus = zrequire('fetch_status');
|
||||
set_global('message_scroll', {
|
||||
const FetchStatus = zrequire("fetch_status");
|
||||
set_global("message_scroll", {
|
||||
hide_loading_older: () => {},
|
||||
show_loading_older: () => {},
|
||||
hide_loading_newer: () => {},
|
||||
@@ -52,7 +52,7 @@ function blocked_history() {
|
||||
assert.equal(fetch_status.history_limited(), true);
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
reset();
|
||||
|
||||
fetch_status.start_newer_batch({ update_loading_indicator: false });
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,79 +1,79 @@
|
||||
const FoldDict = zrequire('fold_dict').FoldDict;
|
||||
const FoldDict = zrequire("fold_dict").FoldDict;
|
||||
|
||||
run_test('basic', () => {
|
||||
run_test("basic", () => {
|
||||
const d = new FoldDict();
|
||||
|
||||
assert.equal(d.size, 0);
|
||||
|
||||
assert.deepEqual(Array.from(d.keys()), []);
|
||||
|
||||
d.set('foo', 'bar');
|
||||
assert.equal(d.get('foo'), 'bar');
|
||||
d.set("foo", "bar");
|
||||
assert.equal(d.get("foo"), "bar");
|
||||
assert.notEqual(d.size, 0);
|
||||
|
||||
d.set('foo', 'baz');
|
||||
assert.equal(d.get('foo'), 'baz');
|
||||
d.set("foo", "baz");
|
||||
assert.equal(d.get("foo"), "baz");
|
||||
assert.equal(d.size, 1);
|
||||
|
||||
d.set('bar', 'qux');
|
||||
assert.equal(d.get('foo'), 'baz');
|
||||
assert.equal(d.get('bar'), 'qux');
|
||||
d.set("bar", "qux");
|
||||
assert.equal(d.get("foo"), "baz");
|
||||
assert.equal(d.get("bar"), "qux");
|
||||
assert.equal(d.size, 2);
|
||||
|
||||
assert.equal(d.has('bar'), true);
|
||||
assert.equal(d.has('baz'), false);
|
||||
assert.equal(d.has("bar"), true);
|
||||
assert.equal(d.has("baz"), false);
|
||||
|
||||
assert.deepEqual(Array.from(d.keys()), ['foo', 'bar']);
|
||||
assert.deepEqual(Array.from(d.values()), ['baz', 'qux']);
|
||||
assert.deepEqual(Array.from(d), [['foo', 'baz'], ['bar', 'qux']]);
|
||||
assert.deepEqual(Array.from(d.keys()), ["foo", "bar"]);
|
||||
assert.deepEqual(Array.from(d.values()), ["baz", "qux"]);
|
||||
assert.deepEqual(Array.from(d), [["foo", "baz"], ["bar", "qux"]]);
|
||||
|
||||
d.delete('bar');
|
||||
assert.equal(d.has('bar'), false);
|
||||
assert.strictEqual(d.get('bar'), undefined);
|
||||
d.delete("bar");
|
||||
assert.equal(d.has("bar"), false);
|
||||
assert.strictEqual(d.get("bar"), undefined);
|
||||
|
||||
assert.deepEqual(Array.from(d.keys()), ['foo']);
|
||||
assert.deepEqual(Array.from(d.keys()), ["foo"]);
|
||||
|
||||
const val = ['foo'];
|
||||
const res = d.set('abc', val);
|
||||
const val = ["foo"];
|
||||
const res = d.set("abc", val);
|
||||
assert.strictEqual(res, d);
|
||||
});
|
||||
|
||||
run_test('case insensitivity', () => {
|
||||
run_test("case insensitivity", () => {
|
||||
const d = new FoldDict();
|
||||
|
||||
assert.deepEqual(Array.from(d.keys()), []);
|
||||
|
||||
assert(!d.has('foo'));
|
||||
d.set('fOO', 'Hello World');
|
||||
assert.equal(d.get('foo'), 'Hello World');
|
||||
assert(d.has('foo'));
|
||||
assert(d.has('FOO'));
|
||||
assert(!d.has('not_a_key'));
|
||||
assert(!d.has("foo"));
|
||||
d.set("fOO", "Hello World");
|
||||
assert.equal(d.get("foo"), "Hello World");
|
||||
assert(d.has("foo"));
|
||||
assert(d.has("FOO"));
|
||||
assert(!d.has("not_a_key"));
|
||||
|
||||
assert.deepEqual(Array.from(d.keys()), ['fOO']);
|
||||
assert.deepEqual(Array.from(d.keys()), ["fOO"]);
|
||||
|
||||
d.delete('Foo');
|
||||
assert.equal(d.has('foo'), false);
|
||||
d.delete("Foo");
|
||||
assert.equal(d.has("foo"), false);
|
||||
|
||||
assert.deepEqual(Array.from(d.keys()), []);
|
||||
});
|
||||
|
||||
run_test('clear', () => {
|
||||
run_test("clear", () => {
|
||||
const d = new FoldDict();
|
||||
|
||||
function populate() {
|
||||
d.set('fOO', 1);
|
||||
assert.equal(d.get('foo'), 1);
|
||||
d.set('bAR', 2);
|
||||
assert.equal(d.get('bar'), 2);
|
||||
d.set("fOO", 1);
|
||||
assert.equal(d.get("foo"), 1);
|
||||
d.set("bAR", 2);
|
||||
assert.equal(d.get("bar"), 2);
|
||||
}
|
||||
|
||||
populate();
|
||||
assert.equal(d.size, 2);
|
||||
|
||||
d.clear();
|
||||
assert.equal(d.get('fOO'), undefined);
|
||||
assert.equal(d.get('bAR'), undefined);
|
||||
assert.equal(d.get("fOO"), undefined);
|
||||
assert.equal(d.get("bAR"), undefined);
|
||||
assert.equal(d.size, 0);
|
||||
|
||||
// make sure it still works after clearing
|
||||
@@ -81,8 +81,8 @@ run_test('clear', () => {
|
||||
assert.equal(d.size, 2);
|
||||
});
|
||||
|
||||
run_test('undefined_keys', () => {
|
||||
blueslip.expect('error', 'Tried to call a FoldDict method with an undefined key.', 2);
|
||||
run_test("undefined_keys", () => {
|
||||
blueslip.expect("error", "Tried to call a FoldDict method with an undefined key.", 2);
|
||||
|
||||
const d = new FoldDict();
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
// The most basic unit tests load up code, call functions,
|
||||
// and assert truths:
|
||||
|
||||
const util = zrequire('util');
|
||||
assert(!util.find_wildcard_mentions('boring text'));
|
||||
assert(util.find_wildcard_mentions('mention @**everyone**'));
|
||||
const util = zrequire("util");
|
||||
assert(!util.find_wildcard_mentions("boring text"));
|
||||
assert(util.find_wildcard_mentions("mention @**everyone**"));
|
||||
|
||||
// Let's test with people.js next. We'll show this technique:
|
||||
// * get a false value
|
||||
// * change the data
|
||||
// * get a true value
|
||||
|
||||
zrequire('people');
|
||||
zrequire("people");
|
||||
const isaac = {
|
||||
email: 'isaac@example.com',
|
||||
email: "isaac@example.com",
|
||||
user_id: 30,
|
||||
full_name: 'Isaac Newton',
|
||||
full_name: "Isaac Newton",
|
||||
};
|
||||
|
||||
assert(!people.is_known_user_id(isaac.user_id));
|
||||
@@ -33,9 +33,9 @@ assert(people.is_known_user_id(isaac.user_id));
|
||||
// require.
|
||||
|
||||
const me = {
|
||||
email: 'me@example.com',
|
||||
email: "me@example.com",
|
||||
user_id: 31,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
people.add_active_user(me);
|
||||
people.initialize_current_user(me.user_id);
|
||||
@@ -45,8 +45,8 @@ people.initialize_current_user(me.user_id);
|
||||
// tests):
|
||||
|
||||
const denmark_stream = {
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
color: "blue",
|
||||
name: "Denmark",
|
||||
stream_id: 101,
|
||||
subscribed: false,
|
||||
};
|
||||
@@ -55,15 +55,15 @@ const denmark_stream = {
|
||||
// structure that the server sends down to us when the app starts. We
|
||||
// prefer to test with a clean slate.
|
||||
|
||||
set_global('page_params', {});
|
||||
set_global("page_params", {});
|
||||
|
||||
zrequire('stream_data');
|
||||
zrequire("stream_data");
|
||||
|
||||
run_test('stream_data', () => {
|
||||
assert.equal(stream_data.get_sub_by_name('Denmark'), undefined);
|
||||
run_test("stream_data", () => {
|
||||
assert.equal(stream_data.get_sub_by_name("Denmark"), undefined);
|
||||
stream_data.add_sub(denmark_stream);
|
||||
const sub = stream_data.get_sub_by_name('Denmark');
|
||||
assert.equal(sub.color, 'blue');
|
||||
const sub = stream_data.get_sub_by_name("Denmark");
|
||||
assert.equal(sub.color, "blue");
|
||||
});
|
||||
|
||||
// Hopefully the basic patterns for testing data-oriented modules
|
||||
@@ -77,9 +77,9 @@ const messages = {
|
||||
id: 400,
|
||||
sender_id: isaac.user_id,
|
||||
stream_id: denmark_stream.stream_id,
|
||||
type: 'stream',
|
||||
flags: ['has_alert_word'],
|
||||
topic: 'copenhagen',
|
||||
type: "stream",
|
||||
flags: ["has_alert_word"],
|
||||
topic: "copenhagen",
|
||||
// note we don't have every field that a "real" message
|
||||
// would have, and that can be fine
|
||||
},
|
||||
@@ -91,21 +91,21 @@ const messages = {
|
||||
|
||||
const noop = () => undefined;
|
||||
|
||||
set_global('alert_words', {});
|
||||
set_global("alert_words", {});
|
||||
|
||||
alert_words.process_message = noop;
|
||||
|
||||
// We can also bring in real code:
|
||||
zrequire('recent_senders');
|
||||
zrequire('unread');
|
||||
zrequire('stream_topic_history');
|
||||
zrequire('recent_topics');
|
||||
zrequire('overlays');
|
||||
zrequire("recent_senders");
|
||||
zrequire("unread");
|
||||
zrequire("stream_topic_history");
|
||||
zrequire("recent_topics");
|
||||
zrequire("overlays");
|
||||
|
||||
// And finally require the module that we will test directly:
|
||||
zrequire('message_store');
|
||||
zrequire("message_store");
|
||||
|
||||
run_test('message_store', () => {
|
||||
run_test("message_store", () => {
|
||||
const in_message = { ...messages.isaac_to_denmark_stream };
|
||||
|
||||
assert.equal(in_message.alerted, undefined);
|
||||
@@ -121,15 +121,15 @@ run_test('message_store', () => {
|
||||
|
||||
// There are more side effects.
|
||||
const topic_names = stream_topic_history.get_recent_topic_names(denmark_stream.stream_id);
|
||||
assert.deepEqual(topic_names, ['copenhagen']);
|
||||
assert.deepEqual(topic_names, ["copenhagen"]);
|
||||
});
|
||||
|
||||
// Tracking unread messages is a very fundamental part of the Zulip
|
||||
// app, and we use the unread object to track unread messages.
|
||||
|
||||
run_test('unread', () => {
|
||||
run_test("unread", () => {
|
||||
const stream_id = denmark_stream.stream_id;
|
||||
const topic_name = 'copenhagen';
|
||||
const topic_name = "copenhagen";
|
||||
|
||||
assert.equal(unread.num_unread_for_topic(stream_id, topic_name), 0);
|
||||
|
||||
@@ -147,12 +147,12 @@ run_test('unread', () => {
|
||||
|
||||
// We use the second argument of zrequire to find the location of the
|
||||
// Filter class.
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire("Filter", "js/filter");
|
||||
|
||||
run_test('filter', () => {
|
||||
run_test("filter", () => {
|
||||
const filter_terms = [
|
||||
{operator: 'stream', operand: 'Denmark'},
|
||||
{operator: 'topic', operand: 'copenhagen'},
|
||||
{operator: "stream", operand: "Denmark"},
|
||||
{operator: "topic", operand: "copenhagen"},
|
||||
];
|
||||
|
||||
const filter = new Filter(filter_terms);
|
||||
@@ -162,18 +162,18 @@ run_test('filter', () => {
|
||||
// We don't need full-fledged messages to test the gist of
|
||||
// our filter. If there are details that are distracting from
|
||||
// your test, you should not feel guilty about removing them.
|
||||
assert.equal(predicate({type: 'personal'}), false);
|
||||
assert.equal(predicate({type: "personal"}), false);
|
||||
|
||||
assert.equal(predicate({
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: denmark_stream.stream_id,
|
||||
topic: 'does not match filter',
|
||||
topic: "does not match filter",
|
||||
}), false);
|
||||
|
||||
assert.equal(predicate({
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: denmark_stream.stream_id,
|
||||
topic: 'copenhagen',
|
||||
topic: "copenhagen",
|
||||
}), true);
|
||||
});
|
||||
|
||||
@@ -181,9 +181,9 @@ run_test('filter', () => {
|
||||
// "filter" abstraction. If you are in a narrow, we track the
|
||||
// state with the narrow_state module.
|
||||
|
||||
zrequire('narrow_state');
|
||||
zrequire("narrow_state");
|
||||
|
||||
run_test('narrow_state', () => {
|
||||
run_test("narrow_state", () => {
|
||||
// As we often do, first make assertions about the starting
|
||||
// state:
|
||||
|
||||
@@ -191,16 +191,16 @@ run_test('narrow_state', () => {
|
||||
|
||||
// Now set the state.
|
||||
const filter_terms = [
|
||||
{operator: 'stream', operand: 'Denmark'},
|
||||
{operator: 'topic', operand: 'copenhagen'},
|
||||
{operator: "stream", operand: "Denmark"},
|
||||
{operator: "topic", operand: "copenhagen"},
|
||||
];
|
||||
|
||||
const filter = new Filter(filter_terms);
|
||||
|
||||
narrow_state.set_current_filter(filter);
|
||||
|
||||
assert.equal(narrow_state.stream(), 'Denmark');
|
||||
assert.equal(narrow_state.topic(), 'copenhagen');
|
||||
assert.equal(narrow_state.stream(), "Denmark");
|
||||
assert.equal(narrow_state.topic(), "copenhagen");
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -279,19 +279,19 @@ run_test('narrow_state', () => {
|
||||
|
||||
*/
|
||||
|
||||
zrequire('server_events_dispatch');
|
||||
zrequire("server_events_dispatch");
|
||||
|
||||
// We will use Bob in several tests.
|
||||
const bob = {
|
||||
email: 'bob@example.com',
|
||||
email: "bob@example.com",
|
||||
user_id: 33,
|
||||
full_name: 'Bob Roberts',
|
||||
full_name: "Bob Roberts",
|
||||
};
|
||||
|
||||
run_test('add_user_event', () => {
|
||||
run_test("add_user_event", () => {
|
||||
const event = {
|
||||
type: 'realm_user',
|
||||
op: 'add',
|
||||
type: "realm_user",
|
||||
op: "add",
|
||||
person: bob,
|
||||
};
|
||||
|
||||
@@ -314,23 +314,23 @@ run_test('add_user_event', () => {
|
||||
|
||||
*/
|
||||
|
||||
set_global('activity', {});
|
||||
set_global('message_live_update', {});
|
||||
set_global('pm_list', {});
|
||||
set_global('settings_users', {});
|
||||
set_global("activity", {});
|
||||
set_global("message_live_update", {});
|
||||
set_global("pm_list", {});
|
||||
set_global("settings_users", {});
|
||||
|
||||
zrequire('user_events');
|
||||
zrequire("user_events");
|
||||
|
||||
run_test('update_user_event', () => {
|
||||
run_test("update_user_event", () => {
|
||||
const new_bob = {
|
||||
email: 'bob@example.com',
|
||||
email: "bob@example.com",
|
||||
user_id: bob.user_id,
|
||||
full_name: 'The Artist Formerly Known as Bob',
|
||||
full_name: "The Artist Formerly Known as Bob",
|
||||
};
|
||||
|
||||
const event = {
|
||||
type: 'realm_user',
|
||||
op: 'update',
|
||||
type: "realm_user",
|
||||
op: "update",
|
||||
person: new_bob,
|
||||
};
|
||||
|
||||
@@ -348,7 +348,7 @@ run_test('update_user_event', () => {
|
||||
const user = people.get_by_user_id(bob.user_id);
|
||||
|
||||
// Verify that the code actually did its main job:
|
||||
assert.equal(user.full_name, 'The Artist Formerly Known as Bob');
|
||||
assert.equal(user.full_name, "The Artist Formerly Known as Bob");
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -370,7 +370,7 @@ function test_helper() {
|
||||
|
||||
return {
|
||||
redirect: (module_name, func_name) => {
|
||||
const full_name = module_name + '.' + func_name;
|
||||
const full_name = module_name + "." + func_name;
|
||||
global[module_name][func_name] = () => {
|
||||
events.push(full_name);
|
||||
};
|
||||
@@ -395,35 +395,35 @@ function test_helper() {
|
||||
|
||||
*/
|
||||
|
||||
set_global('home_msg_list', {});
|
||||
set_global('message_list', {});
|
||||
set_global('message_util', {});
|
||||
set_global('notifications', {});
|
||||
set_global('resize', {});
|
||||
set_global('stream_list', {});
|
||||
set_global('unread_ops', {});
|
||||
set_global('unread_ui', {});
|
||||
set_global("home_msg_list", {});
|
||||
set_global("message_list", {});
|
||||
set_global("message_util", {});
|
||||
set_global("notifications", {});
|
||||
set_global("resize", {});
|
||||
set_global("stream_list", {});
|
||||
set_global("unread_ops", {});
|
||||
set_global("unread_ui", {});
|
||||
|
||||
zrequire('message_events');
|
||||
zrequire("message_events");
|
||||
|
||||
run_test('insert_message', () => {
|
||||
run_test("insert_message", () => {
|
||||
const helper = test_helper();
|
||||
|
||||
const new_message = {
|
||||
sender_id: isaac.user_id,
|
||||
id: 1001,
|
||||
content: 'example content',
|
||||
content: "example content",
|
||||
};
|
||||
|
||||
assert.equal(message_store.get(new_message.id), undefined);
|
||||
|
||||
helper.redirect('huddle_data', 'process_loaded_messages');
|
||||
helper.redirect('message_util', 'add_new_messages');
|
||||
helper.redirect('notifications', 'received_messages');
|
||||
helper.redirect('resize', 'resize_page_components');
|
||||
helper.redirect('stream_list', 'update_streams_sidebar');
|
||||
helper.redirect('unread_ops', 'process_visible');
|
||||
helper.redirect('unread_ui', 'update_unread_counts');
|
||||
helper.redirect("huddle_data", "process_loaded_messages");
|
||||
helper.redirect("message_util", "add_new_messages");
|
||||
helper.redirect("notifications", "received_messages");
|
||||
helper.redirect("resize", "resize_page_components");
|
||||
helper.redirect("stream_list", "update_streams_sidebar");
|
||||
helper.redirect("unread_ops", "process_visible");
|
||||
helper.redirect("unread_ui", "update_unread_counts");
|
||||
|
||||
narrow_state.reset_current_filter();
|
||||
|
||||
@@ -434,14 +434,14 @@ run_test('insert_message', () => {
|
||||
// the code invokes various objects when a new message
|
||||
// comes in:
|
||||
assert.deepEqual(helper.events, [
|
||||
'huddle_data.process_loaded_messages',
|
||||
'message_util.add_new_messages',
|
||||
'message_util.add_new_messages',
|
||||
'unread_ui.update_unread_counts',
|
||||
'resize.resize_page_components',
|
||||
'unread_ops.process_visible',
|
||||
'notifications.received_messages',
|
||||
'stream_list.update_streams_sidebar',
|
||||
"huddle_data.process_loaded_messages",
|
||||
"message_util.add_new_messages",
|
||||
"message_util.add_new_messages",
|
||||
"unread_ui.update_unread_counts",
|
||||
"resize.resize_page_components",
|
||||
"unread_ops.process_visible",
|
||||
"notifications.received_messages",
|
||||
"stream_list.update_streams_sidebar",
|
||||
]);
|
||||
|
||||
// Despite all of our stubbing/mocking, the call to
|
||||
@@ -449,7 +449,7 @@ run_test('insert_message', () => {
|
||||
// side effect that we can verify:
|
||||
const inserted_message = message_store.get(new_message.id);
|
||||
assert.equal(inserted_message.id, new_message.id);
|
||||
assert.equal(inserted_message.content, 'example content');
|
||||
assert.equal(inserted_message.content, "example content");
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -486,22 +486,22 @@ run_test('insert_message', () => {
|
||||
|
||||
*/
|
||||
|
||||
set_global('channel', {});
|
||||
set_global('home_msg_list', {});
|
||||
set_global('message_list', {});
|
||||
set_global('message_viewport', {});
|
||||
zrequire('message_flags');
|
||||
set_global("channel", {});
|
||||
set_global("home_msg_list", {});
|
||||
set_global("message_list", {});
|
||||
set_global("message_viewport", {});
|
||||
zrequire("message_flags");
|
||||
|
||||
zrequire('unread_ops');
|
||||
zrequire("unread_ops");
|
||||
|
||||
run_test('unread_ops', () => {
|
||||
run_test("unread_ops", () => {
|
||||
(function set_up() {
|
||||
const test_messages = [
|
||||
{
|
||||
id: 50,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: denmark_stream.stream_id,
|
||||
topic: 'copenhagen',
|
||||
topic: "copenhagen",
|
||||
unread: true,
|
||||
},
|
||||
];
|
||||
@@ -521,7 +521,7 @@ run_test('unread_ops', () => {
|
||||
|
||||
// Set current_message_list containing messages that
|
||||
// can be marked read
|
||||
set_global('current_msg_list', {
|
||||
set_global("current_msg_list", {
|
||||
all_messages: () => test_messages,
|
||||
can_mark_messages_read: () => true,
|
||||
});
|
||||
@@ -552,9 +552,9 @@ run_test('unread_ops', () => {
|
||||
// we post info to the server. We can verify that the correct
|
||||
// url and parameters are specified:
|
||||
assert.deepEqual(channel_post_opts, {
|
||||
url: '/json/messages/flags',
|
||||
url: "/json/messages/flags",
|
||||
idempotent: true,
|
||||
data: { messages: '[50]', op: 'add', flag: 'read' },
|
||||
data: { messages: "[50]", op: "add", flag: "read" },
|
||||
success: channel_post_opts.success,
|
||||
});
|
||||
|
||||
@@ -573,24 +573,24 @@ run_test('unread_ops', () => {
|
||||
|
||||
*/
|
||||
|
||||
set_global('topic_list', {});
|
||||
set_global("topic_list", {});
|
||||
|
||||
zrequire('stream_sort');
|
||||
zrequire('stream_list');
|
||||
zrequire("stream_sort");
|
||||
zrequire("stream_list");
|
||||
|
||||
const social_stream = {
|
||||
color: 'red',
|
||||
name: 'Social',
|
||||
color: "red",
|
||||
name: "Social",
|
||||
stream_id: 102,
|
||||
subscribed: true,
|
||||
};
|
||||
|
||||
run_test('set_up_filter', () => {
|
||||
run_test("set_up_filter", () => {
|
||||
stream_data.add_sub(social_stream);
|
||||
|
||||
const filter_terms = [
|
||||
{operator: 'stream', operand: 'Social'},
|
||||
{operator: 'topic', operand: 'lunch'},
|
||||
{operator: "stream", operand: "Social"},
|
||||
{operator: "topic", operand: "lunch"},
|
||||
];
|
||||
|
||||
const filter = new Filter(filter_terms);
|
||||
@@ -614,7 +614,7 @@ function jquery_elem() {
|
||||
|
||||
function make_jquery_helper() {
|
||||
const stream_list_filter = jquery_elem();
|
||||
stream_list_filter.val = () => '';
|
||||
stream_list_filter.val = () => "";
|
||||
|
||||
const stream_filters = jquery_elem();
|
||||
|
||||
@@ -625,24 +625,24 @@ function make_jquery_helper() {
|
||||
|
||||
function fake_jquery(selector) {
|
||||
switch (selector) {
|
||||
case '.stream-list-filter':
|
||||
case ".stream-list-filter":
|
||||
return stream_list_filter;
|
||||
case 'ul#stream_filters li':
|
||||
case "ul#stream_filters li":
|
||||
return jquery_elem();
|
||||
case '#stream_filters':
|
||||
case "#stream_filters":
|
||||
return stream_filters;
|
||||
default:
|
||||
throw Error('unknown selector: ' + selector);
|
||||
throw Error("unknown selector: " + selector);
|
||||
}
|
||||
}
|
||||
|
||||
set_global('$', fake_jquery);
|
||||
set_global("$", fake_jquery);
|
||||
|
||||
return {
|
||||
verify_actions: () => {
|
||||
const expected_data_to_append = [
|
||||
[
|
||||
'stream stub',
|
||||
"stream stub",
|
||||
],
|
||||
];
|
||||
|
||||
@@ -692,7 +692,7 @@ function make_sidebar_helper() {
|
||||
update_whether_active: () => {
|
||||
updated_whether_active = true;
|
||||
},
|
||||
get_li: () => ['stream stub'],
|
||||
get_li: () => ["stream stub"],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -709,9 +709,9 @@ function make_sidebar_helper() {
|
||||
};
|
||||
}
|
||||
|
||||
zrequire('topic_zoom');
|
||||
zrequire("topic_zoom");
|
||||
|
||||
run_test('stream_list', () => {
|
||||
run_test("stream_list", () => {
|
||||
const jquery_helper = make_jquery_helper();
|
||||
const sidebar_helper = make_sidebar_helper();
|
||||
const topic_list_helper = make_topic_list_helper();
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
zrequire('hash_util');
|
||||
zrequire('stream_data');
|
||||
zrequire('people');
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('narrow_state');
|
||||
zrequire("hash_util");
|
||||
zrequire("stream_data");
|
||||
zrequire("people");
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("narrow_state");
|
||||
|
||||
set_global('$', global.make_zjquery({
|
||||
set_global("$", global.make_zjquery({
|
||||
silent: true,
|
||||
}));
|
||||
set_global('ui_report', {
|
||||
set_global("ui_report", {
|
||||
displayed_error: false,
|
||||
error: () => {
|
||||
ui_report.displayed_error = true;
|
||||
},
|
||||
});
|
||||
set_global('location', {
|
||||
set_global("location", {
|
||||
protocol: "https:",
|
||||
host: "example.com",
|
||||
pathname: "/",
|
||||
@@ -21,24 +21,24 @@ set_global('location', {
|
||||
|
||||
const hamlet = {
|
||||
user_id: 15,
|
||||
email: 'hamlet@example.com',
|
||||
full_name: 'Hamlet',
|
||||
email: "hamlet@example.com",
|
||||
full_name: "Hamlet",
|
||||
};
|
||||
|
||||
people.add_active_user(hamlet);
|
||||
|
||||
const frontend = {
|
||||
stream_id: 99,
|
||||
name: 'frontend',
|
||||
name: "frontend",
|
||||
};
|
||||
|
||||
stream_data.add_sub(frontend);
|
||||
|
||||
run_test('hash_util', () => {
|
||||
run_test("hash_util", () => {
|
||||
// Test encodeHashComponent
|
||||
const str = 'https://www.zulipexample.com';
|
||||
const str = "https://www.zulipexample.com";
|
||||
const result1 = hash_util.encodeHashComponent(str);
|
||||
assert.equal(result1, 'https.3A.2F.2Fwww.2Ezulipexample.2Ecom');
|
||||
assert.equal(result1, "https.3A.2F.2Fwww.2Ezulipexample.2Ecom");
|
||||
|
||||
// Test decodeHashComponent
|
||||
const result2 = hash_util.decodeHashComponent(result1);
|
||||
@@ -54,20 +54,20 @@ run_test('hash_util', () => {
|
||||
assert.equal(decode_result, operand);
|
||||
}
|
||||
|
||||
let operator = 'sender';
|
||||
let operator = "sender";
|
||||
let operand = hamlet.email;
|
||||
|
||||
encode_decode_operand(operator, operand, '15-hamlet');
|
||||
encode_decode_operand(operator, operand, "15-hamlet");
|
||||
|
||||
operator = 'stream';
|
||||
operand = 'frontend';
|
||||
operator = "stream";
|
||||
operand = "frontend";
|
||||
|
||||
encode_decode_operand(operator, operand, '99-frontend');
|
||||
encode_decode_operand(operator, operand, "99-frontend");
|
||||
|
||||
operator = 'topic';
|
||||
operand = 'testing 123';
|
||||
operator = "topic";
|
||||
operand = "testing 123";
|
||||
|
||||
encode_decode_operand(operator, operand, 'testing.20123');
|
||||
encode_decode_operand(operator, operand, "testing.20123");
|
||||
|
||||
// Test invalid url decode.
|
||||
const result = hash_util.decodeHashComponent("foo.foo");
|
||||
@@ -75,96 +75,96 @@ run_test('hash_util', () => {
|
||||
assert.equal(ui_report.displayed_error, true);
|
||||
});
|
||||
|
||||
run_test('test_get_hash_category', () => {
|
||||
run_test("test_get_hash_category", () => {
|
||||
assert.deepEqual(
|
||||
hash_util.get_hash_category('streams/subscribed'),
|
||||
'streams',
|
||||
hash_util.get_hash_category("streams/subscribed"),
|
||||
"streams",
|
||||
);
|
||||
assert.deepEqual(
|
||||
hash_util.get_hash_category('#settings/display-settings'),
|
||||
'settings',
|
||||
hash_util.get_hash_category("#settings/display-settings"),
|
||||
"settings",
|
||||
);
|
||||
assert.deepEqual(
|
||||
hash_util.get_hash_category('#drafts'),
|
||||
'drafts',
|
||||
hash_util.get_hash_category("#drafts"),
|
||||
"drafts",
|
||||
);
|
||||
assert.deepEqual(
|
||||
hash_util.get_hash_category('invites'),
|
||||
'invites',
|
||||
hash_util.get_hash_category("invites"),
|
||||
"invites",
|
||||
);
|
||||
});
|
||||
|
||||
run_test('test_get_hash_section', () => {
|
||||
run_test("test_get_hash_section", () => {
|
||||
assert.equal(
|
||||
hash_util.get_hash_section('streams/subscribed'),
|
||||
'subscribed',
|
||||
hash_util.get_hash_section("streams/subscribed"),
|
||||
"subscribed",
|
||||
);
|
||||
assert.equal(
|
||||
hash_util.get_hash_section('#settings/your-account'),
|
||||
'your-account',
|
||||
hash_util.get_hash_section("#settings/your-account"),
|
||||
"your-account",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
hash_util.get_hash_section('settings/10/general/'),
|
||||
'10',
|
||||
hash_util.get_hash_section("settings/10/general/"),
|
||||
"10",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
hash_util.get_hash_section('#drafts'),
|
||||
'',
|
||||
hash_util.get_hash_section("#drafts"),
|
||||
"",
|
||||
);
|
||||
assert.equal(
|
||||
hash_util.get_hash_section(''),
|
||||
'',
|
||||
hash_util.get_hash_section(""),
|
||||
"",
|
||||
);
|
||||
});
|
||||
|
||||
run_test('test_parse_narrow', () => {
|
||||
run_test("test_parse_narrow", () => {
|
||||
assert.deepEqual(
|
||||
hash_util.parse_narrow(['narrow', 'stream', '99-frontend']),
|
||||
[{negated: false, operator: 'stream', operand: 'frontend'}],
|
||||
hash_util.parse_narrow(["narrow", "stream", "99-frontend"]),
|
||||
[{negated: false, operator: "stream", operand: "frontend"}],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
hash_util.parse_narrow(['narrow', '-stream', '99-frontend']),
|
||||
[{negated: true, operator: 'stream', operand: 'frontend'}],
|
||||
hash_util.parse_narrow(["narrow", "-stream", "99-frontend"]),
|
||||
[{negated: true, operator: "stream", operand: "frontend"}],
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
hash_util.parse_narrow(['narrow', 'BOGUS']),
|
||||
hash_util.parse_narrow(["narrow", "BOGUS"]),
|
||||
undefined,
|
||||
);
|
||||
|
||||
// For nonexistent streams, we get the full slug.
|
||||
// We possibly should remove the prefix and fix this test.
|
||||
assert.deepEqual(
|
||||
hash_util.parse_narrow(['narrow', 'stream', '42-bogus']),
|
||||
[{negated: false, operator: 'stream', operand: '42-bogus'}],
|
||||
hash_util.parse_narrow(["narrow", "stream", "42-bogus"]),
|
||||
[{negated: false, operator: "stream", operand: "42-bogus"}],
|
||||
);
|
||||
});
|
||||
|
||||
run_test('test_stream_edit_uri', () => {
|
||||
run_test("test_stream_edit_uri", () => {
|
||||
const sub = {
|
||||
name: 'research & development',
|
||||
name: "research & development",
|
||||
stream_id: 42,
|
||||
};
|
||||
assert.equal(hash_util.stream_edit_uri(sub),
|
||||
'#streams/42/research.20.26.20development');
|
||||
"#streams/42/research.20.26.20development");
|
||||
});
|
||||
|
||||
run_test('test_by_conversation_and_time_uri', () => {
|
||||
run_test("test_by_conversation_and_time_uri", () => {
|
||||
let message = {
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: frontend.stream_id,
|
||||
topic: 'testing',
|
||||
topic: "testing",
|
||||
id: 42,
|
||||
};
|
||||
|
||||
assert.equal(hash_util.by_conversation_and_time_uri(message),
|
||||
'https://example.com/#narrow/stream/99-frontend/topic/testing/near/42');
|
||||
"https://example.com/#narrow/stream/99-frontend/topic/testing/near/42");
|
||||
|
||||
message = {
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [
|
||||
{
|
||||
id: hamlet.user_id,
|
||||
@@ -174,12 +174,12 @@ run_test('test_by_conversation_and_time_uri', () => {
|
||||
};
|
||||
|
||||
assert.equal(hash_util.by_conversation_and_time_uri(message),
|
||||
'https://example.com/#narrow/pm-with/15-pm/near/43');
|
||||
"https://example.com/#narrow/pm-with/15-pm/near/43");
|
||||
});
|
||||
|
||||
run_test('test_search_public_streams_notice_url', () => {
|
||||
run_test("test_search_public_streams_notice_url", () => {
|
||||
function set_uri(uri) {
|
||||
const operators = hash_util.parse_narrow(uri.split('/'));
|
||||
const operators = hash_util.parse_narrow(uri.split("/"));
|
||||
narrow_state.set_current_filter(new Filter(operators));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,114 +1,114 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
const window_stub = $.create('window-stub');
|
||||
set_global('location', {
|
||||
protocol: 'http:',
|
||||
host: 'example.com',
|
||||
set_global("$", global.make_zjquery());
|
||||
const window_stub = $.create("window-stub");
|
||||
set_global("location", {
|
||||
protocol: "http:",
|
||||
host: "example.com",
|
||||
});
|
||||
set_global('to_$', () => window_stub);
|
||||
set_global("to_$", () => window_stub);
|
||||
|
||||
zrequire('people');
|
||||
zrequire('hash_util');
|
||||
zrequire('hashchange');
|
||||
zrequire('stream_data');
|
||||
zrequire("people");
|
||||
zrequire("hash_util");
|
||||
zrequire("hashchange");
|
||||
zrequire("stream_data");
|
||||
|
||||
set_global('document', 'document-stub');
|
||||
set_global('history', {});
|
||||
set_global("document", "document-stub");
|
||||
set_global("history", {});
|
||||
|
||||
set_global('admin', {});
|
||||
set_global('drafts', {});
|
||||
set_global('favicon', {});
|
||||
set_global('floating_recipient_bar', {});
|
||||
set_global('info_overlay', {});
|
||||
set_global('message_viewport', {});
|
||||
set_global('narrow', {});
|
||||
set_global('overlays', {});
|
||||
set_global('settings', {});
|
||||
set_global('subs', {});
|
||||
set_global('ui_util', {});
|
||||
set_global("admin", {});
|
||||
set_global("drafts", {});
|
||||
set_global("favicon", {});
|
||||
set_global("floating_recipient_bar", {});
|
||||
set_global("info_overlay", {});
|
||||
set_global("message_viewport", {});
|
||||
set_global("narrow", {});
|
||||
set_global("overlays", {});
|
||||
set_global("settings", {});
|
||||
set_global("subs", {});
|
||||
set_global("ui_util", {});
|
||||
|
||||
run_test('operators_round_trip', () => {
|
||||
run_test("operators_round_trip", () => {
|
||||
let operators;
|
||||
let hash;
|
||||
let narrow;
|
||||
|
||||
operators = [
|
||||
{operator: 'stream', operand: 'devel'},
|
||||
{operator: 'topic', operand: 'algol'},
|
||||
{operator: "stream", operand: "devel"},
|
||||
{operator: "topic", operand: "algol"},
|
||||
];
|
||||
hash = hash_util.operators_to_hash(operators);
|
||||
assert.equal(hash, '#narrow/stream/devel/topic/algol');
|
||||
assert.equal(hash, "#narrow/stream/devel/topic/algol");
|
||||
|
||||
narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
narrow = hash_util.parse_narrow(hash.split("/"));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'stream', operand: 'devel', negated: false},
|
||||
{operator: 'topic', operand: 'algol', negated: false},
|
||||
{operator: "stream", operand: "devel", negated: false},
|
||||
{operator: "topic", operand: "algol", negated: false},
|
||||
]);
|
||||
|
||||
operators = [
|
||||
{operator: 'stream', operand: 'devel'},
|
||||
{operator: 'topic', operand: 'visual c++', negated: true},
|
||||
{operator: "stream", operand: "devel"},
|
||||
{operator: "topic", operand: "visual c++", negated: true},
|
||||
];
|
||||
hash = hash_util.operators_to_hash(operators);
|
||||
assert.equal(hash, '#narrow/stream/devel/-topic/visual.20c.2B.2B');
|
||||
assert.equal(hash, "#narrow/stream/devel/-topic/visual.20c.2B.2B");
|
||||
|
||||
narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
narrow = hash_util.parse_narrow(hash.split("/"));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'stream', operand: 'devel', negated: false},
|
||||
{operator: 'topic', operand: 'visual c++', negated: true},
|
||||
{operator: "stream", operand: "devel", negated: false},
|
||||
{operator: "topic", operand: "visual c++", negated: true},
|
||||
]);
|
||||
|
||||
// test new encodings, where we have a stream id
|
||||
const florida_stream = {
|
||||
name: 'Florida, USA',
|
||||
name: "Florida, USA",
|
||||
stream_id: 987,
|
||||
};
|
||||
stream_data.add_sub(florida_stream);
|
||||
operators = [
|
||||
{operator: 'stream', operand: 'Florida, USA'},
|
||||
{operator: "stream", operand: "Florida, USA"},
|
||||
];
|
||||
hash = hash_util.operators_to_hash(operators);
|
||||
assert.equal(hash, '#narrow/stream/987-Florida.2C-USA');
|
||||
narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
assert.equal(hash, "#narrow/stream/987-Florida.2C-USA");
|
||||
narrow = hash_util.parse_narrow(hash.split("/"));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'stream', operand: 'Florida, USA', negated: false},
|
||||
{operator: "stream", operand: "Florida, USA", negated: false},
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('operators_trailing_slash', () => {
|
||||
const hash = '#narrow/stream/devel/topic/algol/';
|
||||
const narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
run_test("operators_trailing_slash", () => {
|
||||
const hash = "#narrow/stream/devel/topic/algol/";
|
||||
const narrow = hash_util.parse_narrow(hash.split("/"));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'stream', operand: 'devel', negated: false},
|
||||
{operator: 'topic', operand: 'algol', negated: false},
|
||||
{operator: "stream", operand: "devel", negated: false},
|
||||
{operator: "topic", operand: "algol", negated: false},
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('people_slugs', () => {
|
||||
run_test("people_slugs", () => {
|
||||
let operators;
|
||||
let hash;
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 42,
|
||||
full_name: 'Alice Smith',
|
||||
full_name: "Alice Smith",
|
||||
};
|
||||
|
||||
people.add_active_user(alice);
|
||||
operators = [
|
||||
{operator: 'sender', operand: 'alice@example.com'},
|
||||
{operator: "sender", operand: "alice@example.com"},
|
||||
];
|
||||
hash = hash_util.operators_to_hash(operators);
|
||||
assert.equal(hash, '#narrow/sender/42-alice');
|
||||
const narrow = hash_util.parse_narrow(hash.split('/'));
|
||||
assert.equal(hash, "#narrow/sender/42-alice");
|
||||
const narrow = hash_util.parse_narrow(hash.split("/"));
|
||||
assert.deepEqual(narrow, [
|
||||
{operator: 'sender', operand: 'alice@example.com', negated: false},
|
||||
{operator: "sender", operand: "alice@example.com", negated: false},
|
||||
]);
|
||||
|
||||
operators = [
|
||||
{operator: 'pm-with', operand: 'alice@example.com'},
|
||||
{operator: "pm-with", operand: "alice@example.com"},
|
||||
];
|
||||
hash = hash_util.operators_to_hash(operators);
|
||||
assert.equal(hash, '#narrow/pm-with/42-alice');
|
||||
assert.equal(hash, "#narrow/pm-with/42-alice");
|
||||
});
|
||||
|
||||
function test_helper() {
|
||||
@@ -117,31 +117,31 @@ function test_helper() {
|
||||
|
||||
function stub(module_name, func_name) {
|
||||
global[module_name][func_name] = () => {
|
||||
events.push(module_name + '.' + func_name);
|
||||
events.push(module_name + "." + func_name);
|
||||
};
|
||||
}
|
||||
|
||||
stub('admin', 'launch');
|
||||
stub('drafts', 'launch');
|
||||
stub('floating_recipient_bar', 'update');
|
||||
stub('message_viewport', 'stop_auto_scrolling');
|
||||
stub('narrow', 'deactivate');
|
||||
stub('overlays', 'close_for_hash_change');
|
||||
stub('settings', 'launch');
|
||||
stub('subs', 'launch');
|
||||
stub('ui_util', 'blur_active_element');
|
||||
stub("admin", "launch");
|
||||
stub("drafts", "launch");
|
||||
stub("floating_recipient_bar", "update");
|
||||
stub("message_viewport", "stop_auto_scrolling");
|
||||
stub("narrow", "deactivate");
|
||||
stub("overlays", "close_for_hash_change");
|
||||
stub("settings", "launch");
|
||||
stub("subs", "launch");
|
||||
stub("ui_util", "blur_active_element");
|
||||
|
||||
ui_util.change_tab_to = (hash) => {
|
||||
events.push('change_tab_to ' + hash);
|
||||
events.push("change_tab_to " + hash);
|
||||
};
|
||||
|
||||
narrow.activate = (terms) => {
|
||||
narrow_terms = terms;
|
||||
events.push('narrow.activate');
|
||||
events.push("narrow.activate");
|
||||
};
|
||||
|
||||
info_overlay.show = (name) => {
|
||||
events.push('info: ' + name);
|
||||
events.push("info: " + name);
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -155,123 +155,123 @@ function test_helper() {
|
||||
};
|
||||
}
|
||||
|
||||
run_test('hash_interactions', () => {
|
||||
run_test("hash_interactions", () => {
|
||||
const helper = test_helper();
|
||||
|
||||
window.location.hash = '#';
|
||||
window.location.hash = "#";
|
||||
|
||||
helper.clear_events();
|
||||
hashchange.initialize();
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'change_tab_to #home',
|
||||
'narrow.deactivate',
|
||||
'floating_recipient_bar.update',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"change_tab_to #home",
|
||||
"narrow.deactivate",
|
||||
"floating_recipient_bar.update",
|
||||
]);
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'change_tab_to #home',
|
||||
'narrow.deactivate',
|
||||
'floating_recipient_bar.update',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"change_tab_to #home",
|
||||
"narrow.deactivate",
|
||||
"floating_recipient_bar.update",
|
||||
]);
|
||||
|
||||
window.location.hash = '#narrow/stream/Denmark';
|
||||
window.location.hash = "#narrow/stream/Denmark";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'change_tab_to #home',
|
||||
'narrow.activate',
|
||||
'floating_recipient_bar.update',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"change_tab_to #home",
|
||||
"narrow.activate",
|
||||
"floating_recipient_bar.update",
|
||||
]);
|
||||
let terms = helper.get_narrow_terms();
|
||||
assert.equal(terms[0].operand, 'Denmark');
|
||||
assert.equal(terms[0].operand, "Denmark");
|
||||
|
||||
window.location.hash = '#narrow';
|
||||
window.location.hash = "#narrow";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'change_tab_to #home',
|
||||
'narrow.activate',
|
||||
'floating_recipient_bar.update',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"change_tab_to #home",
|
||||
"narrow.activate",
|
||||
"floating_recipient_bar.update",
|
||||
]);
|
||||
terms = helper.get_narrow_terms();
|
||||
assert.equal(terms.length, 0);
|
||||
|
||||
window.location.hash = '#streams/whatever';
|
||||
window.location.hash = "#streams/whatever";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'subs.launch',
|
||||
"overlays.close_for_hash_change",
|
||||
"subs.launch",
|
||||
]);
|
||||
|
||||
window.location.hash = '#keyboard-shortcuts/whatever';
|
||||
window.location.hash = "#keyboard-shortcuts/whatever";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'info: keyboard-shortcuts',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"info: keyboard-shortcuts",
|
||||
]);
|
||||
|
||||
window.location.hash = '#message-formatting/whatever';
|
||||
window.location.hash = "#message-formatting/whatever";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'info: message-formatting',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"info: message-formatting",
|
||||
]);
|
||||
|
||||
window.location.hash = '#search-operators/whatever';
|
||||
window.location.hash = "#search-operators/whatever";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
'info: search-operators',
|
||||
"overlays.close_for_hash_change",
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
"info: search-operators",
|
||||
]);
|
||||
|
||||
window.location.hash = '#drafts';
|
||||
window.location.hash = "#drafts";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'drafts.launch',
|
||||
"overlays.close_for_hash_change",
|
||||
"drafts.launch",
|
||||
]);
|
||||
|
||||
window.location.hash = '#settings/alert-words';
|
||||
window.location.hash = "#settings/alert-words";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'settings.launch',
|
||||
"overlays.close_for_hash_change",
|
||||
"settings.launch",
|
||||
]);
|
||||
|
||||
window.location.hash = '#organization/user-list-admin';
|
||||
window.location.hash = "#organization/user-list-admin";
|
||||
|
||||
helper.clear_events();
|
||||
$(window).trigger($.Event('hashchange', {}));
|
||||
$(window).trigger($.Event("hashchange", {}));
|
||||
helper.assert_events([
|
||||
'overlays.close_for_hash_change',
|
||||
'admin.launch',
|
||||
"overlays.close_for_hash_change",
|
||||
"admin.launch",
|
||||
]);
|
||||
|
||||
let called_back;
|
||||
@@ -282,26 +282,26 @@ run_test('hash_interactions', () => {
|
||||
});
|
||||
|
||||
helper.assert_events([
|
||||
'ui_util.blur_active_element',
|
||||
"ui_util.blur_active_element",
|
||||
]);
|
||||
assert(called_back);
|
||||
|
||||
});
|
||||
|
||||
run_test('save_narrow', () => {
|
||||
run_test("save_narrow", () => {
|
||||
const helper = test_helper();
|
||||
|
||||
let operators = [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
];
|
||||
|
||||
blueslip.expect('warn', 'browser does not support pushState');
|
||||
blueslip.expect("warn", "browser does not support pushState");
|
||||
hashchange.save_narrow(operators);
|
||||
|
||||
helper.assert_events([
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
]);
|
||||
assert.equal(window.location.hash, '#narrow/is/private');
|
||||
assert.equal(window.location.hash, "#narrow/is/private");
|
||||
|
||||
let url_pushed;
|
||||
global.history.pushState = (state, title, url) => {
|
||||
@@ -309,13 +309,13 @@ run_test('save_narrow', () => {
|
||||
};
|
||||
|
||||
operators = [
|
||||
{operator: 'is', operand: 'starred'},
|
||||
{operator: "is", operand: "starred"},
|
||||
];
|
||||
|
||||
helper.clear_events();
|
||||
hashchange.save_narrow(operators);
|
||||
helper.assert_events([
|
||||
'message_viewport.stop_auto_scrolling',
|
||||
"message_viewport.stop_auto_scrolling",
|
||||
]);
|
||||
assert.equal(url_pushed, 'http://example.com/#narrow/is/starred');
|
||||
assert.equal(url_pushed, "http://example.com/#narrow/is/starred");
|
||||
});
|
||||
|
||||
@@ -11,35 +11,35 @@
|
||||
// it calls any external module other than `ui.foo`, it'll crash.
|
||||
// Future work includes making sure it actually does call `ui.foo()`.
|
||||
|
||||
set_global('activity', {
|
||||
set_global("activity", {
|
||||
});
|
||||
|
||||
set_global('navigator', {
|
||||
platform: '',
|
||||
set_global("navigator", {
|
||||
platform: "",
|
||||
});
|
||||
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
});
|
||||
|
||||
set_global('overlays', {
|
||||
set_global("overlays", {
|
||||
});
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
// jQuery stuff should go away if we make an initialize() method.
|
||||
set_global('document', 'document-stub');
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("document", "document-stub");
|
||||
set_global("$", global.make_zjquery());
|
||||
$.fn.keydown = noop;
|
||||
$.fn.keypress = noop;
|
||||
|
||||
zrequire('emoji');
|
||||
const hotkey = zrequire('hotkey');
|
||||
zrequire('common');
|
||||
zrequire("emoji");
|
||||
const hotkey = zrequire("hotkey");
|
||||
zrequire("common");
|
||||
|
||||
set_global('list_util', {
|
||||
set_global("list_util", {
|
||||
});
|
||||
|
||||
set_global('current_msg_list', {
|
||||
set_global("current_msg_list", {
|
||||
selected_id: function () {
|
||||
return 42;
|
||||
},
|
||||
@@ -67,7 +67,7 @@ function stubbing(func_name_to_stub, test_function) {
|
||||
});
|
||||
}
|
||||
|
||||
run_test('mappings', () => {
|
||||
run_test("mappings", () => {
|
||||
function map_press(which, shiftKey) {
|
||||
return hotkey.get_keypress_hotkey({
|
||||
which: which,
|
||||
@@ -89,25 +89,25 @@ run_test('mappings', () => {
|
||||
assert.equal(map_press(33), undefined);
|
||||
|
||||
// Test page-up does work.
|
||||
assert.equal(map_down(33).name, 'page_up');
|
||||
assert.equal(map_down(33).name, "page_up");
|
||||
|
||||
// Test other mappings.
|
||||
assert.equal(map_down(9).name, 'tab');
|
||||
assert.equal(map_down(9, true).name, 'shift_tab');
|
||||
assert.equal(map_down(27).name, 'escape');
|
||||
assert.equal(map_down(37).name, 'left_arrow');
|
||||
assert.equal(map_down(13).name, 'enter');
|
||||
assert.equal(map_down(46).name, 'delete');
|
||||
assert.equal(map_down(13, true).name, 'enter');
|
||||
assert.equal(map_down(9).name, "tab");
|
||||
assert.equal(map_down(9, true).name, "shift_tab");
|
||||
assert.equal(map_down(27).name, "escape");
|
||||
assert.equal(map_down(37).name, "left_arrow");
|
||||
assert.equal(map_down(13).name, "enter");
|
||||
assert.equal(map_down(46).name, "delete");
|
||||
assert.equal(map_down(13, true).name, "enter");
|
||||
|
||||
assert.equal(map_press(47).name, 'search'); // slash
|
||||
assert.equal(map_press(106).name, 'vim_down'); // j
|
||||
assert.equal(map_press(47).name, "search"); // slash
|
||||
assert.equal(map_press(106).name, "vim_down"); // j
|
||||
|
||||
assert.equal(map_down(219, false, true).name, 'escape'); // ctrl + [
|
||||
assert.equal(map_down(67, false, true).name, 'copy_with_c'); // ctrl + c
|
||||
assert.equal(map_down(75, false, true).name, 'search_with_k'); // ctrl + k
|
||||
assert.equal(map_down(83, false, true).name, 'star_message'); // ctrl + s
|
||||
assert.equal(map_down(190, false, true).name, 'narrow_to_compose_target'); // ctrl + .
|
||||
assert.equal(map_down(219, false, true).name, "escape"); // ctrl + [
|
||||
assert.equal(map_down(67, false, true).name, "copy_with_c"); // ctrl + c
|
||||
assert.equal(map_down(75, false, true).name, "search_with_k"); // ctrl + k
|
||||
assert.equal(map_down(83, false, true).name, "star_message"); // ctrl + s
|
||||
assert.equal(map_down(190, false, true).name, "narrow_to_compose_target"); // ctrl + .
|
||||
|
||||
// More negative tests.
|
||||
assert.equal(map_down(47), undefined);
|
||||
@@ -134,21 +134,21 @@ run_test('mappings', () => {
|
||||
|
||||
// CMD tests for MacOS
|
||||
global.navigator.platform = "MacIntel";
|
||||
assert.equal(map_down(219, false, true, false).name, 'escape'); // ctrl + [
|
||||
assert.equal(map_down(219, false, true, false).name, "escape"); // ctrl + [
|
||||
assert.equal(map_down(219, false, false, true), undefined); // cmd + [
|
||||
assert.equal(map_down(67, false, true, true).name, 'copy_with_c'); // ctrl + c
|
||||
assert.equal(map_down(67, false, true, true).name, "copy_with_c"); // ctrl + c
|
||||
assert.equal(map_down(67, false, true, false), undefined); // cmd + c
|
||||
assert.equal(map_down(75, false, false, true).name, 'search_with_k'); // cmd + k
|
||||
assert.equal(map_down(75, false, false, true).name, "search_with_k"); // cmd + k
|
||||
assert.equal(map_down(75, false, true, false), undefined); // ctrl + k
|
||||
assert.equal(map_down(83, false, false, true).name, 'star_message'); // cmd + s
|
||||
assert.equal(map_down(83, false, false, true).name, "star_message"); // cmd + s
|
||||
assert.equal(map_down(83, false, true, false), undefined); // ctrl + s
|
||||
assert.equal(map_down(190, false, false, true).name, 'narrow_to_compose_target'); // cmd + .
|
||||
assert.equal(map_down(190, false, false, true).name, "narrow_to_compose_target"); // cmd + .
|
||||
assert.equal(map_down(190, false, true, false), undefined); // ctrl + .
|
||||
// Reset platform
|
||||
global.navigator.platform = '';
|
||||
global.navigator.platform = "";
|
||||
});
|
||||
|
||||
run_test('basic_chars', () => {
|
||||
run_test("basic_chars", () => {
|
||||
function process(s) {
|
||||
const e = {
|
||||
which: s.charCodeAt(0),
|
||||
@@ -178,25 +178,25 @@ run_test('basic_chars', () => {
|
||||
|
||||
// Unmapped keys should immediately return false, without
|
||||
// calling any functions outside of hotkey.js.
|
||||
assert_unmapped('abfhlmoyz');
|
||||
assert_unmapped('BEFHILNOQTUWXYZ');
|
||||
assert_unmapped("abfhlmoyz");
|
||||
assert_unmapped("BEFHILNOQTUWXYZ");
|
||||
|
||||
// We have to skip some checks due to the way the code is
|
||||
// currently organized for mapped keys.
|
||||
hotkey.in_content_editable_widget = return_false;
|
||||
overlays.settings_open = return_false;
|
||||
|
||||
set_global('popovers', {
|
||||
set_global("popovers", {
|
||||
actions_popped: return_false,
|
||||
message_info_popped: return_false,
|
||||
});
|
||||
set_global('emoji_picker', {
|
||||
set_global("emoji_picker", {
|
||||
reactions_popped: return_false,
|
||||
});
|
||||
set_global('hotspots', {
|
||||
set_global("hotspots", {
|
||||
is_open: return_false,
|
||||
});
|
||||
set_global('gear_menu', {
|
||||
set_global("gear_menu", {
|
||||
is_open: return_false,
|
||||
});
|
||||
|
||||
@@ -204,17 +204,17 @@ run_test('basic_chars', () => {
|
||||
hotkey.processing_text = return_true;
|
||||
|
||||
function test_normal_typing() {
|
||||
assert_unmapped('abcdefghijklmnopqrsuvwxyz');
|
||||
assert_unmapped(' ');
|
||||
assert_unmapped('[]\\.,;');
|
||||
assert_unmapped('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
assert_unmapped("abcdefghijklmnopqrsuvwxyz");
|
||||
assert_unmapped(" ");
|
||||
assert_unmapped("[]\\.,;");
|
||||
assert_unmapped("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
assert_unmapped('~!@#$%^*()_+{}:"<>');
|
||||
}
|
||||
|
||||
for (const settings_open of [return_true, return_false]) {
|
||||
for (const is_active of [return_true, return_false]) {
|
||||
for (const info_overlay_open of [return_true, return_false]) {
|
||||
set_global('overlays', {
|
||||
set_global("overlays", {
|
||||
is_active: is_active,
|
||||
settings_open: settings_open,
|
||||
info_overlay_open: info_overlay_open,
|
||||
@@ -235,48 +235,48 @@ run_test('basic_chars', () => {
|
||||
page_params.can_create_streams = true;
|
||||
overlays.streams_open = return_true;
|
||||
overlays.is_active = return_true;
|
||||
assert_mapping('S', 'subs.keyboard_sub');
|
||||
assert_mapping('V', 'subs.view_stream');
|
||||
assert_mapping('n', 'subs.open_create_stream');
|
||||
assert_mapping("S", "subs.keyboard_sub");
|
||||
assert_mapping("V", "subs.view_stream");
|
||||
assert_mapping("n", "subs.open_create_stream");
|
||||
page_params.can_create_streams = false;
|
||||
assert_unmapped('n');
|
||||
assert_unmapped("n");
|
||||
overlays.streams_open = return_false;
|
||||
test_normal_typing();
|
||||
overlays.is_active = return_false;
|
||||
|
||||
assert_mapping('?', 'info_overlay.maybe_show_keyboard_shortcuts');
|
||||
assert_mapping('/', 'search.initiate_search');
|
||||
assert_mapping('w', 'activity.initiate_search');
|
||||
assert_mapping('q', 'stream_list.initiate_search');
|
||||
assert_mapping("?", "info_overlay.maybe_show_keyboard_shortcuts");
|
||||
assert_mapping("/", "search.initiate_search");
|
||||
assert_mapping("w", "activity.initiate_search");
|
||||
assert_mapping("q", "stream_list.initiate_search");
|
||||
|
||||
assert_mapping('A', 'narrow.stream_cycle_backward');
|
||||
assert_mapping('D', 'narrow.stream_cycle_forward');
|
||||
assert_mapping("A", "narrow.stream_cycle_backward");
|
||||
assert_mapping("D", "narrow.stream_cycle_forward");
|
||||
|
||||
assert_mapping('c', 'compose_actions.start');
|
||||
assert_mapping('x', 'compose_actions.start');
|
||||
assert_mapping('P', 'narrow.by');
|
||||
assert_mapping('g', 'gear_menu.open');
|
||||
assert_mapping("c", "compose_actions.start");
|
||||
assert_mapping("x", "compose_actions.start");
|
||||
assert_mapping("P", "narrow.by");
|
||||
assert_mapping("g", "gear_menu.open");
|
||||
|
||||
overlays.is_active = return_true;
|
||||
overlays.drafts_open = return_true;
|
||||
assert_mapping('d', 'overlays.close_overlay');
|
||||
assert_mapping("d", "overlays.close_overlay");
|
||||
overlays.drafts_open = return_false;
|
||||
test_normal_typing();
|
||||
overlays.is_active = return_false;
|
||||
assert_mapping('d', 'drafts.launch');
|
||||
assert_mapping("d", "drafts.launch");
|
||||
|
||||
|
||||
// Test opening and closing of Recent Topics
|
||||
overlays.is_active = return_true;
|
||||
overlays.recent_topics_open = return_true;
|
||||
assert_mapping('t', 'overlays.close_overlay');
|
||||
assert_mapping("t", "overlays.close_overlay");
|
||||
overlays.recent_topics_open = return_false;
|
||||
test_normal_typing();
|
||||
overlays.is_active = return_false;
|
||||
assert_mapping('t', 'hashchange.go_to_location');
|
||||
assert_mapping("t", "hashchange.go_to_location");
|
||||
|
||||
// Next, test keys that only work on a selected message.
|
||||
const message_view_only_keys = '@+>RjJkKsSuvi:GM';
|
||||
const message_view_only_keys = "@+>RjJkKsSuvi:GM";
|
||||
|
||||
// Check that they do nothing without a selected message
|
||||
global.current_msg_list.empty = return_true;
|
||||
@@ -286,54 +286,54 @@ run_test('basic_chars', () => {
|
||||
|
||||
// Check that they do nothing while in the settings overlay
|
||||
overlays.settings_open = return_true;
|
||||
assert_unmapped('@*+->rRjJkKsSuvi:GM');
|
||||
assert_unmapped("@*+->rRjJkKsSuvi:GM");
|
||||
overlays.settings_open = return_false;
|
||||
|
||||
// TODO: Similar check for being in the subs page
|
||||
|
||||
assert_mapping('@', 'compose_actions.reply_with_mention');
|
||||
assert_mapping('+', 'reactions.toggle_emoji_reaction');
|
||||
assert_mapping('-', 'condense.toggle_collapse');
|
||||
assert_mapping('r', 'compose_actions.respond_to_message');
|
||||
assert_mapping('R', 'compose_actions.respond_to_message', true);
|
||||
assert_mapping('j', 'navigate.down');
|
||||
assert_mapping('J', 'navigate.page_down');
|
||||
assert_mapping('k', 'navigate.up');
|
||||
assert_mapping('K', 'navigate.page_up');
|
||||
assert_mapping('s', 'narrow.by_recipient');
|
||||
assert_mapping('S', 'narrow.by_topic');
|
||||
assert_mapping('u', 'popovers.show_sender_info');
|
||||
assert_mapping('i', 'popovers.open_message_menu');
|
||||
assert_mapping(':', 'reactions.open_reactions_popover', true);
|
||||
assert_mapping('>', 'compose_actions.quote_and_reply');
|
||||
assert_mapping('e', 'message_edit.start');
|
||||
assert_mapping("@", "compose_actions.reply_with_mention");
|
||||
assert_mapping("+", "reactions.toggle_emoji_reaction");
|
||||
assert_mapping("-", "condense.toggle_collapse");
|
||||
assert_mapping("r", "compose_actions.respond_to_message");
|
||||
assert_mapping("R", "compose_actions.respond_to_message", true);
|
||||
assert_mapping("j", "navigate.down");
|
||||
assert_mapping("J", "navigate.page_down");
|
||||
assert_mapping("k", "navigate.up");
|
||||
assert_mapping("K", "navigate.page_up");
|
||||
assert_mapping("s", "narrow.by_recipient");
|
||||
assert_mapping("S", "narrow.by_topic");
|
||||
assert_mapping("u", "popovers.show_sender_info");
|
||||
assert_mapping("i", "popovers.open_message_menu");
|
||||
assert_mapping(":", "reactions.open_reactions_popover", true);
|
||||
assert_mapping(">", "compose_actions.quote_and_reply");
|
||||
assert_mapping("e", "message_edit.start");
|
||||
|
||||
overlays.is_active = return_true;
|
||||
overlays.lightbox_open = return_true;
|
||||
assert_mapping('v', 'overlays.close_overlay');
|
||||
assert_mapping("v", "overlays.close_overlay");
|
||||
overlays.lightbox_open = return_false;
|
||||
test_normal_typing();
|
||||
overlays.is_active = return_false;
|
||||
assert_mapping('v', 'lightbox.show_from_selected_message');
|
||||
assert_mapping("v", "lightbox.show_from_selected_message");
|
||||
|
||||
global.emoji_picker.reactions_popped = return_true;
|
||||
assert_mapping(':', 'emoji_picker.navigate', true);
|
||||
assert_mapping(":", "emoji_picker.navigate", true);
|
||||
global.emoji_picker.reactions_popped = return_false;
|
||||
|
||||
assert_mapping('G', 'navigate.to_end');
|
||||
assert_mapping('M', 'muting_ui.toggle_mute');
|
||||
assert_mapping("G", "navigate.to_end");
|
||||
assert_mapping("M", "muting_ui.toggle_mute");
|
||||
|
||||
// Test keys that work when a message is selected and
|
||||
// also when the message list is empty.
|
||||
assert_mapping('n', 'narrow.narrow_to_next_topic');
|
||||
assert_mapping('p', 'narrow.narrow_to_next_pm_string');
|
||||
assert_mapping("n", "narrow.narrow_to_next_topic");
|
||||
assert_mapping("p", "narrow.narrow_to_next_pm_string");
|
||||
|
||||
global.current_msg_list.empty = return_true;
|
||||
assert_mapping('n', 'narrow.narrow_to_next_topic');
|
||||
assert_mapping("n", "narrow.narrow_to_next_topic");
|
||||
global.current_msg_list.empty = return_false;
|
||||
});
|
||||
|
||||
run_test('motion_keys', () => {
|
||||
run_test("motion_keys", () => {
|
||||
const codes = {
|
||||
down_arrow: 40,
|
||||
end: 35,
|
||||
@@ -344,7 +344,7 @@ run_test('motion_keys', () => {
|
||||
page_down: 34,
|
||||
spacebar: 32,
|
||||
up_arrow: 38,
|
||||
'+': 187,
|
||||
"+": 187,
|
||||
};
|
||||
|
||||
function process(name, shiftKey, ctrlKey) {
|
||||
@@ -381,62 +381,62 @@ run_test('motion_keys', () => {
|
||||
overlays.streams_open = return_false;
|
||||
overlays.lightbox_open = return_false;
|
||||
|
||||
assert_unmapped('down_arrow');
|
||||
assert_unmapped('end');
|
||||
assert_unmapped('home');
|
||||
assert_unmapped('page_up');
|
||||
assert_unmapped('page_down');
|
||||
assert_unmapped('spacebar');
|
||||
assert_unmapped('up_arrow');
|
||||
assert_unmapped("down_arrow");
|
||||
assert_unmapped("end");
|
||||
assert_unmapped("home");
|
||||
assert_unmapped("page_up");
|
||||
assert_unmapped("page_down");
|
||||
assert_unmapped("spacebar");
|
||||
assert_unmapped("up_arrow");
|
||||
|
||||
global.list_util.inside_list = return_true;
|
||||
assert_mapping('up_arrow', 'list_util.go_up');
|
||||
assert_mapping('down_arrow', 'list_util.go_down');
|
||||
assert_mapping("up_arrow", "list_util.go_up");
|
||||
assert_mapping("down_arrow", "list_util.go_down");
|
||||
list_util.inside_list = return_false;
|
||||
|
||||
global.current_msg_list.empty = return_false;
|
||||
assert_mapping('down_arrow', 'navigate.down');
|
||||
assert_mapping('end', 'navigate.to_end');
|
||||
assert_mapping('home', 'navigate.to_home');
|
||||
assert_mapping('left_arrow', 'message_edit.edit_last_sent_message');
|
||||
assert_mapping('page_up', 'navigate.page_up');
|
||||
assert_mapping('page_down', 'navigate.page_down');
|
||||
assert_mapping('spacebar', 'navigate.page_down');
|
||||
assert_mapping('up_arrow', 'navigate.up');
|
||||
assert_mapping("down_arrow", "navigate.down");
|
||||
assert_mapping("end", "navigate.to_end");
|
||||
assert_mapping("home", "navigate.to_home");
|
||||
assert_mapping("left_arrow", "message_edit.edit_last_sent_message");
|
||||
assert_mapping("page_up", "navigate.page_up");
|
||||
assert_mapping("page_down", "navigate.page_down");
|
||||
assert_mapping("spacebar", "navigate.page_down");
|
||||
assert_mapping("up_arrow", "navigate.up");
|
||||
|
||||
overlays.info_overlay_open = return_true;
|
||||
assert_unmapped('down_arrow');
|
||||
assert_unmapped('up_arrow');
|
||||
assert_unmapped("down_arrow");
|
||||
assert_unmapped("up_arrow");
|
||||
overlays.info_overlay_open = return_false;
|
||||
|
||||
overlays.streams_open = return_true;
|
||||
assert_mapping('up_arrow', 'subs.switch_rows');
|
||||
assert_mapping('down_arrow', 'subs.switch_rows');
|
||||
assert_mapping("up_arrow", "subs.switch_rows");
|
||||
assert_mapping("down_arrow", "subs.switch_rows");
|
||||
overlays.streams_open = return_false;
|
||||
|
||||
overlays.lightbox_open = return_true;
|
||||
assert_mapping('left_arrow', 'lightbox.prev');
|
||||
assert_mapping('right_arrow', 'lightbox.next');
|
||||
assert_mapping("left_arrow", "lightbox.prev");
|
||||
assert_mapping("right_arrow", "lightbox.next");
|
||||
overlays.lightbox_open = return_false;
|
||||
|
||||
hotkey.in_content_editable_widget = return_true;
|
||||
assert_unmapped('down_arrow');
|
||||
assert_unmapped('up_arrow');
|
||||
assert_unmapped("down_arrow");
|
||||
assert_unmapped("up_arrow");
|
||||
hotkey.in_content_editable_widget = return_false;
|
||||
|
||||
overlays.settings_open = return_true;
|
||||
assert_unmapped('end');
|
||||
assert_unmapped('home');
|
||||
assert_unmapped('left_arrow');
|
||||
assert_unmapped('page_up');
|
||||
assert_unmapped('page_down');
|
||||
assert_unmapped('spacebar');
|
||||
assert_unmapped("end");
|
||||
assert_unmapped("home");
|
||||
assert_unmapped("left_arrow");
|
||||
assert_unmapped("page_up");
|
||||
assert_unmapped("page_down");
|
||||
assert_unmapped("spacebar");
|
||||
overlays.settings_open = return_false;
|
||||
|
||||
overlays.is_active = return_true;
|
||||
overlays.drafts_open = return_true;
|
||||
assert_mapping('up_arrow', 'drafts.drafts_handle_events');
|
||||
assert_mapping('down_arrow', 'drafts.drafts_handle_events');
|
||||
assert_mapping("up_arrow", "drafts.drafts_handle_events");
|
||||
assert_mapping("down_arrow", "drafts.drafts_handle_events");
|
||||
overlays.is_active = return_false;
|
||||
overlays.drafts_open = return_false;
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
set_global('Handlebars', global.make_handlebars());
|
||||
zrequire('templates');
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("templates");
|
||||
|
||||
// We download our translations in `page_params` (which
|
||||
// are for the user's chosen language), so we simulate
|
||||
// that here for the tests.
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
translation_data: {
|
||||
"Quote and reply": "French translation",
|
||||
"Notification triggers": "Some French text",
|
||||
@@ -16,9 +16,9 @@ set_global('page_params', {
|
||||
// We use `i18n.js` to initialize `i18next` and
|
||||
// to set `i18n` to `i18next` on the global namespace
|
||||
// for `templates.js`.
|
||||
zrequire('i18n');
|
||||
zrequire("i18n");
|
||||
|
||||
run_test('t_tag', () => {
|
||||
run_test("t_tag", () => {
|
||||
const args = {
|
||||
message: {
|
||||
is_stream: true,
|
||||
@@ -33,11 +33,11 @@ run_test('t_tag', () => {
|
||||
narrowed: true,
|
||||
};
|
||||
|
||||
const html = require('../../static/templates/actions_popover_content.hbs')(args);
|
||||
const html = require("../../static/templates/actions_popover_content.hbs")(args);
|
||||
assert(html.indexOf("French translation") > 0);
|
||||
});
|
||||
|
||||
run_test('tr_tag', () => {
|
||||
run_test("tr_tag", () => {
|
||||
const args = {
|
||||
page_params: {
|
||||
full_name: "John Doe",
|
||||
@@ -57,6 +57,6 @@ run_test('tr_tag', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const html = require('../../static/templates/settings_tab.hbs')(args);
|
||||
assert(html.indexOf('Some French text') > 0);
|
||||
const html = require("../../static/templates/settings_tab.hbs")(args);
|
||||
assert(html.indexOf("Some French text") > 0);
|
||||
});
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
zrequire('input_pill');
|
||||
set_global("$", global.make_zjquery());
|
||||
zrequire("input_pill");
|
||||
|
||||
set_global('Handlebars', global.make_handlebars());
|
||||
zrequire('templates');
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("templates");
|
||||
|
||||
set_global('document', {});
|
||||
set_global("document", {});
|
||||
|
||||
const noop = function () {};
|
||||
const example_img_link = 'http://example.com/example.png';
|
||||
const example_img_link = "http://example.com/example.png";
|
||||
|
||||
set_global('ui_util', {
|
||||
set_global("ui_util", {
|
||||
place_caret_at_end: noop,
|
||||
});
|
||||
|
||||
set_global('getSelection', () => ({
|
||||
set_global("getSelection", () => ({
|
||||
anchorOffset: 0,
|
||||
}));
|
||||
|
||||
let id_seq = 0;
|
||||
run_test('set_up_ids', () => {
|
||||
run_test("set_up_ids", () => {
|
||||
// just get coverage on a simple one-liner:
|
||||
input_pill.random_id();
|
||||
|
||||
input_pill.random_id = function () {
|
||||
id_seq += 1;
|
||||
return 'some_id' + id_seq;
|
||||
return "some_id" + id_seq;
|
||||
};
|
||||
});
|
||||
|
||||
@@ -41,24 +41,24 @@ function pill_html(value, data_id, img_src) {
|
||||
opts.img_src = img_src;
|
||||
}
|
||||
|
||||
return require('../../static/templates/input_pill.hbs')(opts);
|
||||
return require("../../static/templates/input_pill.hbs")(opts);
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
const config = {};
|
||||
|
||||
blueslip.expect('error', 'Pill needs container.');
|
||||
blueslip.expect("error", "Pill needs container.");
|
||||
input_pill.create(config);
|
||||
|
||||
const pill_input = $.create('pill_input');
|
||||
const container = $.create('container');
|
||||
container.set_find_results('.input', pill_input);
|
||||
const pill_input = $.create("pill_input");
|
||||
const container = $.create("container");
|
||||
container.set_find_results(".input", pill_input);
|
||||
|
||||
blueslip.expect('error', 'Pill needs create_item_from_text');
|
||||
blueslip.expect("error", "Pill needs create_item_from_text");
|
||||
config.container = container;
|
||||
input_pill.create(config);
|
||||
|
||||
blueslip.expect('error', 'Pill needs get_text_from_item');
|
||||
blueslip.expect("error", "Pill needs get_text_from_item");
|
||||
config.create_item_from_text = noop;
|
||||
input_pill.create(config);
|
||||
|
||||
@@ -66,13 +66,13 @@ run_test('basics', () => {
|
||||
const widget = input_pill.create(config);
|
||||
|
||||
const item = {
|
||||
display_value: 'JavaScript',
|
||||
language: 'js',
|
||||
display_value: "JavaScript",
|
||||
language: "js",
|
||||
img_src: example_img_link,
|
||||
};
|
||||
|
||||
let inserted_before;
|
||||
const expected_html = pill_html('JavaScript', 'some_id1', example_img_link);
|
||||
const expected_html = pill_html("JavaScript", "some_id1", example_img_link);
|
||||
|
||||
pill_input.before = function (elem) {
|
||||
inserted_before = true;
|
||||
@@ -86,26 +86,26 @@ run_test('basics', () => {
|
||||
});
|
||||
|
||||
function set_up() {
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
const items = {
|
||||
blue: {
|
||||
display_value: 'BLUE',
|
||||
description: 'color of the sky',
|
||||
display_value: "BLUE",
|
||||
description: "color of the sky",
|
||||
img_src: example_img_link,
|
||||
},
|
||||
|
||||
red: {
|
||||
display_value: 'RED',
|
||||
description: 'color of stop signs',
|
||||
display_value: "RED",
|
||||
description: "color of stop signs",
|
||||
},
|
||||
|
||||
yellow: {
|
||||
display_value: 'YELLOW',
|
||||
description: 'color of bananas',
|
||||
display_value: "YELLOW",
|
||||
description: "color of bananas",
|
||||
},
|
||||
};
|
||||
|
||||
const pill_input = $.create('pill_input');
|
||||
const pill_input = $.create("pill_input");
|
||||
|
||||
pill_input.before = () => {};
|
||||
|
||||
@@ -113,8 +113,8 @@ function set_up() {
|
||||
return items[text];
|
||||
};
|
||||
|
||||
const container = $.create('container');
|
||||
container.set_find_results('.input', pill_input);
|
||||
const container = $.create("container");
|
||||
container.set_find_results(".input", pill_input);
|
||||
|
||||
const config = {
|
||||
container: container,
|
||||
@@ -132,22 +132,22 @@ function set_up() {
|
||||
};
|
||||
}
|
||||
|
||||
run_test('copy from pill', () => {
|
||||
run_test("copy from pill", () => {
|
||||
const info = set_up();
|
||||
const config = info.config;
|
||||
const container = info.container;
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
widget.appendValue('blue,red');
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
const copy_handler = container.get_on_handler('copy', '.pill');
|
||||
const copy_handler = container.get_on_handler("copy", ".pill");
|
||||
|
||||
let copied_text;
|
||||
|
||||
const pill_stub = {
|
||||
data: (field) => {
|
||||
assert.equal(field, 'id');
|
||||
return 'some_id2';
|
||||
assert.equal(field, "id");
|
||||
return "some_id2";
|
||||
},
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ run_test('copy from pill', () => {
|
||||
originalEvent: {
|
||||
clipboardData: {
|
||||
setData: (format, text) => {
|
||||
assert.equal(format, 'text/plain');
|
||||
assert.equal(format, "text/plain");
|
||||
copied_text = text;
|
||||
},
|
||||
},
|
||||
@@ -163,14 +163,14 @@ run_test('copy from pill', () => {
|
||||
preventDefault: noop,
|
||||
};
|
||||
|
||||
container.set_find_results(':focus', pill_stub);
|
||||
container.set_find_results(":focus", pill_stub);
|
||||
|
||||
copy_handler(e);
|
||||
|
||||
assert.equal(copied_text, 'RED');
|
||||
assert.equal(copied_text, "RED");
|
||||
});
|
||||
|
||||
run_test('paste to input', () => {
|
||||
run_test("paste to input", () => {
|
||||
const info = set_up();
|
||||
const config = info.config;
|
||||
const container = info.container;
|
||||
@@ -178,15 +178,15 @@ run_test('paste to input', () => {
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
|
||||
const paste_handler = container.get_on_handler('paste', '.input');
|
||||
const paste_handler = container.get_on_handler("paste", ".input");
|
||||
|
||||
const paste_text = 'blue,yellow';
|
||||
const paste_text = "blue,yellow";
|
||||
|
||||
const e = {
|
||||
originalEvent: {
|
||||
clipboardData: {
|
||||
getData: (format) => {
|
||||
assert.equal(format, 'text/plain');
|
||||
assert.equal(format, "text/plain");
|
||||
return paste_text;
|
||||
},
|
||||
},
|
||||
@@ -195,8 +195,8 @@ run_test('paste to input', () => {
|
||||
};
|
||||
|
||||
document.execCommand = (cmd, _, text) => {
|
||||
assert.equal(cmd, 'insertText');
|
||||
container.find('.input').text(text);
|
||||
assert.equal(cmd, "insertText");
|
||||
container.find(".input").text(text);
|
||||
};
|
||||
|
||||
paste_handler(e);
|
||||
@@ -215,15 +215,15 @@ run_test('paste to input', () => {
|
||||
assert(entered);
|
||||
});
|
||||
|
||||
run_test('arrows on pills', () => {
|
||||
run_test("arrows on pills", () => {
|
||||
const info = set_up();
|
||||
const config = info.config;
|
||||
const container = info.container;
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
widget.appendValue('blue,red');
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
const key_handler = container.get_on_handler('keydown', '.pill');
|
||||
const key_handler = container.get_on_handler("keydown", ".pill");
|
||||
|
||||
function test_key(c) {
|
||||
key_handler({
|
||||
@@ -250,7 +250,7 @@ run_test('arrows on pills', () => {
|
||||
}),
|
||||
};
|
||||
|
||||
container.set_find_results('.pill:focus', pill_stub);
|
||||
container.set_find_results(".pill:focus", pill_stub);
|
||||
|
||||
// We use the same stub to test both arrows, since we don't
|
||||
// actually cause any real state changes here. We stub out
|
||||
@@ -262,20 +262,20 @@ run_test('arrows on pills', () => {
|
||||
assert(next_focused);
|
||||
});
|
||||
|
||||
run_test('left arrow on input', () => {
|
||||
run_test("left arrow on input", () => {
|
||||
const info = set_up();
|
||||
const config = info.config;
|
||||
const container = info.container;
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
widget.appendValue('blue,red');
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
const LEFT_ARROW = 37;
|
||||
const key_handler = container.get_on_handler('keydown', '.input');
|
||||
const key_handler = container.get_on_handler("keydown", ".input");
|
||||
|
||||
let last_pill_focused = false;
|
||||
|
||||
container.set_find_results('.pill', {
|
||||
container.set_find_results(".pill", {
|
||||
last: () => ({
|
||||
focus: () => {
|
||||
last_pill_focused = true;
|
||||
@@ -290,7 +290,7 @@ run_test('left arrow on input', () => {
|
||||
assert(last_pill_focused);
|
||||
});
|
||||
|
||||
run_test('comma', () => {
|
||||
run_test("comma", () => {
|
||||
const info = set_up();
|
||||
const config = info.config;
|
||||
const items = info.items;
|
||||
@@ -298,7 +298,7 @@ run_test('comma', () => {
|
||||
const container = info.container;
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
widget.appendValue('blue,red');
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
assert.deepEqual(widget.items(), [
|
||||
items.blue,
|
||||
@@ -306,9 +306,9 @@ run_test('comma', () => {
|
||||
]);
|
||||
|
||||
const COMMA = 188;
|
||||
const key_handler = container.get_on_handler('keydown', '.input');
|
||||
const key_handler = container.get_on_handler("keydown", ".input");
|
||||
|
||||
pill_input.text = () => ' yel';
|
||||
pill_input.text = () => " yel";
|
||||
|
||||
key_handler({
|
||||
keyCode: COMMA,
|
||||
@@ -320,7 +320,7 @@ run_test('comma', () => {
|
||||
items.red,
|
||||
]);
|
||||
|
||||
pill_input.text = () => ' yellow';
|
||||
pill_input.text = () => " yellow";
|
||||
|
||||
key_handler({
|
||||
keyCode: COMMA,
|
||||
@@ -334,14 +334,14 @@ run_test('comma', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('enter key with text', () => {
|
||||
run_test("enter key with text", () => {
|
||||
const info = set_up();
|
||||
const config = info.config;
|
||||
const items = info.items;
|
||||
const container = info.container;
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
widget.appendValue('blue,red');
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
assert.deepEqual(widget.items(), [
|
||||
items.blue,
|
||||
@@ -349,14 +349,14 @@ run_test('enter key with text', () => {
|
||||
]);
|
||||
|
||||
const ENTER = 13;
|
||||
const key_handler = container.get_on_handler('keydown', '.input');
|
||||
const key_handler = container.get_on_handler("keydown", ".input");
|
||||
|
||||
key_handler({
|
||||
keyCode: ENTER,
|
||||
preventDefault: noop,
|
||||
stopPropagation: noop,
|
||||
target: {
|
||||
innerText: ' yellow ',
|
||||
innerText: " yellow ",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -367,7 +367,7 @@ run_test('enter key with text', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
run_test('insert_remove', () => {
|
||||
run_test("insert_remove", () => {
|
||||
const info = set_up();
|
||||
|
||||
const config = info.config;
|
||||
@@ -393,15 +393,15 @@ run_test('insert_remove', () => {
|
||||
removed = true;
|
||||
});
|
||||
|
||||
widget.appendValue('blue,chartreuse,red,yellow,mauve');
|
||||
widget.appendValue("blue,chartreuse,red,yellow,mauve");
|
||||
|
||||
assert(created);
|
||||
assert(!removed);
|
||||
|
||||
assert.deepEqual(inserted_html, [
|
||||
pill_html('BLUE', 'some_id1', example_img_link),
|
||||
pill_html('RED', 'some_id2'),
|
||||
pill_html('YELLOW', 'some_id3'),
|
||||
pill_html("BLUE", "some_id1", example_img_link),
|
||||
pill_html("RED", "some_id2"),
|
||||
pill_html("YELLOW", "some_id3"),
|
||||
]);
|
||||
|
||||
assert.deepEqual(widget.items(), [
|
||||
@@ -410,20 +410,20 @@ run_test('insert_remove', () => {
|
||||
items.yellow,
|
||||
]);
|
||||
|
||||
assert.equal(pill_input.text(), 'chartreuse, mauve');
|
||||
assert.equal(pill_input.text(), "chartreuse, mauve");
|
||||
|
||||
assert.equal(widget.is_pending(), true);
|
||||
widget.clear_text();
|
||||
assert.equal(pill_input.text(), '');
|
||||
assert.equal(pill_input.text(), "");
|
||||
assert.equal(widget.is_pending(), false);
|
||||
|
||||
const BACKSPACE = 8;
|
||||
let key_handler = container.get_on_handler('keydown', '.input');
|
||||
let key_handler = container.get_on_handler("keydown", ".input");
|
||||
|
||||
key_handler({
|
||||
keyCode: BACKSPACE,
|
||||
target: {
|
||||
innerText: '',
|
||||
innerText: "",
|
||||
},
|
||||
preventDefault: noop,
|
||||
});
|
||||
@@ -446,14 +446,14 @@ run_test('insert_remove', () => {
|
||||
const focus_pill_stub = {
|
||||
next: () => next_pill_stub,
|
||||
data: (field) => {
|
||||
assert.equal(field, 'id');
|
||||
return 'some_id1';
|
||||
assert.equal(field, "id");
|
||||
return "some_id1";
|
||||
},
|
||||
};
|
||||
|
||||
container.set_find_results('.pill:focus', focus_pill_stub);
|
||||
container.set_find_results(".pill:focus", focus_pill_stub);
|
||||
|
||||
key_handler = container.get_on_handler('keydown', '.pill');
|
||||
key_handler = container.get_on_handler("keydown", ".pill");
|
||||
key_handler({
|
||||
keyCode: BACKSPACE,
|
||||
preventDefault: noop,
|
||||
@@ -462,7 +462,7 @@ run_test('insert_remove', () => {
|
||||
assert(next_pill_focused);
|
||||
});
|
||||
|
||||
run_test('exit button on pill', () => {
|
||||
run_test("exit button on pill", () => {
|
||||
const info = set_up();
|
||||
|
||||
const config = info.config;
|
||||
@@ -471,7 +471,7 @@ run_test('exit button on pill', () => {
|
||||
|
||||
const widget = input_pill.create(config);
|
||||
|
||||
widget.appendValue('blue,red');
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
let next_pill_focused = false;
|
||||
|
||||
@@ -484,15 +484,15 @@ run_test('exit button on pill', () => {
|
||||
const curr_pill_stub = {
|
||||
next: () => next_pill_stub,
|
||||
data: (field) => {
|
||||
assert.equal(field, 'id');
|
||||
return 'some_id1';
|
||||
assert.equal(field, "id");
|
||||
return "some_id1";
|
||||
},
|
||||
};
|
||||
|
||||
const exit_button_stub = {
|
||||
to_$: () => ({
|
||||
closest: (sel) => {
|
||||
assert.equal(sel, '.pill');
|
||||
assert.equal(sel, ".pill");
|
||||
return curr_pill_stub;
|
||||
},
|
||||
}),
|
||||
@@ -501,7 +501,7 @@ run_test('exit button on pill', () => {
|
||||
const e = {
|
||||
stopPropagation: noop,
|
||||
};
|
||||
const exit_click_handler = container.get_on_handler('click', '.exit');
|
||||
const exit_click_handler = container.get_on_handler("click", ".exit");
|
||||
|
||||
exit_click_handler.call(exit_button_stub, e);
|
||||
|
||||
@@ -513,7 +513,7 @@ run_test('exit button on pill', () => {
|
||||
|
||||
});
|
||||
|
||||
run_test('misc things', () => {
|
||||
run_test("misc things", () => {
|
||||
const info = set_up();
|
||||
|
||||
const config = info.config;
|
||||
@@ -523,14 +523,14 @@ run_test('misc things', () => {
|
||||
const widget = input_pill.create(config);
|
||||
|
||||
// animation
|
||||
const animation_end_handler = container.get_on_handler('animationend', '.input');
|
||||
const animation_end_handler = container.get_on_handler("animationend", ".input");
|
||||
|
||||
let shake_class_removed = false;
|
||||
|
||||
const input_stub = {
|
||||
to_$: () => ({
|
||||
removeClass: (cls) => {
|
||||
assert.equal(cls, 'shake');
|
||||
assert.equal(cls, "shake");
|
||||
shake_class_removed = true;
|
||||
},
|
||||
}),
|
||||
@@ -540,16 +540,16 @@ run_test('misc things', () => {
|
||||
assert(shake_class_removed);
|
||||
|
||||
// bad data
|
||||
blueslip.expect('error', 'no display_value returned');
|
||||
widget.appendValidatedData('this-has-no-item-attribute');
|
||||
blueslip.expect("error", "no display_value returned");
|
||||
widget.appendValidatedData("this-has-no-item-attribute");
|
||||
|
||||
// click on container
|
||||
const container_click_handler = container.get_on_handler('click');
|
||||
const container_click_handler = container.get_on_handler("click");
|
||||
|
||||
const stub = $.create('the-pill-container');
|
||||
stub.set_find_results('.input', pill_input);
|
||||
const stub = $.create("the-pill-container");
|
||||
stub.set_find_results(".input", pill_input);
|
||||
stub.is = (sel) => {
|
||||
assert.equal(sel, '.pill-container');
|
||||
assert.equal(sel, ".pill-container");
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
zrequire('keydown_util');
|
||||
zrequire("keydown_util");
|
||||
|
||||
run_test('test_early_returns', () => {
|
||||
const stub = $.create('stub');
|
||||
run_test("test_early_returns", () => {
|
||||
const stub = $.create("stub");
|
||||
const opts = {
|
||||
elem: stub,
|
||||
handlers: {
|
||||
left_arrow: () => {
|
||||
throw Error('do not dispatch this with alt key');
|
||||
throw Error("do not dispatch this with alt key");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const LazySet = zrequire('lazy_set').LazySet;
|
||||
const LazySet = zrequire("lazy_set").LazySet;
|
||||
|
||||
/*
|
||||
We mostly test LazySet indirectly. This code
|
||||
@@ -6,7 +6,7 @@ const LazySet = zrequire('lazy_set').LazySet;
|
||||
how we download subscribers in page_params.
|
||||
*/
|
||||
|
||||
run_test('map', () => {
|
||||
run_test("map", () => {
|
||||
const ls = new LazySet([1, 2]);
|
||||
|
||||
const triple = (n) => n * 3;
|
||||
@@ -14,9 +14,9 @@ run_test('map', () => {
|
||||
assert.deepEqual(ls.map(triple), [3, 6]);
|
||||
});
|
||||
|
||||
run_test('conversions', () => {
|
||||
blueslip.expect('error', 'not a number', 2);
|
||||
run_test("conversions", () => {
|
||||
blueslip.expect("error", "not a number", 2);
|
||||
const ls = new LazySet([1, 2]);
|
||||
ls.add('3');
|
||||
assert(ls.has('3'));
|
||||
ls.add("3");
|
||||
assert(ls.has("3"));
|
||||
});
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
// a shared fixture.
|
||||
|
||||
exports.test_user = {
|
||||
email: 'test@example.com',
|
||||
email: "test@example.com",
|
||||
user_id: 101,
|
||||
full_name: 'Test User',
|
||||
full_name: "Test User",
|
||||
};
|
||||
|
||||
exports.test_message = {
|
||||
@@ -19,26 +19,26 @@ exports.test_message = {
|
||||
|
||||
exports.fixtures = {
|
||||
alert_words: {
|
||||
type: 'alert_words',
|
||||
alert_words: ['fire', 'lunch'],
|
||||
type: "alert_words",
|
||||
alert_words: ["fire", "lunch"],
|
||||
},
|
||||
|
||||
attachment: {
|
||||
type: 'attachment',
|
||||
type: "attachment",
|
||||
},
|
||||
|
||||
default_streams: {
|
||||
type: 'default_streams',
|
||||
type: "default_streams",
|
||||
default_streams: [
|
||||
{
|
||||
name: 'devel',
|
||||
description: 'devel',
|
||||
name: "devel",
|
||||
description: "devel",
|
||||
invite_only: false,
|
||||
stream_id: 1,
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
description: 'test',
|
||||
name: "test",
|
||||
description: "test",
|
||||
invite_only: true,
|
||||
stream_id: 1,
|
||||
},
|
||||
@@ -46,25 +46,25 @@ exports.fixtures = {
|
||||
},
|
||||
|
||||
hotspots: {
|
||||
type: 'hotspots',
|
||||
hotspots: ['nice', 'chicken'],
|
||||
type: "hotspots",
|
||||
hotspots: ["nice", "chicken"],
|
||||
},
|
||||
|
||||
invites_changed: {
|
||||
type: 'invites_changed',
|
||||
type: "invites_changed",
|
||||
},
|
||||
|
||||
muted_topics: {
|
||||
type: 'muted_topics',
|
||||
muted_topics: [['devel', 'js'], ['lunch', 'burritos']],
|
||||
type: "muted_topics",
|
||||
muted_topics: [["devel", "js"], ["lunch", "burritos"]],
|
||||
},
|
||||
|
||||
presence: {
|
||||
type: 'presence',
|
||||
email: 'alice@example.com',
|
||||
type: "presence",
|
||||
email: "alice@example.com",
|
||||
user_id: 42,
|
||||
presence: {
|
||||
client_name: 'electron',
|
||||
client_name: "electron",
|
||||
is_mirror_dummy: false,
|
||||
// etc.
|
||||
},
|
||||
@@ -72,10 +72,10 @@ exports.fixtures = {
|
||||
},
|
||||
|
||||
reaction__add: {
|
||||
type: 'reaction',
|
||||
op: 'add',
|
||||
type: "reaction",
|
||||
op: "add",
|
||||
message_id: 128,
|
||||
emoji_name: 'anguished_pig',
|
||||
emoji_name: "anguished_pig",
|
||||
user_id: "1",
|
||||
user: {
|
||||
id: "1",
|
||||
@@ -83,10 +83,10 @@ exports.fixtures = {
|
||||
},
|
||||
|
||||
reaction__remove: {
|
||||
type: 'reaction',
|
||||
op: 'remove',
|
||||
type: "reaction",
|
||||
op: "remove",
|
||||
message_id: 256,
|
||||
emoji_name: 'angery',
|
||||
emoji_name: "angery",
|
||||
user_id: "1",
|
||||
user: {
|
||||
id: "1",
|
||||
@@ -96,93 +96,93 @@ exports.fixtures = {
|
||||
// Please keep this next section un-nested, as we want this to partly
|
||||
// be simple documentation on the formats of individual events.
|
||||
realm__update__create_stream_policy: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'create_stream_policy',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "create_stream_policy",
|
||||
value: 2,
|
||||
},
|
||||
|
||||
realm__update__invite_to_stream_policy: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'invite_to_stream_policy',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "invite_to_stream_policy",
|
||||
value: 2,
|
||||
},
|
||||
|
||||
realm__update__invite_required: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'invite_required',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "invite_required",
|
||||
value: false,
|
||||
},
|
||||
|
||||
realm__update__name: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'name',
|
||||
value: 'new_realm_name',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "name",
|
||||
value: "new_realm_name",
|
||||
},
|
||||
|
||||
realm__update__emails_restricted_to_domains: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'emails_restricted_to_domains',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "emails_restricted_to_domains",
|
||||
value: false,
|
||||
},
|
||||
|
||||
realm__update__bot_creation_policy: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'bot_creation_policy',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "bot_creation_policy",
|
||||
value: 1,
|
||||
},
|
||||
|
||||
realm__update__email_addresses_visibility: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'email_address_visibility',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "email_address_visibility",
|
||||
value: 3,
|
||||
},
|
||||
|
||||
realm__update__disallow_disposable_email_addresses: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'disallow_disposable_email_addresses',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "disallow_disposable_email_addresses",
|
||||
value: false,
|
||||
},
|
||||
|
||||
realm__update_default_twenty_four_hour_time: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'default_twenty_four_hour_time',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "default_twenty_four_hour_time",
|
||||
value: false,
|
||||
},
|
||||
|
||||
realm__update_notifications_stream_id: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'notifications_stream_id',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "notifications_stream_id",
|
||||
value: 42,
|
||||
},
|
||||
|
||||
realm__update_signup_notifications_stream_id: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'signup_notifications_stream_id',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "signup_notifications_stream_id",
|
||||
value: 41,
|
||||
},
|
||||
|
||||
realm__update_default_code_block_language: {
|
||||
type: 'realm',
|
||||
op: 'update',
|
||||
property: 'default_code_block_language',
|
||||
value: 'javascript',
|
||||
type: "realm",
|
||||
op: "update",
|
||||
property: "default_code_block_language",
|
||||
value: "javascript",
|
||||
},
|
||||
|
||||
realm__update_dict__default: {
|
||||
type: 'realm',
|
||||
op: 'update_dict',
|
||||
property: 'default',
|
||||
type: "realm",
|
||||
op: "update_dict",
|
||||
property: "default",
|
||||
data: {
|
||||
allow_message_editing: true,
|
||||
message_content_edit_limit_seconds: 5,
|
||||
@@ -193,165 +193,165 @@ exports.fixtures = {
|
||||
},
|
||||
|
||||
realm__update_dict__icon: {
|
||||
type: 'realm',
|
||||
op: 'update_dict',
|
||||
property: 'icon',
|
||||
type: "realm",
|
||||
op: "update_dict",
|
||||
property: "icon",
|
||||
data: {
|
||||
icon_url: 'icon.png',
|
||||
icon_source: 'U',
|
||||
icon_url: "icon.png",
|
||||
icon_source: "U",
|
||||
},
|
||||
},
|
||||
|
||||
realm__update_dict__logo: {
|
||||
type: 'realm',
|
||||
op: 'update_dict',
|
||||
property: 'logo',
|
||||
type: "realm",
|
||||
op: "update_dict",
|
||||
property: "logo",
|
||||
data: {
|
||||
logo_url: 'logo.png',
|
||||
logo_source: 'U',
|
||||
logo_url: "logo.png",
|
||||
logo_source: "U",
|
||||
},
|
||||
},
|
||||
|
||||
realm__update_dict__night_logo: {
|
||||
type: 'realm',
|
||||
op: 'update_dict',
|
||||
property: 'night_logo',
|
||||
type: "realm",
|
||||
op: "update_dict",
|
||||
property: "night_logo",
|
||||
data: {
|
||||
night_logo_url: 'night_logo.png',
|
||||
night_logo_source: 'U',
|
||||
night_logo_url: "night_logo.png",
|
||||
night_logo_source: "U",
|
||||
},
|
||||
},
|
||||
|
||||
realm__deactivated: {
|
||||
type: 'realm',
|
||||
op: 'deactivated',
|
||||
type: "realm",
|
||||
op: "deactivated",
|
||||
},
|
||||
|
||||
realm_bot__add: {
|
||||
type: 'realm_bot',
|
||||
op: 'add',
|
||||
type: "realm_bot",
|
||||
op: "add",
|
||||
bot: {
|
||||
email: 'the-bot@example.com',
|
||||
full_name: 'The Bot',
|
||||
email: "the-bot@example.com",
|
||||
full_name: "The Bot",
|
||||
// etc.
|
||||
},
|
||||
},
|
||||
|
||||
realm_bot__remove: {
|
||||
type: 'realm_bot',
|
||||
op: 'remove',
|
||||
type: "realm_bot",
|
||||
op: "remove",
|
||||
bot: {
|
||||
email: 'the-bot@example.com',
|
||||
user_id: '42',
|
||||
full_name: 'The Bot',
|
||||
email: "the-bot@example.com",
|
||||
user_id: "42",
|
||||
full_name: "The Bot",
|
||||
},
|
||||
},
|
||||
|
||||
realm_bot__delete: {
|
||||
type: 'realm_bot',
|
||||
op: 'delete',
|
||||
type: "realm_bot",
|
||||
op: "delete",
|
||||
bot: {
|
||||
email: 'the-bot@example.com',
|
||||
user_id: '42',
|
||||
email: "the-bot@example.com",
|
||||
user_id: "42",
|
||||
},
|
||||
},
|
||||
|
||||
realm_bot__update: {
|
||||
type: 'realm_bot',
|
||||
op: 'update',
|
||||
type: "realm_bot",
|
||||
op: "update",
|
||||
bot: {
|
||||
email: 'the-bot@example.com',
|
||||
email: "the-bot@example.com",
|
||||
user_id: 4321,
|
||||
full_name: 'The Bot Has A New Name',
|
||||
full_name: "The Bot Has A New Name",
|
||||
},
|
||||
},
|
||||
|
||||
realm_emoji: {
|
||||
type: 'realm_emoji',
|
||||
type: "realm_emoji",
|
||||
realm_emoji: {
|
||||
airplane: {
|
||||
source_url: 'some_url',
|
||||
source_url: "some_url",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
realm_filters: {
|
||||
type: 'realm_filters',
|
||||
type: "realm_filters",
|
||||
realm_filters: [
|
||||
['#[123]', 'ticket %(id)s'],
|
||||
["#[123]", "ticket %(id)s"],
|
||||
],
|
||||
},
|
||||
|
||||
realm_domains__add: {
|
||||
type: 'realm_domains',
|
||||
op: 'add',
|
||||
type: "realm_domains",
|
||||
op: "add",
|
||||
realm_domain: {
|
||||
domain: 'ramen',
|
||||
domain: "ramen",
|
||||
allow_subdomains: false,
|
||||
},
|
||||
},
|
||||
|
||||
realm_domains__change: {
|
||||
type: 'realm_domains',
|
||||
op: 'change',
|
||||
type: "realm_domains",
|
||||
op: "change",
|
||||
realm_domain: {
|
||||
domain: 'ramen',
|
||||
domain: "ramen",
|
||||
allow_subdomains: true,
|
||||
},
|
||||
},
|
||||
|
||||
realm_domains__remove: {
|
||||
type: 'realm_domains',
|
||||
op: 'remove',
|
||||
domain: 'ramen',
|
||||
type: "realm_domains",
|
||||
op: "remove",
|
||||
domain: "ramen",
|
||||
},
|
||||
|
||||
realm_user__add: {
|
||||
type: 'realm_user',
|
||||
op: 'add',
|
||||
type: "realm_user",
|
||||
op: "add",
|
||||
person: {
|
||||
email: 'added@example.com',
|
||||
full_name: 'Added Person',
|
||||
email: "added@example.com",
|
||||
full_name: "Added Person",
|
||||
user_id: 1001,
|
||||
},
|
||||
},
|
||||
|
||||
realm_user__remove: {
|
||||
type: 'realm_user',
|
||||
op: 'remove',
|
||||
type: "realm_user",
|
||||
op: "remove",
|
||||
person: {
|
||||
email: 'added@example.com',
|
||||
email: "added@example.com",
|
||||
user_id: 1001,
|
||||
},
|
||||
},
|
||||
|
||||
realm_user__update: {
|
||||
type: 'realm_user',
|
||||
op: 'update',
|
||||
type: "realm_user",
|
||||
op: "update",
|
||||
person: {
|
||||
email: 'alice@example.com',
|
||||
full_name: 'Alice NewName',
|
||||
email: "alice@example.com",
|
||||
full_name: "Alice NewName",
|
||||
// etc.
|
||||
},
|
||||
},
|
||||
|
||||
restart: {
|
||||
type: 'restart',
|
||||
type: "restart",
|
||||
immediate: true,
|
||||
},
|
||||
|
||||
stream__update: {
|
||||
type: 'stream',
|
||||
op: 'update',
|
||||
name: 'devel',
|
||||
type: "stream",
|
||||
op: "update",
|
||||
name: "devel",
|
||||
stream_id: 99,
|
||||
property: 'color',
|
||||
value: 'blue',
|
||||
property: "color",
|
||||
value: "blue",
|
||||
},
|
||||
|
||||
stream__create: {
|
||||
type: 'stream',
|
||||
op: 'create',
|
||||
type: "stream",
|
||||
op: "create",
|
||||
streams: [
|
||||
{stream_id: 42},
|
||||
{stream_id: 99},
|
||||
@@ -359,8 +359,8 @@ exports.fixtures = {
|
||||
},
|
||||
|
||||
stream__delete: {
|
||||
type: 'stream',
|
||||
op: 'delete',
|
||||
type: "stream",
|
||||
op: "delete",
|
||||
streams: [
|
||||
{stream_id: 42},
|
||||
{stream_id: 99},
|
||||
@@ -368,257 +368,257 @@ exports.fixtures = {
|
||||
},
|
||||
|
||||
submessage: {
|
||||
type: 'submessage',
|
||||
type: "submessage",
|
||||
submessage_id: 99,
|
||||
sender_id: 42,
|
||||
msg_type: 'stream',
|
||||
msg_type: "stream",
|
||||
message_id: 56,
|
||||
content: 'test',
|
||||
content: "test",
|
||||
},
|
||||
|
||||
subscription__add: {
|
||||
type: 'subscription',
|
||||
op: 'add',
|
||||
type: "subscription",
|
||||
op: "add",
|
||||
subscriptions: [
|
||||
{
|
||||
name: 'devel',
|
||||
name: "devel",
|
||||
stream_id: 42,
|
||||
subscribers: ['alice@example.com', 'bob@example.com'],
|
||||
email_address: 'devel+0138515295f4@zulipdev.com:9991',
|
||||
subscribers: ["alice@example.com", "bob@example.com"],
|
||||
email_address: "devel+0138515295f4@zulipdev.com:9991",
|
||||
// etc.
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
subscription__remove: {
|
||||
type: 'subscription',
|
||||
op: 'remove',
|
||||
type: "subscription",
|
||||
op: "remove",
|
||||
subscriptions: [
|
||||
{
|
||||
name: 'devel',
|
||||
name: "devel",
|
||||
stream_id: 42,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
subscription__peer_add: {
|
||||
type: 'subscription',
|
||||
op: 'peer_add',
|
||||
type: "subscription",
|
||||
op: "peer_add",
|
||||
user_id: exports.test_user.user_id,
|
||||
stream_id: 42,
|
||||
},
|
||||
|
||||
subscription__peer_remove: {
|
||||
type: 'subscription',
|
||||
op: 'peer_remove',
|
||||
type: "subscription",
|
||||
op: "peer_remove",
|
||||
user_id: exports.test_user.user_id,
|
||||
stream_id: 42,
|
||||
},
|
||||
|
||||
subscription__update: {
|
||||
type: 'subscription',
|
||||
op: 'update',
|
||||
name: 'devel',
|
||||
type: "subscription",
|
||||
op: "update",
|
||||
name: "devel",
|
||||
stream_id: 43,
|
||||
property: 'color',
|
||||
value: 'black',
|
||||
property: "color",
|
||||
value: "black",
|
||||
},
|
||||
|
||||
typing__start: {
|
||||
type: 'typing',
|
||||
type: "typing",
|
||||
sender: {
|
||||
user_id: 4,
|
||||
},
|
||||
op: 'start',
|
||||
op: "start",
|
||||
},
|
||||
|
||||
typing__stop: {
|
||||
type: 'typing',
|
||||
type: "typing",
|
||||
sender: {
|
||||
user_id: 6,
|
||||
},
|
||||
op: 'stop',
|
||||
op: "stop",
|
||||
},
|
||||
|
||||
typing__self: {
|
||||
type: 'typing',
|
||||
type: "typing",
|
||||
sender: {
|
||||
user_id: 5,
|
||||
},
|
||||
},
|
||||
|
||||
update_display_settings__default_language: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'default_language',
|
||||
setting: 'fr',
|
||||
language_name: 'French',
|
||||
type: "update_display_settings",
|
||||
setting_name: "default_language",
|
||||
setting: "fr",
|
||||
language_name: "French",
|
||||
},
|
||||
|
||||
update_display_settings__left_side_userlist: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'left_side_userlist',
|
||||
type: "update_display_settings",
|
||||
setting_name: "left_side_userlist",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__twenty_four_hour_time: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'twenty_four_hour_time',
|
||||
type: "update_display_settings",
|
||||
setting_name: "twenty_four_hour_time",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__high_contrast_mode: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'high_contrast_mode',
|
||||
type: "update_display_settings",
|
||||
setting_name: "high_contrast_mode",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__dense_mode: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'dense_mode',
|
||||
type: "update_display_settings",
|
||||
setting_name: "dense_mode",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__color_scheme_automatic: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'color_scheme',
|
||||
type: "update_display_settings",
|
||||
setting_name: "color_scheme",
|
||||
setting: 1,
|
||||
},
|
||||
|
||||
update_display_settings__color_scheme_dark: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'color_scheme',
|
||||
type: "update_display_settings",
|
||||
setting_name: "color_scheme",
|
||||
setting: 2,
|
||||
},
|
||||
|
||||
update_display_settings__color_scheme_light: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'color_scheme',
|
||||
type: "update_display_settings",
|
||||
setting_name: "color_scheme",
|
||||
setting: 3,
|
||||
},
|
||||
|
||||
update_display_settings__starred_message_counts: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'starred_message_counts',
|
||||
type: "update_display_settings",
|
||||
setting_name: "starred_message_counts",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__fluid_layout_width: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'fluid_layout_width',
|
||||
type: "update_display_settings",
|
||||
setting_name: "fluid_layout_width",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__demote_inactive_streams: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'demote_inactive_streams',
|
||||
type: "update_display_settings",
|
||||
setting_name: "demote_inactive_streams",
|
||||
setting: 2,
|
||||
},
|
||||
|
||||
update_display_settings__translate_emoticons: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'translate_emoticons',
|
||||
type: "update_display_settings",
|
||||
setting_name: "translate_emoticons",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_display_settings__emojiset: {
|
||||
type: 'update_display_settings',
|
||||
setting_name: 'emojiset',
|
||||
setting: 'google',
|
||||
type: "update_display_settings",
|
||||
setting_name: "emojiset",
|
||||
setting: "google",
|
||||
},
|
||||
|
||||
update_global_notifications: {
|
||||
type: 'update_global_notifications',
|
||||
notification_name: 'enable_stream_audible_notifications',
|
||||
type: "update_global_notifications",
|
||||
notification_name: "enable_stream_audible_notifications",
|
||||
setting: true,
|
||||
},
|
||||
|
||||
update_message_flags__read: {
|
||||
type: 'update_message_flags',
|
||||
operation: 'add',
|
||||
flag: 'read',
|
||||
type: "update_message_flags",
|
||||
operation: "add",
|
||||
flag: "read",
|
||||
messages: [999],
|
||||
},
|
||||
|
||||
update_message_flags__starred_add: {
|
||||
type: 'update_message_flags',
|
||||
operation: 'add',
|
||||
flag: 'starred',
|
||||
type: "update_message_flags",
|
||||
operation: "add",
|
||||
flag: "starred",
|
||||
messages: [exports.test_message.id],
|
||||
},
|
||||
|
||||
update_message_flags__starred_remove: {
|
||||
type: 'update_message_flags',
|
||||
operation: 'remove',
|
||||
flag: 'starred',
|
||||
type: "update_message_flags",
|
||||
operation: "remove",
|
||||
flag: "starred",
|
||||
messages: [exports.test_message.id],
|
||||
},
|
||||
|
||||
delete_message: {
|
||||
type: 'delete_message',
|
||||
type: "delete_message",
|
||||
message_ids: [1337],
|
||||
message_type: "stream",
|
||||
stream_id: 99,
|
||||
topic: 'topic1',
|
||||
topic: "topic1",
|
||||
},
|
||||
|
||||
custom_profile_fields: {
|
||||
type: 'custom_profile_fields',
|
||||
type: "custom_profile_fields",
|
||||
fields: [
|
||||
{id: 1, name: 'teams', type: 1},
|
||||
{id: 2, name: 'hobbies', type: 1},
|
||||
{id: 1, name: "teams", type: 1},
|
||||
{id: 2, name: "hobbies", type: 1},
|
||||
],
|
||||
},
|
||||
user_group__add: {
|
||||
type: 'user_group',
|
||||
op: 'add',
|
||||
type: "user_group",
|
||||
op: "add",
|
||||
group: {
|
||||
name: 'Mobile',
|
||||
id: '1',
|
||||
name: "Mobile",
|
||||
id: "1",
|
||||
members: [1],
|
||||
},
|
||||
},
|
||||
user_group__add_members: {
|
||||
type: 'user_group',
|
||||
op: 'add_members',
|
||||
type: "user_group",
|
||||
op: "add_members",
|
||||
group_id: 1,
|
||||
user_ids: [2],
|
||||
},
|
||||
user_group__remove_members: {
|
||||
type: 'user_group',
|
||||
op: 'remove_members',
|
||||
type: "user_group",
|
||||
op: "remove_members",
|
||||
group_id: 3,
|
||||
user_ids: [99, 100],
|
||||
},
|
||||
user_group__update: {
|
||||
type: 'user_group',
|
||||
op: 'update',
|
||||
type: "user_group",
|
||||
op: "update",
|
||||
group_id: 3,
|
||||
data: {
|
||||
name: 'Frontend',
|
||||
description: 'All Frontend people',
|
||||
name: "Frontend",
|
||||
description: "All Frontend people",
|
||||
},
|
||||
},
|
||||
user_status__revoke_away: {
|
||||
type: 'user_status',
|
||||
type: "user_status",
|
||||
user_id: 63,
|
||||
away: false,
|
||||
},
|
||||
user_status__set_away: {
|
||||
type: 'user_status',
|
||||
type: "user_status",
|
||||
user_id: 55,
|
||||
away: true,
|
||||
},
|
||||
user_status__set_status_text: {
|
||||
type: 'user_status',
|
||||
type: "user_status",
|
||||
user_id: exports.test_user.user_id,
|
||||
status_text: 'out to lunch',
|
||||
status_text: "out to lunch",
|
||||
},
|
||||
realm_export: {
|
||||
type: 'realm_export',
|
||||
type: "realm_export",
|
||||
exports: {
|
||||
acting_user_id: 55,
|
||||
event_time: 'noon',
|
||||
path: 'some_path',
|
||||
event_time: "noon",
|
||||
path: "some_path",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
zrequire('rows');
|
||||
zrequire('lightbox');
|
||||
zrequire("rows");
|
||||
zrequire("lightbox");
|
||||
|
||||
set_global('message_store', {});
|
||||
set_global('Image', class Image {});
|
||||
set_global('overlays', {
|
||||
set_global("message_store", {});
|
||||
set_global("Image", class Image {});
|
||||
set_global("overlays", {
|
||||
close_overlay: () => {},
|
||||
close_active: () => {},
|
||||
open_overlay: () => {},
|
||||
});
|
||||
set_global('popovers', {
|
||||
set_global("popovers", {
|
||||
hide_all: () => {},
|
||||
});
|
||||
|
||||
rows.is_draft_row = () => false;
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
run_test('pan_and_zoom', () => {
|
||||
run_test("pan_and_zoom", () => {
|
||||
$.clear_all_elements();
|
||||
|
||||
const img = $.create('img-stub');
|
||||
const link = $.create('link-stub');
|
||||
const msg = $.create('msg-stub');
|
||||
const img = $.create("img-stub");
|
||||
const link = $.create("link-stub");
|
||||
const msg = $.create("msg-stub");
|
||||
|
||||
$(img).closest = () => [];
|
||||
|
||||
@@ -34,45 +34,45 @@ run_test('pan_and_zoom', () => {
|
||||
|
||||
message_store.get = (zid) => {
|
||||
fetched_zid = zid;
|
||||
return 'message-stub';
|
||||
return "message-stub";
|
||||
};
|
||||
|
||||
// Used by render_lightbox_list_images
|
||||
$.stub_selector('.focused_table .message_inline_image img', []);
|
||||
$.stub_selector(".focused_table .message_inline_image img", []);
|
||||
|
||||
lightbox.open(img);
|
||||
|
||||
assert.equal(fetched_zid, 1234);
|
||||
});
|
||||
|
||||
run_test('youtube', () => {
|
||||
run_test("youtube", () => {
|
||||
$.clear_all_elements();
|
||||
|
||||
const href = 'https://youtube.com/some-random-clip';
|
||||
const img = $.create('img-stub');
|
||||
const link = $.create('link-stub');
|
||||
const msg = $.create('msg-stub');
|
||||
const href = "https://youtube.com/some-random-clip";
|
||||
const img = $.create("img-stub");
|
||||
const link = $.create("link-stub");
|
||||
const msg = $.create("msg-stub");
|
||||
|
||||
msg.attr("zid", "4321");
|
||||
|
||||
$(img).attr('src', href);
|
||||
$(img).attr("src", href);
|
||||
|
||||
$(img).closest = (sel) => {
|
||||
if (sel === '.youtube-video') {
|
||||
if (sel === ".youtube-video") {
|
||||
// We just need a nonempty array to
|
||||
// set is_youtube_video to true.
|
||||
return ['whatever'];
|
||||
return ["whatever"];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
img.set_parent(link);
|
||||
link.closest = () => msg;
|
||||
link.attr('href', href);
|
||||
link.attr("href", href);
|
||||
|
||||
// Used by render_lightbox_list_images
|
||||
$.stub_selector('.focused_table .message_inline_image img', []);
|
||||
$.stub_selector(".focused_table .message_inline_image img", []);
|
||||
|
||||
lightbox.open(img);
|
||||
assert.equal($('.image-actions .open').attr('href'), href);
|
||||
assert.equal($(".image-actions .open").attr("href"), href);
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
zrequire('list_cursor');
|
||||
zrequire("list_cursor");
|
||||
|
||||
run_test('config errors', () => {
|
||||
blueslip.expect('error', 'Programming error');
|
||||
run_test("config errors", () => {
|
||||
blueslip.expect("error", "Programming error");
|
||||
list_cursor({});
|
||||
});
|
||||
|
||||
function basic_conf() {
|
||||
const list = {
|
||||
scroll_container_sel: 'whatever',
|
||||
scroll_container_sel: "whatever",
|
||||
find_li: () => {},
|
||||
first_key: () => {},
|
||||
prev_key: () => {},
|
||||
@@ -16,13 +16,13 @@ function basic_conf() {
|
||||
|
||||
const conf = {
|
||||
list: list,
|
||||
highlight_class: 'highlight',
|
||||
highlight_class: "highlight",
|
||||
};
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
run_test('misc errors', () => {
|
||||
run_test("misc errors", () => {
|
||||
const conf = basic_conf();
|
||||
|
||||
const cursor = list_cursor(conf);
|
||||
@@ -30,28 +30,28 @@ run_test('misc errors', () => {
|
||||
// Test that we just ignore empty
|
||||
// lists for unknown keys.
|
||||
conf.list.find_li = (opts) => {
|
||||
assert.equal(opts.key, 'nada');
|
||||
assert.equal(opts.key, "nada");
|
||||
assert.equal(opts.force_render, true);
|
||||
return [];
|
||||
};
|
||||
|
||||
cursor.get_row('nada');
|
||||
cursor.get_row("nada");
|
||||
|
||||
blueslip.expect('error', 'Caller is not checking keys for list_cursor.go_to');
|
||||
blueslip.expect("error", "Caller is not checking keys for list_cursor.go_to");
|
||||
cursor.go_to(undefined);
|
||||
|
||||
blueslip.expect('error', 'Cannot highlight key for list_cursor: nada');
|
||||
cursor.go_to('nada');
|
||||
blueslip.expect("error", "Cannot highlight key for list_cursor: nada");
|
||||
cursor.go_to("nada");
|
||||
|
||||
cursor.prev();
|
||||
cursor.next();
|
||||
});
|
||||
|
||||
run_test('single item list', () => {
|
||||
run_test("single item list", () => {
|
||||
const conf = basic_conf();
|
||||
const cursor = list_cursor(conf);
|
||||
|
||||
const valid_key = '42';
|
||||
const valid_key = "42";
|
||||
const li_stub = {
|
||||
length: 1,
|
||||
addClass: () => {},
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
zrequire('list_render');
|
||||
zrequire("list_render");
|
||||
|
||||
// We need these stubs to get by instanceof checks.
|
||||
// The list_render library allows you to insert objects
|
||||
// that are either jQuery, Element, or just raw HTML
|
||||
// strings. We initially test with raw strings.
|
||||
set_global('jQuery', 'stub');
|
||||
set_global("jQuery", "stub");
|
||||
function Element() {
|
||||
return { };
|
||||
}
|
||||
set_global('Element', Element);
|
||||
set_global('ui', {});
|
||||
set_global("Element", Element);
|
||||
set_global("ui", {});
|
||||
|
||||
// We only need very simple jQuery wrappers for when the
|
||||
// "real" code wraps html or sets up click handlers.
|
||||
// We'll simulate most other objects ourselves.
|
||||
set_global('$', (arg) => {
|
||||
set_global("$", (arg) => {
|
||||
if (arg.to_jquery) {
|
||||
return arg.to_jquery();
|
||||
}
|
||||
@@ -41,8 +41,8 @@ function make_container() {
|
||||
container.length = () => 1;
|
||||
container.is = () => false;
|
||||
container.css = (prop) => {
|
||||
assert.equal(prop, 'max-height');
|
||||
return 'none';
|
||||
assert.equal(prop, "max-height");
|
||||
return "none";
|
||||
};
|
||||
|
||||
// Make our append function just set a field we can
|
||||
@@ -62,14 +62,14 @@ function make_scroll_container() {
|
||||
// Capture the scroll callback so we can call it in
|
||||
// our tests.
|
||||
scroll_container.on = (ev, f) => {
|
||||
assert.equal(ev, 'scroll.list_widget_container');
|
||||
assert.equal(ev, "scroll.list_widget_container");
|
||||
scroll_container.call_scroll = () => {
|
||||
f.call(scroll_container);
|
||||
};
|
||||
};
|
||||
|
||||
scroll_container.off = (ev) => {
|
||||
assert.equal(ev, 'scroll.list_widget_container');
|
||||
assert.equal(ev, "scroll.list_widget_container");
|
||||
scroll_container.cleared = true;
|
||||
};
|
||||
|
||||
@@ -82,13 +82,13 @@ function make_sort_container() {
|
||||
sort_container.cleared = false;
|
||||
|
||||
sort_container.on = (ev, sel, f) => {
|
||||
assert.equal(ev, 'click.list_widget_sort');
|
||||
assert.equal(sel, '[data-sort]');
|
||||
assert.equal(ev, "click.list_widget_sort");
|
||||
assert.equal(sel, "[data-sort]");
|
||||
sort_container.f = f;
|
||||
};
|
||||
|
||||
sort_container.off = (ev) => {
|
||||
assert.equal(ev, 'click.list_widget_sort');
|
||||
assert.equal(ev, "click.list_widget_sort");
|
||||
sort_container.cleared = true;
|
||||
};
|
||||
|
||||
@@ -101,12 +101,12 @@ function make_filter_element() {
|
||||
element.cleared = false;
|
||||
|
||||
element.on = (ev, f) => {
|
||||
assert.equal(ev, 'input.list_widget_filter');
|
||||
assert.equal(ev, "input.list_widget_filter");
|
||||
element.f = f;
|
||||
};
|
||||
|
||||
element.off = (ev) => {
|
||||
assert.equal(ev, 'input.list_widget_filter');
|
||||
assert.equal(ev, "input.list_widget_filter");
|
||||
element.cleared = true;
|
||||
};
|
||||
|
||||
@@ -121,7 +121,7 @@ function make_search_input() {
|
||||
$element.to_jquery = () => $element;
|
||||
|
||||
$element.on = (event_name, f) => {
|
||||
assert.equal(event_name, 'input.list_widget_filter');
|
||||
assert.equal(event_name, "input.list_widget_filter");
|
||||
$element.simulate_input_event = () => {
|
||||
const elem = {
|
||||
value: $element.val(),
|
||||
@@ -134,10 +134,10 @@ function make_search_input() {
|
||||
}
|
||||
|
||||
function div(item) {
|
||||
return '<div>' + item + '</div>';
|
||||
return "<div>" + item + "</div>";
|
||||
}
|
||||
|
||||
run_test('scrolling', () => {
|
||||
run_test("scrolling", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
|
||||
@@ -150,7 +150,7 @@ run_test('scrolling', () => {
|
||||
};
|
||||
|
||||
for (let i = 0; i < 200; i += 1) {
|
||||
items.push('item ' + i);
|
||||
items.push("item " + i);
|
||||
}
|
||||
|
||||
const opts = {
|
||||
@@ -158,12 +158,12 @@ run_test('scrolling', () => {
|
||||
simplebar_container: scroll_container,
|
||||
};
|
||||
|
||||
container.html = (html) => { assert.equal(html, ''); };
|
||||
container.html = (html) => { assert.equal(html, ""); };
|
||||
list_render.create(container, items, opts);
|
||||
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
items.slice(0, 80).join(''),
|
||||
items.slice(0, 80).join(""),
|
||||
);
|
||||
assert.equal(get_scroll_element_called, true);
|
||||
|
||||
@@ -177,24 +177,24 @@ run_test('scrolling', () => {
|
||||
scroll_container.call_scroll();
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
items.slice(80, 100).join(''),
|
||||
items.slice(80, 100).join(""),
|
||||
);
|
||||
});
|
||||
|
||||
run_test('filtering', () => {
|
||||
run_test("filtering", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
|
||||
const search_input = make_search_input();
|
||||
|
||||
const list = [
|
||||
'apple',
|
||||
'banana',
|
||||
'carrot',
|
||||
'dog',
|
||||
'egg',
|
||||
'fence',
|
||||
'grape',
|
||||
"apple",
|
||||
"banana",
|
||||
"carrot",
|
||||
"dog",
|
||||
"egg",
|
||||
"fence",
|
||||
"grape",
|
||||
];
|
||||
const opts = {
|
||||
filter: {
|
||||
@@ -205,47 +205,47 @@ run_test('filtering', () => {
|
||||
simplebar_container: scroll_container,
|
||||
};
|
||||
|
||||
container.html = (html) => { assert.equal(html, ''); };
|
||||
container.html = (html) => { assert.equal(html, ""); };
|
||||
const widget = list_render.create(container, list, opts);
|
||||
|
||||
let expected_html =
|
||||
'<div>apple</div>' +
|
||||
'<div>banana</div>' +
|
||||
'<div>carrot</div>' +
|
||||
'<div>dog</div>' +
|
||||
'<div>egg</div>' +
|
||||
'<div>fence</div>' +
|
||||
'<div>grape</div>';
|
||||
"<div>apple</div>" +
|
||||
"<div>banana</div>" +
|
||||
"<div>carrot</div>" +
|
||||
"<div>dog</div>" +
|
||||
"<div>egg</div>" +
|
||||
"<div>fence</div>" +
|
||||
"<div>grape</div>";
|
||||
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
|
||||
// Filtering will pick out dog/egg/grape when we put "g"
|
||||
// into our search input. (This uses the default filter, which
|
||||
// is a glorified indexOf call.)
|
||||
search_input.val = () => 'g';
|
||||
search_input.val = () => "g";
|
||||
search_input.simulate_input_event();
|
||||
expected_html = '<div>dog</div><div>egg</div><div>grape</div>';
|
||||
expected_html = "<div>dog</div><div>egg</div><div>grape</div>";
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
|
||||
// We can insert new data into the widget.
|
||||
const new_data = [
|
||||
'greta',
|
||||
'faye',
|
||||
'gary',
|
||||
'frank',
|
||||
'giraffe',
|
||||
'fox',
|
||||
"greta",
|
||||
"faye",
|
||||
"gary",
|
||||
"frank",
|
||||
"giraffe",
|
||||
"fox",
|
||||
];
|
||||
|
||||
widget.replace_list_data(new_data);
|
||||
expected_html =
|
||||
'<div>greta</div>' +
|
||||
'<div>gary</div>' +
|
||||
'<div>giraffe</div>';
|
||||
"<div>greta</div>" +
|
||||
"<div>gary</div>" +
|
||||
"<div>giraffe</div>";
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
});
|
||||
|
||||
run_test('no filtering', () => {
|
||||
run_test("no filtering", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
container.html = () => {};
|
||||
@@ -255,12 +255,12 @@ run_test('no filtering', () => {
|
||||
modifier: (item) => div(item),
|
||||
simplebar_container: scroll_container,
|
||||
};
|
||||
const widget = list_render.create(container, ['apple', 'banana'], opts);
|
||||
const widget = list_render.create(container, ["apple", "banana"], opts);
|
||||
widget.render();
|
||||
|
||||
const expected_html =
|
||||
'<div>apple</div>' +
|
||||
'<div>banana</div>';
|
||||
"<div>apple</div>" +
|
||||
"<div>banana</div>";
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
});
|
||||
|
||||
@@ -274,7 +274,7 @@ function sort_button(opts) {
|
||||
switch (sel) {
|
||||
case "sort": return opts.sort_type;
|
||||
case "sort-prop": return opts.prop_name;
|
||||
default: throw Error('unknown selector: ' + sel);
|
||||
default: throw Error("unknown selector: " + sel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ function sort_button(opts) {
|
||||
|
||||
const button = {
|
||||
data: data,
|
||||
closest: lookup('.progressive-table-wrapper', {
|
||||
data: lookup('list-render', opts.list_name),
|
||||
closest: lookup(".progressive-table-wrapper", {
|
||||
data: lookup("list-render", opts.list_name),
|
||||
}),
|
||||
addClass: (cls) => {
|
||||
classList.add(cls);
|
||||
@@ -299,9 +299,9 @@ function sort_button(opts) {
|
||||
removeClass: (cls) => {
|
||||
classList.delete(cls);
|
||||
},
|
||||
siblings: lookup('.active', {
|
||||
siblings: lookup(".active", {
|
||||
removeClass: (cls) => {
|
||||
assert.equal(cls, 'active');
|
||||
assert.equal(cls, "active");
|
||||
button.siblings_deactivated = true;
|
||||
},
|
||||
}),
|
||||
@@ -312,14 +312,14 @@ function sort_button(opts) {
|
||||
return button;
|
||||
}
|
||||
|
||||
run_test('wire up filter element', () => {
|
||||
run_test("wire up filter element", () => {
|
||||
const lst = [
|
||||
'alice',
|
||||
'JESSE',
|
||||
'moses',
|
||||
'scott',
|
||||
'Sean',
|
||||
'Xavier',
|
||||
"alice",
|
||||
"JESSE",
|
||||
"moses",
|
||||
"scott",
|
||||
"Sean",
|
||||
"Xavier",
|
||||
];
|
||||
|
||||
const container = make_container();
|
||||
@@ -334,39 +334,39 @@ run_test('wire up filter element', () => {
|
||||
filterer: (list, value) => list.filter((item) => item.toLowerCase().includes(value)),
|
||||
element: filter_element,
|
||||
},
|
||||
modifier: (s) => '(' + s + ')',
|
||||
modifier: (s) => "(" + s + ")",
|
||||
simplebar_container: scroll_container,
|
||||
};
|
||||
|
||||
list_render.create(container, lst, opts);
|
||||
filter_element.f.apply({value: 'se'});
|
||||
filter_element.f.apply({value: "se"});
|
||||
assert.equal(
|
||||
container.appended_data.html(),
|
||||
'(JESSE)(moses)(Sean)',
|
||||
"(JESSE)(moses)(Sean)",
|
||||
);
|
||||
});
|
||||
|
||||
run_test('sorting', () => {
|
||||
run_test("sorting", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
const sort_container = make_sort_container();
|
||||
|
||||
let cleared;
|
||||
container.html = (html) => {
|
||||
assert.equal(html, '');
|
||||
assert.equal(html, "");
|
||||
cleared = true;
|
||||
};
|
||||
|
||||
const alice = { name: 'alice', salary: 50 };
|
||||
const bob = { name: 'Bob', salary: 40 };
|
||||
const cal = { name: 'cal', salary: 30 };
|
||||
const dave = { name: 'dave', salary: 25 };
|
||||
const ellen = { name: 'ellen', salary: 95 };
|
||||
const alice = { name: "alice", salary: 50 };
|
||||
const bob = { name: "Bob", salary: 40 };
|
||||
const cal = { name: "cal", salary: 30 };
|
||||
const dave = { name: "dave", salary: 25 };
|
||||
const ellen = { name: "ellen", salary: 95 };
|
||||
|
||||
const list = [bob, ellen, dave, alice, cal];
|
||||
|
||||
const opts = {
|
||||
name: 'sorting-list',
|
||||
name: "sorting-list",
|
||||
parent_container: sort_container,
|
||||
modifier: (item) => div(item.name) + div(item.salary),
|
||||
filter: {
|
||||
@@ -376,7 +376,7 @@ run_test('sorting', () => {
|
||||
};
|
||||
|
||||
function html_for(people) {
|
||||
return people.map(opts.modifier).join('');
|
||||
return people.map(opts.modifier).join("");
|
||||
}
|
||||
|
||||
list_render.create(container, list, opts);
|
||||
@@ -386,9 +386,9 @@ run_test('sorting', () => {
|
||||
let expected_html;
|
||||
|
||||
button_opts = {
|
||||
sort_type: 'alphabetic',
|
||||
prop_name: 'name',
|
||||
list_name: 'my-list',
|
||||
sort_type: "alphabetic",
|
||||
prop_name: "name",
|
||||
list_name: "my-list",
|
||||
active: false,
|
||||
};
|
||||
|
||||
@@ -420,7 +420,7 @@ run_test('sorting', () => {
|
||||
alice,
|
||||
]);
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
assert(button.hasClass('descend'));
|
||||
assert(button.hasClass("descend"));
|
||||
|
||||
// And then hit a third time to go back to the forward sort.
|
||||
cleared = false;
|
||||
@@ -434,13 +434,13 @@ run_test('sorting', () => {
|
||||
ellen,
|
||||
]);
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
assert(!button.hasClass('descend'));
|
||||
assert(!button.hasClass("descend"));
|
||||
|
||||
// Now try a numeric sort.
|
||||
button_opts = {
|
||||
sort_type: 'numeric',
|
||||
prop_name: 'salary',
|
||||
list_name: 'my-list',
|
||||
sort_type: "numeric",
|
||||
prop_name: "salary",
|
||||
list_name: "my-list",
|
||||
active: false,
|
||||
};
|
||||
|
||||
@@ -475,10 +475,10 @@ run_test('sorting', () => {
|
||||
dave,
|
||||
]);
|
||||
assert.deepEqual(container.appended_data.html(), expected_html);
|
||||
assert(button.hasClass('descend'));
|
||||
assert(button.hasClass("descend"));
|
||||
});
|
||||
|
||||
run_test('custom sort', () => {
|
||||
run_test("custom sort", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
container.html = () => {};
|
||||
@@ -498,8 +498,8 @@ run_test('custom sort', () => {
|
||||
}
|
||||
|
||||
list_render.create(container, list, {
|
||||
name: 'custom-sort-list',
|
||||
modifier: (n) => '(' + n.x + ', ' + n.y + ')',
|
||||
name: "custom-sort-list",
|
||||
modifier: (n) => "(" + n.x + ", " + n.y + ")",
|
||||
sort_fields: {
|
||||
product: sort_by_product,
|
||||
x_value: sort_by_x,
|
||||
@@ -510,15 +510,15 @@ run_test('custom sort', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
'(6, 7)(1, 43)(4, 11)',
|
||||
"(6, 7)(1, 43)(4, 11)",
|
||||
);
|
||||
|
||||
const widget = list_render.get('custom-sort-list');
|
||||
const widget = list_render.get("custom-sort-list");
|
||||
|
||||
widget.sort('x_value');
|
||||
widget.sort("x_value");
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
'(1, 43)(4, 11)(6, 7)',
|
||||
"(1, 43)(4, 11)(6, 7)",
|
||||
);
|
||||
|
||||
// We can sort without registering the function, too.
|
||||
@@ -529,11 +529,11 @@ run_test('custom sort', () => {
|
||||
widget.sort(sort_by_y);
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
'(6, 7)(4, 11)(1, 43)',
|
||||
"(6, 7)(4, 11)(1, 43)",
|
||||
);
|
||||
});
|
||||
|
||||
run_test('clear_event_handlers', () => {
|
||||
run_test("clear_event_handlers", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
const sort_container = make_sort_container();
|
||||
@@ -544,7 +544,7 @@ run_test('clear_event_handlers', () => {
|
||||
container.html = () => {};
|
||||
|
||||
const opts = {
|
||||
name: 'list-we-create-twice',
|
||||
name: "list-we-create-twice",
|
||||
parent_container: sort_container,
|
||||
modifier: () => {},
|
||||
filter: {
|
||||
@@ -567,39 +567,39 @@ run_test('clear_event_handlers', () => {
|
||||
assert.equal(filter_element.cleared, true);
|
||||
});
|
||||
|
||||
run_test('errors', () => {
|
||||
run_test("errors", () => {
|
||||
// We don't care about actual data for this test.
|
||||
const list = 'stub';
|
||||
const list = "stub";
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
|
||||
blueslip.expect('error', 'Need opts to create widget.');
|
||||
blueslip.expect("error", "Need opts to create widget.");
|
||||
list_render.create(container, list);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'simplebar_container is missing.');
|
||||
blueslip.expect("error", "simplebar_container is missing.");
|
||||
list_render.create(container, list, {
|
||||
modifier: 'hello world',
|
||||
modifier: "hello world",
|
||||
});
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'get_item should be a function');
|
||||
blueslip.expect("error", "get_item should be a function");
|
||||
list_render.create(container, list, {
|
||||
get_item: 'not a function',
|
||||
get_item: "not a function",
|
||||
simplebar_container: scroll_container,
|
||||
});
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Filter predicate is not a function.');
|
||||
blueslip.expect("error", "Filter predicate is not a function.");
|
||||
list_render.create(container, list, {
|
||||
filter: {
|
||||
predicate: 'wrong type',
|
||||
predicate: "wrong type",
|
||||
},
|
||||
simplebar_container: scroll_container,
|
||||
});
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Filterer and predicate are mutually exclusive.');
|
||||
blueslip.expect("error", "Filterer and predicate are mutually exclusive.");
|
||||
list_render.create(container, list, {
|
||||
filter: {
|
||||
filterer: () => true,
|
||||
@@ -609,7 +609,7 @@ run_test('errors', () => {
|
||||
});
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Filter filterer is not a function (or missing).');
|
||||
blueslip.expect("error", "Filter filterer is not a function (or missing).");
|
||||
list_render.create(container, list, {
|
||||
filter: {
|
||||
},
|
||||
@@ -618,7 +618,7 @@ run_test('errors', () => {
|
||||
blueslip.reset();
|
||||
|
||||
container.html = () => {};
|
||||
blueslip.expect('error', 'List item is not a string: 999');
|
||||
blueslip.expect("error", "List item is not a string: 999");
|
||||
list_render.create(container, list, {
|
||||
modifier: () => 999,
|
||||
simplebar_container: scroll_container,
|
||||
@@ -626,19 +626,19 @@ run_test('errors', () => {
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
run_test('sort helpers', () => {
|
||||
run_test("sort helpers", () => {
|
||||
/*
|
||||
We mostly test our sorting helpers using the
|
||||
actual widget, but this test gets us a bit
|
||||
more line coverage.
|
||||
*/
|
||||
const alice2 = {name: 'alice', id: 2};
|
||||
const alice10 = {name: 'alice', id: 10};
|
||||
const bob2 = {name: 'bob', id: 2};
|
||||
const bob10 = {name: 'bob', id: 10};
|
||||
const alice2 = {name: "alice", id: 2};
|
||||
const alice10 = {name: "alice", id: 10};
|
||||
const bob2 = {name: "bob", id: 2};
|
||||
const bob10 = {name: "bob", id: 10};
|
||||
|
||||
const alpha_cmp = list_render.alphabetic_sort('name');
|
||||
const num_cmp = list_render.numeric_sort('id');
|
||||
const alpha_cmp = list_render.alphabetic_sort("name");
|
||||
const num_cmp = list_render.numeric_sort("id");
|
||||
|
||||
assert.equal(alpha_cmp(alice2, alice10), 0);
|
||||
assert.equal(alpha_cmp(alice2, bob2), -1);
|
||||
@@ -648,7 +648,7 @@ run_test('sort helpers', () => {
|
||||
assert.equal(num_cmp(alice10, bob2), 1);
|
||||
});
|
||||
|
||||
run_test('replace_list_data w/filter update', () => {
|
||||
run_test("replace_list_data w/filter update", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
container.html = () => {};
|
||||
@@ -657,8 +657,8 @@ run_test('replace_list_data w/filter update', () => {
|
||||
let num_updates = 0;
|
||||
|
||||
list_render.create(container, list, {
|
||||
name: 'replace-list',
|
||||
modifier: (n) => '(' + n.toString() + ')',
|
||||
name: "replace-list",
|
||||
modifier: (n) => "(" + n.toString() + ")",
|
||||
filter: {
|
||||
predicate: (n) => n % 2 === 0,
|
||||
onupdate: () => {
|
||||
@@ -672,27 +672,27 @@ run_test('replace_list_data w/filter update', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
'(2)(4)',
|
||||
"(2)(4)",
|
||||
);
|
||||
|
||||
const widget = list_render.get('replace-list');
|
||||
const widget = list_render.get("replace-list");
|
||||
widget.replace_list_data([5, 6, 7, 8]);
|
||||
|
||||
assert.equal(num_updates, 1);
|
||||
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
'(6)(8)',
|
||||
"(6)(8)",
|
||||
);
|
||||
});
|
||||
|
||||
run_test('opts.get_item', () => {
|
||||
run_test("opts.get_item", () => {
|
||||
const items = {};
|
||||
|
||||
items[1] = 'one';
|
||||
items[2] = 'two';
|
||||
items[3] = 'three';
|
||||
items[4] = 'four';
|
||||
items[1] = "one";
|
||||
items[2] = "two";
|
||||
items[3] = "three";
|
||||
items[4] = "four";
|
||||
|
||||
const list = [1, 2, 3, 4];
|
||||
|
||||
@@ -702,9 +702,9 @@ run_test('opts.get_item', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
list_render.get_filtered_items(
|
||||
'whatever', list, boring_opts,
|
||||
"whatever", list, boring_opts,
|
||||
),
|
||||
['one', 'two', 'three', 'four'],
|
||||
["one", "two", "three", "four"],
|
||||
);
|
||||
|
||||
const predicate = (item, value) => item.startsWith(value);
|
||||
@@ -718,9 +718,9 @@ run_test('opts.get_item', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
list_render.get_filtered_items(
|
||||
't', list, predicate_opts,
|
||||
"t", list, predicate_opts,
|
||||
),
|
||||
['two', 'three'],
|
||||
["two", "three"],
|
||||
);
|
||||
|
||||
const filterer_opts = {
|
||||
@@ -732,13 +732,13 @@ run_test('opts.get_item', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
list_render.get_filtered_items(
|
||||
't', list, filterer_opts,
|
||||
"t", list, filterer_opts,
|
||||
),
|
||||
['two', 'three'],
|
||||
["two", "three"],
|
||||
);
|
||||
});
|
||||
|
||||
run_test('render item', () => {
|
||||
run_test("render item", () => {
|
||||
const container = make_container();
|
||||
const scroll_container = make_scroll_container();
|
||||
const INITIAL_RENDER_COUNT = 80; // Keep this in sync with the actual code.
|
||||
@@ -768,11 +768,11 @@ run_test('render item', () => {
|
||||
|
||||
const list = [...Array(100).keys()];
|
||||
|
||||
let text = 'initial';
|
||||
let text = "initial";
|
||||
const get_item = (item) => ({text: `${text}: ${item}`, value: item});
|
||||
|
||||
const widget = list_render.create(container, list, {
|
||||
name: 'replace-list',
|
||||
name: "replace-list",
|
||||
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
|
||||
get_item: get_item,
|
||||
html_selector: (item) => `tr[data-item='${item}']`,
|
||||
@@ -780,13 +780,13 @@ run_test('render item', () => {
|
||||
});
|
||||
const item = INITIAL_RENDER_COUNT - 1;
|
||||
|
||||
assert(container.appended_data.html().includes('<tr data-item=2>initial: 2</tr>'));
|
||||
assert(container.appended_data.html().includes('<tr data-item=3>initial: 3</tr>'));
|
||||
text = 'updated';
|
||||
assert(container.appended_data.html().includes("<tr data-item=2>initial: 2</tr>"));
|
||||
assert(container.appended_data.html().includes("<tr data-item=3>initial: 3</tr>"));
|
||||
text = "updated";
|
||||
called = false;
|
||||
widget.render_item(INITIAL_RENDER_COUNT - 1);
|
||||
assert(called);
|
||||
assert(container.appended_data.html().includes('<tr data-item=2>initial: 2</tr>'));
|
||||
assert(container.appended_data.html().includes("<tr data-item=2>initial: 2</tr>"));
|
||||
assert(container.appended_data.html().includes(`<tr data-item=${item}>updated: ${item}</tr>`));
|
||||
|
||||
// Item 80 should not be in the rendered list. (0 indexed)
|
||||
@@ -799,19 +799,19 @@ run_test('render item', () => {
|
||||
|
||||
// Tests below this are for the corner cases, where we abort the rerender.
|
||||
|
||||
blueslip.expect('error', 'html_selector should be a function.');
|
||||
blueslip.expect("error", "html_selector should be a function.");
|
||||
list_render.create(container, list, {
|
||||
name: 'replace-list',
|
||||
name: "replace-list",
|
||||
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
|
||||
get_item: get_item,
|
||||
html_selector: 'hello world',
|
||||
html_selector: "hello world",
|
||||
simplebar_container: scroll_container,
|
||||
});
|
||||
blueslip.reset();
|
||||
|
||||
let get_item_called;
|
||||
const widget_2 = list_render.create(container, list, {
|
||||
name: 'replace-list',
|
||||
name: "replace-list",
|
||||
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
|
||||
get_item: (item) => {
|
||||
get_item_called = true;
|
||||
@@ -826,7 +826,7 @@ run_test('render item', () => {
|
||||
|
||||
let rendering_item = false;
|
||||
const widget_3 = list_render.create(container, list, {
|
||||
name: 'replace-list',
|
||||
name: "replace-list",
|
||||
modifier: (item) => rendering_item ? undefined : `${item}\n`,
|
||||
get_item: get_item,
|
||||
html_selector: (item) => `tr[data-item='${item}']`,
|
||||
@@ -835,7 +835,7 @@ run_test('render item', () => {
|
||||
// Once we have initially rendered the widget, change the
|
||||
// behavior of the modifier function.
|
||||
rendering_item = true;
|
||||
blueslip.expect('error', 'List item is not a string: undefined');
|
||||
blueslip.expect("error", "List item is not a string: undefined");
|
||||
widget_3.render_item(item);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
zrequire('hash_util');
|
||||
set_global('katex', zrequire('katex', 'katex/dist/katex.min.js'));
|
||||
set_global('marked', zrequire('marked', 'third/marked/lib/marked'));
|
||||
zrequire("hash_util");
|
||||
set_global("katex", zrequire("katex", "katex/dist/katex.min.js"));
|
||||
set_global("marked", zrequire("marked", "third/marked/lib/marked"));
|
||||
|
||||
zrequire('fenced_code');
|
||||
zrequire('stream_data');
|
||||
zrequire('people');
|
||||
zrequire('user_groups');
|
||||
const emoji_codes = zrequire('emoji_codes', 'generated/emoji/emoji_codes.json');
|
||||
zrequire('emoji');
|
||||
zrequire('message_store');
|
||||
const markdown_config = zrequire('markdown_config');
|
||||
zrequire('markdown');
|
||||
zrequire("fenced_code");
|
||||
zrequire("stream_data");
|
||||
zrequire("people");
|
||||
zrequire("user_groups");
|
||||
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
|
||||
zrequire("emoji");
|
||||
zrequire("message_store");
|
||||
const markdown_config = zrequire("markdown_config");
|
||||
zrequire("markdown");
|
||||
|
||||
set_global('location', {
|
||||
origin: 'http://zulip.zulipdev.com',
|
||||
set_global("location", {
|
||||
origin: "http://zulip.zulipdev.com",
|
||||
});
|
||||
|
||||
set_global('moment', require('moment-timezone'));
|
||||
set_global("moment", require("moment-timezone"));
|
||||
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
realm_users: [],
|
||||
realm_emoji: {
|
||||
1: {id: 1,
|
||||
name: 'burrito',
|
||||
source_url: '/static/generated/emoji/images/emoji/burrito.png',
|
||||
name: "burrito",
|
||||
source_url: "/static/generated/emoji/images/emoji/burrito.png",
|
||||
deactivated: false,
|
||||
},
|
||||
},
|
||||
@@ -47,49 +47,49 @@ set_global('page_params', {
|
||||
function Image() {
|
||||
return {};
|
||||
}
|
||||
set_global('Image', Image);
|
||||
set_global("Image", Image);
|
||||
emoji.initialize();
|
||||
|
||||
const doc = "";
|
||||
set_global('document', doc);
|
||||
set_global("document", doc);
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
const cordelia = {
|
||||
full_name: 'Cordelia Lear',
|
||||
full_name: "Cordelia Lear",
|
||||
user_id: 101,
|
||||
email: 'cordelia@zulip.com',
|
||||
email: "cordelia@zulip.com",
|
||||
};
|
||||
people.add_active_user(cordelia);
|
||||
|
||||
people.add_active_user({
|
||||
full_name: 'Leo',
|
||||
full_name: "Leo",
|
||||
user_id: 102,
|
||||
email: 'leo@zulip.com',
|
||||
email: "leo@zulip.com",
|
||||
});
|
||||
|
||||
people.add_active_user({
|
||||
full_name: 'Bobby <h1>Tables</h1>',
|
||||
full_name: "Bobby <h1>Tables</h1>",
|
||||
user_id: 103,
|
||||
email: 'bobby@zulip.com',
|
||||
email: "bobby@zulip.com",
|
||||
});
|
||||
|
||||
people.add_active_user({
|
||||
full_name: 'Mark Twin',
|
||||
full_name: "Mark Twin",
|
||||
user_id: 104,
|
||||
email: 'twin1@zulip.com',
|
||||
email: "twin1@zulip.com",
|
||||
});
|
||||
|
||||
people.add_active_user({
|
||||
full_name: 'Mark Twin',
|
||||
full_name: "Mark Twin",
|
||||
user_id: 105,
|
||||
email: 'twin2@zulip.com',
|
||||
email: "twin2@zulip.com",
|
||||
});
|
||||
|
||||
people.add_active_user({
|
||||
full_name: 'Brother of Bobby|123',
|
||||
full_name: "Brother of Bobby|123",
|
||||
user_id: 106,
|
||||
email: 'bobby2@zulip.com',
|
||||
email: "bobby2@zulip.com",
|
||||
});
|
||||
|
||||
people.add_active_user({
|
||||
@@ -136,37 +136,37 @@ global.user_groups.add(amp_group);
|
||||
const stream_data = global.stream_data;
|
||||
const denmark = {
|
||||
subscribed: false,
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
color: "blue",
|
||||
name: "Denmark",
|
||||
stream_id: 1,
|
||||
is_muted: true,
|
||||
};
|
||||
const social = {
|
||||
subscribed: true,
|
||||
color: 'red',
|
||||
name: 'social',
|
||||
color: "red",
|
||||
name: "social",
|
||||
stream_id: 2,
|
||||
is_muted: false,
|
||||
invite_only: true,
|
||||
};
|
||||
const edgecase_stream = {
|
||||
subscribed: true,
|
||||
color: 'green',
|
||||
name: 'Bobby <h1>Tables</h1>',
|
||||
color: "green",
|
||||
name: "Bobby <h1>Tables</h1>",
|
||||
stream_id: 3,
|
||||
is_muted: false,
|
||||
};
|
||||
const edgecase_stream_2 = {
|
||||
subscribed: true,
|
||||
color: 'yellow',
|
||||
name: 'Bobby <h1',
|
||||
color: "yellow",
|
||||
name: "Bobby <h1",
|
||||
stream_id: 4,
|
||||
is_muted: false,
|
||||
};
|
||||
const amp_stream = {
|
||||
subscribed: true,
|
||||
color: 'orange',
|
||||
name: '& & &',
|
||||
color: "orange",
|
||||
name: "& & &",
|
||||
stream_id: 5,
|
||||
is_muted: false,
|
||||
};
|
||||
@@ -180,8 +180,8 @@ stream_data.add_sub(amp_stream);
|
||||
|
||||
// Check the default behavior of fenced code blocks
|
||||
// works properly before markdown is initialized.
|
||||
run_test('fenced_block_defaults', () => {
|
||||
const input = '\n```\nfenced code\n```\n\nand then after\n';
|
||||
run_test("fenced_block_defaults", () => {
|
||||
const input = "\n```\nfenced code\n```\n\nand then after\n";
|
||||
const expected = '\n\n<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n\nand then after\n\n';
|
||||
const output = fenced_code.process_fenced_code(input);
|
||||
assert.equal(output, expected);
|
||||
@@ -192,9 +192,9 @@ markdown.initialize(
|
||||
markdown_config.get_helpers(),
|
||||
);
|
||||
|
||||
const markdown_data = global.read_fixture_data('markdown_test_cases.json');
|
||||
const markdown_data = global.read_fixture_data("markdown_test_cases.json");
|
||||
|
||||
run_test('markdown_detection', () => {
|
||||
run_test("markdown_detection", () => {
|
||||
const no_markup = [
|
||||
"This is a plaintext message",
|
||||
"This is a plaintext: message",
|
||||
@@ -240,7 +240,7 @@ run_test('markdown_detection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('marked_shared', () => {
|
||||
run_test("marked_shared", () => {
|
||||
const tests = markdown_data.regular_tests;
|
||||
|
||||
tests.forEach((test) => {
|
||||
@@ -266,154 +266,154 @@ run_test('marked_shared', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('message_flags', () => {
|
||||
let message = {raw_content: '@**Leo**'};
|
||||
run_test("message_flags", () => {
|
||||
let message = {raw_content: "@**Leo**"};
|
||||
markdown.apply_markdown(message);
|
||||
assert(!message.mentioned);
|
||||
assert(!message.mentioned_me_directly);
|
||||
|
||||
message = {raw_content: '@**Cordelia Lear**'};
|
||||
message = {raw_content: "@**Cordelia Lear**"};
|
||||
markdown.apply_markdown(message);
|
||||
assert(message.mentioned);
|
||||
assert(message.mentioned_me_directly);
|
||||
|
||||
message = {raw_content: '@**all**'};
|
||||
message = {raw_content: "@**all**"};
|
||||
markdown.apply_markdown(message);
|
||||
assert(message.mentioned);
|
||||
assert(!message.mentioned_me_directly);
|
||||
});
|
||||
|
||||
run_test('marked', () => {
|
||||
run_test("marked", () => {
|
||||
const test_cases = [
|
||||
{input: 'hello', expected: '<p>hello</p>'},
|
||||
{input: 'hello there', expected: '<p>hello there</p>'},
|
||||
{input: 'hello **bold** for you', expected: '<p>hello <strong>bold</strong> for you</p>'},
|
||||
{input: 'hello ***foo*** for you', expected: '<p>hello <strong><em>foo</em></strong> for you</p>'},
|
||||
{input: '__hello__', expected: '<p>__hello__</p>'},
|
||||
{input: '\n```\nfenced code\n```\n\nand then after\n',
|
||||
{input: "hello", expected: "<p>hello</p>"},
|
||||
{input: "hello there", expected: "<p>hello there</p>"},
|
||||
{input: "hello **bold** for you", expected: "<p>hello <strong>bold</strong> for you</p>"},
|
||||
{input: "hello ***foo*** for you", expected: "<p>hello <strong><em>foo</em></strong> for you</p>"},
|
||||
{input: "__hello__", expected: "<p>__hello__</p>"},
|
||||
{input: "\n```\nfenced code\n```\n\nand then after\n",
|
||||
expected: '<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n<p>and then after</p>'},
|
||||
{input: '\n```\n fenced code trailing whitespace \n```\n\nand then after\n',
|
||||
{input: "\n```\n fenced code trailing whitespace \n```\n\nand then after\n",
|
||||
expected: '<div class="codehilite"><pre><span></span><code> fenced code trailing whitespace\n</code></pre></div>\n\n\n<p>and then after</p>'},
|
||||
{input: '* a\n* list \n* here',
|
||||
expected: '<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>'},
|
||||
{input: '\n```c#\nfenced code special\n```\n\nand then after\n',
|
||||
{input: "* a\n* list \n* here",
|
||||
expected: "<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>"},
|
||||
{input: "\n```c#\nfenced code special\n```\n\nand then after\n",
|
||||
expected: '<div class="codehilite"><pre><span></span><code>fenced code special\n</code></pre></div>\n\n\n<p>and then after</p>'},
|
||||
{input: '\n```vb.net\nfenced code dot\n```\n\nand then after\n',
|
||||
{input: "\n```vb.net\nfenced code dot\n```\n\nand then after\n",
|
||||
expected: '<div class="codehilite"><pre><span></span><code>fenced code dot\n</code></pre></div>\n\n\n<p>and then after</p>'},
|
||||
{input: 'Some text first\n* a\n* list \n* here\n\nand then after',
|
||||
expected: '<p>Some text first</p>\n<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>\n<p>and then after</p>'},
|
||||
{input: '1. an\n2. ordered \n3. list',
|
||||
expected: '<ol>\n<li>an</li>\n<li>ordered </li>\n<li>list</li>\n</ol>'},
|
||||
{input: '\n~~~quote\nquote this for me\n~~~\nthanks\n',
|
||||
expected: '<blockquote>\n<p>quote this for me</p>\n</blockquote>\n<p>thanks</p>'},
|
||||
{input: 'This is a @**CordeLIA Lear** mention',
|
||||
{input: "Some text first\n* a\n* list \n* here\n\nand then after",
|
||||
expected: "<p>Some text first</p>\n<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>\n<p>and then after</p>"},
|
||||
{input: "1. an\n2. ordered \n3. list",
|
||||
expected: "<ol>\n<li>an</li>\n<li>ordered </li>\n<li>list</li>\n</ol>"},
|
||||
{input: "\n~~~quote\nquote this for me\n~~~\nthanks\n",
|
||||
expected: "<blockquote>\n<p>quote this for me</p>\n</blockquote>\n<p>thanks</p>"},
|
||||
{input: "This is a @**CordeLIA Lear** mention",
|
||||
expected: '<p>This is a <span class="user-mention" data-user-id="101">@Cordelia Lear</span> mention</p>'},
|
||||
{input: 'These @ @**** are not mentions',
|
||||
expected: '<p>These @ @<em>**</em> are not mentions</p>'},
|
||||
{input: 'These # #**** are not mentions',
|
||||
expected: '<p>These # #<em>**</em> are not mentions</p>'},
|
||||
{input: 'These @* are not mentions',
|
||||
expected: '<p>These @* are not mentions</p>'},
|
||||
{input: 'These #* #*** are also not mentions',
|
||||
expected: '<p>These #* #*** are also not mentions</p>'},
|
||||
{input: 'This is a #**Denmark** stream link',
|
||||
{input: "These @ @**** are not mentions",
|
||||
expected: "<p>These @ @<em>**</em> are not mentions</p>"},
|
||||
{input: "These # #**** are not mentions",
|
||||
expected: "<p>These # #<em>**</em> are not mentions</p>"},
|
||||
{input: "These @* are not mentions",
|
||||
expected: "<p>These @* are not mentions</p>"},
|
||||
{input: "These #* #*** are also not mentions",
|
||||
expected: "<p>These #* #*** are also not mentions</p>"},
|
||||
{input: "This is a #**Denmark** stream link",
|
||||
expected: '<p>This is a <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> stream link</p>'},
|
||||
{input: 'This is #**Denmark** and #**social** stream links',
|
||||
{input: "This is #**Denmark** and #**social** stream links",
|
||||
expected: '<p>This is <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> and <a class="stream" data-stream-id="2" href="/#narrow/stream/2-social">#social</a> stream links</p>'},
|
||||
{input: 'And this is a #**wrong** stream link',
|
||||
expected: '<p>And this is a #**wrong** stream link</p>'},
|
||||
{input: 'This is a #**Denmark>some topic** stream_topic link',
|
||||
{input: "And this is a #**wrong** stream link",
|
||||
expected: "<p>And this is a #**wrong** stream link</p>"},
|
||||
{input: "This is a #**Denmark>some topic** stream_topic link",
|
||||
expected: '<p>This is a <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> stream_topic link</p>'},
|
||||
{input: 'This has two links: #**Denmark>some topic** and #**social>other topic**.',
|
||||
{input: "This has two links: #**Denmark>some topic** and #**social>other topic**.",
|
||||
expected: '<p>This has two links: <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> and <a class="stream-topic" data-stream-id="2" href="/#narrow/stream/2-social/topic/other.20topic">#social > other topic</a>.</p>'},
|
||||
{input: 'This is not a #**Denmark>** stream_topic link',
|
||||
expected: '<p>This is not a #**Denmark>** stream_topic link</p>'},
|
||||
{input: 'mmm...:burrito:s',
|
||||
{input: "This is not a #**Denmark>** stream_topic link",
|
||||
expected: "<p>This is not a #**Denmark>** stream_topic link</p>"},
|
||||
{input: "mmm...:burrito:s",
|
||||
expected: '<p>mmm...<img alt=":burrito:" class="emoji" src="/static/generated/emoji/images/emoji/burrito.png" title="burrito">s</p>'},
|
||||
{input: 'This is an :poop: message',
|
||||
{input: "This is an :poop: message",
|
||||
expected: '<p>This is an <span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span> message</p>'},
|
||||
{input: "\ud83d\udca9",
|
||||
expected: '<p><span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span></p>'},
|
||||
{input: '\u{1f6b2}',
|
||||
expected: '<p>\u{1f6b2}</p>' },
|
||||
{input: 'Silent mention: @_**Cordelia Lear**',
|
||||
{input: "\u{1f6b2}",
|
||||
expected: "<p>\u{1f6b2}</p>" },
|
||||
{input: "Silent mention: @_**Cordelia Lear**",
|
||||
expected: '<p>Silent mention: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>'},
|
||||
{input: '> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**',
|
||||
{input: "> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**",
|
||||
expected: '<blockquote>\n<p>Mention in quote: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>\n</blockquote>\n<p>Mention outside quote: <span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
|
||||
// Test only those realm filters which don't return True for
|
||||
// `contains_backend_only_syntax()`. Those which return True
|
||||
// are tested separately.
|
||||
{input: 'This is a realm filter #1234 with text after it',
|
||||
{input: "This is a realm filter #1234 with text after it",
|
||||
expected: '<p>This is a realm filter <a href="https://trac.example.com/ticket/1234" title="https://trac.example.com/ticket/1234">#1234</a> with text after it</p>'},
|
||||
{input: '#1234is not a realm filter.',
|
||||
expected: '<p>#1234is not a realm filter.</p>'},
|
||||
{input: 'A pattern written as #1234is not a realm filter.',
|
||||
expected: '<p>A pattern written as #1234is not a realm filter.</p>'},
|
||||
{input: 'This is a realm filter with ZGROUP_123:45 groups',
|
||||
{input: "#1234is not a realm filter.",
|
||||
expected: "<p>#1234is not a realm filter.</p>"},
|
||||
{input: "A pattern written as #1234is not a realm filter.",
|
||||
expected: "<p>A pattern written as #1234is not a realm filter.</p>"},
|
||||
{input: "This is a realm filter with ZGROUP_123:45 groups",
|
||||
expected: '<p>This is a realm filter with <a href="https://zone_45.zulip.net/ticket/123" title="https://zone_45.zulip.net/ticket/123">ZGROUP_123:45</a> groups</p>'},
|
||||
{input: 'Test *italic*',
|
||||
expected: '<p>Test <em>italic</em></p>'},
|
||||
{input: 'T\n#**Denmark**',
|
||||
{input: "Test *italic*",
|
||||
expected: "<p>Test <em>italic</em></p>"},
|
||||
{input: "T\n#**Denmark**",
|
||||
expected: '<p>T<br>\n<a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a></p>'},
|
||||
{input: 'T\n@**Cordelia Lear**',
|
||||
{input: "T\n@**Cordelia Lear**",
|
||||
expected: '<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
|
||||
{input: '@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.',
|
||||
{input: "@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.",
|
||||
expected: '<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>'},
|
||||
{input: '@**Invalid User|1234**',
|
||||
expected: '<p>@**Invalid User|1234**</p>'},
|
||||
{input: '@**Cordelia LeAR|103** has a wrong user_id.',
|
||||
expected: '<p>@**Cordelia LeAR|103** has a wrong user_id.</p>'},
|
||||
{input: '@**Brother of Bobby|123** is really the full name.',
|
||||
{input: "@**Invalid User|1234**",
|
||||
expected: "<p>@**Invalid User|1234**</p>"},
|
||||
{input: "@**Cordelia LeAR|103** has a wrong user_id.",
|
||||
expected: "<p>@**Cordelia LeAR|103** has a wrong user_id.</p>"},
|
||||
{input: "@**Brother of Bobby|123** is really the full name.",
|
||||
expected: '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span> is really the full name.</p>'},
|
||||
{input: '@**Brother of Bobby|123|106**',
|
||||
{input: "@**Brother of Bobby|123|106**",
|
||||
expected: '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span></p>'},
|
||||
{input: 'T\n@hamletcharacters',
|
||||
expected: '<p>T<br>\n@hamletcharacters</p>'},
|
||||
{input: 'T\n@*hamletcharacters*',
|
||||
{input: "T\n@hamletcharacters",
|
||||
expected: "<p>T<br>\n@hamletcharacters</p>"},
|
||||
{input: "T\n@*hamletcharacters*",
|
||||
expected: '<p>T<br>\n<span class="user-group-mention" data-user-group-id="1">@hamletcharacters</span></p>'},
|
||||
{input: 'T\n@*notagroup*',
|
||||
expected: '<p>T<br>\n@*notagroup*</p>'},
|
||||
{input: 'T\n@*backend*',
|
||||
{input: "T\n@*notagroup*",
|
||||
expected: "<p>T<br>\n@*notagroup*</p>"},
|
||||
{input: "T\n@*backend*",
|
||||
expected: '<p>T<br>\n<span class="user-group-mention" data-user-group-id="2">@Backend</span></p>'},
|
||||
{input: '@*notagroup*',
|
||||
expected: '<p>@*notagroup*</p>'},
|
||||
{input: 'This is a realm filter `hello` with text after it',
|
||||
expected: '<p>This is a realm filter <code>hello</code> with text after it</p>'},
|
||||
{input: "@*notagroup*",
|
||||
expected: "<p>@*notagroup*</p>"},
|
||||
{input: "This is a realm filter `hello` with text after it",
|
||||
expected: "<p>This is a realm filter <code>hello</code> with text after it</p>"},
|
||||
// Test the emoticon conversion
|
||||
{input: ':)',
|
||||
expected: '<p>:)</p>'},
|
||||
{input: ':)',
|
||||
{input: ":)",
|
||||
expected: "<p>:)</p>"},
|
||||
{input: ":)",
|
||||
expected: '<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>',
|
||||
translate_emoticons: true},
|
||||
// Test HTML Escape in Custom Zulip Rules
|
||||
{input: '@**<h1>The Rogue One</h1>**',
|
||||
expected: '<p>@**<h1>The Rogue One</h1>**</p>'},
|
||||
{input: '#**<h1>The Rogue One</h1>**',
|
||||
expected: '<p>#**<h1>The Rogue One</h1>**</p>'},
|
||||
{input: ':<h1>The Rogue One</h1>:',
|
||||
expected: '<p>:<h1>The Rogue One</h1>:</p>'},
|
||||
{input: '@**O\'Connell**',
|
||||
expected: '<p>@**O'Connell**</p>'},
|
||||
{input: '@*Bobby <h1>Tables</h1>*',
|
||||
{input: "@**<h1>The Rogue One</h1>**",
|
||||
expected: "<p>@**<h1>The Rogue One</h1>**</p>"},
|
||||
{input: "#**<h1>The Rogue One</h1>**",
|
||||
expected: "<p>#**<h1>The Rogue One</h1>**</p>"},
|
||||
{input: ":<h1>The Rogue One</h1>:",
|
||||
expected: "<p>:<h1>The Rogue One</h1>:</p>"},
|
||||
{input: "@**O'Connell**",
|
||||
expected: "<p>@**O'Connell**</p>"},
|
||||
{input: "@*Bobby <h1>Tables</h1>*",
|
||||
expected: '<p><span class="user-group-mention" data-user-group-id="3">@Bobby <h1>Tables</h1></span></p>'},
|
||||
{input: '@*& & &amp;*',
|
||||
{input: "@*& & &amp;*",
|
||||
expected: '<p><span class="user-group-mention" data-user-group-id="4">@& & &amp;</span></p>'},
|
||||
{input: '@**Bobby <h1>Tables</h1>**',
|
||||
{input: "@**Bobby <h1>Tables</h1>**",
|
||||
expected: '<p><span class="user-mention" data-user-id="103">@Bobby <h1>Tables</h1></span></p>'},
|
||||
{input: '@**& & &amp;**',
|
||||
{input: "@**& & &amp;**",
|
||||
expected: '<p><span class="user-mention" data-user-id="107">@& & &amp;</span></p>'},
|
||||
{input: '#**Bobby <h1>Tables</h1>**',
|
||||
{input: "#**Bobby <h1>Tables</h1>**",
|
||||
expected: '<p><a class="stream-topic" data-stream-id="4" href="/#narrow/stream/4-Bobby-.3Ch1/topic/Tables.3C.2Fh1.3E">#Bobby <h1 > Tables</h1></a></p>'},
|
||||
{input: '#**& & &amp;**',
|
||||
{input: "#**& & &amp;**",
|
||||
expected: '<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#& & &amp;</a></p>'},
|
||||
{input: '#**& & &amp;>& & &amp;**',
|
||||
{input: "#**& & &amp;>& & &amp;**",
|
||||
expected: '<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B/topic/.26.20.26.20.26amp.3B">#& & &amp; > & & &amp;</a></p>'},
|
||||
];
|
||||
|
||||
// We remove one of the unicode emoji we put as input in one of the test
|
||||
// cases (U+1F6B2), to verify that we display the emoji as it was input if it
|
||||
// isn't present in emoji_codes.codepoint_to_name.
|
||||
delete emoji_codes.codepoint_to_name['1f6b2'];
|
||||
delete emoji_codes.codepoint_to_name["1f6b2"];
|
||||
|
||||
test_cases.forEach((test_case) => {
|
||||
// Disable emoji conversion by default.
|
||||
@@ -429,44 +429,44 @@ run_test('marked', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('topic_links', () => {
|
||||
let message = {type: 'stream', topic: "No links here"};
|
||||
run_test("topic_links", () => {
|
||||
let message = {type: "stream", topic: "No links here"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 0);
|
||||
|
||||
message = {type: 'stream', topic: "One #123 link here"};
|
||||
message = {type: "stream", topic: "One #123 link here"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 1);
|
||||
assert.equal(message.topic_links[0], "https://trac.example.com/ticket/123");
|
||||
|
||||
message = {type: 'stream', topic: "Two #123 #456 link here"};
|
||||
message = {type: "stream", topic: "Two #123 #456 link here"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 2);
|
||||
assert.equal(message.topic_links[0], "https://trac.example.com/ticket/123");
|
||||
assert.equal(message.topic_links[1], "https://trac.example.com/ticket/456");
|
||||
|
||||
message = {type: 'stream', topic: "New ZBUG_123 link here"};
|
||||
message = {type: "stream", topic: "New ZBUG_123 link here"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 1);
|
||||
assert.equal(message.topic_links[0], "https://trac2.zulip.net/ticket/123");
|
||||
|
||||
message = {type: 'stream', topic: "New ZBUG_123 with #456 link here"};
|
||||
message = {type: "stream", topic: "New ZBUG_123 with #456 link here"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 2);
|
||||
assert(message.topic_links.includes("https://trac2.zulip.net/ticket/123"));
|
||||
assert(message.topic_links.includes("https://trac.example.com/ticket/456"));
|
||||
|
||||
message = {type: 'stream', topic: "One ZGROUP_123:45 link here"};
|
||||
message = {type: "stream", topic: "One ZGROUP_123:45 link here"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 1);
|
||||
assert.equal(message.topic_links[0], "https://zone_45.zulip.net/ticket/123");
|
||||
|
||||
message = {type: 'stream', topic: "Hello https://google.com"};
|
||||
message = {type: "stream", topic: "Hello https://google.com"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 1);
|
||||
assert.equal(message.topic_links[0], "https://google.com");
|
||||
|
||||
message = {type: 'stream', topic: "#456 https://google.com https://github.com"};
|
||||
message = {type: "stream", topic: "#456 https://google.com https://github.com"};
|
||||
markdown.add_topic_links(message);
|
||||
assert.equal(message.topic_links.length, 3);
|
||||
assert(message.topic_links.includes("https://google.com"));
|
||||
@@ -478,7 +478,7 @@ run_test('topic_links', () => {
|
||||
assert.equal(message.topic_links.length, 0);
|
||||
});
|
||||
|
||||
run_test('message_flags', () => {
|
||||
run_test("message_flags", () => {
|
||||
let input = "/me is testing this";
|
||||
let message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
@@ -550,47 +550,47 @@ run_test('message_flags', () => {
|
||||
assert.equal(message.mentioned, false);
|
||||
});
|
||||
|
||||
run_test('backend_only_realm_filters', () => {
|
||||
run_test("backend_only_realm_filters", () => {
|
||||
const backend_only_realm_filters = [
|
||||
'Here is the PR-#123.',
|
||||
'Function abc() was introduced in (PR)#123.',
|
||||
"Here is the PR-#123.",
|
||||
"Function abc() was introduced in (PR)#123.",
|
||||
];
|
||||
backend_only_realm_filters.forEach((content) => {
|
||||
assert.equal(markdown.contains_backend_only_syntax(content), true);
|
||||
});
|
||||
});
|
||||
|
||||
run_test('python_to_js_filter', () => {
|
||||
run_test("python_to_js_filter", () => {
|
||||
// The only way to reach python_to_js_filter is indirectly, hence the call
|
||||
// to update_realm_filter_rules.
|
||||
markdown.update_realm_filter_rules([['/a(?im)a/g'], ['/a(?L)a/g']]);
|
||||
markdown.update_realm_filter_rules([["/a(?im)a/g"], ["/a(?L)a/g"]]);
|
||||
let actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
let expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
// Test case with multiple replacements.
|
||||
markdown.update_realm_filter_rules([['#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)', 'http://google.com']]);
|
||||
markdown.update_realm_filter_rules([["#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)", "http://google.com"]]);
|
||||
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
expected_value = [/#cf([0-9]+)([A-Z][0-9A-Z]*)(?![\w])/g];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
// Test incorrect syntax.
|
||||
blueslip.expect('error', 'python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group');
|
||||
markdown.update_realm_filter_rules([['!@#@(!#&((!&(@#(', 'http://google.com']]);
|
||||
blueslip.expect("error", "python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group");
|
||||
markdown.update_realm_filter_rules([["!@#@(!#&((!&(@#(", "http://google.com"]]);
|
||||
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
expected_value = [];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
});
|
||||
|
||||
run_test('katex_throws_unexpected_exceptions', () => {
|
||||
katex.renderToString = function () { throw new Error('some-exception'); };
|
||||
blueslip.expect('error', 'Error: some-exception');
|
||||
const message = { raw_content: '$$a$$' };
|
||||
run_test("katex_throws_unexpected_exceptions", () => {
|
||||
katex.renderToString = function () { throw new Error("some-exception"); };
|
||||
blueslip.expect("error", "Error: some-exception");
|
||||
const message = { raw_content: "$$a$$" };
|
||||
markdown.apply_markdown(message);
|
||||
});
|
||||
|
||||
run_test('translate_emoticons_to_names', () => {
|
||||
run_test("translate_emoticons_to_names", () => {
|
||||
// Simple test
|
||||
const test_text = 'Testing :)';
|
||||
const expected = 'Testing :slight_smile:';
|
||||
const test_text = "Testing :)";
|
||||
const expected = "Testing :slight_smile:";
|
||||
const result = markdown.translate_emoticons_to_names(test_text);
|
||||
assert.equal(expected, result);
|
||||
|
||||
@@ -598,16 +598,16 @@ run_test('translate_emoticons_to_names', () => {
|
||||
// The following code loops over the test cases and each emoticon conversion
|
||||
// to generate multiple test cases.
|
||||
const testcases = [
|
||||
{name: 'only emoticon', original: '<original>', expected: '<converted>'},
|
||||
{name: 'space at start', original: ' <original>', expected: ' <converted>'},
|
||||
{name: 'space at end', original: '<original> ', expected: '<converted> '},
|
||||
{name: 'symbol at end', original: '<original>!', expected: '<converted>!'},
|
||||
{name: 'symbol at start', original: 'Hello,<original>', expected: 'Hello,<converted>'},
|
||||
{name: 'after a word', original: 'Hello<original>', expected: 'Hello<original>'},
|
||||
{name: 'between words', original: 'Hello<original>World', expected: 'Hello<original>World'},
|
||||
{name: 'end of sentence', original: 'End of sentence. <original>', expected: 'End of sentence. <converted>'},
|
||||
{name: 'between symbols', original: 'Hello.<original>! World.', expected: 'Hello.<original>! World.'},
|
||||
{name: 'before end of sentence', original: 'Hello <original>!', expected: 'Hello <converted>!'},
|
||||
{name: "only emoticon", original: "<original>", expected: "<converted>"},
|
||||
{name: "space at start", original: " <original>", expected: " <converted>"},
|
||||
{name: "space at end", original: "<original> ", expected: "<converted> "},
|
||||
{name: "symbol at end", original: "<original>!", expected: "<converted>!"},
|
||||
{name: "symbol at start", original: "Hello,<original>", expected: "Hello,<converted>"},
|
||||
{name: "after a word", original: "Hello<original>", expected: "Hello<original>"},
|
||||
{name: "between words", original: "Hello<original>World", expected: "Hello<original>World"},
|
||||
{name: "end of sentence", original: "End of sentence. <original>", expected: "End of sentence. <converted>"},
|
||||
{name: "between symbols", original: "Hello.<original>! World.", expected: "Hello.<original>! World."},
|
||||
{name: "before end of sentence", original: "Hello <original>!", expected: "Hello <converted>!"},
|
||||
];
|
||||
for (const [shortcut, full_name] of Object.entries(emoji_codes.emoticon_conversions)) {
|
||||
for (const t of testcases) {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
set_global('document', null);
|
||||
set_global('page_params', {
|
||||
set_global("document", null);
|
||||
set_global("page_params", {
|
||||
realm_community_topic_editing_limit_seconds: 86400,
|
||||
});
|
||||
|
||||
global.stub_out_jquery();
|
||||
|
||||
set_global('XDate', zrequire('XDate', 'xdate/src/xdate'));
|
||||
zrequire('message_edit');
|
||||
set_global("XDate", zrequire("XDate", "xdate/src/xdate"));
|
||||
zrequire("message_edit");
|
||||
|
||||
const get_editability = message_edit.get_editability;
|
||||
const editability_types = message_edit.editability_types;
|
||||
|
||||
run_test('get_editability', () => {
|
||||
run_test("get_editability", () => {
|
||||
// You can't edit a null message
|
||||
assert.equal(get_editability(null), editability_types.NO);
|
||||
// You can't edit a message you didn't send
|
||||
@@ -62,16 +62,16 @@ run_test('get_editability', () => {
|
||||
assert.equal(get_editability(message, 55), editability_types.FULL);
|
||||
// It's been 60 > 45+10 since message.timestamp. When realm_allow_message_editing
|
||||
// is true, we can edit the topic if there is one.
|
||||
message.type = 'stream';
|
||||
message.type = "stream";
|
||||
assert.equal(get_editability(message, 45), editability_types.TOPIC_ONLY);
|
||||
message.type = 'private';
|
||||
message.type = "private";
|
||||
assert.equal(get_editability(message, 45), editability_types.NO_LONGER);
|
||||
// If we don't pass a second argument, treat it as 0
|
||||
assert.equal(get_editability(message), editability_types.NO_LONGER);
|
||||
|
||||
message = {
|
||||
sent_by_me: false,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
global.page_params = {
|
||||
realm_allow_community_topic_editing: true,
|
||||
@@ -103,7 +103,7 @@ run_test('get_editability', () => {
|
||||
assert.equal(message_edit.is_topic_editable(message), false);
|
||||
});
|
||||
|
||||
run_test('get_deletability', () => {
|
||||
run_test("get_deletability", () => {
|
||||
global.page_params = {
|
||||
is_admin: true,
|
||||
realm_allow_message_deleting: false,
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
zrequire('message_events');
|
||||
zrequire('message_store');
|
||||
zrequire('muting');
|
||||
zrequire('people');
|
||||
zrequire('recent_senders');
|
||||
zrequire('stream_data');
|
||||
zrequire('stream_topic_history');
|
||||
zrequire('unread');
|
||||
zrequire("message_events");
|
||||
zrequire("message_store");
|
||||
zrequire("muting");
|
||||
zrequire("people");
|
||||
zrequire("recent_senders");
|
||||
zrequire("stream_data");
|
||||
zrequire("stream_topic_history");
|
||||
zrequire("unread");
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('alert_words', {});
|
||||
set_global('condense', {});
|
||||
set_global('current_msg_list', {});
|
||||
set_global('message_edit', {});
|
||||
set_global('message_list', {});
|
||||
set_global('notifications', {});
|
||||
set_global('page_params', {});
|
||||
set_global('pm_list', {});
|
||||
set_global('stream_list', {});
|
||||
set_global('unread_ui', {});
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("alert_words", {});
|
||||
set_global("condense", {});
|
||||
set_global("current_msg_list", {});
|
||||
set_global("message_edit", {});
|
||||
set_global("message_list", {});
|
||||
set_global("notifications", {});
|
||||
set_global("page_params", {});
|
||||
set_global("pm_list", {});
|
||||
set_global("stream_list", {});
|
||||
set_global("unread_ui", {});
|
||||
|
||||
alert_words.process_message = () => {};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 32,
|
||||
full_name: 'Alice Patel',
|
||||
full_name: "Alice Patel",
|
||||
};
|
||||
|
||||
people.add_active_user(alice);
|
||||
|
||||
const denmark = {
|
||||
subscribed: false,
|
||||
name: 'Denmark',
|
||||
name: "Denmark",
|
||||
stream_id: 101,
|
||||
};
|
||||
stream_data.add_sub(denmark);
|
||||
@@ -40,7 +40,7 @@ function test_helper(side_effects) {
|
||||
const events = [];
|
||||
|
||||
for (const side_effect of side_effects) {
|
||||
const parts = side_effect.split('.');
|
||||
const parts = side_effect.split(".");
|
||||
const module = parts[0];
|
||||
const field = parts[1];
|
||||
|
||||
@@ -58,15 +58,15 @@ function test_helper(side_effects) {
|
||||
return self;
|
||||
}
|
||||
|
||||
run_test('update_messages', () => {
|
||||
run_test("update_messages", () => {
|
||||
const original_message = {
|
||||
id: 111,
|
||||
display_recipient: denmark.name,
|
||||
flags: ['mentioned'],
|
||||
flags: ["mentioned"],
|
||||
sender_id: alice.user_id,
|
||||
stream_id: denmark.stream_id,
|
||||
topic: 'lunch',
|
||||
type: 'stream',
|
||||
topic: "lunch",
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
message_store.add_message_metadata(original_message);
|
||||
@@ -77,7 +77,7 @@ run_test('update_messages', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
stream_topic_history.get_recent_topic_names(denmark.stream_id),
|
||||
['lunch'],
|
||||
["lunch"],
|
||||
);
|
||||
|
||||
unread.update_message_for_mention(original_message);
|
||||
@@ -87,15 +87,15 @@ run_test('update_messages', () => {
|
||||
{
|
||||
message_id: original_message.id,
|
||||
flags: [],
|
||||
orig_content: 'old stuff',
|
||||
content: '**new content**',
|
||||
rendered_content: '<b>new content</b>',
|
||||
orig_content: "old stuff",
|
||||
content: "**new content**",
|
||||
rendered_content: "<b>new content</b>",
|
||||
},
|
||||
];
|
||||
|
||||
current_msg_list.get_row = (message_id) => {
|
||||
assert.equal(message_id, 111);
|
||||
return ['row-stub'];
|
||||
return ["row-stub"];
|
||||
};
|
||||
current_msg_list.view = {};
|
||||
|
||||
@@ -107,18 +107,18 @@ run_test('update_messages', () => {
|
||||
};
|
||||
|
||||
const side_effects = [
|
||||
'condense.un_cache_message_content_height',
|
||||
'message_edit.end_message_row_edit',
|
||||
'notifications.received_messages',
|
||||
'unread_ui.update_unread_counts',
|
||||
'stream_list.update_streams_sidebar',
|
||||
'pm_list.update_private_messages',
|
||||
"condense.un_cache_message_content_height",
|
||||
"message_edit.end_message_row_edit",
|
||||
"notifications.received_messages",
|
||||
"unread_ui.update_unread_counts",
|
||||
"stream_list.update_streams_sidebar",
|
||||
"pm_list.update_private_messages",
|
||||
];
|
||||
|
||||
const helper = test_helper(side_effects);
|
||||
|
||||
page_params.realm_allow_edit_history = false;
|
||||
message_list.narrowed = 'stub-to-ignore';
|
||||
message_list.narrowed = "stub-to-ignore";
|
||||
|
||||
// TEST THIS:
|
||||
message_events.update_messages(events);
|
||||
@@ -131,7 +131,7 @@ run_test('update_messages', () => {
|
||||
{
|
||||
alerted: false,
|
||||
collapsed: false,
|
||||
content: '<b>new content</b>',
|
||||
content: "<b>new content</b>",
|
||||
display_recipient: denmark.name,
|
||||
historical: false,
|
||||
id: 111,
|
||||
@@ -139,7 +139,7 @@ run_test('update_messages', () => {
|
||||
last_edit_timestamp: undefined,
|
||||
mentioned: false,
|
||||
mentioned_me_directly: false,
|
||||
raw_content: '**new content**',
|
||||
raw_content: "**new content**",
|
||||
reactions: [],
|
||||
reply_to: alice.email,
|
||||
sender_email: alice.email,
|
||||
@@ -149,8 +149,8 @@ run_test('update_messages', () => {
|
||||
starred: false,
|
||||
stream: denmark.name,
|
||||
stream_id: denmark.stream_id,
|
||||
topic: 'lunch',
|
||||
type: 'stream',
|
||||
topic: "lunch",
|
||||
type: "stream",
|
||||
unread: true,
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('document', 'document-stub');
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("document", "document-stub");
|
||||
|
||||
zrequire('message_fetch');
|
||||
zrequire("message_fetch");
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
function MessageListView() {
|
||||
return {};
|
||||
}
|
||||
set_global('MessageListView', MessageListView);
|
||||
set_global("MessageListView", MessageListView);
|
||||
|
||||
zrequire('FetchStatus', 'js/fetch_status');
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire('message_list');
|
||||
zrequire('people');
|
||||
zrequire("FetchStatus", "js/fetch_status");
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("MessageListData", "js/message_list_data");
|
||||
zrequire("message_list");
|
||||
zrequire("people");
|
||||
|
||||
set_global('recent_topics', {
|
||||
set_global("recent_topics", {
|
||||
process_messages: noop,
|
||||
});
|
||||
// Still required for page_params.initial_pointer
|
||||
set_global('page_params', {});
|
||||
set_global('ui_report', {
|
||||
set_global("page_params", {});
|
||||
set_global("ui_report", {
|
||||
hide_error: noop,
|
||||
});
|
||||
|
||||
set_global('channel', {});
|
||||
set_global('document', 'document-stub');
|
||||
set_global('message_scroll', {
|
||||
set_global("channel", {});
|
||||
set_global("document", "document-stub");
|
||||
set_global("message_scroll", {
|
||||
show_loading_older: noop,
|
||||
hide_loading_older: noop,
|
||||
show_loading_newer: noop,
|
||||
hide_loading_newer: noop,
|
||||
update_top_of_narrow_notices: () => {},
|
||||
});
|
||||
set_global('message_util', {});
|
||||
set_global('message_store', {});
|
||||
set_global('narrow_state', {});
|
||||
set_global('pm_list', {});
|
||||
set_global('server_events', {});
|
||||
set_global('stream_list', {
|
||||
set_global("message_util", {});
|
||||
set_global("message_store", {});
|
||||
set_global("narrow_state", {});
|
||||
set_global("pm_list", {});
|
||||
set_global("server_events", {});
|
||||
set_global("stream_list", {
|
||||
maybe_scroll_narrow_into_view: () => {},
|
||||
});
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 7,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
people.add_active_user(alice);
|
||||
|
||||
@@ -59,7 +59,7 @@ function stub_message_view(list) {
|
||||
}
|
||||
|
||||
function make_home_msg_list() {
|
||||
const table_name = 'whatever';
|
||||
const table_name = "whatever";
|
||||
const filter = new Filter();
|
||||
|
||||
const list = new message_list.MessageList({
|
||||
@@ -74,8 +74,8 @@ function make_all_list() {
|
||||
}
|
||||
|
||||
function reset_lists() {
|
||||
set_global('home_msg_list', make_home_msg_list());
|
||||
set_global('current_msg_list', home_msg_list);
|
||||
set_global("home_msg_list", make_home_msg_list());
|
||||
set_global("current_msg_list", home_msg_list);
|
||||
message_list.all = make_all_list();
|
||||
stub_message_view(home_msg_list);
|
||||
stub_message_view(message_list.all);
|
||||
@@ -92,7 +92,7 @@ function config_fake_channel(conf) {
|
||||
if (!conf.can_call_again) {
|
||||
assert(self.success === undefined);
|
||||
}
|
||||
assert.equal(opts.url, '/json/messages');
|
||||
assert.equal(opts.url, "/json/messages");
|
||||
assert.deepEqual(opts.data, conf.expected_opts_data);
|
||||
self.success = opts.success;
|
||||
called = true;
|
||||
@@ -141,7 +141,7 @@ function message_range(start, end) {
|
||||
const initialize_data = {
|
||||
initial_fetch: {
|
||||
req: {
|
||||
anchor: 'first_unread',
|
||||
anchor: "first_unread",
|
||||
num_before: 200,
|
||||
num_after: 200,
|
||||
client_gravatar: true,
|
||||
@@ -155,7 +155,7 @@ const initialize_data = {
|
||||
|
||||
forward_fill: {
|
||||
req: {
|
||||
anchor: '800',
|
||||
anchor: "800",
|
||||
num_before: 0,
|
||||
num_after: 1000,
|
||||
client_gravatar: true,
|
||||
@@ -168,7 +168,7 @@ const initialize_data = {
|
||||
|
||||
back_fill: {
|
||||
req: {
|
||||
anchor: '201',
|
||||
anchor: "201",
|
||||
num_before: 1000,
|
||||
num_after: 0,
|
||||
client_gravatar: true,
|
||||
@@ -228,7 +228,7 @@ function forward_fill_step() {
|
||||
const response = initialize_data.forward_fill.resp;
|
||||
|
||||
let idle_config;
|
||||
$('document-stub').idle = function (config) {
|
||||
$("document-stub").idle = function (config) {
|
||||
idle_config = config;
|
||||
};
|
||||
|
||||
@@ -260,7 +260,7 @@ function test_backfill_idle(idle_config) {
|
||||
});
|
||||
}
|
||||
|
||||
run_test('initialize', () => {
|
||||
run_test("initialize", () => {
|
||||
reset_lists();
|
||||
|
||||
const step1 = initial_fetch_step();
|
||||
@@ -284,19 +284,19 @@ function simulate_narrow() {
|
||||
|
||||
narrow_state.active = function () { return true; };
|
||||
narrow_state.public_operators = function () {
|
||||
return [{ operator: 'pm-with', operand: alice.email }];
|
||||
return [{ operator: "pm-with", operand: alice.email }];
|
||||
};
|
||||
|
||||
const msg_list = new message_list.MessageList({
|
||||
table_name: 'zfilt',
|
||||
table_name: "zfilt",
|
||||
filter: filter,
|
||||
});
|
||||
set_global('current_msg_list', msg_list);
|
||||
set_global("current_msg_list", msg_list);
|
||||
|
||||
return msg_list;
|
||||
}
|
||||
|
||||
run_test('loading_newer', () => {
|
||||
run_test("loading_newer", () => {
|
||||
function test_dup_new_fetch(msg_list) {
|
||||
assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false);
|
||||
message_fetch.maybe_load_newer_messages({
|
||||
@@ -350,7 +350,7 @@ run_test('loading_newer', () => {
|
||||
|
||||
const data = {
|
||||
req: {
|
||||
anchor: '444',
|
||||
anchor: "444",
|
||||
num_before: 0,
|
||||
num_after: 100,
|
||||
narrow: `[{"operator":"pm-with","operand":[${alice.user_id}]}]`,
|
||||
@@ -407,7 +407,7 @@ run_test('loading_newer', () => {
|
||||
const data = [
|
||||
{
|
||||
req: {
|
||||
anchor: '444',
|
||||
anchor: "444",
|
||||
num_before: 0,
|
||||
num_after: 100,
|
||||
client_gravatar: true,
|
||||
@@ -419,7 +419,7 @@ run_test('loading_newer', () => {
|
||||
},
|
||||
{
|
||||
req: {
|
||||
anchor: '599',
|
||||
anchor: "599",
|
||||
num_before: 0,
|
||||
num_after: 100,
|
||||
client_gravatar: true,
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
zrequire('unread');
|
||||
zrequire('unread_ops');
|
||||
zrequire('message_flags');
|
||||
zrequire("unread");
|
||||
zrequire("unread_ops");
|
||||
zrequire("message_flags");
|
||||
|
||||
set_global('ui', {});
|
||||
set_global('channel', {});
|
||||
set_global('starred_messages', {
|
||||
set_global("ui", {});
|
||||
set_global("channel", {});
|
||||
set_global("starred_messages", {
|
||||
add: () => {},
|
||||
remove: () => {},
|
||||
});
|
||||
|
||||
run_test('starred', () => {
|
||||
run_test("starred", () => {
|
||||
const message = {
|
||||
id: 50,
|
||||
};
|
||||
set_global('current_msg_list', {
|
||||
set_global("current_msg_list", {
|
||||
all_messages: () => [message],
|
||||
is_search: () => false,
|
||||
});
|
||||
@@ -26,7 +26,7 @@ run_test('starred', () => {
|
||||
let posted_data;
|
||||
|
||||
channel.post = (opts) => {
|
||||
assert.equal(opts.url, '/json/messages/flags');
|
||||
assert.equal(opts.url, "/json/messages/flags");
|
||||
posted_data = opts.data;
|
||||
};
|
||||
|
||||
@@ -35,9 +35,9 @@ run_test('starred', () => {
|
||||
assert(ui_updated);
|
||||
|
||||
assert.deepEqual(posted_data, {
|
||||
messages: '[50]',
|
||||
flag: 'starred',
|
||||
op: 'add',
|
||||
messages: "[50]",
|
||||
flag: "starred",
|
||||
op: "add",
|
||||
});
|
||||
|
||||
assert.deepEqual(message, {
|
||||
@@ -52,9 +52,9 @@ run_test('starred', () => {
|
||||
assert(ui_updated);
|
||||
|
||||
assert.deepEqual(posted_data, {
|
||||
messages: '[50]',
|
||||
flag: 'starred',
|
||||
op: 'remove',
|
||||
messages: "[50]",
|
||||
flag: "starred",
|
||||
op: "remove",
|
||||
});
|
||||
|
||||
assert.deepEqual(message, {
|
||||
@@ -62,7 +62,7 @@ run_test('starred', () => {
|
||||
starred: false,
|
||||
});
|
||||
});
|
||||
run_test('read', () => {
|
||||
run_test("read", () => {
|
||||
// Way to capture posted info in every request
|
||||
let channel_post_opts;
|
||||
channel.post = (opts) => {
|
||||
@@ -82,12 +82,12 @@ run_test('read', () => {
|
||||
];
|
||||
message_flags.send_read(msgs_to_flag_read);
|
||||
assert.deepEqual(channel_post_opts, {
|
||||
url: '/json/messages/flags',
|
||||
url: "/json/messages/flags",
|
||||
idempotent: true,
|
||||
data: {
|
||||
messages: '[1,2,3,4,5]',
|
||||
op: 'add',
|
||||
flag: 'read',
|
||||
messages: "[1,2,3,4,5]",
|
||||
op: "add",
|
||||
flag: "read",
|
||||
},
|
||||
success: channel_post_opts.success,
|
||||
});
|
||||
@@ -98,12 +98,12 @@ run_test('read', () => {
|
||||
};
|
||||
channel_post_opts.success(success_response_data);
|
||||
assert.deepEqual(channel_post_opts, {
|
||||
url: '/json/messages/flags',
|
||||
url: "/json/messages/flags",
|
||||
idempotent: true,
|
||||
data: {
|
||||
messages: '[6,7]',
|
||||
op: 'add',
|
||||
flag: 'read',
|
||||
messages: "[6,7]",
|
||||
op: "add",
|
||||
flag: "read",
|
||||
},
|
||||
success: channel_post_opts.success,
|
||||
});
|
||||
@@ -126,12 +126,12 @@ run_test('read', () => {
|
||||
];
|
||||
message_flags.send_read(msgs_to_flag_read);
|
||||
assert.deepEqual(channel_post_opts, {
|
||||
url: '/json/messages/flags',
|
||||
url: "/json/messages/flags",
|
||||
idempotent: true,
|
||||
data: {
|
||||
messages: '[3,4,5,6,7]',
|
||||
op: 'add',
|
||||
flag: 'read',
|
||||
messages: "[3,4,5,6,7]",
|
||||
op: "add",
|
||||
flag: "read",
|
||||
},
|
||||
success: channel_post_opts.success,
|
||||
});
|
||||
@@ -148,12 +148,12 @@ run_test('read', () => {
|
||||
|
||||
// Former locally echoed messages flagging retried
|
||||
assert.deepEqual(channel_post_opts, {
|
||||
url: '/json/messages/flags',
|
||||
url: "/json/messages/flags",
|
||||
idempotent: true,
|
||||
data: {
|
||||
messages: '[1,2]',
|
||||
op: 'add',
|
||||
flag: 'read',
|
||||
messages: "[1,2]",
|
||||
op: "add",
|
||||
flag: "read",
|
||||
},
|
||||
success: channel_post_opts.success,
|
||||
});
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
const noop = function () {};
|
||||
|
||||
set_global('Filter', noop);
|
||||
set_global("Filter", noop);
|
||||
global.stub_out_jquery();
|
||||
set_global('document', null);
|
||||
set_global('current_msg_list', {});
|
||||
set_global("document", null);
|
||||
set_global("current_msg_list", {});
|
||||
|
||||
zrequire('FetchStatus', 'js/fetch_status');
|
||||
zrequire('muting');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire('MessageListView', 'js/message_list_view');
|
||||
const MessageList = zrequire('message_list').MessageList;
|
||||
zrequire("FetchStatus", "js/fetch_status");
|
||||
zrequire("muting");
|
||||
zrequire("MessageListData", "js/message_list_data");
|
||||
zrequire("MessageListView", "js/message_list_view");
|
||||
const MessageList = zrequire("message_list").MessageList;
|
||||
|
||||
const with_overrides = global.with_overrides; // make lint happy
|
||||
|
||||
@@ -25,7 +25,7 @@ function accept_all_filter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
const filter = accept_all_filter();
|
||||
|
||||
const list = new MessageList({
|
||||
@@ -35,7 +35,7 @@ run_test('basics', () => {
|
||||
const messages = [
|
||||
{
|
||||
id: 50,
|
||||
content: 'fifty',
|
||||
content: "fifty",
|
||||
},
|
||||
{
|
||||
id: 60,
|
||||
@@ -57,7 +57,7 @@ run_test('basics', () => {
|
||||
assert.equal(list.first().id, 50);
|
||||
assert.equal(list.last().id, 80);
|
||||
|
||||
assert.equal(list.get(50).content, 'fifty');
|
||||
assert.equal(list.get(50).content, "fifty");
|
||||
|
||||
assert.equal(list.closest_id(49), 50);
|
||||
assert.equal(list.closest_id(50), 50);
|
||||
@@ -69,7 +69,7 @@ run_test('basics', () => {
|
||||
assert.deepEqual(list.all_messages(), messages);
|
||||
|
||||
global.$.Event = function (ev) {
|
||||
assert.equal(ev, 'message_selected.zulip');
|
||||
assert.equal(ev, "message_selected.zulip");
|
||||
};
|
||||
list.select_id(50);
|
||||
|
||||
@@ -119,7 +119,7 @@ run_test('basics', () => {
|
||||
assert.deepEqual(list.all_messages(), []);
|
||||
});
|
||||
|
||||
run_test('prev_next', () => {
|
||||
run_test("prev_next", () => {
|
||||
const list = new MessageList({});
|
||||
|
||||
assert.equal(list.prev(), undefined);
|
||||
@@ -158,7 +158,7 @@ run_test('prev_next', () => {
|
||||
assert.equal(list.is_at_end(), true);
|
||||
});
|
||||
|
||||
run_test('message_range', () => {
|
||||
run_test("message_range", () => {
|
||||
const list = new MessageList({});
|
||||
|
||||
const messages = [{id: 30}, {id: 40}, {id: 50}, {id: 60}];
|
||||
@@ -168,11 +168,11 @@ run_test('message_range', () => {
|
||||
assert.deepEqual(list.message_range(30, 40), [{id: 30}, {id: 40}]);
|
||||
assert.deepEqual(list.message_range(31, 39), [{id: 40}]);
|
||||
assert.deepEqual(list.message_range(31, 1000), [{id: 40}, {id: 50}, {id: 60}]);
|
||||
blueslip.expect('error', 'message_range given a start of -1');
|
||||
blueslip.expect("error", "message_range given a start of -1");
|
||||
assert.deepEqual(list.message_range(-1, 40), [{id: 30}, {id: 40}]);
|
||||
});
|
||||
|
||||
run_test('updates', () => {
|
||||
run_test("updates", () => {
|
||||
const list = new MessageList({});
|
||||
list.view.rerender_preserving_scrolltop = noop;
|
||||
|
||||
@@ -209,7 +209,7 @@ run_test('updates', () => {
|
||||
assert.equal(list.get(1).stream, "denmark");
|
||||
});
|
||||
|
||||
run_test('nth_most_recent_id', () => {
|
||||
run_test("nth_most_recent_id", () => {
|
||||
const list = new MessageList({});
|
||||
list.append([{id: 10}, {id: 20}, {id: 30}]);
|
||||
assert.equal(list.nth_most_recent_id(1), 30);
|
||||
@@ -218,7 +218,7 @@ run_test('nth_most_recent_id', () => {
|
||||
assert.equal(list.nth_most_recent_id(4), -1);
|
||||
});
|
||||
|
||||
run_test('change_message_id', () => {
|
||||
run_test("change_message_id", () => {
|
||||
const list = new MessageList({});
|
||||
list.data._add_to_hash([{id: 10.5, content: "good job"}, {id: 20.5, content: "ok!"}]);
|
||||
|
||||
@@ -236,7 +236,7 @@ run_test('change_message_id', () => {
|
||||
assert.equal(list.change_message_id(13, 15), undefined);
|
||||
});
|
||||
|
||||
run_test('last_sent_by_me', () => {
|
||||
run_test("last_sent_by_me", () => {
|
||||
const list = new MessageList({});
|
||||
const items = [
|
||||
{
|
||||
@@ -259,7 +259,7 @@ run_test('last_sent_by_me', () => {
|
||||
assert.equal(list.get_last_message_sent_by_me().id, 2);
|
||||
});
|
||||
|
||||
run_test('local_echo', () => {
|
||||
run_test("local_echo", () => {
|
||||
let list = new MessageList({});
|
||||
list.append([{id: 10}, {id: 20}, {id: 30}, {id: 20.02},
|
||||
{id: 20.03}, {id: 40}, {id: 50}, {id: 60}]);
|
||||
@@ -308,7 +308,7 @@ run_test('local_echo', () => {
|
||||
assert.equal(list.closest_id(50.01), 50.01);
|
||||
});
|
||||
|
||||
run_test('bookend', () => {
|
||||
run_test("bookend", () => {
|
||||
const list = new MessageList({});
|
||||
|
||||
with_overrides((override) => {
|
||||
@@ -323,7 +323,7 @@ run_test('bookend', () => {
|
||||
global.with_stub((stub) => {
|
||||
list.view.render_trailing_bookend = stub.f;
|
||||
list.update_trailing_bookend();
|
||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||
const bookend = stub.get_args("content", "subscribed", "show_button");
|
||||
assert.equal(bookend.content, expected);
|
||||
assert.equal(bookend.subscribed, true);
|
||||
assert.equal(bookend.show_button, true);
|
||||
@@ -338,7 +338,7 @@ run_test('bookend', () => {
|
||||
global.with_stub((stub) => {
|
||||
list.view.render_trailing_bookend = stub.f;
|
||||
list.update_trailing_bookend();
|
||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||
const bookend = stub.get_args("content", "subscribed", "show_button");
|
||||
assert.equal(bookend.content, expected);
|
||||
assert.equal(bookend.subscribed, false);
|
||||
assert.equal(bookend.show_button, true);
|
||||
@@ -353,7 +353,7 @@ run_test('bookend', () => {
|
||||
global.with_stub((stub) => {
|
||||
list.view.render_trailing_bookend = stub.f;
|
||||
list.update_trailing_bookend();
|
||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||
const bookend = stub.get_args("content", "subscribed", "show_button");
|
||||
assert.equal(bookend.content, expected);
|
||||
assert.equal(bookend.subscribed, false);
|
||||
assert.equal(bookend.show_button, false);
|
||||
@@ -365,7 +365,7 @@ run_test('bookend', () => {
|
||||
global.with_stub((stub) => {
|
||||
list.view.render_trailing_bookend = stub.f;
|
||||
list.update_trailing_bookend();
|
||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||
const bookend = stub.get_args("content", "subscribed", "show_button");
|
||||
assert.equal(bookend.content, expected);
|
||||
assert.equal(bookend.subscribed, false);
|
||||
assert.equal(bookend.show_button, true);
|
||||
@@ -373,7 +373,7 @@ run_test('bookend', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('unmuted_messages', () => {
|
||||
run_test("unmuted_messages", () => {
|
||||
const list = new MessageList({});
|
||||
|
||||
const muted_stream_id = 999;
|
||||
@@ -383,13 +383,13 @@ run_test('unmuted_messages', () => {
|
||||
id: 50,
|
||||
stream_id: muted_stream_id,
|
||||
mentioned: true, // overrides mute
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
},
|
||||
{
|
||||
id: 60,
|
||||
stream_id: 42,
|
||||
mentioned: false,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
},
|
||||
];
|
||||
const muted = [
|
||||
@@ -397,12 +397,12 @@ run_test('unmuted_messages', () => {
|
||||
id: 70,
|
||||
stream_id: muted_stream_id,
|
||||
mentioned: false,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
},
|
||||
];
|
||||
|
||||
with_overrides((override) => {
|
||||
override('muting.is_topic_muted', (stream_id) => stream_id === muted_stream_id);
|
||||
override("muting.is_topic_muted", (stream_id) => stream_id === muted_stream_id);
|
||||
|
||||
// Make sure unmuted_message filters out the "muted" entry,
|
||||
// which we mark as having a muted topic, and not mentioned.
|
||||
@@ -411,7 +411,7 @@ run_test('unmuted_messages', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('add_remove_rerender', () => {
|
||||
run_test("add_remove_rerender", () => {
|
||||
const filter = accept_all_filter();
|
||||
|
||||
const list = new MessageList({filter: filter});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
zrequire('unread');
|
||||
zrequire("unread");
|
||||
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('FetchStatus', 'js/fetch_status');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("FetchStatus", "js/fetch_status");
|
||||
zrequire("MessageListData", "js/message_list_data");
|
||||
|
||||
set_global('page_params', {});
|
||||
set_global('muting', {});
|
||||
set_global("page_params", {});
|
||||
set_global("muting", {});
|
||||
|
||||
global.patch_builtin('setTimeout', (f, delay) => {
|
||||
global.patch_builtin("setTimeout", (f, delay) => {
|
||||
assert.equal(delay, 0);
|
||||
return f();
|
||||
});
|
||||
@@ -16,7 +16,7 @@ function make_msg(msg_id) {
|
||||
return {
|
||||
id: msg_id,
|
||||
unread: true,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ function assert_contents(mld, msg_ids) {
|
||||
assert.deepEqual(msgs, make_msgs(msg_ids));
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
const mld = new MessageListData({
|
||||
muting_enabled: false,
|
||||
filter: undefined,
|
||||
@@ -98,7 +98,7 @@ run_test('basics', () => {
|
||||
assert.equal(mld.first_unread_message_id(), 145);
|
||||
});
|
||||
|
||||
run_test('muting enabled', () => {
|
||||
run_test("muting enabled", () => {
|
||||
const mld = new MessageListData({
|
||||
muting_enabled: true,
|
||||
filter: undefined,
|
||||
@@ -126,9 +126,9 @@ run_test('muting enabled', () => {
|
||||
assert.deepEqual(mld._all_items, []);
|
||||
});
|
||||
|
||||
run_test('more muting', () => {
|
||||
run_test("more muting", () => {
|
||||
muting.is_topic_muted = function (stream_id, topic) {
|
||||
return topic === 'muted';
|
||||
return topic === "muted";
|
||||
};
|
||||
|
||||
const mld = new MessageListData({
|
||||
@@ -137,10 +137,10 @@ run_test('more muting', () => {
|
||||
});
|
||||
|
||||
const orig_messages = [
|
||||
{id: 3, topic: 'muted'},
|
||||
{id: 4, topic: 'whatever'},
|
||||
{id: 7, topic: 'muted'},
|
||||
{id: 8, topic: 'whatever'},
|
||||
{id: 3, topic: "muted"},
|
||||
{id: 4, topic: "whatever"},
|
||||
{id: 7, topic: "muted"},
|
||||
{id: 8, topic: "whatever"},
|
||||
];
|
||||
|
||||
const orig_info = mld.add_messages(orig_messages);
|
||||
@@ -149,8 +149,8 @@ run_test('more muting', () => {
|
||||
top_messages: [],
|
||||
interior_messages: [],
|
||||
bottom_messages: [
|
||||
{id: 4, topic: 'whatever'},
|
||||
{id: 8, topic: 'whatever'},
|
||||
{id: 4, topic: "whatever"},
|
||||
{id: 8, topic: "whatever"},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -165,13 +165,13 @@ run_test('more muting', () => {
|
||||
);
|
||||
|
||||
const more_messages = [
|
||||
{id: 1, topic: 'muted'},
|
||||
{id: 2, topic: 'whatever'},
|
||||
{id: 3, topic: 'muted'}, // dup
|
||||
{id: 5, topic: 'muted'},
|
||||
{id: 6, topic: 'whatever'},
|
||||
{id: 9, topic: 'muted'},
|
||||
{id: 10, topic: 'whatever'},
|
||||
{id: 1, topic: "muted"},
|
||||
{id: 2, topic: "whatever"},
|
||||
{id: 3, topic: "muted"}, // dup
|
||||
{id: 5, topic: "muted"},
|
||||
{id: 6, topic: "whatever"},
|
||||
{id: 9, topic: "muted"},
|
||||
{id: 10, topic: "whatever"},
|
||||
];
|
||||
|
||||
const more_info = mld.add_messages(more_messages);
|
||||
@@ -188,30 +188,30 @@ run_test('more muting', () => {
|
||||
|
||||
assert.deepEqual(more_info, {
|
||||
top_messages: [
|
||||
{id: 2, topic: 'whatever'},
|
||||
{id: 2, topic: "whatever"},
|
||||
],
|
||||
interior_messages: [
|
||||
{id: 6, topic: 'whatever'},
|
||||
{id: 6, topic: "whatever"},
|
||||
],
|
||||
bottom_messages: [
|
||||
{id: 10, topic: 'whatever'},
|
||||
{id: 10, topic: "whatever"},
|
||||
],
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
run_test('errors', () => {
|
||||
run_test("errors", () => {
|
||||
const mld = new MessageListData({
|
||||
muting_enabled: false,
|
||||
filter: undefined,
|
||||
});
|
||||
assert.equal(mld.get('bogus-id'), undefined);
|
||||
assert.equal(mld.get("bogus-id"), undefined);
|
||||
|
||||
assert.throws(() => {
|
||||
mld._add_to_hash(['asdf']);
|
||||
}, {message: 'Bad message id'});
|
||||
mld._add_to_hash(["asdf"]);
|
||||
}, {message: "Bad message id"});
|
||||
|
||||
blueslip.expect('error', 'Duplicate message added to MessageListData');
|
||||
mld._hash.set(1, 'taken');
|
||||
blueslip.expect("error", "Duplicate message added to MessageListData");
|
||||
mld._hash.set(1, "taken");
|
||||
mld._add_to_hash(make_msgs([1]));
|
||||
});
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('document', 'document-stub');
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("document", "document-stub");
|
||||
|
||||
set_global('XDate', zrequire('XDate', 'xdate/src/xdate'));
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('FetchStatus', 'js/fetch_status');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire('MessageListView', 'js/message_list_view');
|
||||
zrequire('message_list');
|
||||
set_global("XDate", zrequire("XDate", "xdate/src/xdate"));
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("FetchStatus", "js/fetch_status");
|
||||
zrequire("MessageListData", "js/message_list_data");
|
||||
zrequire("MessageListView", "js/message_list_view");
|
||||
zrequire("message_list");
|
||||
|
||||
const noop = function () {};
|
||||
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
twenty_four_hour_time: false,
|
||||
});
|
||||
set_global('home_msg_list', null);
|
||||
set_global('people', {small_avatar_url: function () { return ''; }});
|
||||
set_global('unread', {message_unread: function () {}});
|
||||
set_global("home_msg_list", null);
|
||||
set_global("people", {small_avatar_url: function () { return ""; }});
|
||||
set_global("unread", {message_unread: function () {}});
|
||||
// timerender calls setInterval when imported
|
||||
set_global('timerender', {
|
||||
set_global("timerender", {
|
||||
render_date: function (time1, time2) {
|
||||
if (time2 === undefined) {
|
||||
return [{outerHTML: String(time1.getTime())}];
|
||||
}
|
||||
return [{outerHTML: String(time1.getTime()) + ' - ' + String(time2.getTime())}];
|
||||
return [{outerHTML: String(time1.getTime()) + " - " + String(time2.getTime())}];
|
||||
},
|
||||
stringify_time: function (time) {
|
||||
if (page_params.twenty_four_hour_time) {
|
||||
return time.toString('HH:mm');
|
||||
return time.toString("HH:mm");
|
||||
}
|
||||
return time.toString('h:mm TT');
|
||||
return time.toString("h:mm TT");
|
||||
},
|
||||
});
|
||||
|
||||
set_global('rows', {
|
||||
set_global("rows", {
|
||||
get_table: function () {
|
||||
return {
|
||||
children: function () {
|
||||
@@ -46,7 +46,7 @@ set_global('rows', {
|
||||
|
||||
let next_timestamp = 1500000000;
|
||||
|
||||
run_test('msg_edited_vars', () => {
|
||||
run_test("msg_edited_vars", () => {
|
||||
// This is a test to verify that only one of the three bools,
|
||||
// `edited_in_left_col`, `edited_alongside_sender`, `edited_status_msg`
|
||||
// is not false; Tests for three different kinds of messages:
|
||||
@@ -123,7 +123,7 @@ run_test('msg_edited_vars', () => {
|
||||
}());
|
||||
});
|
||||
|
||||
run_test('merge_message_groups', () => {
|
||||
run_test("merge_message_groups", () => {
|
||||
// MessageListView has lots of DOM code, so we are going to test the message
|
||||
// group mearging logic on its own.
|
||||
|
||||
@@ -139,12 +139,12 @@ run_test('merge_message_groups', () => {
|
||||
...message_context,
|
||||
};
|
||||
message_context.msg = {
|
||||
id: _.uniqueId('test_message_'),
|
||||
id: _.uniqueId("test_message_"),
|
||||
status_message: false,
|
||||
type: 'stream',
|
||||
stream: 'Test Stream 1',
|
||||
topic: 'Test Subject 1',
|
||||
sender_email: 'test@example.com',
|
||||
type: "stream",
|
||||
stream: "Test Stream 1",
|
||||
topic: "Test Subject 1",
|
||||
sender_email: "test@example.com",
|
||||
timestamp: next_timestamp += 1,
|
||||
...message,
|
||||
};
|
||||
@@ -154,7 +154,7 @@ run_test('merge_message_groups', () => {
|
||||
function build_message_group(messages) {
|
||||
return {
|
||||
message_containers: messages,
|
||||
message_group_id: _.uniqueId('test_message_group_'),
|
||||
message_group_id: _.uniqueId("test_message_group_"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ run_test('merge_message_groups', () => {
|
||||
build_message_context(),
|
||||
]);
|
||||
|
||||
const result = list.merge_message_groups([message_group], 'bottom');
|
||||
const result = list.merge_message_groups([message_group], "bottom");
|
||||
|
||||
assert_message_groups_list_equal(list._message_groups, [message_group]);
|
||||
assert_message_groups_list_equal(result.append_groups, [message_group]);
|
||||
@@ -219,7 +219,7 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'bottom');
|
||||
const result = list.merge_message_groups([message_group2], "bottom");
|
||||
|
||||
assert_message_groups_list_equal(
|
||||
list._message_groups,
|
||||
@@ -238,13 +238,13 @@ run_test('merge_message_groups', () => {
|
||||
message1,
|
||||
]);
|
||||
|
||||
const message2 = build_message_context({topic: 'Test subject 2'});
|
||||
const message2 = build_message_context({topic: "Test subject 2"});
|
||||
const message_group2 = build_message_group([
|
||||
message2,
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'bottom');
|
||||
const result = list.merge_message_groups([message_group2], "bottom");
|
||||
|
||||
assert(!message_group2.group_date_divider_html);
|
||||
assert_message_groups_list_equal(
|
||||
@@ -264,14 +264,14 @@ run_test('merge_message_groups', () => {
|
||||
message1,
|
||||
]);
|
||||
|
||||
const message2 = build_message_context({topic: 'Test subject 2',
|
||||
const message2 = build_message_context({topic: "Test subject 2",
|
||||
timestamp: 900000});
|
||||
const message_group2 = build_message_group([
|
||||
message2,
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'bottom');
|
||||
const result = list.merge_message_groups([message_group2], "bottom");
|
||||
|
||||
assert_message_groups_list_equal(
|
||||
list._message_groups,
|
||||
@@ -283,7 +283,7 @@ run_test('merge_message_groups', () => {
|
||||
assert.deepEqual(result.rerender_messages_next_same_sender, []);
|
||||
assert.equal(
|
||||
message_group2.group_date_divider_html,
|
||||
'900000000 - 1000000');
|
||||
"900000000 - 1000000");
|
||||
}());
|
||||
|
||||
(function test_append_message_different_day() {
|
||||
@@ -299,7 +299,7 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'bottom');
|
||||
const result = list.merge_message_groups([message_group2], "bottom");
|
||||
|
||||
assert_message_groups_list_equal(list._message_groups, [message_group1]);
|
||||
assert.deepEqual(result.append_groups, []);
|
||||
@@ -323,7 +323,7 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'bottom');
|
||||
const result = list.merge_message_groups([message_group2], "bottom");
|
||||
|
||||
assert(message_group2.bookend_top);
|
||||
assert_message_groups_list_equal(
|
||||
@@ -349,7 +349,7 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'bottom');
|
||||
const result = list.merge_message_groups([message_group2], "bottom");
|
||||
|
||||
assert(message2.include_sender);
|
||||
assert_message_groups_list_equal(
|
||||
@@ -375,7 +375,7 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'top');
|
||||
const result = list.merge_message_groups([message_group2], "top");
|
||||
|
||||
assert_message_groups_list_equal(
|
||||
list._message_groups,
|
||||
@@ -395,13 +395,13 @@ run_test('merge_message_groups', () => {
|
||||
message1,
|
||||
]);
|
||||
|
||||
const message2 = build_message_context({topic: 'Test Subject 2'});
|
||||
const message2 = build_message_context({topic: "Test Subject 2"});
|
||||
const message_group2 = build_message_group([
|
||||
message2,
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'top');
|
||||
const result = list.merge_message_groups([message_group2], "top");
|
||||
|
||||
assert_message_groups_list_equal(
|
||||
list._message_groups,
|
||||
@@ -420,19 +420,19 @@ run_test('merge_message_groups', () => {
|
||||
message1,
|
||||
]);
|
||||
|
||||
const message2 = build_message_context({topic: 'Test Subject 2',
|
||||
const message2 = build_message_context({topic: "Test Subject 2",
|
||||
timestamp: 1000});
|
||||
const message_group2 = build_message_group([
|
||||
message2,
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'top');
|
||||
const result = list.merge_message_groups([message_group2], "top");
|
||||
|
||||
// We should have a group date divider between the recipient blocks.
|
||||
assert.equal(
|
||||
message_group1.group_date_divider_html,
|
||||
'900000000 - 1000000');
|
||||
"900000000 - 1000000");
|
||||
assert_message_groups_list_equal(
|
||||
list._message_groups,
|
||||
[message_group2, message_group1]);
|
||||
@@ -456,12 +456,12 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'top');
|
||||
const result = list.merge_message_groups([message_group2], "top");
|
||||
|
||||
// We should have a group date divider within the single recipient block.
|
||||
assert.equal(
|
||||
message_group2.message_containers[1].date_divider_html,
|
||||
'900000000 - 1000000');
|
||||
"900000000 - 1000000");
|
||||
assert_message_groups_list_equal(
|
||||
list._message_groups,
|
||||
[message_group2]);
|
||||
@@ -485,7 +485,7 @@ run_test('merge_message_groups', () => {
|
||||
]);
|
||||
|
||||
const list = build_list([message_group1]);
|
||||
const result = list.merge_message_groups([message_group2], 'top');
|
||||
const result = list.merge_message_groups([message_group2], "top");
|
||||
|
||||
assert(message_group1.bookend_top);
|
||||
assert_message_groups_list_equal(
|
||||
@@ -504,14 +504,14 @@ run_test('merge_message_groups', () => {
|
||||
// where new messages added via local echo have a different date from
|
||||
// the older messages.
|
||||
|
||||
run_test('render_windows', () => {
|
||||
run_test("render_windows", () => {
|
||||
// We only render up to 400 messages at a time in our message list,
|
||||
// and we only change the window (which is a range, really, with
|
||||
// start/end) when the pointer moves outside of the window or close
|
||||
// to the edges.
|
||||
|
||||
const view = (function make_view() {
|
||||
const table_name = 'zfilt';
|
||||
const table_name = "zfilt";
|
||||
const filter = new Filter();
|
||||
|
||||
const list = new message_list.MessageList({
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
const util = zrequire('util');
|
||||
zrequire('pm_conversations');
|
||||
zrequire('people');
|
||||
zrequire('message_store');
|
||||
const util = zrequire("util");
|
||||
zrequire("pm_conversations");
|
||||
zrequire("people");
|
||||
zrequire("message_store");
|
||||
|
||||
const noop = function () {};
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('document', 'document-stub');
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("document", "document-stub");
|
||||
|
||||
set_global('alert_words', {
|
||||
set_global("alert_words", {
|
||||
process_message: noop,
|
||||
});
|
||||
|
||||
set_global('stream_topic_history', {
|
||||
set_global("stream_topic_history", {
|
||||
add_message: noop,
|
||||
});
|
||||
|
||||
set_global('recent_senders', {
|
||||
set_global("recent_senders", {
|
||||
process_message_for_senders: noop,
|
||||
});
|
||||
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
realm_allow_message_editing: true,
|
||||
is_admin: true,
|
||||
});
|
||||
|
||||
const me = {
|
||||
email: 'me@example.com',
|
||||
email: "me@example.com",
|
||||
user_id: 101,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 102,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
|
||||
const bob = {
|
||||
email: 'bob@example.com',
|
||||
email: "bob@example.com",
|
||||
user_id: 103,
|
||||
full_name: 'Bob',
|
||||
full_name: "Bob",
|
||||
};
|
||||
|
||||
const cindy = {
|
||||
email: 'cindy@example.com',
|
||||
email: "cindy@example.com",
|
||||
user_id: 104,
|
||||
full_name: 'Cindy',
|
||||
full_name: "Cindy",
|
||||
};
|
||||
|
||||
const denise = {
|
||||
email: 'denise@example.com',
|
||||
email: "denise@example.com",
|
||||
user_id: 105,
|
||||
full_name: 'Denise ',
|
||||
full_name: "Denise ",
|
||||
};
|
||||
|
||||
people.add_active_user(me);
|
||||
@@ -72,13 +72,13 @@ function convert_recipients(people) {
|
||||
}));
|
||||
}
|
||||
|
||||
run_test('add_message_metadata', () => {
|
||||
run_test("add_message_metadata", () => {
|
||||
let message = {
|
||||
sender_email: 'me@example.com',
|
||||
sender_email: "me@example.com",
|
||||
sender_id: me.user_id,
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: convert_recipients([me, bob, cindy]),
|
||||
flags: ['has_alert_word'],
|
||||
flags: ["has_alert_word"],
|
||||
is_me_message: false,
|
||||
id: 2067,
|
||||
};
|
||||
@@ -90,17 +90,17 @@ run_test('add_message_metadata', () => {
|
||||
[me.user_id, bob.user_id, cindy.user_id]);
|
||||
|
||||
assert.equal(message.is_private, true);
|
||||
assert.equal(message.reply_to, 'bob@example.com,cindy@example.com');
|
||||
assert.equal(message.to_user_ids, '103,104');
|
||||
assert.equal(message.display_reply_to, 'Bob, Cindy');
|
||||
assert.equal(message.reply_to, "bob@example.com,cindy@example.com");
|
||||
assert.equal(message.to_user_ids, "103,104");
|
||||
assert.equal(message.display_reply_to, "Bob, Cindy");
|
||||
assert.equal(message.alerted, true);
|
||||
assert.equal(message.is_me_message, false);
|
||||
|
||||
let retrieved_message = message_store.get(2067);
|
||||
assert.equal(retrieved_message, message);
|
||||
|
||||
blueslip.expect('error', 'message_store got non-number: 2067');
|
||||
retrieved_message = message_store.get('2067');
|
||||
blueslip.expect("error", "message_store got non-number: 2067");
|
||||
retrieved_message = message_store.get("2067");
|
||||
assert.equal(retrieved_message, message);
|
||||
|
||||
// access cached previous message, and test match subject/content
|
||||
@@ -111,26 +111,26 @@ run_test('add_message_metadata', () => {
|
||||
};
|
||||
message = message_store.add_message_metadata(message);
|
||||
|
||||
assert.equal(message.reply_to, 'bob@example.com,cindy@example.com');
|
||||
assert.equal(message.to_user_ids, '103,104');
|
||||
assert.equal(message.display_reply_to, 'Bob, Cindy');
|
||||
assert.equal(util.get_match_topic(message), 'topic foo');
|
||||
assert.equal(message.match_content, 'bar content');
|
||||
assert.equal(message.reply_to, "bob@example.com,cindy@example.com");
|
||||
assert.equal(message.to_user_ids, "103,104");
|
||||
assert.equal(message.display_reply_to, "Bob, Cindy");
|
||||
assert.equal(util.get_match_topic(message), "topic foo");
|
||||
assert.equal(message.match_content, "bar content");
|
||||
|
||||
message = {
|
||||
sender_email: denise.email,
|
||||
sender_id: denise.user_id,
|
||||
type: 'stream',
|
||||
display_recipient: 'Zoolippy',
|
||||
topic: 'cool thing',
|
||||
subject: 'the_subject',
|
||||
type: "stream",
|
||||
display_recipient: "Zoolippy",
|
||||
topic: "cool thing",
|
||||
subject: "the_subject",
|
||||
id: 2068,
|
||||
};
|
||||
|
||||
message_store.set_message_booleans(message);
|
||||
message_store.add_message_metadata(message);
|
||||
assert.deepEqual(message.stream, message.display_recipient);
|
||||
assert.equal(message.reply_to, 'denise@example.com');
|
||||
assert.equal(message.reply_to, "denise@example.com");
|
||||
assert.deepEqual(message.flags, undefined);
|
||||
assert.equal(message.alerted, false);
|
||||
|
||||
@@ -139,38 +139,38 @@ run_test('add_message_metadata', () => {
|
||||
[me.user_id, bob.user_id, cindy.user_id, denise.user_id]);
|
||||
});
|
||||
|
||||
run_test('message_booleans_parity', () => {
|
||||
run_test("message_booleans_parity", () => {
|
||||
// We have two code paths that update/set message booleans.
|
||||
// This test asserts that both have identical behavior for the
|
||||
// flags common between them.
|
||||
const assert_bool_match = (flags, expected_message) => {
|
||||
const set_message = {topic: 'set_message_booleans', flags: flags};
|
||||
const update_message = {topic: 'update_booleans'};
|
||||
const set_message = {topic: "set_message_booleans", flags: flags};
|
||||
const update_message = {topic: "update_booleans"};
|
||||
message_store.set_message_booleans(set_message);
|
||||
message_store.update_booleans(update_message, flags);
|
||||
Object.keys(expected_message).forEach((key) => {
|
||||
assert.equal(set_message[key], expected_message[key], `'${key}' != ${expected_message[key]}`);
|
||||
assert.equal(update_message[key], expected_message[key]);
|
||||
});
|
||||
assert.equal(set_message.topic, 'set_message_booleans');
|
||||
assert.equal(update_message.topic, 'update_booleans');
|
||||
assert.equal(set_message.topic, "set_message_booleans");
|
||||
assert.equal(update_message.topic, "update_booleans");
|
||||
};
|
||||
|
||||
assert_bool_match(['wildcard_mentioned'],
|
||||
assert_bool_match(["wildcard_mentioned"],
|
||||
{
|
||||
mentioned: true,
|
||||
mentioned_me_directly: false,
|
||||
alerted: false,
|
||||
});
|
||||
|
||||
assert_bool_match(['mentioned'],
|
||||
assert_bool_match(["mentioned"],
|
||||
{
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
alerted: false,
|
||||
});
|
||||
|
||||
assert_bool_match(['has_alert_word'],
|
||||
assert_bool_match(["has_alert_word"],
|
||||
{
|
||||
mentioned: false,
|
||||
mentioned_me_directly: false,
|
||||
@@ -178,32 +178,32 @@ run_test('message_booleans_parity', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('errors', () => {
|
||||
run_test("errors", () => {
|
||||
// Test a user that doesn't exist
|
||||
let message = {
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [{id: 92714}],
|
||||
};
|
||||
|
||||
blueslip.expect('error', 'Unknown user_id in get_by_user_id: 92714', 2);
|
||||
blueslip.expect('error', 'Unknown user id 92714', 2); // From person.js
|
||||
blueslip.expect("error", "Unknown user_id in get_by_user_id: 92714", 2);
|
||||
blueslip.expect("error", "Unknown user id 92714", 2); // From person.js
|
||||
|
||||
// Expect each to throw two blueslip errors
|
||||
// One from message_store.js, one from person.js
|
||||
const emails = message_store.get_pm_emails(message);
|
||||
assert.equal(emails, '?');
|
||||
assert.equal(emails, "?");
|
||||
|
||||
const names = message_store.get_pm_full_names(message);
|
||||
assert.equal(names, '?');
|
||||
assert.equal(names, "?");
|
||||
|
||||
message = {
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
display_recipient: [{}],
|
||||
};
|
||||
|
||||
// This should early return and not run pm_conversation.set_partner
|
||||
let num_partner = 0;
|
||||
set_global('pm_conversation', {
|
||||
set_global("pm_conversation", {
|
||||
set_partner: function () {
|
||||
num_partner += 1;
|
||||
},
|
||||
@@ -212,7 +212,7 @@ run_test('errors', () => {
|
||||
assert.equal(num_partner, 0);
|
||||
});
|
||||
|
||||
run_test('update_booleans', () => {
|
||||
run_test("update_booleans", () => {
|
||||
const message = {};
|
||||
|
||||
// First, test fields that we do actually want to update.
|
||||
@@ -220,18 +220,18 @@ run_test('update_booleans', () => {
|
||||
message.mentioned_me_directly = false;
|
||||
message.alerted = false;
|
||||
|
||||
let flags = ['mentioned', 'has_alert_word', 'read'];
|
||||
let flags = ["mentioned", "has_alert_word", "read"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, true);
|
||||
assert.equal(message.mentioned_me_directly, true);
|
||||
assert.equal(message.alerted, true);
|
||||
|
||||
flags = ['wildcard_mentioned', 'unread'];
|
||||
flags = ["wildcard_mentioned", "unread"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, true);
|
||||
assert.equal(message.mentioned_me_directly, false);
|
||||
|
||||
flags = ['read'];
|
||||
flags = ["read"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, false);
|
||||
assert.equal(message.mentioned_me_directly, false);
|
||||
@@ -239,40 +239,40 @@ run_test('update_booleans', () => {
|
||||
|
||||
// Make sure we don't muck with unread.
|
||||
message.unread = false;
|
||||
flags = [''];
|
||||
flags = [""];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.unread, false);
|
||||
|
||||
message.unread = true;
|
||||
flags = ['read'];
|
||||
flags = ["read"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.unread, true);
|
||||
});
|
||||
|
||||
run_test('each', () => {
|
||||
run_test("each", () => {
|
||||
message_store.each((message) => {
|
||||
assert(message.alerted !== undefined);
|
||||
});
|
||||
});
|
||||
|
||||
run_test('message_id_change', () => {
|
||||
run_test("message_id_change", () => {
|
||||
const message = {
|
||||
sender_email: 'me@example.com',
|
||||
sender_email: "me@example.com",
|
||||
sender_id: me.user_id,
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: convert_recipients([me, bob, cindy]),
|
||||
flags: ['has_alert_word'],
|
||||
flags: ["has_alert_word"],
|
||||
id: 401,
|
||||
};
|
||||
message_store.add_message_metadata(message);
|
||||
|
||||
set_global('pointer', {
|
||||
set_global("pointer", {
|
||||
furthest_read: 401,
|
||||
set_furthest_read: function (value) { this.furthest_read = value; },
|
||||
});
|
||||
|
||||
set_global('message_list', {});
|
||||
set_global('home_msg_list', {});
|
||||
set_global("message_list", {});
|
||||
set_global("home_msg_list", {});
|
||||
|
||||
const opts = {
|
||||
old_id: 401,
|
||||
@@ -282,7 +282,7 @@ run_test('message_id_change', () => {
|
||||
global.with_stub((stub) => {
|
||||
home_msg_list.change_message_id = stub.f;
|
||||
message_store.reify_message_id(opts);
|
||||
const msg_id = stub.get_args('old', 'new');
|
||||
const msg_id = stub.get_args("old", "new");
|
||||
assert.equal(msg_id.old, 401);
|
||||
assert.equal(msg_id.new, 402);
|
||||
});
|
||||
@@ -291,14 +291,14 @@ run_test('message_id_change', () => {
|
||||
global.with_stub((stub) => {
|
||||
home_msg_list.view.change_message_id = stub.f;
|
||||
message_store.reify_message_id(opts);
|
||||
const msg_id = stub.get_args('old', 'new');
|
||||
const msg_id = stub.get_args("old", "new");
|
||||
assert.equal(msg_id.old, 401);
|
||||
assert.equal(msg_id.new, 402);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
run_test('errors', () => {
|
||||
blueslip.expect('error', 'message_store.get got bad value: undefined');
|
||||
run_test("errors", () => {
|
||||
blueslip.expect("error", "message_store.get got bad value: undefined");
|
||||
message_store.get(undefined);
|
||||
});
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
|
||||
zrequire('timerender');
|
||||
zrequire('muting');
|
||||
zrequire('stream_data');
|
||||
set_global('XDate', zrequire('XDate', 'xdate'));
|
||||
set_global('page_params', {});
|
||||
zrequire("timerender");
|
||||
zrequire("muting");
|
||||
zrequire("stream_data");
|
||||
set_global("XDate", zrequire("XDate", "xdate"));
|
||||
set_global("page_params", {});
|
||||
|
||||
run_test('edge_cases', () => {
|
||||
run_test("edge_cases", () => {
|
||||
// private messages
|
||||
assert(!muting.is_topic_muted(undefined, undefined));
|
||||
});
|
||||
|
||||
const design = {
|
||||
stream_id: 100,
|
||||
name: 'design',
|
||||
name: "design",
|
||||
};
|
||||
|
||||
const devel = {
|
||||
stream_id: 101,
|
||||
name: 'devel',
|
||||
name: "devel",
|
||||
};
|
||||
|
||||
const office = {
|
||||
stream_id: 102,
|
||||
name: 'office',
|
||||
name: "office",
|
||||
};
|
||||
|
||||
const social = {
|
||||
stream_id: 103,
|
||||
name: 'social',
|
||||
name: "social",
|
||||
};
|
||||
|
||||
const unknown = {
|
||||
stream_id: 999,
|
||||
name: 'whatever',
|
||||
name: "whatever",
|
||||
};
|
||||
|
||||
stream_data.add_sub(design);
|
||||
@@ -40,53 +40,53 @@ stream_data.add_sub(devel);
|
||||
stream_data.add_sub(office);
|
||||
stream_data.add_sub(social);
|
||||
|
||||
run_test('basics', () => {
|
||||
assert(!muting.is_topic_muted(devel.stream_id, 'java'));
|
||||
muting.add_muted_topic(devel.stream_id, 'java');
|
||||
assert(muting.is_topic_muted(devel.stream_id, 'java'));
|
||||
run_test("basics", () => {
|
||||
assert(!muting.is_topic_muted(devel.stream_id, "java"));
|
||||
muting.add_muted_topic(devel.stream_id, "java");
|
||||
assert(muting.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
// test idempotentcy
|
||||
muting.add_muted_topic(devel.stream_id, 'java');
|
||||
assert(muting.is_topic_muted(devel.stream_id, 'java'));
|
||||
muting.add_muted_topic(devel.stream_id, "java");
|
||||
assert(muting.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
muting.remove_muted_topic(devel.stream_id, 'java');
|
||||
assert(!muting.is_topic_muted(devel.stream_id, 'java'));
|
||||
muting.remove_muted_topic(devel.stream_id, "java");
|
||||
assert(!muting.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
// test idempotentcy
|
||||
muting.remove_muted_topic(devel.stream_id, 'java');
|
||||
assert(!muting.is_topic_muted(devel.stream_id, 'java'));
|
||||
muting.remove_muted_topic(devel.stream_id, "java");
|
||||
assert(!muting.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
// test unknown stream is harmless too
|
||||
muting.remove_muted_topic(unknown.stream_id, 'java');
|
||||
assert(!muting.is_topic_muted(unknown.stream_id, 'java'));
|
||||
muting.remove_muted_topic(unknown.stream_id, "java");
|
||||
assert(!muting.is_topic_muted(unknown.stream_id, "java"));
|
||||
});
|
||||
|
||||
run_test('get_and_set_muted_topics', () => {
|
||||
run_test("get_and_set_muted_topics", () => {
|
||||
assert.deepEqual(muting.get_muted_topics(), []);
|
||||
muting.add_muted_topic(office.stream_id, 'gossip', 1577836800);
|
||||
muting.add_muted_topic(devel.stream_id, 'java', 1577836800);
|
||||
muting.add_muted_topic(office.stream_id, "gossip", 1577836800);
|
||||
muting.add_muted_topic(devel.stream_id, "java", 1577836800);
|
||||
assert.deepEqual(muting.get_muted_topics().sort(), [
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
date_muted_str: 'Jan 01',
|
||||
date_muted_str: "Jan 01",
|
||||
stream: devel.name,
|
||||
stream_id: devel.stream_id,
|
||||
topic: 'java',
|
||||
topic: "java",
|
||||
},
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
date_muted_str: 'Jan 01',
|
||||
date_muted_str: "Jan 01",
|
||||
stream: office.name,
|
||||
stream_id: office.stream_id,
|
||||
topic: 'gossip',
|
||||
topic: "gossip",
|
||||
}]);
|
||||
|
||||
blueslip.expect('warn', 'Unknown stream in set_muted_topics: BOGUS STREAM');
|
||||
blueslip.expect("warn", "Unknown stream in set_muted_topics: BOGUS STREAM");
|
||||
|
||||
page_params.muted_topics = [
|
||||
['social', 'breakfast', 1577836800],
|
||||
['design', 'typography', 1577836800],
|
||||
['BOGUS STREAM', 'whatever', 1577836800],
|
||||
["social", "breakfast", 1577836800],
|
||||
["design", "typography", 1577836800],
|
||||
["BOGUS STREAM", "whatever", 1577836800],
|
||||
];
|
||||
muting.initialize();
|
||||
|
||||
@@ -94,26 +94,26 @@ run_test('get_and_set_muted_topics', () => {
|
||||
assert.deepEqual(muting.get_muted_topics().sort(), [
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
date_muted_str: 'Jan 01',
|
||||
date_muted_str: "Jan 01",
|
||||
stream: social.name,
|
||||
stream_id: social.stream_id,
|
||||
topic: 'breakfast',
|
||||
topic: "breakfast",
|
||||
},
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
date_muted_str: 'Jan 01',
|
||||
date_muted_str: "Jan 01",
|
||||
stream: design.name,
|
||||
stream_id: design.stream_id,
|
||||
topic: 'typography',
|
||||
topic: "typography",
|
||||
}]);
|
||||
});
|
||||
|
||||
run_test('case_insensitivity', () => {
|
||||
run_test("case_insensitivity", () => {
|
||||
muting.set_muted_topics([]);
|
||||
assert(!muting.is_topic_muted(social.stream_id, 'breakfast'));
|
||||
assert(!muting.is_topic_muted(social.stream_id, "breakfast"));
|
||||
muting.set_muted_topics([
|
||||
['SOCial', 'breakfast'],
|
||||
["SOCial", "breakfast"],
|
||||
]);
|
||||
assert(muting.is_topic_muted(social.stream_id, 'breakfast'));
|
||||
assert(muting.is_topic_muted(social.stream_id, 'breakFAST'));
|
||||
assert(muting.is_topic_muted(social.stream_id, "breakfast"));
|
||||
assert(muting.is_topic_muted(social.stream_id, "breakFAST"));
|
||||
});
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
zrequire('hash_util');
|
||||
zrequire('hashchange');
|
||||
zrequire('narrow_state');
|
||||
zrequire('people');
|
||||
zrequire('stream_data');
|
||||
zrequire('Filter', 'js/filter');
|
||||
set_global('page_params', {
|
||||
stop_words: ['what', 'about'],
|
||||
set_global("$", global.make_zjquery());
|
||||
zrequire("hash_util");
|
||||
zrequire("hashchange");
|
||||
zrequire("narrow_state");
|
||||
zrequire("people");
|
||||
zrequire("stream_data");
|
||||
zrequire("Filter", "js/filter");
|
||||
set_global("page_params", {
|
||||
stop_words: ["what", "about"],
|
||||
});
|
||||
set_global('resize', {
|
||||
set_global("resize", {
|
||||
resize_page_components: () => {},
|
||||
resize_stream_filters_container: () => {},
|
||||
});
|
||||
|
||||
|
||||
zrequire('narrow');
|
||||
zrequire("narrow");
|
||||
|
||||
function set_filter(operators) {
|
||||
operators = operators.map((op) => ({
|
||||
@@ -25,110 +25,110 @@ function set_filter(operators) {
|
||||
}
|
||||
|
||||
const me = {
|
||||
email: 'me@example.com',
|
||||
email: "me@example.com",
|
||||
user_id: 5,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 23,
|
||||
full_name: 'Alice Smith',
|
||||
full_name: "Alice Smith",
|
||||
};
|
||||
|
||||
const ray = {
|
||||
email: 'ray@example.com',
|
||||
email: "ray@example.com",
|
||||
user_id: 22,
|
||||
full_name: 'Raymond',
|
||||
full_name: "Raymond",
|
||||
};
|
||||
|
||||
run_test('uris', () => {
|
||||
run_test("uris", () => {
|
||||
people.add_active_user(ray);
|
||||
people.add_active_user(alice);
|
||||
people.add_active_user(me);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
let uri = hash_util.pm_with_uri(ray.email);
|
||||
assert.equal(uri, '#narrow/pm-with/22-ray');
|
||||
assert.equal(uri, "#narrow/pm-with/22-ray");
|
||||
|
||||
uri = hash_util.huddle_with_uri("22,23");
|
||||
assert.equal(uri, '#narrow/pm-with/22,23-group');
|
||||
assert.equal(uri, "#narrow/pm-with/22,23-group");
|
||||
|
||||
uri = hash_util.by_sender_uri(ray.email);
|
||||
assert.equal(uri, '#narrow/sender/22-ray');
|
||||
assert.equal(uri, "#narrow/sender/22-ray");
|
||||
|
||||
let emails = global.hash_util.decode_operand('pm-with', '22,23-group');
|
||||
assert.equal(emails, 'alice@example.com,ray@example.com');
|
||||
let emails = global.hash_util.decode_operand("pm-with", "22,23-group");
|
||||
assert.equal(emails, "alice@example.com,ray@example.com");
|
||||
|
||||
emails = global.hash_util.decode_operand('pm-with', '5,22,23-group');
|
||||
assert.equal(emails, 'alice@example.com,ray@example.com');
|
||||
emails = global.hash_util.decode_operand("pm-with", "5,22,23-group");
|
||||
assert.equal(emails, "alice@example.com,ray@example.com");
|
||||
|
||||
emails = global.hash_util.decode_operand('pm-with', '5-group');
|
||||
assert.equal(emails, 'me@example.com');
|
||||
emails = global.hash_util.decode_operand("pm-with", "5-group");
|
||||
assert.equal(emails, "me@example.com");
|
||||
});
|
||||
|
||||
run_test('show_empty_narrow_message', () => {
|
||||
run_test("show_empty_narrow_message", () => {
|
||||
narrow_state.reset_current_filter();
|
||||
narrow.show_empty_narrow_message();
|
||||
assert.equal($('.empty_feed_notice').visible(), false);
|
||||
assert($('#empty_narrow_message').visible());
|
||||
assert.equal($(".empty_feed_notice").visible(), false);
|
||||
assert($("#empty_narrow_message").visible());
|
||||
assert.equal(
|
||||
$('#left_bar_compose_reply_button_big').attr('title'),
|
||||
'translated: There are no messages to reply to.',
|
||||
$("#left_bar_compose_reply_button_big").attr("title"),
|
||||
"translated: There are no messages to reply to.",
|
||||
);
|
||||
|
||||
// for non-existent or private stream
|
||||
set_filter([['stream', 'Foo']]);
|
||||
set_filter([["stream", "Foo"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#nonsubbed_private_nonexistent_stream_narrow_message').visible());
|
||||
assert($("#nonsubbed_private_nonexistent_stream_narrow_message").visible());
|
||||
|
||||
// for non sub public stream
|
||||
stream_data.add_sub({name: 'ROME', stream_id: 99});
|
||||
stream_data.add_sub({name: "ROME", stream_id: 99});
|
||||
stream_data.update_calculated_fields(stream_data.get_sub("ROME"));
|
||||
set_filter([['stream', 'Rome']]);
|
||||
set_filter([["stream", "Rome"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#nonsubbed_stream_narrow_message').visible());
|
||||
assert($("#nonsubbed_stream_narrow_message").visible());
|
||||
|
||||
set_filter([['is', 'starred']]);
|
||||
set_filter([["is", "starred"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_star_narrow_message').visible());
|
||||
assert($("#empty_star_narrow_message").visible());
|
||||
|
||||
set_filter([['is', 'mentioned']]);
|
||||
set_filter([["is", "mentioned"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_narrow_all_mentioned').visible());
|
||||
assert($("#empty_narrow_all_mentioned").visible());
|
||||
|
||||
set_filter([['is', 'private']]);
|
||||
set_filter([["is", "private"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_narrow_all_private_message').visible());
|
||||
assert($("#empty_narrow_all_private_message").visible());
|
||||
|
||||
set_filter([['is', 'unread']]);
|
||||
set_filter([["is", "unread"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#no_unread_narrow_message').visible());
|
||||
assert($("#no_unread_narrow_message").visible());
|
||||
|
||||
set_filter([['pm-with', ['Yo']]]);
|
||||
set_filter([["pm-with", ["Yo"]]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#non_existing_user').visible());
|
||||
assert($("#non_existing_user").visible());
|
||||
|
||||
people.add_active_user(alice);
|
||||
set_filter([['pm-with', ['alice@example.com', 'Yo']]]);
|
||||
set_filter([["pm-with", ["alice@example.com", "Yo"]]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#non_existing_users').visible());
|
||||
assert($("#non_existing_users").visible());
|
||||
|
||||
set_filter([['pm-with', 'alice@example.com']]);
|
||||
set_filter([["pm-with", "alice@example.com"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_narrow_private_message').visible());
|
||||
assert($("#empty_narrow_private_message").visible());
|
||||
|
||||
set_filter([['group-pm-with', 'alice@example.com']]);
|
||||
set_filter([["group-pm-with", "alice@example.com"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_narrow_group_private_message').visible());
|
||||
assert($("#empty_narrow_group_private_message").visible());
|
||||
|
||||
set_filter([['sender', 'ray@example.com']]);
|
||||
set_filter([["sender", "ray@example.com"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#silent_user').visible());
|
||||
assert($("#silent_user").visible());
|
||||
|
||||
set_filter([['sender', 'sinwar@example.com']]);
|
||||
set_filter([["sender", "sinwar@example.com"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#non_existing_user').visible());
|
||||
assert($("#non_existing_user").visible());
|
||||
|
||||
const display = $("#empty_search_stop_words_string");
|
||||
|
||||
@@ -137,16 +137,16 @@ run_test('show_empty_narrow_message', () => {
|
||||
items.push(html);
|
||||
};
|
||||
|
||||
set_filter([['search', 'grail']]);
|
||||
set_filter([["search", "grail"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
|
||||
assert.equal(items.length, 2);
|
||||
assert.equal(items[0], ' ');
|
||||
assert.equal(items[1].text(), 'grail');
|
||||
assert.equal(items[0], " ");
|
||||
assert.equal(items[1].text(), "grail");
|
||||
});
|
||||
|
||||
run_test('show_search_stopwords', () => {
|
||||
run_test("show_search_stopwords", () => {
|
||||
narrow_state.reset_current_filter();
|
||||
let items = [];
|
||||
|
||||
@@ -158,67 +158,67 @@ run_test('show_search_stopwords', () => {
|
||||
}
|
||||
};
|
||||
|
||||
set_filter([['search', 'what about grail']]);
|
||||
set_filter([["search", "what about grail"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
|
||||
assert.equal(items.length, 3);
|
||||
assert.equal(items[0], '<del>what');
|
||||
assert.equal(items[1], '<del>about');
|
||||
assert.equal(items[2], '<span>grail');
|
||||
assert.equal(items[0], "<del>what");
|
||||
assert.equal(items[1], "<del>about");
|
||||
assert.equal(items[2], "<span>grail");
|
||||
|
||||
items = [];
|
||||
set_filter([['stream', 'streamA'], ['search', 'what about grail']]);
|
||||
set_filter([["stream", "streamA"], ["search", "what about grail"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
|
||||
assert.equal(items.length, 4);
|
||||
assert.equal(items[0], '<span>stream: streamA');
|
||||
assert.equal(items[1], '<del>what');
|
||||
assert.equal(items[2], '<del>about');
|
||||
assert.equal(items[3], '<span>grail');
|
||||
assert.equal(items[0], "<span>stream: streamA");
|
||||
assert.equal(items[1], "<del>what");
|
||||
assert.equal(items[2], "<del>about");
|
||||
assert.equal(items[3], "<span>grail");
|
||||
|
||||
items = [];
|
||||
set_filter([['stream', 'streamA'], ['topic', 'topicA'], ['search', 'what about grail']]);
|
||||
set_filter([["stream", "streamA"], ["topic", "topicA"], ["search", "what about grail"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
|
||||
assert.equal(items.length, 4);
|
||||
assert.equal(items[0], '<span>stream: streamA topic: topicA');
|
||||
assert.equal(items[1], '<del>what');
|
||||
assert.equal(items[2], '<del>about');
|
||||
assert.equal(items[3], '<span>grail');
|
||||
assert.equal(items[0], "<span>stream: streamA topic: topicA");
|
||||
assert.equal(items[1], "<del>what");
|
||||
assert.equal(items[2], "<del>about");
|
||||
assert.equal(items[3], "<span>grail");
|
||||
});
|
||||
|
||||
run_test('show_invalid_narrow_message', () => {
|
||||
run_test("show_invalid_narrow_message", () => {
|
||||
narrow_state.reset_current_filter();
|
||||
const display = $("#empty_search_stop_words_string");
|
||||
|
||||
stream_data.add_sub({name: 'streamA', stream_id: 88});
|
||||
stream_data.add_sub({name: 'streamB', stream_id: 77});
|
||||
stream_data.add_sub({name: "streamA", stream_id: 88});
|
||||
stream_data.add_sub({name: "streamB", stream_id: 77});
|
||||
|
||||
set_filter([['stream', 'streamA'], ['stream', 'streamB']]);
|
||||
set_filter([["stream", "streamA"], ["stream", "streamB"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert.equal(display.text(), 'translated: You are searching for messages that belong to more than one stream, which is not possible.');
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
assert.equal(display.text(), "translated: You are searching for messages that belong to more than one stream, which is not possible.");
|
||||
|
||||
set_filter([['topic', 'topicA'], ['topic', 'topicB']]);
|
||||
set_filter([["topic", "topicA"], ["topic", "topicB"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert.equal(display.text(), 'translated: You are searching for messages that belong to more than one topic, which is not possible.');
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
assert.equal(display.text(), "translated: You are searching for messages that belong to more than one topic, which is not possible.");
|
||||
|
||||
people.add_active_user(ray);
|
||||
people.add_active_user(alice);
|
||||
|
||||
set_filter([['sender', 'alice@example.com'], ['sender', 'ray@example.com']]);
|
||||
set_filter([["sender", "alice@example.com"], ["sender", "ray@example.com"]]);
|
||||
narrow.show_empty_narrow_message();
|
||||
assert($('#empty_search_narrow_message').visible());
|
||||
assert.equal(display.text(), 'translated: You are searching for messages that are sent by more than one person, which is not possible.');
|
||||
assert($("#empty_search_narrow_message").visible());
|
||||
assert.equal(display.text(), "translated: You are searching for messages that are sent by more than one person, which is not possible.");
|
||||
});
|
||||
|
||||
run_test('narrow_to_compose_target', () => {
|
||||
set_global('compose_state', {});
|
||||
set_global('stream_topic_history', {});
|
||||
run_test("narrow_to_compose_target", () => {
|
||||
set_global("compose_state", {});
|
||||
set_global("stream_topic_history", {});
|
||||
const args = {called: false};
|
||||
const activate_backup = narrow.activate;
|
||||
narrow.activate = function (operators, opts) {
|
||||
@@ -234,45 +234,45 @@ run_test('narrow_to_compose_target', () => {
|
||||
global.compose_state.composing = () => true;
|
||||
|
||||
// No-op when empty stream.
|
||||
global.compose_state.get_message_type = () => 'stream';
|
||||
global.compose_state.stream_name = () => '';
|
||||
global.compose_state.get_message_type = () => "stream";
|
||||
global.compose_state.stream_name = () => "";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, false);
|
||||
|
||||
// --- Tests for stream messages ---
|
||||
global.compose_state.get_message_type = () => 'stream';
|
||||
stream_data.add_sub({name: 'ROME', stream_id: 99});
|
||||
global.compose_state.stream_name = () => 'ROME';
|
||||
global.stream_topic_history.get_recent_topic_names = () => ['one', 'two', 'three'];
|
||||
global.compose_state.get_message_type = () => "stream";
|
||||
stream_data.add_sub({name: "ROME", stream_id: 99});
|
||||
global.compose_state.stream_name = () => "ROME";
|
||||
global.stream_topic_history.get_recent_topic_names = () => ["one", "two", "three"];
|
||||
|
||||
// Test with existing topic
|
||||
global.compose_state.topic = () => 'one';
|
||||
global.compose_state.topic = () => "one";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.equal(args.opts.trigger, 'narrow_to_compose_target');
|
||||
assert.equal(args.opts.trigger, "narrow_to_compose_target");
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'stream', operand: 'ROME'},
|
||||
{operator: 'topic', operand: 'one'},
|
||||
{operator: "stream", operand: "ROME"},
|
||||
{operator: "topic", operand: "one"},
|
||||
]);
|
||||
|
||||
// Test with new topic
|
||||
global.compose_state.topic = () => 'four';
|
||||
global.compose_state.topic = () => "four";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'stream', operand: 'ROME'},
|
||||
{operator: "stream", operand: "ROME"},
|
||||
]);
|
||||
|
||||
// Test with blank topic
|
||||
global.compose_state.topic = () => '';
|
||||
global.compose_state.topic = () => "";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'stream', operand: 'ROME'},
|
||||
{operator: "stream", operand: "ROME"},
|
||||
]);
|
||||
|
||||
// Test with no topic
|
||||
@@ -281,58 +281,58 @@ run_test('narrow_to_compose_target', () => {
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'stream', operand: 'ROME'},
|
||||
{operator: "stream", operand: "ROME"},
|
||||
]);
|
||||
|
||||
// --- Tests for PMs ---
|
||||
global.compose_state.get_message_type = () => 'private';
|
||||
global.compose_state.get_message_type = () => "private";
|
||||
people.add_active_user(ray);
|
||||
people.add_active_user(alice);
|
||||
people.add_active_user(me);
|
||||
|
||||
// Test with valid person
|
||||
global.compose_state.private_message_recipient = () => 'alice@example.com';
|
||||
global.compose_state.private_message_recipient = () => "alice@example.com";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'pm-with', operand: 'alice@example.com'},
|
||||
{operator: "pm-with", operand: "alice@example.com"},
|
||||
]);
|
||||
|
||||
// Test with valid persons
|
||||
global.compose_state.private_message_recipient = () => 'alice@example.com,ray@example.com';
|
||||
global.compose_state.private_message_recipient = () => "alice@example.com,ray@example.com";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'pm-with', operand: 'alice@example.com,ray@example.com'},
|
||||
{operator: "pm-with", operand: "alice@example.com,ray@example.com"},
|
||||
]);
|
||||
|
||||
// Test with some invalid persons
|
||||
global.compose_state.private_message_recipient = () => 'alice@example.com,random,ray@example.com';
|
||||
global.compose_state.private_message_recipient = () => "alice@example.com,random,ray@example.com";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
]);
|
||||
|
||||
// Test with all invalid persons
|
||||
global.compose_state.private_message_recipient = () => 'alice,random,ray';
|
||||
global.compose_state.private_message_recipient = () => "alice,random,ray";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
]);
|
||||
|
||||
// Test with no persons
|
||||
global.compose_state.private_message_recipient = () => '';
|
||||
global.compose_state.private_message_recipient = () => "";
|
||||
args.called = false;
|
||||
narrow.to_compose_target();
|
||||
assert.equal(args.called, true);
|
||||
assert.deepEqual(args.operators, [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
]);
|
||||
|
||||
narrow.activate = activate_backup;
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
const util = zrequire('util');
|
||||
set_global('$', global.make_zjquery());
|
||||
const util = zrequire("util");
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
zrequire('narrow_state');
|
||||
set_global('resize', {
|
||||
zrequire("narrow_state");
|
||||
set_global("resize", {
|
||||
resize_stream_filters_container: () => {},
|
||||
});
|
||||
zrequire('stream_data');
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('FetchStatus', 'js/fetch_status');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire('unread');
|
||||
zrequire('narrow');
|
||||
zrequire('search_pill');
|
||||
zrequire("stream_data");
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("FetchStatus", "js/fetch_status");
|
||||
zrequire("MessageListData", "js/message_list_data");
|
||||
zrequire("unread");
|
||||
zrequire("narrow");
|
||||
zrequire("search_pill");
|
||||
|
||||
set_global('channel', {});
|
||||
set_global('compose', {});
|
||||
set_global('compose_actions', {});
|
||||
set_global('current_msg_list', {});
|
||||
set_global('hashchange', {});
|
||||
set_global('home_msg_list', {});
|
||||
set_global('message_fetch', {});
|
||||
set_global('message_list', {
|
||||
set_global("channel", {});
|
||||
set_global("compose", {});
|
||||
set_global("compose_actions", {});
|
||||
set_global("current_msg_list", {});
|
||||
set_global("hashchange", {});
|
||||
set_global("home_msg_list", {});
|
||||
set_global("message_fetch", {});
|
||||
set_global("message_list", {
|
||||
set_narrowed: function (value) { this.narrowed = value; },
|
||||
});
|
||||
set_global('message_scroll', {});
|
||||
set_global('message_util', {});
|
||||
set_global('notifications', {});
|
||||
set_global('page_params', {});
|
||||
set_global('search', {});
|
||||
set_global('stream_list', {});
|
||||
set_global('tab_bar', {});
|
||||
set_global('top_left_corner', {});
|
||||
set_global('typing_events', {});
|
||||
set_global('ui_util', {});
|
||||
set_global('unread_ops', {});
|
||||
set_global('search_pill_widget', {
|
||||
set_global("message_scroll", {});
|
||||
set_global("message_util", {});
|
||||
set_global("notifications", {});
|
||||
set_global("page_params", {});
|
||||
set_global("search", {});
|
||||
set_global("stream_list", {});
|
||||
set_global("tab_bar", {});
|
||||
set_global("top_left_corner", {});
|
||||
set_global("typing_events", {});
|
||||
set_global("ui_util", {});
|
||||
set_global("unread_ops", {});
|
||||
set_global("search_pill_widget", {
|
||||
widget: {
|
||||
clear: function () {return true;},
|
||||
appendValue: function () {return true;},
|
||||
@@ -44,19 +44,19 @@ set_global('search_pill_widget', {
|
||||
//
|
||||
// We have strange hacks in narrow.activate to sleep 0
|
||||
// seconds.
|
||||
global.patch_builtin('setTimeout', (f, t) => {
|
||||
global.patch_builtin("setTimeout", (f, t) => {
|
||||
assert.equal(t, 0);
|
||||
f();
|
||||
});
|
||||
|
||||
set_global('muting', {
|
||||
set_global("muting", {
|
||||
is_topic_muted: () => false,
|
||||
});
|
||||
|
||||
const denmark = {
|
||||
subscribed: false,
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
color: "blue",
|
||||
name: "Denmark",
|
||||
stream_id: 1,
|
||||
is_muted: true,
|
||||
};
|
||||
@@ -67,26 +67,26 @@ function test_helper() {
|
||||
|
||||
function stub(module_name, func_name) {
|
||||
global[module_name][func_name] = () => {
|
||||
events.push(module_name + '.' + func_name);
|
||||
events.push(module_name + "." + func_name);
|
||||
};
|
||||
}
|
||||
|
||||
stub('compose_actions', 'on_narrow');
|
||||
stub('hashchange', 'save_narrow');
|
||||
stub('message_scroll', 'hide_indicators');
|
||||
stub('message_scroll', 'show_loading_older');
|
||||
stub('message_scroll', 'hide_top_of_narrow_notices');
|
||||
stub('notifications', 'clear_compose_notifications');
|
||||
stub('notifications', 'redraw_title');
|
||||
stub('search', 'update_button_visibility');
|
||||
stub('stream_list', 'handle_narrow_activated');
|
||||
stub('tab_bar', 'initialize');
|
||||
stub('top_left_corner', 'handle_narrow_activated');
|
||||
stub('typing_events', 'render_notifications_for_narrow');
|
||||
stub('ui_util', 'change_tab_to');
|
||||
stub('unread_ops', 'process_visible');
|
||||
stub('compose', 'update_closed_compose_buttons_for_stream');
|
||||
stub('compose', 'update_closed_compose_buttons_for_private');
|
||||
stub("compose_actions", "on_narrow");
|
||||
stub("hashchange", "save_narrow");
|
||||
stub("message_scroll", "hide_indicators");
|
||||
stub("message_scroll", "show_loading_older");
|
||||
stub("message_scroll", "hide_top_of_narrow_notices");
|
||||
stub("notifications", "clear_compose_notifications");
|
||||
stub("notifications", "redraw_title");
|
||||
stub("search", "update_button_visibility");
|
||||
stub("stream_list", "handle_narrow_activated");
|
||||
stub("tab_bar", "initialize");
|
||||
stub("top_left_corner", "handle_narrow_activated");
|
||||
stub("typing_events", "render_notifications_for_narrow");
|
||||
stub("ui_util", "change_tab_to");
|
||||
stub("unread_ops", "process_visible");
|
||||
stub("compose", "update_closed_compose_buttons_for_stream");
|
||||
stub("compose", "update_closed_compose_buttons_for_private");
|
||||
|
||||
return {
|
||||
clear: () => {
|
||||
@@ -129,21 +129,21 @@ function stub_message_list() {
|
||||
};
|
||||
}
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
stub_message_list();
|
||||
|
||||
const helper = test_helper();
|
||||
const terms = [
|
||||
{ operator: 'stream', operand: 'Denmark' },
|
||||
{ operator: "stream", operand: "Denmark" },
|
||||
];
|
||||
|
||||
const selected_id = 1000;
|
||||
|
||||
const selected_message = {
|
||||
id: selected_id,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: denmark.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
|
||||
const messages = [selected_message];
|
||||
@@ -192,41 +192,41 @@ run_test('basics', () => {
|
||||
assert.equal(narrow_state.narrowed_to_pms(), false);
|
||||
|
||||
helper.assert_events([
|
||||
'notifications.clear_compose_notifications',
|
||||
'notifications.redraw_title',
|
||||
'message_scroll.hide_top_of_narrow_notices',
|
||||
'message_scroll.hide_indicators',
|
||||
'ui_util.change_tab_to',
|
||||
'unread_ops.process_visible',
|
||||
'hashchange.save_narrow',
|
||||
'compose.update_closed_compose_buttons_for_stream',
|
||||
'search.update_button_visibility',
|
||||
'compose_actions.on_narrow',
|
||||
'top_left_corner.handle_narrow_activated',
|
||||
'stream_list.handle_narrow_activated',
|
||||
'typing_events.render_notifications_for_narrow',
|
||||
'tab_bar.initialize',
|
||||
"notifications.clear_compose_notifications",
|
||||
"notifications.redraw_title",
|
||||
"message_scroll.hide_top_of_narrow_notices",
|
||||
"message_scroll.hide_indicators",
|
||||
"ui_util.change_tab_to",
|
||||
"unread_ops.process_visible",
|
||||
"hashchange.save_narrow",
|
||||
"compose.update_closed_compose_buttons_for_stream",
|
||||
"search.update_button_visibility",
|
||||
"compose_actions.on_narrow",
|
||||
"top_left_corner.handle_narrow_activated",
|
||||
"stream_list.handle_narrow_activated",
|
||||
"typing_events.render_notifications_for_narrow",
|
||||
"tab_bar.initialize",
|
||||
]);
|
||||
|
||||
current_msg_list.selected_id = () => -1;
|
||||
current_msg_list.get_row = () => row;
|
||||
util.sorted_ids = () => [];
|
||||
|
||||
narrow.activate([{ operator: 'is', operand: 'private' }], {
|
||||
narrow.activate([{ operator: "is", operand: "private" }], {
|
||||
then_select_id: selected_id,
|
||||
});
|
||||
|
||||
assert.equal(narrow_state.narrowed_to_pms(), true);
|
||||
|
||||
channel.post = (opts) => {
|
||||
assert.equal(opts.url, '/json/report/narrow_times');
|
||||
helper.push_event('report narrow times');
|
||||
assert.equal(opts.url, "/json/report/narrow_times");
|
||||
helper.push_event("report narrow times");
|
||||
};
|
||||
|
||||
helper.clear();
|
||||
cont();
|
||||
helper.assert_events([
|
||||
'report narrow times',
|
||||
"report narrow times",
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('FetchStatus', 'js/fetch_status');
|
||||
zrequire('MessageListData', 'js/message_list_data');
|
||||
zrequire('narrow_state');
|
||||
zrequire('narrow');
|
||||
zrequire('stream_data');
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("FetchStatus", "js/fetch_status");
|
||||
zrequire("MessageListData", "js/message_list_data");
|
||||
zrequire("narrow_state");
|
||||
zrequire("narrow");
|
||||
zrequire("stream_data");
|
||||
|
||||
set_global('message_list', {});
|
||||
set_global('muting', {
|
||||
set_global("message_list", {});
|
||||
set_global("muting", {
|
||||
is_topic_muted: () => false,
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ function test_with(fixture) {
|
||||
// Make sure our simulated tests data satisfies the
|
||||
// invarariant that the first unread message we find
|
||||
// does indeed satisfy our filter.
|
||||
if (fixture.unread_info.flavor === 'found') {
|
||||
if (fixture.unread_info.flavor === "found") {
|
||||
for (const msg of fixture.all_messages) {
|
||||
if (msg.id === fixture.unread_info.msg_id) {
|
||||
assert(filter.predicate()(msg));
|
||||
@@ -72,23 +72,23 @@ function test_with(fixture) {
|
||||
assert.deepEqual(msg_ids, fixture.expected_msg_ids);
|
||||
}
|
||||
|
||||
run_test('near after unreads', () => {
|
||||
run_test("near after unreads", () => {
|
||||
// Current near: behavior is to ignore the unreads and take you
|
||||
// to the target message, with reading disabled.
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'near', operand: 42},
|
||||
{operator: "near", operand: 42},
|
||||
],
|
||||
target_id: 42,
|
||||
unread_info: {
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: 37,
|
||||
},
|
||||
has_found_newest: false,
|
||||
all_messages: [
|
||||
{id: 37, topic: 'whatever'},
|
||||
{id: 42, topic: 'whatever'},
|
||||
{id: 44, topic: 'whatever'},
|
||||
{id: 37, topic: "whatever"},
|
||||
{id: 42, topic: "whatever"},
|
||||
{id: 44, topic: "whatever"},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: 42,
|
||||
@@ -101,23 +101,23 @@ run_test('near after unreads', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('near not in message list', () => {
|
||||
run_test("near not in message list", () => {
|
||||
// Current behavior is to ignore the unreads and take you
|
||||
// to the closest messages, with reading disabled.
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'near', operand: 42},
|
||||
{operator: "near", operand: 42},
|
||||
],
|
||||
target_id: 42,
|
||||
unread_info: {
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: 46,
|
||||
},
|
||||
has_found_newest: false,
|
||||
all_messages: [
|
||||
{id: 41, topic: 'whatever'},
|
||||
{id: 45, topic: 'whatever'},
|
||||
{id: 46, topic: 'whatever'},
|
||||
{id: 41, topic: "whatever"},
|
||||
{id: 45, topic: "whatever"},
|
||||
{id: 46, topic: "whatever"},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: 42,
|
||||
@@ -130,21 +130,21 @@ run_test('near not in message list', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('near before unreads', () => {
|
||||
run_test("near before unreads", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'near', operand: 42},
|
||||
{operator: "near", operand: 42},
|
||||
],
|
||||
target_id: 42,
|
||||
unread_info: {
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: 43,
|
||||
},
|
||||
has_found_newest: false,
|
||||
all_messages: [
|
||||
{id: 42, topic: 'whatever'},
|
||||
{id: 43, topic: 'whatever'},
|
||||
{id: 44, topic: 'whatever'},
|
||||
{id: 42, topic: "whatever"},
|
||||
{id: 43, topic: "whatever"},
|
||||
{id: 44, topic: "whatever"},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: 42,
|
||||
@@ -157,14 +157,14 @@ run_test('near before unreads', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('near with no unreads', () => {
|
||||
run_test("near with no unreads", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'near', operand: 42},
|
||||
{operator: "near", operand: 42},
|
||||
],
|
||||
target_id: 42,
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: false,
|
||||
empty: true,
|
||||
@@ -179,20 +179,20 @@ run_test('near with no unreads', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('is private with no target', () => {
|
||||
run_test("is private with no target", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
],
|
||||
unread_info: {
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: 550,
|
||||
},
|
||||
has_found_newest: true,
|
||||
all_messages: [
|
||||
{id: 450, type: 'private'},
|
||||
{id: 500, type: 'private'},
|
||||
{id: 550, type: 'private'},
|
||||
{id: 450, type: "private"},
|
||||
{id: 500, type: "private"},
|
||||
{id: 550, type: "private"},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: undefined,
|
||||
@@ -205,14 +205,14 @@ run_test('is private with no target', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('pm-with with target outside of range', () => {
|
||||
run_test("pm-with with target outside of range", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'pm-with', operand: 'alice@example.com'},
|
||||
{operator: "pm-with", operand: "alice@example.com"},
|
||||
],
|
||||
target_id: 5,
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: false,
|
||||
all_messages: [
|
||||
@@ -229,13 +229,13 @@ run_test('pm-with with target outside of range', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('is:private with no unreads before fetch', () => {
|
||||
run_test("is:private with no unreads before fetch", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
],
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: false,
|
||||
empty: true,
|
||||
@@ -250,22 +250,22 @@ run_test('is:private with no unreads before fetch', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('is:private with target and no unreads', () => {
|
||||
run_test("is:private with target and no unreads", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
],
|
||||
target_id: 450,
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: true,
|
||||
empty: false,
|
||||
all_messages: [
|
||||
{id: 350},
|
||||
{id: 400, type: 'private'},
|
||||
{id: 450, type: 'private'},
|
||||
{id: 500, type: 'private'},
|
||||
{id: 400, type: "private"},
|
||||
{id: 450, type: "private"},
|
||||
{id: 500, type: "private"},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: 450,
|
||||
@@ -278,13 +278,13 @@ run_test('is:private with target and no unreads', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('is:mentioned with no unreads and no matches', () => {
|
||||
run_test("is:mentioned with no unreads and no matches", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'is', operand: 'mentioned'},
|
||||
{operator: "is", operand: "mentioned"},
|
||||
],
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: true,
|
||||
all_messages: [],
|
||||
@@ -299,18 +299,18 @@ run_test('is:mentioned with no unreads and no matches', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('is:alerted with no unreads and one match', () => {
|
||||
run_test("is:alerted with no unreads and one match", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'is', operand: 'alerted'},
|
||||
{operator: "is", operand: "alerted"},
|
||||
],
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: true,
|
||||
all_messages: [
|
||||
{id: 55, topic: 'whatever', alerted: true},
|
||||
{id: 57, topic: 'whatever', alerted: false},
|
||||
{id: 55, topic: "whatever", alerted: true},
|
||||
{id: 57, topic: "whatever", alerted: false},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: undefined,
|
||||
@@ -323,13 +323,13 @@ run_test('is:alerted with no unreads and one match', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('search', () => {
|
||||
run_test("search", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'search', operand: 'whatever'},
|
||||
{operator: "search", operand: "whatever"},
|
||||
],
|
||||
unread_info: {
|
||||
flavor: 'cannot_compute',
|
||||
flavor: "cannot_compute",
|
||||
},
|
||||
expected_id_info: {
|
||||
target_id: undefined,
|
||||
@@ -342,15 +342,15 @@ run_test('search', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('search near', () => {
|
||||
run_test("search near", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'search', operand: 'whatever'},
|
||||
{operator: 'near', operand: 22},
|
||||
{operator: "search", operand: "whatever"},
|
||||
{operator: "near", operand: 22},
|
||||
],
|
||||
target_id: 22,
|
||||
unread_info: {
|
||||
flavor: 'cannot_compute',
|
||||
flavor: "cannot_compute",
|
||||
},
|
||||
expected_id_info: {
|
||||
target_id: 22,
|
||||
@@ -363,7 +363,7 @@ run_test('search near', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('stream, no unread, not in all_messages', () => {
|
||||
run_test("stream, no unread, not in all_messages", () => {
|
||||
// This might be something you'd see zooming out from
|
||||
// a muted topic, maybe? It's possibly this scenario
|
||||
// is somewhat contrived, but we exercise fairly simple
|
||||
@@ -372,11 +372,11 @@ run_test('stream, no unread, not in all_messages', () => {
|
||||
// the range of all_messages.
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'stream', operand: 'whatever'},
|
||||
{operator: "stream", operand: "whatever"},
|
||||
],
|
||||
target_id: 450,
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: true,
|
||||
empty: false,
|
||||
@@ -395,14 +395,14 @@ run_test('stream, no unread, not in all_messages', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('search, stream, not in all_messages', () => {
|
||||
run_test("search, stream, not in all_messages", () => {
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'search', operand: 'foo'},
|
||||
{operator: 'stream', operand: 'whatever'},
|
||||
{operator: "search", operand: "foo"},
|
||||
{operator: "stream", operand: "whatever"},
|
||||
],
|
||||
unread_info: {
|
||||
flavor: 'cannot_compute',
|
||||
flavor: "cannot_compute",
|
||||
},
|
||||
has_found_newest: true,
|
||||
empty: false,
|
||||
@@ -421,19 +421,19 @@ run_test('search, stream, not in all_messages', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('stream/topic not in all_messages', () => {
|
||||
run_test("stream/topic not in all_messages", () => {
|
||||
// This is a bit of a corner case, but you could have a scenario
|
||||
// where you've gone way back in a topic (perhaps something that
|
||||
// has been muted a long time) and find an unread message that isn't
|
||||
// actually in message_list.all.
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'stream', operand: 'one'},
|
||||
{operator: 'topic', operand: 'whatever'},
|
||||
{operator: "stream", operand: "one"},
|
||||
{operator: "topic", operand: "whatever"},
|
||||
],
|
||||
target_id: 1000,
|
||||
unread_info: {
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: 2,
|
||||
},
|
||||
has_found_newest: true,
|
||||
@@ -452,24 +452,24 @@ run_test('stream/topic not in all_messages', () => {
|
||||
test_with(fixture);
|
||||
});
|
||||
|
||||
run_test('final corner case', () => {
|
||||
run_test("final corner case", () => {
|
||||
// This tries to get all the way to the end of
|
||||
// the function (as written now). The data here
|
||||
// may be completely contrived.
|
||||
const fixture = {
|
||||
filter_terms: [
|
||||
{operator: 'is', operand: 'starred'},
|
||||
{operator: "is", operand: "starred"},
|
||||
],
|
||||
target_id: 450,
|
||||
unread_info: {
|
||||
flavor: 'not_found',
|
||||
flavor: "not_found",
|
||||
},
|
||||
has_found_newest: true,
|
||||
empty: false,
|
||||
all_messages: [
|
||||
{id: 400, topic: 'whatever'},
|
||||
{id: 425, topic: 'whatever', starred: true},
|
||||
{id: 500, topic: 'whatever'},
|
||||
{id: 400, topic: "whatever"},
|
||||
{id: 425, topic: "whatever", starred: true},
|
||||
{id: 500, topic: "whatever"},
|
||||
],
|
||||
expected_id_info: {
|
||||
target_id: 450,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
zrequire('people');
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('stream_data');
|
||||
zrequire('narrow_state');
|
||||
zrequire("people");
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("stream_data");
|
||||
zrequire("narrow_state");
|
||||
|
||||
set_global('page_params', {});
|
||||
set_global("page_params", {});
|
||||
|
||||
function set_filter(operators) {
|
||||
operators = operators.map((op) => ({
|
||||
@@ -14,39 +14,39 @@ function set_filter(operators) {
|
||||
narrow_state.set_current_filter(new Filter(operators));
|
||||
}
|
||||
|
||||
run_test('stream', () => {
|
||||
run_test("stream", () => {
|
||||
assert.equal(narrow_state.public_operators(), undefined);
|
||||
assert(!narrow_state.active());
|
||||
|
||||
const test_stream = {name: 'Test', stream_id: 15};
|
||||
const test_stream = {name: "Test", stream_id: 15};
|
||||
stream_data.add_sub(test_stream);
|
||||
|
||||
assert(!narrow_state.is_for_stream_id(test_stream.stream_id));
|
||||
|
||||
set_filter([
|
||||
['stream', 'Test'],
|
||||
['topic', 'Bar'],
|
||||
['search', 'yo'],
|
||||
["stream", "Test"],
|
||||
["topic", "Bar"],
|
||||
["search", "yo"],
|
||||
]);
|
||||
assert(narrow_state.active());
|
||||
|
||||
assert.equal(narrow_state.stream(), 'Test');
|
||||
assert.equal(narrow_state.stream(), "Test");
|
||||
assert.equal(narrow_state.stream_id(), test_stream.stream_id);
|
||||
assert.equal(narrow_state.topic(), 'Bar');
|
||||
assert.equal(narrow_state.topic(), "Bar");
|
||||
assert(narrow_state.is_for_stream_id(test_stream.stream_id));
|
||||
|
||||
const expected_operators = [
|
||||
{ negated: false, operator: 'stream', operand: 'Test' },
|
||||
{ negated: false, operator: 'topic', operand: 'Bar' },
|
||||
{ negated: false, operator: 'search', operand: 'yo' },
|
||||
{ negated: false, operator: "stream", operand: "Test" },
|
||||
{ negated: false, operator: "topic", operand: "Bar" },
|
||||
{ negated: false, operator: "search", operand: "yo" },
|
||||
];
|
||||
|
||||
const public_operators = narrow_state.public_operators();
|
||||
assert.deepEqual(public_operators, expected_operators);
|
||||
assert.equal(narrow_state.search_string(), 'stream:Test topic:Bar yo');
|
||||
assert.equal(narrow_state.search_string(), "stream:Test topic:Bar yo");
|
||||
});
|
||||
|
||||
run_test('narrowed', () => {
|
||||
run_test("narrowed", () => {
|
||||
narrow_state.reset_current_filter(); // not narrowed, basically
|
||||
assert(!narrow_state.narrowed_to_pms());
|
||||
assert(!narrow_state.narrowed_by_reply());
|
||||
@@ -58,7 +58,7 @@ run_test('narrowed', () => {
|
||||
assert.equal(narrow_state.stream_id(), undefined);
|
||||
assert(!narrow_state.narrowed_to_starred());
|
||||
|
||||
set_filter([['stream', 'Foo']]);
|
||||
set_filter([["stream", "Foo"]]);
|
||||
assert(!narrow_state.narrowed_to_pms());
|
||||
assert(!narrow_state.narrowed_by_reply());
|
||||
assert(!narrow_state.narrowed_by_pm_reply());
|
||||
@@ -68,7 +68,7 @@ run_test('narrowed', () => {
|
||||
assert(narrow_state.narrowed_by_stream_reply());
|
||||
assert(!narrow_state.narrowed_to_starred());
|
||||
|
||||
set_filter([['pm-with', 'steve@zulip.com']]);
|
||||
set_filter([["pm-with", "steve@zulip.com"]]);
|
||||
assert(narrow_state.narrowed_to_pms());
|
||||
assert(narrow_state.narrowed_by_reply());
|
||||
assert(narrow_state.narrowed_by_pm_reply());
|
||||
@@ -78,7 +78,7 @@ run_test('narrowed', () => {
|
||||
assert(!narrow_state.narrowed_by_stream_reply());
|
||||
assert(!narrow_state.narrowed_to_starred());
|
||||
|
||||
set_filter([['stream', 'Foo'], ['topic', 'bar']]);
|
||||
set_filter([["stream", "Foo"], ["topic", "bar"]]);
|
||||
assert(!narrow_state.narrowed_to_pms());
|
||||
assert(narrow_state.narrowed_by_reply());
|
||||
assert(!narrow_state.narrowed_by_pm_reply());
|
||||
@@ -88,7 +88,7 @@ run_test('narrowed', () => {
|
||||
assert(!narrow_state.narrowed_by_stream_reply());
|
||||
assert(!narrow_state.narrowed_to_starred());
|
||||
|
||||
set_filter([['search', 'grail']]);
|
||||
set_filter([["search", "grail"]]);
|
||||
assert(!narrow_state.narrowed_to_pms());
|
||||
assert(!narrow_state.narrowed_by_reply());
|
||||
assert(!narrow_state.narrowed_by_pm_reply());
|
||||
@@ -98,7 +98,7 @@ run_test('narrowed', () => {
|
||||
assert(!narrow_state.narrowed_by_stream_reply());
|
||||
assert(!narrow_state.narrowed_to_starred());
|
||||
|
||||
set_filter([['is', 'starred']]);
|
||||
set_filter([["is", "starred"]]);
|
||||
assert(!narrow_state.narrowed_to_pms());
|
||||
assert(!narrow_state.narrowed_by_reply());
|
||||
assert(!narrow_state.narrowed_by_pm_reply());
|
||||
@@ -109,110 +109,110 @@ run_test('narrowed', () => {
|
||||
assert(narrow_state.narrowed_to_starred());
|
||||
});
|
||||
|
||||
run_test('operators', () => {
|
||||
set_filter([['stream', 'Foo'], ['topic', 'Bar'], ['search', 'Yo']]);
|
||||
run_test("operators", () => {
|
||||
set_filter([["stream", "Foo"], ["topic", "Bar"], ["search", "Yo"]]);
|
||||
let result = narrow_state.operators();
|
||||
assert.equal(result.length, 3);
|
||||
assert.equal(result[0].operator, 'stream');
|
||||
assert.equal(result[0].operand, 'Foo');
|
||||
assert.equal(result[0].operator, "stream");
|
||||
assert.equal(result[0].operand, "Foo");
|
||||
|
||||
assert.equal(result[1].operator, 'topic');
|
||||
assert.equal(result[1].operand, 'Bar');
|
||||
assert.equal(result[1].operator, "topic");
|
||||
assert.equal(result[1].operand, "Bar");
|
||||
|
||||
assert.equal(result[2].operator, 'search');
|
||||
assert.equal(result[2].operand, 'yo');
|
||||
assert.equal(result[2].operator, "search");
|
||||
assert.equal(result[2].operand, "yo");
|
||||
|
||||
narrow_state.reset_current_filter();
|
||||
result = narrow_state.operators();
|
||||
assert.equal(result.length, 0);
|
||||
});
|
||||
|
||||
run_test('muting_enabled', () => {
|
||||
set_filter([['stream', 'devel']]);
|
||||
run_test("muting_enabled", () => {
|
||||
set_filter([["stream", "devel"]]);
|
||||
assert(narrow_state.muting_enabled());
|
||||
|
||||
narrow_state.reset_current_filter(); // not narrowed, basically
|
||||
assert(narrow_state.muting_enabled());
|
||||
|
||||
set_filter([['stream', 'devel'], ['topic', 'mac']]);
|
||||
set_filter([["stream", "devel"], ["topic", "mac"]]);
|
||||
assert(!narrow_state.muting_enabled());
|
||||
|
||||
set_filter([['search', 'whatever']]);
|
||||
set_filter([["search", "whatever"]]);
|
||||
assert(!narrow_state.muting_enabled());
|
||||
|
||||
set_filter([['is', 'private']]);
|
||||
set_filter([["is", "private"]]);
|
||||
assert(!narrow_state.muting_enabled());
|
||||
|
||||
set_filter([['is', 'starred']]);
|
||||
set_filter([["is", "starred"]]);
|
||||
assert(!narrow_state.muting_enabled());
|
||||
});
|
||||
|
||||
run_test('set_compose_defaults', () => {
|
||||
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
||||
run_test("set_compose_defaults", () => {
|
||||
set_filter([["stream", "Foo"], ["topic", "Bar"]]);
|
||||
|
||||
const stream_and_subject = narrow_state.set_compose_defaults();
|
||||
assert.equal(stream_and_subject.stream, 'Foo');
|
||||
assert.equal(stream_and_subject.topic, 'Bar');
|
||||
assert.equal(stream_and_subject.stream, "Foo");
|
||||
assert.equal(stream_and_subject.topic, "Bar");
|
||||
|
||||
set_filter([['pm-with', 'foo@bar.com']]);
|
||||
set_filter([["pm-with", "foo@bar.com"]]);
|
||||
let pm_test = narrow_state.set_compose_defaults();
|
||||
assert.equal(pm_test.private_message_recipient, undefined);
|
||||
|
||||
const john = {
|
||||
email: 'john@doe.com',
|
||||
email: "john@doe.com",
|
||||
user_id: 57,
|
||||
full_name: 'John Doe',
|
||||
full_name: "John Doe",
|
||||
};
|
||||
people.add_active_user(john);
|
||||
people.add_active_user(john);
|
||||
|
||||
set_filter([['pm-with', 'john@doe.com']]);
|
||||
set_filter([["pm-with", "john@doe.com"]]);
|
||||
pm_test = narrow_state.set_compose_defaults();
|
||||
assert.equal(pm_test.private_message_recipient, 'john@doe.com');
|
||||
assert.equal(pm_test.private_message_recipient, "john@doe.com");
|
||||
|
||||
set_filter([['topic', 'duplicate'], ['topic', 'duplicate']]);
|
||||
set_filter([["topic", "duplicate"], ["topic", "duplicate"]]);
|
||||
assert.deepEqual(narrow_state.set_compose_defaults(), {});
|
||||
|
||||
stream_data.add_sub({name: 'ROME', stream_id: 99});
|
||||
set_filter([['stream', 'rome']]);
|
||||
stream_data.add_sub({name: "ROME", stream_id: 99});
|
||||
set_filter([["stream", "rome"]]);
|
||||
|
||||
const stream_test = narrow_state.set_compose_defaults();
|
||||
assert.equal(stream_test.stream, 'ROME');
|
||||
assert.equal(stream_test.stream, "ROME");
|
||||
});
|
||||
|
||||
run_test('update_email', () => {
|
||||
run_test("update_email", () => {
|
||||
const steve = {
|
||||
email: 'steve@foo.com',
|
||||
email: "steve@foo.com",
|
||||
user_id: 43,
|
||||
full_name: 'Steve',
|
||||
full_name: "Steve",
|
||||
};
|
||||
|
||||
people.add_active_user(steve);
|
||||
set_filter([
|
||||
['pm-with', 'steve@foo.com'],
|
||||
['sender', 'steve@foo.com'],
|
||||
['stream', 'steve@foo.com'], // try to be tricky
|
||||
["pm-with", "steve@foo.com"],
|
||||
["sender", "steve@foo.com"],
|
||||
["stream", "steve@foo.com"], // try to be tricky
|
||||
]);
|
||||
narrow_state.update_email(steve.user_id, 'showell@foo.com');
|
||||
narrow_state.update_email(steve.user_id, "showell@foo.com");
|
||||
const filter = narrow_state.filter();
|
||||
assert.deepEqual(filter.operands('pm-with'), ['showell@foo.com']);
|
||||
assert.deepEqual(filter.operands('sender'), ['showell@foo.com']);
|
||||
assert.deepEqual(filter.operands('stream'), ['steve@foo.com']);
|
||||
assert.deepEqual(filter.operands("pm-with"), ["showell@foo.com"]);
|
||||
assert.deepEqual(filter.operands("sender"), ["showell@foo.com"]);
|
||||
assert.deepEqual(filter.operands("stream"), ["steve@foo.com"]);
|
||||
});
|
||||
|
||||
run_test('topic', () => {
|
||||
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
||||
assert.equal(narrow_state.topic(), 'Bar');
|
||||
run_test("topic", () => {
|
||||
set_filter([["stream", "Foo"], ["topic", "Bar"]]);
|
||||
assert.equal(narrow_state.topic(), "Bar");
|
||||
|
||||
set_filter([['stream', 'release'], ['topic', '@#$$^test']]);
|
||||
assert.equal(narrow_state.topic(), '@#$$^test');
|
||||
set_filter([["stream", "release"], ["topic", "@#$$^test"]]);
|
||||
assert.equal(narrow_state.topic(), "@#$$^test");
|
||||
|
||||
set_filter([]);
|
||||
assert.equal(narrow_state.topic(), undefined);
|
||||
|
||||
set_filter([
|
||||
['sender', 'test@foo.com'],
|
||||
['pm-with', 'test@foo.com'],
|
||||
["sender", "test@foo.com"],
|
||||
["pm-with", "test@foo.com"],
|
||||
]);
|
||||
assert.equal(narrow_state.topic(), undefined);
|
||||
|
||||
@@ -220,56 +220,56 @@ run_test('topic', () => {
|
||||
assert.equal(narrow_state.topic(), undefined);
|
||||
});
|
||||
|
||||
run_test('stream', () => {
|
||||
run_test("stream", () => {
|
||||
set_filter([]);
|
||||
assert.equal(narrow_state.stream(), undefined);
|
||||
assert.equal(narrow_state.stream_id(), undefined);
|
||||
|
||||
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
||||
assert.equal(narrow_state.stream(), 'Foo');
|
||||
set_filter([["stream", "Foo"], ["topic", "Bar"]]);
|
||||
assert.equal(narrow_state.stream(), "Foo");
|
||||
assert.equal(narrow_state.stream_sub(), undefined);
|
||||
assert.equal(narrow_state.stream_id(), undefined);
|
||||
|
||||
const sub = {name: 'Foo', stream_id: 55};
|
||||
const sub = {name: "Foo", stream_id: 55};
|
||||
stream_data.add_sub(sub);
|
||||
assert.equal(narrow_state.stream_id(), 55);
|
||||
assert.deepEqual(narrow_state.stream_sub(), sub);
|
||||
|
||||
set_filter([['sender', 'someone'], ['topic', 'random']]);
|
||||
set_filter([["sender", "someone"], ["topic", "random"]]);
|
||||
assert.equal(narrow_state.stream(), undefined);
|
||||
});
|
||||
|
||||
run_test('pm_string', () => {
|
||||
run_test("pm_string", () => {
|
||||
// This function will return undefined unless we're clearly
|
||||
// narrowed to a specific PM (including huddles) with real
|
||||
// users.
|
||||
narrow_state.set_current_filter(undefined);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
|
||||
set_filter([['stream', 'Foo'], ['topic', 'Bar']]);
|
||||
set_filter([["stream", "Foo"], ["topic", "Bar"]]);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
|
||||
set_filter([['pm-with', '']]);
|
||||
set_filter([["pm-with", ""]]);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
|
||||
set_filter([['pm-with', 'bogus@foo.com']]);
|
||||
set_filter([["pm-with", "bogus@foo.com"]]);
|
||||
assert.equal(narrow_state.pm_string(), undefined);
|
||||
|
||||
const alice = {
|
||||
email: 'alice@foo.com',
|
||||
email: "alice@foo.com",
|
||||
user_id: 444,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
|
||||
const bob = {
|
||||
email: 'bob@foo.com',
|
||||
email: "bob@foo.com",
|
||||
user_id: 555,
|
||||
full_name: 'Bob',
|
||||
full_name: "Bob",
|
||||
};
|
||||
|
||||
people.add_active_user(alice);
|
||||
people.add_active_user(bob);
|
||||
|
||||
set_filter([['pm-with', 'bob@foo.com,alice@foo.com']]);
|
||||
assert.equal(narrow_state.pm_string(), '444,555');
|
||||
set_filter([["pm-with", "bob@foo.com,alice@foo.com"]]);
|
||||
assert.equal(narrow_state.pm_string(), "444,555");
|
||||
});
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('people');
|
||||
zrequire('stream_data');
|
||||
zrequire('unread');
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("people");
|
||||
zrequire("stream_data");
|
||||
zrequire("unread");
|
||||
|
||||
set_global('message_store', {});
|
||||
set_global('page_params', {});
|
||||
set_global("message_store", {});
|
||||
set_global("page_params", {});
|
||||
|
||||
set_global('muting', {
|
||||
set_global("muting", {
|
||||
is_topic_muted: () => false,
|
||||
});
|
||||
|
||||
// The main code we are testing lives here.
|
||||
zrequire('narrow_state');
|
||||
zrequire("narrow_state");
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 11,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
|
||||
people.init();
|
||||
@@ -37,20 +37,20 @@ function candidate_ids() {
|
||||
return narrow_state._possible_unread_message_ids();
|
||||
}
|
||||
|
||||
run_test('get_unread_ids', () => {
|
||||
run_test("get_unread_ids", () => {
|
||||
let unread_ids;
|
||||
let terms;
|
||||
|
||||
const sub = {
|
||||
name: 'My Stream',
|
||||
name: "My Stream",
|
||||
stream_id: 55,
|
||||
};
|
||||
|
||||
const stream_msg = {
|
||||
id: 101,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
stream_id: sub.stream_id,
|
||||
topic: 'my topic',
|
||||
topic: "my topic",
|
||||
unread: true,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
@@ -58,7 +58,7 @@ run_test('get_unread_ids', () => {
|
||||
|
||||
const private_msg = {
|
||||
id: 102,
|
||||
type: 'private',
|
||||
type: "private",
|
||||
unread: true,
|
||||
display_recipient: [
|
||||
{id: alice.user_id},
|
||||
@@ -71,35 +71,35 @@ run_test('get_unread_ids', () => {
|
||||
assert.equal(unread_ids, undefined);
|
||||
|
||||
terms = [
|
||||
{operator: 'search', operand: 'whatever'},
|
||||
{operator: "search", operand: "whatever"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.equal(unread_ids, undefined);
|
||||
assert_unread_info({flavor: 'cannot_compute'});
|
||||
assert_unread_info({flavor: "cannot_compute"});
|
||||
|
||||
terms = [
|
||||
{operator: 'bogus_operator', operand: 'me@example.com'},
|
||||
{operator: "bogus_operator", operand: "me@example.com"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, []);
|
||||
assert_unread_info({flavor: 'not_found'});
|
||||
assert_unread_info({flavor: "not_found"});
|
||||
|
||||
terms = [
|
||||
{operator: 'stream', operand: 'bogus'},
|
||||
{operator: "stream", operand: "bogus"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, []);
|
||||
|
||||
terms = [
|
||||
{operator: 'stream', operand: sub.name},
|
||||
{operator: "stream", operand: sub.name},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, []);
|
||||
assert_unread_info({flavor: 'not_found'});
|
||||
assert_unread_info({flavor: "not_found"});
|
||||
|
||||
unread.process_loaded_messages([stream_msg]);
|
||||
message_store.get = (msg_id) => {
|
||||
@@ -110,35 +110,35 @@ run_test('get_unread_ids', () => {
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, [stream_msg.id]);
|
||||
assert_unread_info({
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: stream_msg.id,
|
||||
});
|
||||
|
||||
terms = [
|
||||
{operator: 'stream', operand: 'bogus'},
|
||||
{operator: 'topic', operand: 'my topic'},
|
||||
{operator: "stream", operand: "bogus"},
|
||||
{operator: "topic", operand: "my topic"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, []);
|
||||
|
||||
terms = [
|
||||
{operator: 'stream', operand: sub.name},
|
||||
{operator: 'topic', operand: 'my topic'},
|
||||
{operator: "stream", operand: sub.name},
|
||||
{operator: "topic", operand: "my topic"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, [stream_msg.id]);
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'mentioned'},
|
||||
{operator: "is", operand: "mentioned"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, [stream_msg.id]);
|
||||
|
||||
terms = [
|
||||
{operator: 'sender', operand: 'me@example.com'},
|
||||
{operator: "sender", operand: "me@example.com"},
|
||||
];
|
||||
set_filter(terms);
|
||||
// note that our candidate ids are just "all" ids now
|
||||
@@ -146,10 +146,10 @@ run_test('get_unread_ids', () => {
|
||||
assert.deepEqual(unread_ids, [stream_msg.id]);
|
||||
|
||||
// this actually does filtering
|
||||
assert_unread_info({flavor: 'not_found'});
|
||||
assert_unread_info({flavor: "not_found"});
|
||||
|
||||
terms = [
|
||||
{operator: 'pm-with', operand: 'alice@example.com'},
|
||||
{operator: "pm-with", operand: "alice@example.com"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
@@ -166,12 +166,12 @@ run_test('get_unread_ids', () => {
|
||||
assert.deepEqual(unread_ids, [private_msg.id]);
|
||||
|
||||
assert_unread_info({
|
||||
flavor: 'found',
|
||||
flavor: "found",
|
||||
msg_id: private_msg.id,
|
||||
});
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'private'},
|
||||
{operator: "is", operand: "private"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
@@ -180,14 +180,14 @@ run_test('get_unread_ids', () => {
|
||||
// For a negated search, our candidate ids will be all
|
||||
// unread messages, even ones that don't pass the filter.
|
||||
terms = [
|
||||
{operator: 'is', operand: 'private', negated: true},
|
||||
{operator: "is", operand: "private", negated: true},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, [stream_msg.id, private_msg.id]);
|
||||
|
||||
terms = [
|
||||
{operator: 'pm-with', operand: 'bob@example.com'},
|
||||
{operator: "pm-with", operand: "bob@example.com"},
|
||||
];
|
||||
set_filter(terms);
|
||||
|
||||
@@ -195,39 +195,39 @@ run_test('get_unread_ids', () => {
|
||||
assert.deepEqual(unread_ids, []);
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'starred'},
|
||||
{operator: "is", operand: "starred"},
|
||||
];
|
||||
set_filter(terms);
|
||||
unread_ids = candidate_ids();
|
||||
assert.deepEqual(unread_ids, []);
|
||||
|
||||
terms = [
|
||||
{operator: 'search', operand: 'needle'},
|
||||
{operator: "search", operand: "needle"},
|
||||
];
|
||||
set_filter(terms);
|
||||
|
||||
assert_unread_info({
|
||||
flavor: 'cannot_compute',
|
||||
flavor: "cannot_compute",
|
||||
});
|
||||
|
||||
narrow_state.reset_current_filter();
|
||||
blueslip.expect('error', 'unexpected call to get_first_unread_info');
|
||||
blueslip.expect("error", "unexpected call to get_first_unread_info");
|
||||
assert_unread_info({
|
||||
flavor: 'cannot_compute',
|
||||
flavor: "cannot_compute",
|
||||
});
|
||||
});
|
||||
|
||||
run_test('defensive code', () => {
|
||||
run_test("defensive code", () => {
|
||||
// Test defensive code. We actually avoid calling
|
||||
// _possible_unread_message_ids for any case where we
|
||||
// couldn't compute the unread message ids, but that
|
||||
// invariant is hard to future-proof.
|
||||
narrow_state._possible_unread_message_ids = () => undefined;
|
||||
const terms = [
|
||||
{operator: 'some-unhandled-case', operand: 'whatever'},
|
||||
{operator: "some-unhandled-case", operand: "whatever"},
|
||||
];
|
||||
set_filter(terms);
|
||||
assert_unread_info({
|
||||
flavor: 'cannot_compute',
|
||||
flavor: "cannot_compute",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Dependencies
|
||||
set_global('$', global.make_zjquery({
|
||||
set_global("$", global.make_zjquery({
|
||||
silent: true,
|
||||
}));
|
||||
set_global('document', {
|
||||
set_global("document", {
|
||||
hasFocus: function () {
|
||||
return true;
|
||||
},
|
||||
});
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
is_admin: false,
|
||||
realm_users: [],
|
||||
enable_desktop_notifications: true,
|
||||
@@ -15,24 +15,24 @@ set_global('page_params', {
|
||||
wildcard_mentions_notify: true,
|
||||
});
|
||||
const _navigator = {
|
||||
userAgent: 'Mozilla/5.0 AppleWebKit/537.36 Chrome/64.0.3282.167 Safari/537.36',
|
||||
userAgent: "Mozilla/5.0 AppleWebKit/537.36 Chrome/64.0.3282.167 Safari/537.36",
|
||||
};
|
||||
set_global('navigator', _navigator);
|
||||
set_global("navigator", _navigator);
|
||||
|
||||
zrequire('alert_words');
|
||||
zrequire('muting');
|
||||
zrequire('stream_data');
|
||||
zrequire('people');
|
||||
zrequire('ui');
|
||||
zrequire('spoilers');
|
||||
zrequire("alert_words");
|
||||
zrequire("muting");
|
||||
zrequire("stream_data");
|
||||
zrequire("people");
|
||||
zrequire("ui");
|
||||
zrequire("spoilers");
|
||||
spoilers.hide_spoilers_in_notification = () => {};
|
||||
|
||||
zrequire('notifications');
|
||||
zrequire("notifications");
|
||||
|
||||
// Not muted streams
|
||||
const general = {
|
||||
subscribed: true,
|
||||
name: 'general',
|
||||
name: "general",
|
||||
stream_id: 10,
|
||||
is_muted: false,
|
||||
wildcard_mentions_notify: null,
|
||||
@@ -41,7 +41,7 @@ const general = {
|
||||
// Muted streams
|
||||
const muted = {
|
||||
subscribed: true,
|
||||
name: 'muted',
|
||||
name: "muted",
|
||||
stream_id: 20,
|
||||
is_muted: true,
|
||||
wildcard_mentions_notify: null,
|
||||
@@ -50,9 +50,9 @@ const muted = {
|
||||
stream_data.add_sub(general);
|
||||
stream_data.add_sub(muted);
|
||||
|
||||
muting.add_muted_topic(general.stream_id, 'muted topic');
|
||||
muting.add_muted_topic(general.stream_id, "muted topic");
|
||||
|
||||
run_test('message_is_notifiable', () => {
|
||||
run_test("message_is_notifiable", () => {
|
||||
// A notification is sent if both message_is_notifiable(message)
|
||||
// and the appropriate should_send_*_notification function return
|
||||
// true.
|
||||
@@ -63,15 +63,15 @@ run_test('message_is_notifiable', () => {
|
||||
// EXCEPT sent_by_me, which should trump them
|
||||
let message = {
|
||||
id: muted.stream_id,
|
||||
content: 'message number 1',
|
||||
content: "message number 1",
|
||||
sent_by_me: true,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: general.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -85,15 +85,15 @@ run_test('message_is_notifiable', () => {
|
||||
// (ie: it mentions user, it's not muted, etc)
|
||||
message = {
|
||||
id: general.stream_id,
|
||||
content: 'message number 2',
|
||||
content: "message number 2",
|
||||
sent_by_me: false,
|
||||
notification_sent: true,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: general.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -104,15 +104,15 @@ run_test('message_is_notifiable', () => {
|
||||
// Mentioning trumps muting
|
||||
message = {
|
||||
id: 30,
|
||||
content: 'message number 3',
|
||||
content: "message number 3",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'muted',
|
||||
type: "stream",
|
||||
stream: "muted",
|
||||
stream_id: muted.stream_id,
|
||||
topic: 'topic_three',
|
||||
topic: "topic_three",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -122,15 +122,15 @@ run_test('message_is_notifiable', () => {
|
||||
// Mentioning should trigger notification in unmuted topic
|
||||
message = {
|
||||
id: 40,
|
||||
content: 'message number 4',
|
||||
content: "message number 4",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: general.stream_id,
|
||||
topic: 'vanilla',
|
||||
topic: "vanilla",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -141,15 +141,15 @@ run_test('message_is_notifiable', () => {
|
||||
// if wildcard_mentions_notify
|
||||
message = {
|
||||
id: 40,
|
||||
content: 'message number 4',
|
||||
content: "message number 4",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: false,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: general.stream_id,
|
||||
topic: 'vanilla',
|
||||
topic: "vanilla",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -176,15 +176,15 @@ run_test('message_is_notifiable', () => {
|
||||
// DO NOT notify the user
|
||||
message = {
|
||||
id: 50,
|
||||
content: 'message number 5',
|
||||
content: "message number 5",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: false,
|
||||
type: 'stream',
|
||||
stream: 'muted',
|
||||
type: "stream",
|
||||
stream: "muted",
|
||||
stream_id: muted.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -195,15 +195,15 @@ run_test('message_is_notifiable', () => {
|
||||
// DO notify the user
|
||||
message = {
|
||||
id: 50,
|
||||
content: 'message number 5',
|
||||
content: "message number 5",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'muted',
|
||||
type: "stream",
|
||||
stream: "muted",
|
||||
stream_id: muted.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -214,15 +214,15 @@ run_test('message_is_notifiable', () => {
|
||||
// DO NOT notify the user
|
||||
message = {
|
||||
id: 50,
|
||||
content: 'message number 6',
|
||||
content: "message number 6",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: true,
|
||||
mentioned_me_directly: false,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: general.stream_id,
|
||||
topic: 'muted topic',
|
||||
topic: "muted topic",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), true);
|
||||
assert.equal(notifications.should_send_audible_notification(message), true);
|
||||
@@ -234,22 +234,22 @@ run_test('message_is_notifiable', () => {
|
||||
// return true to pass it to notifications settings, which will return false.
|
||||
message = {
|
||||
id: 60,
|
||||
content: 'message number 7',
|
||||
content: "message number 7",
|
||||
sent_by_me: false,
|
||||
notification_sent: false,
|
||||
mentioned: false,
|
||||
mentioned_me_directly: false,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: general.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
assert.equal(notifications.should_send_desktop_notification(message), false);
|
||||
assert.equal(notifications.should_send_audible_notification(message), false);
|
||||
assert.equal(notifications.message_is_notifiable(message), true);
|
||||
});
|
||||
|
||||
run_test('basic_notifications', () => {
|
||||
run_test("basic_notifications", () => {
|
||||
|
||||
let n; // Object for storing all notification data for assertions.
|
||||
let last_closed_message_id = null;
|
||||
@@ -279,43 +279,43 @@ run_test('basic_notifications', () => {
|
||||
|
||||
const message_1 = {
|
||||
id: 1000,
|
||||
content: '@-mentions the user',
|
||||
avatar_url: 'url',
|
||||
content: "@-mentions the user",
|
||||
avatar_url: "url",
|
||||
sent_by_me: false,
|
||||
sender_full_name: 'Jesse Pinkman',
|
||||
sender_full_name: "Jesse Pinkman",
|
||||
notification_sent: false,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: muted.stream_id,
|
||||
topic: 'whatever',
|
||||
topic: "whatever",
|
||||
};
|
||||
|
||||
const message_2 = {
|
||||
id: 1500,
|
||||
avatar_url: 'url',
|
||||
content: '@-mentions the user',
|
||||
avatar_url: "url",
|
||||
content: "@-mentions the user",
|
||||
sent_by_me: false,
|
||||
sender_full_name: 'Gus Fring',
|
||||
sender_full_name: "Gus Fring",
|
||||
notification_sent: false,
|
||||
mentioned_me_directly: true,
|
||||
type: 'stream',
|
||||
stream: 'general',
|
||||
type: "stream",
|
||||
stream: "general",
|
||||
stream_id: muted.stream_id,
|
||||
topic: 'lunch',
|
||||
topic: "lunch",
|
||||
};
|
||||
|
||||
// Send notification.
|
||||
notifications.process_notification({message: message_1, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 1);
|
||||
assert.equal(last_shown_message_id, message_1.id);
|
||||
|
||||
// Remove notification.
|
||||
notifications.close_notification(message_1);
|
||||
n = notifications.get_notifications();
|
||||
assert.equal(n.has('Jesse Pinkman to general > whatever'), false);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), false);
|
||||
assert.equal(n.size, 0);
|
||||
assert.equal(last_closed_message_id, message_1.id);
|
||||
|
||||
@@ -323,7 +323,7 @@ run_test('basic_notifications', () => {
|
||||
message_1.id = 1001;
|
||||
notifications.process_notification({message: message_1, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 1);
|
||||
assert.equal(last_shown_message_id, message_1.id);
|
||||
|
||||
@@ -331,15 +331,15 @@ run_test('basic_notifications', () => {
|
||||
message_1.id = 1002;
|
||||
notifications.process_notification({message: message_1, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 1);
|
||||
assert.equal(last_shown_message_id, message_1.id);
|
||||
|
||||
// Send another message. Notification count should increase.
|
||||
notifications.process_notification({message: message_2, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
assert.equal(n.has('Gus Fring to general > lunch'), true);
|
||||
assert.equal(n.has('Jesse Pinkman to general > whatever'), true);
|
||||
assert.equal(n.has("Gus Fring to general > lunch"), true);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 2);
|
||||
assert.equal(last_shown_message_id, message_2.id);
|
||||
|
||||
@@ -347,7 +347,7 @@ run_test('basic_notifications', () => {
|
||||
notifications.close_notification(message_1);
|
||||
notifications.close_notification(message_2);
|
||||
n = notifications.get_notifications();
|
||||
assert.equal(n.has('Jesse Pinkman to general > whatever'), false);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), false);
|
||||
assert.equal(n.size, 0);
|
||||
assert.equal(last_closed_message_id, message_2.id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
set_global('zxcvbn', zrequire('zxcvbn', 'zxcvbn'));
|
||||
zrequire('common');
|
||||
set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn"));
|
||||
zrequire("common");
|
||||
|
||||
run_test('basics', () => {
|
||||
run_test("basics", () => {
|
||||
let accepted;
|
||||
let password;
|
||||
let warning;
|
||||
@@ -15,7 +15,7 @@ run_test('basics', () => {
|
||||
};
|
||||
|
||||
self.removeClass = function (arg) {
|
||||
assert.equal(arg, 'bar-success bar-danger');
|
||||
assert.equal(arg, "bar-success bar-danger");
|
||||
return self;
|
||||
};
|
||||
|
||||
@@ -31,9 +31,9 @@ run_test('basics', () => {
|
||||
const self = {};
|
||||
|
||||
self.data = function (field) {
|
||||
if (field === 'minLength') {
|
||||
if (field === "minLength") {
|
||||
return min_length;
|
||||
} else if (field === 'minGuesses') {
|
||||
} else if (field === "minGuesses") {
|
||||
return min_guesses;
|
||||
}
|
||||
};
|
||||
@@ -41,31 +41,31 @@ run_test('basics', () => {
|
||||
return self;
|
||||
}
|
||||
|
||||
password = 'z!X4@S_&';
|
||||
password = "z!X4@S_&";
|
||||
accepted = common.password_quality(password, bar, password_field(10, 80000));
|
||||
assert(!accepted);
|
||||
assert.equal(bar.w, '39.7%');
|
||||
assert.equal(bar.added_class, 'bar-danger');
|
||||
assert.equal(bar.w, "39.7%");
|
||||
assert.equal(bar.added_class, "bar-danger");
|
||||
warning = common.password_warning(password, password_field(10));
|
||||
assert.equal(warning, 'translated: Password should be at least 10 characters long');
|
||||
assert.equal(warning, "translated: Password should be at least 10 characters long");
|
||||
|
||||
password = 'foo';
|
||||
password = "foo";
|
||||
accepted = common.password_quality(password, bar, password_field(2, 200));
|
||||
assert(accepted);
|
||||
assert.equal(bar.w, '10.390277164940581%');
|
||||
assert.equal(bar.added_class, 'bar-success');
|
||||
assert.equal(bar.w, "10.390277164940581%");
|
||||
assert.equal(bar.added_class, "bar-success");
|
||||
warning = common.password_warning(password, password_field(2));
|
||||
assert.equal(warning, 'translated: Password is too weak');
|
||||
assert.equal(warning, "translated: Password is too weak");
|
||||
|
||||
password = 'aaaaaaaa';
|
||||
password = "aaaaaaaa";
|
||||
accepted = common.password_quality(password, bar, password_field(6, 1e100));
|
||||
assert(!accepted);
|
||||
assert.equal(bar.added_class, 'bar-danger');
|
||||
assert.equal(bar.added_class, "bar-danger");
|
||||
warning = common.password_warning(password, password_field(6));
|
||||
assert.equal(warning, 'Repeats like "aaa" are easy to guess');
|
||||
|
||||
delete global.zxcvbn;
|
||||
password = 'aaaaaaaa';
|
||||
password = "aaaaaaaa";
|
||||
accepted = common.password_quality(password, bar, password_field(6, 1e100));
|
||||
assert(accepted === undefined);
|
||||
warning = common.password_warning(password, password_field(6));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +1,96 @@
|
||||
zrequire('people');
|
||||
zrequire("people");
|
||||
|
||||
const return_false = function () { return false; };
|
||||
const return_true = function () { return true; };
|
||||
set_global('reload_state', {
|
||||
set_global("reload_state", {
|
||||
is_in_progress: return_false,
|
||||
});
|
||||
|
||||
const me = {
|
||||
email: 'me@example.com',
|
||||
email: "me@example.com",
|
||||
user_id: 30,
|
||||
full_name: 'Me Myself',
|
||||
timezone: 'US/Pacific',
|
||||
full_name: "Me Myself",
|
||||
timezone: "US/Pacific",
|
||||
};
|
||||
|
||||
people.init();
|
||||
people.add_active_user(me);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
run_test('report_late_add', () => {
|
||||
blueslip.expect('error', 'Added user late: user_id=55 email=foo@example.com');
|
||||
people.report_late_add(55, 'foo@example.com');
|
||||
run_test("report_late_add", () => {
|
||||
blueslip.expect("error", "Added user late: user_id=55 email=foo@example.com");
|
||||
people.report_late_add(55, "foo@example.com");
|
||||
|
||||
blueslip.expect('log', 'Added user late: user_id=55 email=foo@example.com');
|
||||
blueslip.expect("log", "Added user late: user_id=55 email=foo@example.com");
|
||||
reload_state.is_in_progress = return_true;
|
||||
people.report_late_add(55, 'foo@example.com');
|
||||
people.report_late_add(55, "foo@example.com");
|
||||
});
|
||||
|
||||
run_test('is_my_user_id', () => {
|
||||
blueslip.expect('error', 'user_id is a string in my_user_id: 999');
|
||||
assert.equal(people.is_my_user_id('999'), false);
|
||||
run_test("is_my_user_id", () => {
|
||||
blueslip.expect("error", "user_id is a string in my_user_id: 999");
|
||||
assert.equal(people.is_my_user_id("999"), false);
|
||||
|
||||
blueslip.expect('error', 'user_id is a string in my_user_id: 30');
|
||||
blueslip.expect("error", "user_id is a string in my_user_id: 30");
|
||||
assert.equal(people.is_my_user_id(me.user_id.toString()), true);
|
||||
});
|
||||
|
||||
run_test('blueslip', () => {
|
||||
run_test("blueslip", () => {
|
||||
const unknown_email = "alicebobfred@example.com";
|
||||
|
||||
blueslip.expect('debug', 'User email operand unknown: ' + unknown_email);
|
||||
blueslip.expect("debug", "User email operand unknown: " + unknown_email);
|
||||
people.id_matches_email_operand(42, unknown_email);
|
||||
|
||||
blueslip.expect('error', 'Unknown user_id: 9999');
|
||||
blueslip.expect("error", "Unknown user_id: 9999");
|
||||
people.get_actual_name_from_user_id(9999);
|
||||
|
||||
blueslip.expect('error', 'Unknown email for get_user_id: ' + unknown_email);
|
||||
blueslip.expect("error", "Unknown email for get_user_id: " + unknown_email);
|
||||
people.get_user_id(unknown_email);
|
||||
|
||||
blueslip.expect('warn', 'No user_id provided for person@example.com');
|
||||
blueslip.expect("warn", "No user_id provided for person@example.com");
|
||||
const person = {
|
||||
email: 'person@example.com',
|
||||
email: "person@example.com",
|
||||
user_id: undefined,
|
||||
full_name: 'Person Person',
|
||||
full_name: "Person Person",
|
||||
};
|
||||
people.add_active_user(person);
|
||||
|
||||
blueslip.expect('error', 'No user_id found for person@example.com');
|
||||
const user_id = people.get_user_id('person@example.com');
|
||||
blueslip.expect("error", "No user_id found for person@example.com");
|
||||
const user_id = people.get_user_id("person@example.com");
|
||||
assert.equal(user_id, undefined);
|
||||
|
||||
blueslip.expect('warn', 'Unknown user ids: 1,2');
|
||||
people.user_ids_string_to_emails_string('1,2');
|
||||
blueslip.expect("warn", "Unknown user ids: 1,2");
|
||||
people.user_ids_string_to_emails_string("1,2");
|
||||
|
||||
blueslip.expect('warn', 'Unknown emails: ' + unknown_email);
|
||||
blueslip.expect("warn", "Unknown emails: " + unknown_email);
|
||||
people.email_list_to_user_ids_string([unknown_email]);
|
||||
|
||||
let message = {
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [],
|
||||
sender_id: me.user_id,
|
||||
};
|
||||
blueslip.expect('error', 'Empty recipient list in message', 4);
|
||||
blueslip.expect("error", "Empty recipient list in message", 4);
|
||||
people.pm_with_user_ids(message);
|
||||
people.group_pm_with_user_ids(message);
|
||||
people.all_user_ids_in_pm(message);
|
||||
assert.equal(people.pm_perma_link(message), undefined);
|
||||
|
||||
const charles = {
|
||||
email: 'charles@example.com',
|
||||
email: "charles@example.com",
|
||||
user_id: 451,
|
||||
full_name: 'Charles Dickens',
|
||||
avatar_url: 'charles.com/foo.png',
|
||||
full_name: "Charles Dickens",
|
||||
avatar_url: "charles.com/foo.png",
|
||||
};
|
||||
const maria = {
|
||||
email: 'athens@example.com',
|
||||
email: "athens@example.com",
|
||||
user_id: 452,
|
||||
full_name: 'Maria Athens',
|
||||
full_name: "Maria Athens",
|
||||
};
|
||||
people.add_active_user(charles);
|
||||
people.add_active_user(maria);
|
||||
|
||||
message = {
|
||||
type: 'private',
|
||||
type: "private",
|
||||
display_recipient: [
|
||||
{id: maria.user_id},
|
||||
{id: 42},
|
||||
@@ -98,19 +98,19 @@ run_test('blueslip', () => {
|
||||
],
|
||||
sender_id: charles.user_id,
|
||||
};
|
||||
blueslip.expect('error', 'Unknown user id in message: 42');
|
||||
blueslip.expect("error", "Unknown user id in message: 42");
|
||||
const reply_to = people.pm_reply_to(message);
|
||||
assert(reply_to.includes('?'));
|
||||
assert(reply_to.includes("?"));
|
||||
|
||||
people.pm_with_user_ids = function () { return [42]; };
|
||||
people.get_by_user_id = function () { return; };
|
||||
blueslip.expect('error', 'Unknown people in message');
|
||||
blueslip.expect("error", "Unknown people in message");
|
||||
const uri = people.pm_with_url({});
|
||||
assert.equal(uri.indexOf('unk'), uri.length - 3);
|
||||
assert.equal(uri.indexOf("unk"), uri.length - 3);
|
||||
|
||||
blueslip.expect('error', 'Undefined field id');
|
||||
blueslip.expect("error", "Undefined field id");
|
||||
assert.equal(people.my_custom_profile_data(undefined), undefined);
|
||||
|
||||
blueslip.expect('error', 'Trying to set undefined field id');
|
||||
blueslip.expect("error", "Trying to set undefined field id");
|
||||
people.set_custom_profile_field_data(maria.user_id, {});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const pmc = zrequire('pm_conversations');
|
||||
const pmc = zrequire("pm_conversations");
|
||||
|
||||
run_test('partners', () => {
|
||||
run_test("partners", () => {
|
||||
const user1_id = 1;
|
||||
const user2_id = 2;
|
||||
const user3_id = 3;
|
||||
@@ -15,7 +15,7 @@ run_test('partners', () => {
|
||||
|
||||
zrequire("people");
|
||||
|
||||
run_test('insert_recent_private_message', () => {
|
||||
run_test("insert_recent_private_message", () => {
|
||||
const params = {
|
||||
recent_private_conversations: [
|
||||
{user_ids: [11, 2],
|
||||
@@ -33,9 +33,9 @@ run_test('insert_recent_private_message', () => {
|
||||
pmc.recent.initialize(params);
|
||||
|
||||
assert.deepEqual(pmc.recent.get(), [
|
||||
{user_ids_string: '2,11', max_message_id: 150},
|
||||
{user_ids_string: '1', max_message_id: 111},
|
||||
{user_ids_string: '15', max_message_id: 7},
|
||||
{user_ids_string: "2,11", max_message_id: 150},
|
||||
{user_ids_string: "1", max_message_id: 111},
|
||||
{user_ids_string: "15", max_message_id: 7},
|
||||
]);
|
||||
|
||||
pmc.recent.insert([1], 1001);
|
||||
@@ -46,11 +46,11 @@ run_test('insert_recent_private_message', () => {
|
||||
pmc.recent.insert([1], 555);
|
||||
|
||||
assert.deepEqual(pmc.recent.get(), [
|
||||
{user_ids_string: '1', max_message_id: 3001},
|
||||
{user_ids_string: '2', max_message_id: 2001},
|
||||
{user_ids_string: '2,11', max_message_id: 150},
|
||||
{user_ids_string: '15', max_message_id: 7},
|
||||
{user_ids_string: "1", max_message_id: 3001},
|
||||
{user_ids_string: "2", max_message_id: 2001},
|
||||
{user_ids_string: "2,11", max_message_id: 150},
|
||||
{user_ids_string: "15", max_message_id: 7},
|
||||
]);
|
||||
|
||||
assert.deepEqual(pmc.recent.get_strings(), ['1', '2', '2,11', '15']);
|
||||
assert.deepEqual(pmc.recent.get_strings(), ["1", "2", "2,11", "15"]);
|
||||
});
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
set_global('narrow_state', {});
|
||||
set_global('ui', {
|
||||
set_global("narrow_state", {});
|
||||
set_global("ui", {
|
||||
get_content_element: (element) => element,
|
||||
});
|
||||
set_global('stream_popover', {
|
||||
set_global("stream_popover", {
|
||||
hide_topic_popover: function () {},
|
||||
});
|
||||
set_global('unread', {});
|
||||
set_global('unread_ui', {});
|
||||
set_global('vdom', {
|
||||
render: () => 'fake-dom-for-pm-list',
|
||||
set_global("unread", {});
|
||||
set_global("unread_ui", {});
|
||||
set_global("vdom", {
|
||||
render: () => "fake-dom-for-pm-list",
|
||||
});
|
||||
set_global('pm_list_dom', {});
|
||||
set_global("pm_list_dom", {});
|
||||
|
||||
zrequire('user_status');
|
||||
zrequire('presence');
|
||||
zrequire('buddy_data');
|
||||
zrequire('hash_util');
|
||||
zrequire('people');
|
||||
zrequire('pm_conversations');
|
||||
zrequire('pm_list');
|
||||
zrequire("user_status");
|
||||
zrequire("presence");
|
||||
zrequire("buddy_data");
|
||||
zrequire("hash_util");
|
||||
zrequire("people");
|
||||
zrequire("pm_conversations");
|
||||
zrequire("pm_list");
|
||||
|
||||
const alice = {
|
||||
email: 'alice@zulip.com',
|
||||
email: "alice@zulip.com",
|
||||
user_id: 101,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
const bob = {
|
||||
email: 'bob@zulip.com',
|
||||
email: "bob@zulip.com",
|
||||
user_id: 102,
|
||||
full_name: 'Bob',
|
||||
full_name: "Bob",
|
||||
};
|
||||
const me = {
|
||||
email: 'me@zulip.com',
|
||||
email: "me@zulip.com",
|
||||
user_id: 103,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
const bot_test = {
|
||||
email: 'outgoingwebhook@zulip.com',
|
||||
email: "outgoingwebhook@zulip.com",
|
||||
user_id: 314,
|
||||
full_name: "Outgoing webhook",
|
||||
is_admin: false,
|
||||
@@ -50,16 +50,16 @@ people.add_active_user(me);
|
||||
people.add_active_user(bot_test);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
run_test('close', () => {
|
||||
run_test("close", () => {
|
||||
let collapsed;
|
||||
$('#private-container').empty = function () {
|
||||
$("#private-container").empty = function () {
|
||||
collapsed = true;
|
||||
};
|
||||
pm_list.close();
|
||||
assert(collapsed);
|
||||
});
|
||||
|
||||
run_test('build_private_messages_list', () => {
|
||||
run_test("build_private_messages_list", () => {
|
||||
const timestamp = 0;
|
||||
pm_conversations.recent.insert([101, 102], timestamp);
|
||||
|
||||
@@ -78,13 +78,13 @@ run_test('build_private_messages_list', () => {
|
||||
|
||||
const expected_data = [
|
||||
{
|
||||
recipients: 'Alice, Bob',
|
||||
user_ids_string: '101,102',
|
||||
recipients: "Alice, Bob",
|
||||
user_ids_string: "101,102",
|
||||
unread: 1,
|
||||
is_zero: false,
|
||||
is_active: false,
|
||||
url: '#narrow/pm-with/101,102-group',
|
||||
user_circle_class: 'user_circle_fraction',
|
||||
url: "#narrow/pm-with/101,102-group",
|
||||
user_circle_class: "user_circle_fraction",
|
||||
fraction_present: undefined,
|
||||
is_group: true,
|
||||
},
|
||||
@@ -105,7 +105,7 @@ run_test('build_private_messages_list', () => {
|
||||
assert.deepEqual(pm_data, expected_data);
|
||||
});
|
||||
|
||||
run_test('build_private_messages_list_bot', () => {
|
||||
run_test("build_private_messages_list_bot", () => {
|
||||
const timestamp = 0;
|
||||
pm_conversations.recent.insert([314], timestamp);
|
||||
|
||||
@@ -123,24 +123,24 @@ run_test('build_private_messages_list_bot', () => {
|
||||
pm_list._build_private_messages_list();
|
||||
const expected_data = [
|
||||
{
|
||||
recipients: 'Outgoing webhook',
|
||||
user_ids_string: '314',
|
||||
recipients: "Outgoing webhook",
|
||||
user_ids_string: "314",
|
||||
unread: 1,
|
||||
is_zero: false,
|
||||
is_active: false,
|
||||
url: '#narrow/pm-with/314-outgoingwebhook',
|
||||
user_circle_class: 'user_circle_green',
|
||||
url: "#narrow/pm-with/314-outgoingwebhook",
|
||||
user_circle_class: "user_circle_green",
|
||||
fraction_present: undefined,
|
||||
is_group: false,
|
||||
},
|
||||
{
|
||||
recipients: 'Alice, Bob',
|
||||
user_ids_string: '101,102',
|
||||
recipients: "Alice, Bob",
|
||||
user_ids_string: "101,102",
|
||||
unread: 1,
|
||||
is_zero: false,
|
||||
is_active: false,
|
||||
url: '#narrow/pm-with/101,102-group',
|
||||
user_circle_class: 'user_circle_fraction',
|
||||
url: "#narrow/pm-with/101,102-group",
|
||||
user_circle_class: "user_circle_fraction",
|
||||
fraction_present: undefined,
|
||||
is_group: true,
|
||||
},
|
||||
@@ -149,15 +149,15 @@ run_test('build_private_messages_list_bot', () => {
|
||||
assert.deepEqual(pm_data, expected_data);
|
||||
});
|
||||
|
||||
run_test('update_dom_with_unread_counts', () => {
|
||||
run_test("update_dom_with_unread_counts", () => {
|
||||
let counts;
|
||||
let toggle_button_set;
|
||||
|
||||
const total_value = $.create('total-value-stub');
|
||||
const total_count = $.create('total-count-stub');
|
||||
const total_value = $.create("total-value-stub");
|
||||
const total_count = $.create("total-count-stub");
|
||||
const private_li = $(".top_left_private_messages");
|
||||
private_li.set_find_results('.count', total_count);
|
||||
total_count.set_find_results('.value', total_value);
|
||||
private_li.set_find_results(".count", total_count);
|
||||
total_count.set_find_results(".value", total_value);
|
||||
|
||||
counts = {
|
||||
private_message_count: 10,
|
||||
@@ -186,7 +186,7 @@ run_test('update_dom_with_unread_counts', () => {
|
||||
assert(toggle_button_set);
|
||||
});
|
||||
|
||||
run_test('get_active_user_ids_string', () => {
|
||||
run_test("get_active_user_ids_string", () => {
|
||||
narrow_state.filter = () => {};
|
||||
|
||||
assert.equal(
|
||||
@@ -196,7 +196,7 @@ run_test('get_active_user_ids_string', () => {
|
||||
function set_filter_result(emails) {
|
||||
narrow_state.filter = () => ({
|
||||
operands: (operand) => {
|
||||
assert.equal(operand, 'pm-with');
|
||||
assert.equal(operand, "pm-with");
|
||||
return emails;
|
||||
},
|
||||
});
|
||||
@@ -207,13 +207,13 @@ run_test('get_active_user_ids_string', () => {
|
||||
pm_list.get_active_user_ids_string(),
|
||||
undefined);
|
||||
|
||||
set_filter_result(['bob@zulip.com,alice@zulip.com']);
|
||||
set_filter_result(["bob@zulip.com,alice@zulip.com"]);
|
||||
assert.equal(
|
||||
pm_list.get_active_user_ids_string(),
|
||||
'101,102');
|
||||
"101,102");
|
||||
});
|
||||
|
||||
run_test('is_all_privates', () => {
|
||||
run_test("is_all_privates", () => {
|
||||
narrow_state.filter = () => {};
|
||||
|
||||
assert.equal(
|
||||
@@ -222,8 +222,8 @@ run_test('is_all_privates', () => {
|
||||
|
||||
narrow_state.filter = () => ({
|
||||
operands: (operand) => {
|
||||
assert.equal(operand, 'is');
|
||||
return ['private', 'starred'];
|
||||
assert.equal(operand, "is");
|
||||
return ["private", "starred"];
|
||||
},
|
||||
});
|
||||
|
||||
@@ -234,12 +234,12 @@ run_test('is_all_privates', () => {
|
||||
|
||||
function with_fake_list(f) {
|
||||
const orig = pm_list._build_private_messages_list;
|
||||
pm_list._build_private_messages_list = () => 'PM_LIST_CONTENTS';
|
||||
pm_list._build_private_messages_list = () => "PM_LIST_CONTENTS";
|
||||
f();
|
||||
pm_list._build_private_messages_list = orig;
|
||||
}
|
||||
|
||||
run_test('expand', () => {
|
||||
run_test("expand", () => {
|
||||
with_fake_list(() => {
|
||||
let html_updated;
|
||||
|
||||
@@ -253,11 +253,11 @@ run_test('expand', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('update_private_messages', () => {
|
||||
run_test("update_private_messages", () => {
|
||||
narrow_state.active = () => true;
|
||||
|
||||
$('#private-container').find = (sel) => {
|
||||
assert.equal(sel, 'ul');
|
||||
$("#private-container").find = (sel) => {
|
||||
assert.equal(sel, "ul");
|
||||
};
|
||||
|
||||
with_fake_list(() => {
|
||||
@@ -277,18 +277,18 @@ run_test('update_private_messages', () => {
|
||||
pm_list.update_private_messages();
|
||||
|
||||
assert(html_updated);
|
||||
assert($(".top_left_private_messages").hasClass('active-filter'));
|
||||
assert($(".top_left_private_messages").hasClass("active-filter"));
|
||||
|
||||
pm_list.is_all_privates = orig_is_all_privates;
|
||||
});
|
||||
});
|
||||
|
||||
run_test('ensure coverage', () => {
|
||||
run_test("ensure coverage", () => {
|
||||
// These aren't rigorous; they just cover cases
|
||||
// where functions early exit.
|
||||
narrow_state.active = () => false;
|
||||
pm_list.rebuild_recent = () => {
|
||||
throw Error('we should not call rebuild_recent');
|
||||
throw Error("we should not call rebuild_recent");
|
||||
};
|
||||
pm_list.update_private_messages();
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
zrequire('poll_widget');
|
||||
zrequire("poll_widget");
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
set_global('people', {});
|
||||
set_global("people", {});
|
||||
|
||||
const noop = () => {};
|
||||
const return_false = () => false;
|
||||
const return_true = () => true;
|
||||
|
||||
run_test('poll_data_holder my question', () => {
|
||||
run_test("poll_data_holder my question", () => {
|
||||
const is_my_poll = true;
|
||||
const question = 'Favorite color?';
|
||||
const question = "Favorite color?";
|
||||
|
||||
const sender_id = 99;
|
||||
people.my_current_user_id = () => sender_id;
|
||||
@@ -21,12 +21,12 @@ run_test('poll_data_holder my question', () => {
|
||||
|
||||
assert.deepEqual(data, {
|
||||
options: [],
|
||||
question: 'Favorite color?',
|
||||
question: "Favorite color?",
|
||||
});
|
||||
|
||||
const question_event = {
|
||||
type: 'question',
|
||||
question: 'best plan?',
|
||||
type: "question",
|
||||
question: "best plan?",
|
||||
};
|
||||
|
||||
data_holder.handle_event(sender_id, question_event);
|
||||
@@ -34,16 +34,16 @@ run_test('poll_data_holder my question', () => {
|
||||
|
||||
assert.deepEqual(data, {
|
||||
options: [],
|
||||
question: 'best plan?',
|
||||
question: "best plan?",
|
||||
});
|
||||
|
||||
const option_event = {
|
||||
type: 'new_option',
|
||||
type: "new_option",
|
||||
idx: 1,
|
||||
option: 'release now',
|
||||
option: "release now",
|
||||
};
|
||||
|
||||
people.safe_full_names = () => '';
|
||||
people.safe_full_names = () => "";
|
||||
|
||||
data_holder.handle_event(sender_id, option_event);
|
||||
data = data_holder.get_widget_data();
|
||||
@@ -51,19 +51,19 @@ run_test('poll_data_holder my question', () => {
|
||||
assert.deepEqual(data, {
|
||||
options: [
|
||||
{
|
||||
option: 'release now',
|
||||
names: '',
|
||||
option: "release now",
|
||||
names: "",
|
||||
count: 0,
|
||||
key: '99,1',
|
||||
key: "99,1",
|
||||
current_user_vote: false,
|
||||
},
|
||||
],
|
||||
question: 'best plan?',
|
||||
question: "best plan?",
|
||||
});
|
||||
|
||||
let vote_event = {
|
||||
type: 'vote',
|
||||
key: '99,1',
|
||||
type: "vote",
|
||||
key: "99,1",
|
||||
vote: 1,
|
||||
};
|
||||
|
||||
@@ -73,46 +73,46 @@ run_test('poll_data_holder my question', () => {
|
||||
assert.deepEqual(data, {
|
||||
options: [
|
||||
{
|
||||
option: 'release now',
|
||||
names: '',
|
||||
option: "release now",
|
||||
names: "",
|
||||
count: 1,
|
||||
key: '99,1',
|
||||
key: "99,1",
|
||||
current_user_vote: true,
|
||||
},
|
||||
],
|
||||
question: 'best plan?',
|
||||
question: "best plan?",
|
||||
});
|
||||
|
||||
const invalid_vote_event = {
|
||||
type: 'vote',
|
||||
key: '98,1',
|
||||
type: "vote",
|
||||
key: "98,1",
|
||||
vote: 1,
|
||||
};
|
||||
|
||||
blueslip.expect('warn', `unknown key for poll: ${invalid_vote_event.key}`);
|
||||
blueslip.expect("warn", `unknown key for poll: ${invalid_vote_event.key}`);
|
||||
data_holder.handle_event(sender_id, invalid_vote_event);
|
||||
data = data_holder.get_widget_data();
|
||||
|
||||
const option_outbound_event = data_holder.handle.new_option.outbound('new option');
|
||||
const option_outbound_event = data_holder.handle.new_option.outbound("new option");
|
||||
assert.deepEqual(option_outbound_event, {
|
||||
type: 'new_option',
|
||||
type: "new_option",
|
||||
idx: 2,
|
||||
option: 'new option',
|
||||
option: "new option",
|
||||
});
|
||||
|
||||
const new_question = 'Any new plan?';
|
||||
const new_question = "Any new plan?";
|
||||
const question_outbound_event = data_holder.handle.question.outbound(new_question);
|
||||
assert.deepEqual(question_outbound_event, {
|
||||
type: 'question',
|
||||
type: "question",
|
||||
question: new_question,
|
||||
});
|
||||
|
||||
const vote_outbound_event = data_holder.handle.vote.outbound('99,1');
|
||||
assert.deepEqual(vote_outbound_event, { type: 'vote', key: '99,1', vote: -1 });
|
||||
const vote_outbound_event = data_holder.handle.vote.outbound("99,1");
|
||||
assert.deepEqual(vote_outbound_event, { type: "vote", key: "99,1", vote: -1 });
|
||||
|
||||
vote_event = {
|
||||
type: 'vote',
|
||||
key: '99,1',
|
||||
type: "vote",
|
||||
key: "99,1",
|
||||
vote: -1,
|
||||
};
|
||||
|
||||
@@ -122,29 +122,29 @@ run_test('poll_data_holder my question', () => {
|
||||
assert.deepEqual(data, {
|
||||
options: [
|
||||
{
|
||||
option: 'release now',
|
||||
names: '',
|
||||
option: "release now",
|
||||
names: "",
|
||||
count: 0,
|
||||
key: '99,1',
|
||||
key: "99,1",
|
||||
current_user_vote: false,
|
||||
},
|
||||
],
|
||||
question: 'best plan?',
|
||||
question: "best plan?",
|
||||
});
|
||||
});
|
||||
|
||||
run_test('activate another person poll', () => {
|
||||
run_test("activate another person poll", () => {
|
||||
people.is_my_user_id = return_false;
|
||||
global.stub_templates((template_name) => {
|
||||
if (template_name === 'widgets/poll_widget') {
|
||||
return 'widgets/poll_widget';
|
||||
if (template_name === "widgets/poll_widget") {
|
||||
return "widgets/poll_widget";
|
||||
}
|
||||
if (template_name === 'widgets/poll_widget_results') {
|
||||
return 'widgets/poll_widget_results';
|
||||
if (template_name === "widgets/poll_widget_results") {
|
||||
return "widgets/poll_widget_results";
|
||||
}
|
||||
});
|
||||
|
||||
const widget_elem = $('<div>').addClass('widget-content');
|
||||
const widget_elem = $("<div>").addClass("widget-content");
|
||||
|
||||
let out_data; // Used to check the event data sent to the server
|
||||
const callback = (data) => {
|
||||
@@ -158,7 +158,7 @@ run_test('activate another person poll', () => {
|
||||
sender_id: 100,
|
||||
},
|
||||
extra_data: {
|
||||
question: 'What do you want?',
|
||||
question: "What do you want?",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -168,33 +168,33 @@ run_test('activate another person poll', () => {
|
||||
return elem;
|
||||
};
|
||||
|
||||
const poll_option = set_widget_find_result('button.poll-option');
|
||||
const poll_option_input = set_widget_find_result('input.poll-option');
|
||||
const widget_option_container = set_widget_find_result('ul.poll-widget');
|
||||
const poll_option = set_widget_find_result("button.poll-option");
|
||||
const poll_option_input = set_widget_find_result("input.poll-option");
|
||||
const widget_option_container = set_widget_find_result("ul.poll-widget");
|
||||
|
||||
const poll_question_submit = set_widget_find_result('button.poll-question-check');
|
||||
const poll_edit_question = set_widget_find_result('.poll-edit-question');
|
||||
const poll_question_header = set_widget_find_result('.poll-question-header');
|
||||
const poll_question_container = set_widget_find_result('.poll-question-bar');
|
||||
const poll_option_container = set_widget_find_result('.poll-option-bar');
|
||||
const poll_question_submit = set_widget_find_result("button.poll-question-check");
|
||||
const poll_edit_question = set_widget_find_result(".poll-edit-question");
|
||||
const poll_question_header = set_widget_find_result(".poll-question-header");
|
||||
const poll_question_container = set_widget_find_result(".poll-question-bar");
|
||||
const poll_option_container = set_widget_find_result(".poll-option-bar");
|
||||
|
||||
const poll_vote_button = set_widget_find_result('button.poll-vote');
|
||||
const poll_please_wait = set_widget_find_result('.poll-please-wait');
|
||||
const poll_author_help = set_widget_find_result('.poll-author-help');
|
||||
const poll_vote_button = set_widget_find_result("button.poll-vote");
|
||||
const poll_please_wait = set_widget_find_result(".poll-please-wait");
|
||||
const poll_author_help = set_widget_find_result(".poll-author-help");
|
||||
|
||||
set_widget_find_result('button.poll-question-remove');
|
||||
set_widget_find_result('input.poll-question');
|
||||
set_widget_find_result("button.poll-question-remove");
|
||||
set_widget_find_result("input.poll-question");
|
||||
|
||||
let option_button_callback;
|
||||
let vote_button_callback;
|
||||
|
||||
poll_option.on = (event, func) => {
|
||||
assert.equal(event, 'click');
|
||||
assert.equal(event, "click");
|
||||
option_button_callback = func;
|
||||
};
|
||||
|
||||
poll_vote_button.on = (event, func) => {
|
||||
assert.equal(event, 'click');
|
||||
assert.equal(event, "click");
|
||||
vote_button_callback = func;
|
||||
};
|
||||
|
||||
@@ -229,9 +229,9 @@ run_test('activate another person poll', () => {
|
||||
|
||||
poll_widget.activate(opts);
|
||||
|
||||
assert.equal(widget_elem.html(), 'widgets/poll_widget');
|
||||
assert.equal(widget_option_container.html(), 'widgets/poll_widget_results');
|
||||
assert.equal(poll_question_header.text(), 'What do you want?');
|
||||
assert.equal(widget_elem.html(), "widgets/poll_widget");
|
||||
assert.equal(widget_option_container.html(), "widgets/poll_widget_results");
|
||||
assert.equal(poll_question_header.text(), "What do you want?");
|
||||
|
||||
const e = {
|
||||
stopPropagation: noop,
|
||||
@@ -239,12 +239,12 @@ run_test('activate another person poll', () => {
|
||||
|
||||
{
|
||||
/* Testing data sent to server on adding option */
|
||||
poll_option_input.val('cool choice');
|
||||
poll_option_input.val("cool choice");
|
||||
out_data = undefined;
|
||||
option_button_callback(e);
|
||||
assert.deepEqual(out_data, { type: 'new_option', idx: 1, option: 'cool choice' });
|
||||
assert.deepEqual(out_data, { type: "new_option", idx: 1, option: "cool choice" });
|
||||
|
||||
poll_option_input.val('');
|
||||
poll_option_input.val("");
|
||||
out_data = undefined;
|
||||
option_button_callback(e);
|
||||
assert.deepEqual(out_data, undefined);
|
||||
@@ -254,16 +254,16 @@ run_test('activate another person poll', () => {
|
||||
{
|
||||
sender_id: 100,
|
||||
data: {
|
||||
type: 'new_option',
|
||||
type: "new_option",
|
||||
idx: 1,
|
||||
option: 'release now',
|
||||
option: "release now",
|
||||
},
|
||||
},
|
||||
{
|
||||
sender_id: 100,
|
||||
data: {
|
||||
type: 'vote',
|
||||
key: '100,1',
|
||||
type: "vote",
|
||||
key: "100,1",
|
||||
vote: 1,
|
||||
},
|
||||
},
|
||||
@@ -273,22 +273,22 @@ run_test('activate another person poll', () => {
|
||||
|
||||
{
|
||||
/* Testing data sent to server on voting */
|
||||
poll_vote_button.attr('data-key', '100,1');
|
||||
poll_vote_button.attr("data-key", "100,1");
|
||||
const e = {
|
||||
stopPropagation: noop,
|
||||
target: poll_vote_button,
|
||||
};
|
||||
out_data = undefined;
|
||||
vote_button_callback(e);
|
||||
assert.deepEqual(out_data, { type: 'vote', key: '100,1', vote: 1 });
|
||||
assert.deepEqual(out_data, { type: "vote", key: "100,1", vote: 1 });
|
||||
}
|
||||
|
||||
const add_question_event = [
|
||||
{
|
||||
sender_id: 100,
|
||||
data: {
|
||||
type: 'question',
|
||||
question: 'best plan?',
|
||||
type: "question",
|
||||
question: "best plan?",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -296,20 +296,20 @@ run_test('activate another person poll', () => {
|
||||
widget_elem.handle_events(add_question_event);
|
||||
});
|
||||
|
||||
run_test('activate own poll', () => {
|
||||
run_test("activate own poll", () => {
|
||||
$.clear_all_elements();
|
||||
|
||||
people.is_my_user_id = return_true;
|
||||
global.stub_templates((template_name) => {
|
||||
if (template_name === 'widgets/poll_widget') {
|
||||
return 'widgets/poll_widget';
|
||||
if (template_name === "widgets/poll_widget") {
|
||||
return "widgets/poll_widget";
|
||||
}
|
||||
if (template_name === 'widgets/poll_widget_results') {
|
||||
return 'widgets/poll_widget_results';
|
||||
if (template_name === "widgets/poll_widget_results") {
|
||||
return "widgets/poll_widget_results";
|
||||
}
|
||||
});
|
||||
|
||||
const widget_elem = $('<div>').addClass('widget-content');
|
||||
const widget_elem = $("<div>").addClass("widget-content");
|
||||
let out_data;
|
||||
const callback = (data) => {
|
||||
out_data = data;
|
||||
@@ -321,7 +321,7 @@ run_test('activate own poll', () => {
|
||||
sender_id: 100,
|
||||
},
|
||||
extra_data: {
|
||||
question: 'Where to go?',
|
||||
question: "Where to go?",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -331,27 +331,27 @@ run_test('activate own poll', () => {
|
||||
return elem;
|
||||
};
|
||||
|
||||
const poll_option = set_widget_find_result('button.poll-option');
|
||||
const poll_option_input = set_widget_find_result('input.poll-option');
|
||||
const widget_option_container = set_widget_find_result('ul.poll-widget');
|
||||
const poll_option = set_widget_find_result("button.poll-option");
|
||||
const poll_option_input = set_widget_find_result("input.poll-option");
|
||||
const widget_option_container = set_widget_find_result("ul.poll-widget");
|
||||
|
||||
const poll_question_submit = set_widget_find_result('button.poll-question-check');
|
||||
const poll_edit_question = set_widget_find_result('.poll-edit-question');
|
||||
const poll_question_input = set_widget_find_result('input.poll-question');
|
||||
const poll_question_header = set_widget_find_result('.poll-question-header');
|
||||
const poll_question_container = set_widget_find_result('.poll-question-bar');
|
||||
const poll_option_container = set_widget_find_result('.poll-option-bar');
|
||||
const poll_question_submit = set_widget_find_result("button.poll-question-check");
|
||||
const poll_edit_question = set_widget_find_result(".poll-edit-question");
|
||||
const poll_question_input = set_widget_find_result("input.poll-question");
|
||||
const poll_question_header = set_widget_find_result(".poll-question-header");
|
||||
const poll_question_container = set_widget_find_result(".poll-question-bar");
|
||||
const poll_option_container = set_widget_find_result(".poll-option-bar");
|
||||
|
||||
const poll_vote_button = set_widget_find_result('button.poll-vote');
|
||||
const poll_please_wait = set_widget_find_result('.poll-please-wait');
|
||||
const poll_author_help = set_widget_find_result('.poll-author-help');
|
||||
const poll_vote_button = set_widget_find_result("button.poll-vote");
|
||||
const poll_please_wait = set_widget_find_result(".poll-please-wait");
|
||||
const poll_author_help = set_widget_find_result(".poll-author-help");
|
||||
|
||||
set_widget_find_result('button.poll-question-remove');
|
||||
set_widget_find_result("button.poll-question-remove");
|
||||
|
||||
let question_button_callback;
|
||||
|
||||
poll_question_submit.on = (event, func) => {
|
||||
assert.equal(event, 'click');
|
||||
assert.equal(event, "click");
|
||||
question_button_callback = func;
|
||||
};
|
||||
|
||||
@@ -391,9 +391,9 @@ run_test('activate own poll', () => {
|
||||
|
||||
poll_widget.activate(opts);
|
||||
|
||||
assert.equal(widget_elem.html(), 'widgets/poll_widget');
|
||||
assert.equal(widget_option_container.html(), 'widgets/poll_widget_results');
|
||||
assert.equal(poll_question_header.text(), 'Where to go?');
|
||||
assert.equal(widget_elem.html(), "widgets/poll_widget");
|
||||
assert.equal(widget_option_container.html(), "widgets/poll_widget_results");
|
||||
assert.equal(poll_question_header.text(), "Where to go?");
|
||||
|
||||
{
|
||||
/* Testing data sent to server on editing question */
|
||||
@@ -401,13 +401,13 @@ run_test('activate own poll', () => {
|
||||
stopPropagation: noop,
|
||||
};
|
||||
|
||||
poll_question_input.val('Is it new?');
|
||||
poll_question_input.val("Is it new?");
|
||||
out_data = undefined;
|
||||
show_submit = true;
|
||||
question_button_callback(e);
|
||||
assert.deepEqual(out_data, { type: 'question', question: 'Is it new?' });
|
||||
assert.deepEqual(out_data, { type: "question", question: "Is it new?" });
|
||||
|
||||
poll_option_input.val('');
|
||||
poll_option_input.val("");
|
||||
out_data = undefined;
|
||||
question_button_callback(e);
|
||||
assert.deepEqual(out_data, undefined);
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
zrequire('hash_util');
|
||||
zrequire('narrow');
|
||||
zrequire('narrow_state');
|
||||
zrequire('people');
|
||||
zrequire('presence');
|
||||
zrequire('buddy_data');
|
||||
zrequire('user_status');
|
||||
zrequire('feature_flags');
|
||||
zrequire('message_edit');
|
||||
zrequire("hash_util");
|
||||
zrequire("narrow");
|
||||
zrequire("narrow_state");
|
||||
zrequire("people");
|
||||
zrequire("presence");
|
||||
zrequire("buddy_data");
|
||||
zrequire("user_status");
|
||||
zrequire("feature_flags");
|
||||
zrequire("message_edit");
|
||||
|
||||
const noop = function () {};
|
||||
$.fn.popover = noop; // this will get wrapped by our code
|
||||
|
||||
zrequire('popovers');
|
||||
zrequire("popovers");
|
||||
popovers.hide_user_profile = noop;
|
||||
|
||||
set_global('current_msg_list', {});
|
||||
set_global('page_params', {
|
||||
set_global("current_msg_list", {});
|
||||
set_global("page_params", {
|
||||
is_admin: false,
|
||||
realm_email_address_visibility: 3,
|
||||
custom_profile_fields: [],
|
||||
});
|
||||
set_global('rows', {});
|
||||
set_global("rows", {});
|
||||
|
||||
set_global('message_viewport', {
|
||||
set_global("message_viewport", {
|
||||
height: () => 500,
|
||||
});
|
||||
|
||||
set_global('emoji_picker', {
|
||||
set_global("emoji_picker", {
|
||||
hide_emoji_popover: noop,
|
||||
});
|
||||
|
||||
set_global('stream_popover', {
|
||||
set_global("stream_popover", {
|
||||
hide_stream_popover: noop,
|
||||
hide_topic_popover: noop,
|
||||
hide_all_messages_popover: noop,
|
||||
@@ -40,16 +40,16 @@ set_global('stream_popover', {
|
||||
hide_streamlist_sidebar: noop,
|
||||
});
|
||||
|
||||
set_global('stream_data', {});
|
||||
set_global("stream_data", {});
|
||||
|
||||
function ClipboardJS(sel) {
|
||||
assert.equal(sel, '.copy_link');
|
||||
assert.equal(sel, ".copy_link");
|
||||
}
|
||||
set_global('ClipboardJS', ClipboardJS);
|
||||
set_global("ClipboardJS", ClipboardJS);
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
full_name: 'Alice Smith',
|
||||
email: "alice@example.com",
|
||||
full_name: "Alice Smith",
|
||||
user_id: 42,
|
||||
avatar_version: 5,
|
||||
is_guest: false,
|
||||
@@ -57,13 +57,13 @@ const alice = {
|
||||
};
|
||||
|
||||
const me = {
|
||||
email: 'me@example.com',
|
||||
email: "me@example.com",
|
||||
user_id: 30,
|
||||
full_name: 'Me Myself',
|
||||
timezone: 'US/Pacific',
|
||||
full_name: "Me Myself",
|
||||
timezone: "US/Pacific",
|
||||
};
|
||||
|
||||
const target = $.create('click target');
|
||||
const target = $.create("click target");
|
||||
target.offset = () => ({
|
||||
top: 10,
|
||||
});
|
||||
@@ -96,7 +96,7 @@ function make_image_stubber() {
|
||||
return image;
|
||||
}
|
||||
|
||||
set_global('Image', stub_image);
|
||||
set_global("Image", stub_image);
|
||||
|
||||
return {
|
||||
get: (i) => images[i],
|
||||
@@ -105,9 +105,9 @@ function make_image_stubber() {
|
||||
|
||||
popovers.register_click_handlers();
|
||||
|
||||
run_test('sender_hover', () => {
|
||||
run_test("sender_hover", () => {
|
||||
const selection = ".sender_name, .sender_name-in-status, .inline_profile_picture";
|
||||
const handler = $('#main_div').get_on_handler('click', selection);
|
||||
const handler = $("#main_div").get_on_handler("click", selection);
|
||||
|
||||
const message = {
|
||||
id: 999,
|
||||
@@ -116,7 +116,7 @@ run_test('sender_hover', () => {
|
||||
|
||||
user_status.set_status_text({
|
||||
user_id: alice.user_id,
|
||||
status_text: 'on the beach',
|
||||
status_text: "on the beach",
|
||||
});
|
||||
|
||||
rows.id = () => message.id;
|
||||
@@ -131,82 +131,82 @@ run_test('sender_hover', () => {
|
||||
};
|
||||
|
||||
target.closest = (sel) => {
|
||||
assert.equal(sel, '.message_row');
|
||||
assert.equal(sel, ".message_row");
|
||||
return {};
|
||||
};
|
||||
|
||||
global.stub_templates((fn, opts) => {
|
||||
switch (fn) {
|
||||
case 'no_arrow_popover':
|
||||
case "no_arrow_popover":
|
||||
assert.deepEqual(opts, {
|
||||
class: 'message-info-popover',
|
||||
class: "message-info-popover",
|
||||
});
|
||||
return 'popover-html';
|
||||
return "popover-html";
|
||||
|
||||
case 'user_info_popover_title':
|
||||
case "user_info_popover_title":
|
||||
assert.deepEqual(opts, {
|
||||
user_avatar: 'avatar/alice@example.com',
|
||||
user_avatar: "avatar/alice@example.com",
|
||||
user_is_guest: false,
|
||||
});
|
||||
return 'title-html';
|
||||
return "title-html";
|
||||
|
||||
case 'user_info_popover_content':
|
||||
case "user_info_popover_content":
|
||||
assert.deepEqual(opts, {
|
||||
can_set_away: false,
|
||||
can_revoke_away: false,
|
||||
user_full_name: 'Alice Smith',
|
||||
user_email: 'alice@example.com',
|
||||
user_full_name: "Alice Smith",
|
||||
user_email: "alice@example.com",
|
||||
user_id: 42,
|
||||
user_time: undefined,
|
||||
user_type: i18n.t('Member'),
|
||||
user_circle_class: 'user_circle_empty',
|
||||
user_last_seen_time_status: 'translated: More than 2 weeks ago',
|
||||
pm_with_uri: '#narrow/pm-with/42-alice',
|
||||
sent_by_uri: '#narrow/sender/42-alice',
|
||||
private_message_class: 'respond_personal_button',
|
||||
user_type: i18n.t("Member"),
|
||||
user_circle_class: "user_circle_empty",
|
||||
user_last_seen_time_status: "translated: More than 2 weeks ago",
|
||||
pm_with_uri: "#narrow/pm-with/42-alice",
|
||||
sent_by_uri: "#narrow/sender/42-alice",
|
||||
private_message_class: "respond_personal_button",
|
||||
show_email: false,
|
||||
show_user_profile: false,
|
||||
is_me: false,
|
||||
is_active: true,
|
||||
is_bot: undefined,
|
||||
is_sender_popover: true,
|
||||
status_text: 'on the beach',
|
||||
status_text: "on the beach",
|
||||
});
|
||||
return 'content-html';
|
||||
return "content-html";
|
||||
|
||||
default:
|
||||
throw Error('unrecognized template: ' + fn);
|
||||
throw Error("unrecognized template: " + fn);
|
||||
}
|
||||
});
|
||||
|
||||
$('.user_popover_email').each = noop;
|
||||
$(".user_popover_email").each = noop;
|
||||
const image_stubber = make_image_stubber();
|
||||
window.location = {
|
||||
href: 'http://chat.zulip.org/',
|
||||
href: "http://chat.zulip.org/",
|
||||
};
|
||||
const base_url = window.location.href;
|
||||
handler.call(target, e);
|
||||
|
||||
const avatar_img = image_stubber.get(0);
|
||||
const expected_url = new URL('avatar/42/medium?v=' + alice.avatar_version, base_url);
|
||||
const expected_url = new URL("avatar/42/medium?v=" + alice.avatar_version, base_url);
|
||||
assert.equal(avatar_img.src.toString(), expected_url.toString());
|
||||
|
||||
// todo: load image
|
||||
});
|
||||
|
||||
run_test('actions_popover', () => {
|
||||
const handler = $('#main_div').get_on_handler('click', '.actions_hover');
|
||||
run_test("actions_popover", () => {
|
||||
const handler = $("#main_div").get_on_handler("click", ".actions_hover");
|
||||
|
||||
window.location = {
|
||||
protocol: 'http:',
|
||||
host: 'chat.zulip.org',
|
||||
pathname: '/',
|
||||
protocol: "http:",
|
||||
host: "chat.zulip.org",
|
||||
pathname: "/",
|
||||
};
|
||||
|
||||
const message = {
|
||||
id: 999,
|
||||
topic: 'Actions (1)',
|
||||
type: 'stream',
|
||||
topic: "Actions (1)",
|
||||
type: "stream",
|
||||
stream_id: 123,
|
||||
};
|
||||
|
||||
@@ -219,11 +219,11 @@ run_test('actions_popover', () => {
|
||||
|
||||
stream_data.id_to_slug = (stream_id) => {
|
||||
assert.equal(stream_id, 123);
|
||||
return 'Bracket ( stream';
|
||||
return "Bracket ( stream";
|
||||
};
|
||||
|
||||
target.closest = (sel) => {
|
||||
assert.equal(sel, '.message_row');
|
||||
assert.equal(sel, ".message_row");
|
||||
return {
|
||||
toggleClass: noop,
|
||||
};
|
||||
@@ -232,13 +232,13 @@ run_test('actions_popover', () => {
|
||||
global.stub_templates((fn, opts) => {
|
||||
// TODO: Test all the properties of the popover
|
||||
switch (fn) {
|
||||
case 'actions_popover_content':
|
||||
case "actions_popover_content":
|
||||
assert.equal(
|
||||
opts.conversation_time_uri,
|
||||
'http://chat.zulip.org/#narrow/stream/Bracket.20%28.20stream/topic/Actions.20%281%29/near/999');
|
||||
return 'actions-content';
|
||||
"http://chat.zulip.org/#narrow/stream/Bracket.20%28.20stream/topic/Actions.20%281%29/near/999");
|
||||
return "actions-content";
|
||||
default:
|
||||
throw Error('unrecognized template: ' + fn);
|
||||
throw Error("unrecognized template: " + fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
zrequire('people');
|
||||
zrequire('presence');
|
||||
zrequire("people");
|
||||
zrequire("presence");
|
||||
|
||||
const return_false = function () { return false; };
|
||||
|
||||
set_global('server_events', {});
|
||||
set_global('reload_state', {
|
||||
set_global("server_events", {});
|
||||
set_global("reload_state", {
|
||||
is_in_progress: return_false,
|
||||
});
|
||||
function XDate(ms) {
|
||||
return {seconds: ms};
|
||||
}
|
||||
set_global('XDate', XDate);
|
||||
set_global("XDate", XDate);
|
||||
|
||||
const OFFLINE_THRESHOLD_SECS = 140;
|
||||
|
||||
const me = {
|
||||
email: 'me@zulip.com',
|
||||
email: "me@zulip.com",
|
||||
user_id: 101,
|
||||
full_name: 'Me Myself',
|
||||
full_name: "Me Myself",
|
||||
};
|
||||
|
||||
const alice = {
|
||||
email: 'alice@zulip.com',
|
||||
email: "alice@zulip.com",
|
||||
user_id: 1,
|
||||
full_name: 'Alice Smith',
|
||||
full_name: "Alice Smith",
|
||||
};
|
||||
|
||||
const fred = {
|
||||
email: 'fred@zulip.com',
|
||||
email: "fred@zulip.com",
|
||||
user_id: 2,
|
||||
full_name: "Fred Flintstone",
|
||||
};
|
||||
|
||||
const sally = {
|
||||
email: 'sally@example.com',
|
||||
email: "sally@example.com",
|
||||
user_id: 3,
|
||||
full_name: 'Sally Jones',
|
||||
full_name: "Sally Jones",
|
||||
};
|
||||
|
||||
const zoe = {
|
||||
email: 'zoe@example.com',
|
||||
email: "zoe@example.com",
|
||||
user_id: 6,
|
||||
full_name: 'Zoe Yang',
|
||||
full_name: "Zoe Yang",
|
||||
};
|
||||
|
||||
const bot = {
|
||||
email: 'bot@zulip.com',
|
||||
email: "bot@zulip.com",
|
||||
user_id: 7,
|
||||
full_name: 'The Bot',
|
||||
full_name: "The Bot",
|
||||
is_bot: true,
|
||||
};
|
||||
|
||||
const john = {
|
||||
email: 'john@zulip.com',
|
||||
email: "john@zulip.com",
|
||||
user_id: 8,
|
||||
full_name: "John Doe",
|
||||
};
|
||||
|
||||
const jane = {
|
||||
email: 'jane@zulip.com',
|
||||
email: "jane@zulip.com",
|
||||
user_id: 9,
|
||||
full_name: "Jane Doe",
|
||||
};
|
||||
@@ -73,17 +73,17 @@ people.add_active_user(john);
|
||||
people.add_active_user(jane);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
run_test('my user', () => {
|
||||
assert.equal(presence.get_status(me.user_id), 'active');
|
||||
run_test("my user", () => {
|
||||
assert.equal(presence.get_status(me.user_id), "active");
|
||||
});
|
||||
|
||||
run_test('unknown user', () => {
|
||||
run_test("unknown user", () => {
|
||||
const unknown_user_id = 999;
|
||||
const now = 888888;
|
||||
const presences = {};
|
||||
presences[unknown_user_id.toString()] = 'does-not-matter';
|
||||
presences[unknown_user_id.toString()] = "does-not-matter";
|
||||
|
||||
blueslip.expect('error', 'Unknown user ID in presence data: 999');
|
||||
blueslip.expect("error", "Unknown user ID in presence data: 999");
|
||||
presence.set_info(presences, now);
|
||||
|
||||
// If the server is suspected to be offline or reloading,
|
||||
@@ -98,7 +98,7 @@ run_test('unknown user', () => {
|
||||
reload_state.is_in_progress = () => false;
|
||||
});
|
||||
|
||||
run_test('status_from_raw', () => {
|
||||
run_test("status_from_raw", () => {
|
||||
const status_from_raw = presence.status_from_raw;
|
||||
|
||||
const now = 5000;
|
||||
@@ -112,7 +112,7 @@ run_test('status_from_raw', () => {
|
||||
assert.deepEqual(
|
||||
status_from_raw(raw),
|
||||
{
|
||||
status: 'active',
|
||||
status: "active",
|
||||
last_active: raw.active_timestamp,
|
||||
},
|
||||
);
|
||||
@@ -125,7 +125,7 @@ run_test('status_from_raw', () => {
|
||||
assert.deepEqual(
|
||||
status_from_raw(raw),
|
||||
{
|
||||
status: 'offline',
|
||||
status: "offline",
|
||||
last_active: raw.active_timestamp,
|
||||
},
|
||||
);
|
||||
@@ -138,13 +138,13 @@ run_test('status_from_raw', () => {
|
||||
assert.deepEqual(
|
||||
status_from_raw(raw),
|
||||
{
|
||||
status: 'idle',
|
||||
status: "idle",
|
||||
last_active: raw.idle_timestamp,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
run_test('set_presence_info', () => {
|
||||
run_test("set_presence_info", () => {
|
||||
const presences = {};
|
||||
const now = 5000;
|
||||
const recent = now + 1 - OFFLINE_THRESHOLD_SECS;
|
||||
@@ -181,51 +181,51 @@ run_test('set_presence_info', () => {
|
||||
presence.initialize(params);
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(alice.user_id),
|
||||
{ status: 'active', last_active: recent},
|
||||
{ status: "active", last_active: recent},
|
||||
);
|
||||
assert.equal(presence.get_status(alice.user_id), 'active');
|
||||
assert.equal(presence.get_status(alice.user_id), "active");
|
||||
assert.deepEqual(
|
||||
presence.last_active_date(alice.user_id),
|
||||
{seconds: recent * 1000},
|
||||
);
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(fred.user_id),
|
||||
{ status: 'idle', last_active: now},
|
||||
{ status: "idle", last_active: now},
|
||||
);
|
||||
assert.equal(presence.get_status(fred.user_id), 'idle');
|
||||
assert.equal(presence.get_status(fred.user_id), "idle");
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(me.user_id),
|
||||
{ status: 'active', last_active: now},
|
||||
{ status: "active", last_active: now},
|
||||
);
|
||||
assert.equal(presence.get_status(me.user_id), 'active');
|
||||
assert.equal(presence.get_status(me.user_id), "active");
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(sally.user_id),
|
||||
{ status: 'offline', last_active: a_while_ago},
|
||||
{ status: "offline", last_active: a_while_ago},
|
||||
);
|
||||
assert.equal(presence.get_status(sally.user_id), 'offline');
|
||||
assert.equal(presence.get_status(sally.user_id), "offline");
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(zoe.user_id),
|
||||
{ status: 'offline', last_active: undefined},
|
||||
{ status: "offline", last_active: undefined},
|
||||
);
|
||||
assert.equal(presence.get_status(zoe.user_id), 'offline');
|
||||
assert.equal(presence.get_status(zoe.user_id), "offline");
|
||||
assert.equal(presence.last_active_date(zoe.user_id), undefined);
|
||||
|
||||
assert(!presence.presence_info.has(bot.user_id));
|
||||
assert.equal(presence.get_status(bot.user_id), 'offline');
|
||||
assert.equal(presence.get_status(bot.user_id), "offline");
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(john.user_id),
|
||||
{ status: 'offline', last_active: a_while_ago},
|
||||
{ status: "offline", last_active: a_while_ago},
|
||||
);
|
||||
assert.equal(presence.get_status(john.user_id), 'offline');
|
||||
assert.equal(presence.get_status(john.user_id), "offline");
|
||||
|
||||
assert.deepEqual(presence.presence_info.get(jane.user_id),
|
||||
{ status: 'idle', last_active: now},
|
||||
{ status: "idle", last_active: now},
|
||||
);
|
||||
assert.equal(presence.get_status(jane.user_id), 'idle');
|
||||
assert.equal(presence.get_status(jane.user_id), "idle");
|
||||
|
||||
});
|
||||
|
||||
run_test('falsy values', () => {
|
||||
run_test("falsy values", () => {
|
||||
/*
|
||||
When a user does not have a relevant active timestamp,
|
||||
the server just leaves off the `active_timestamp` field
|
||||
@@ -250,7 +250,7 @@ run_test('falsy values', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
presence.presence_info.get(zoe.user_id),
|
||||
{ status: 'idle', last_active: a_bit_ago },
|
||||
{ status: "idle", last_active: a_bit_ago },
|
||||
);
|
||||
|
||||
presences[zoe.user_id.toString()] = {
|
||||
@@ -262,12 +262,12 @@ run_test('falsy values', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
presence.presence_info.get(zoe.user_id),
|
||||
{ status: 'offline', last_active: undefined },
|
||||
{ status: "offline", last_active: undefined },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
run_test('big realms', () => {
|
||||
run_test("big realms", () => {
|
||||
const presences = {};
|
||||
const now = 5000;
|
||||
|
||||
@@ -286,7 +286,7 @@ run_test('big realms', () => {
|
||||
people.get_active_human_count = get_active_human_count;
|
||||
});
|
||||
|
||||
run_test('last_active_date', () => {
|
||||
run_test("last_active_date", () => {
|
||||
const unknown_id = 42;
|
||||
presence.presence_info.clear();
|
||||
presence.presence_info.set(alice.user_id, { last_active: 500 });
|
||||
@@ -297,7 +297,7 @@ run_test('last_active_date', () => {
|
||||
assert.deepEqual(presence.last_active_date(alice.user_id), {seconds: 500000});
|
||||
});
|
||||
|
||||
run_test('update_info_from_event', () => {
|
||||
run_test("update_info_from_event", () => {
|
||||
let info;
|
||||
|
||||
info = {
|
||||
@@ -312,7 +312,7 @@ run_test('update_info_from_event', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
presence.presence_info.get(alice.user_id),
|
||||
{ status: 'active', last_active: 500 },
|
||||
{ status: "active", last_active: 500 },
|
||||
);
|
||||
|
||||
info = {
|
||||
@@ -325,7 +325,7 @@ run_test('update_info_from_event', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
presence.presence_info.get(alice.user_id),
|
||||
{ status: 'active', last_active: 510 },
|
||||
{ status: "active", last_active: 510 },
|
||||
);
|
||||
|
||||
info = {
|
||||
@@ -338,6 +338,6 @@ run_test('update_info_from_event', () => {
|
||||
|
||||
assert.deepEqual(
|
||||
presence.presence_info.get(alice.user_id),
|
||||
{ status: 'idle', last_active: 1000 },
|
||||
{ status: "idle", last_active: 1000 },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
set_global('document', 'document-stub');
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global("document", "document-stub");
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
zrequire('emoji');
|
||||
zrequire('people');
|
||||
zrequire('reactions');
|
||||
zrequire("emoji");
|
||||
zrequire("people");
|
||||
zrequire("reactions");
|
||||
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
user_id: 5,
|
||||
realm_emoji: {
|
||||
991: {
|
||||
id: '991',
|
||||
name: 'realm_emoji',
|
||||
source_url: 'TBD',
|
||||
id: "991",
|
||||
name: "realm_emoji",
|
||||
source_url: "TBD",
|
||||
deactivated: false,
|
||||
},
|
||||
992: {
|
||||
id: '992',
|
||||
name: 'inactive_realm_emoji',
|
||||
source_url: 'TBD',
|
||||
id: "992",
|
||||
name: "inactive_realm_emoji",
|
||||
source_url: "TBD",
|
||||
deactivated: true,
|
||||
},
|
||||
zulip: {
|
||||
id: 'zulip',
|
||||
name: 'zulip',
|
||||
source_url: 'TBD',
|
||||
id: "zulip",
|
||||
name: "zulip",
|
||||
source_url: "TBD",
|
||||
deactivated: false,
|
||||
},
|
||||
},
|
||||
@@ -31,25 +31,25 @@ set_global('page_params', {
|
||||
|
||||
emoji.initialize();
|
||||
|
||||
set_global('channel', {});
|
||||
set_global('emoji_picker', {
|
||||
set_global("channel", {});
|
||||
set_global("emoji_picker", {
|
||||
hide_emoji_popover: function () {},
|
||||
});
|
||||
|
||||
const alice = {
|
||||
email: 'alice@example.com',
|
||||
email: "alice@example.com",
|
||||
user_id: 5,
|
||||
full_name: 'Alice',
|
||||
full_name: "Alice",
|
||||
};
|
||||
const bob = {
|
||||
email: 'bob@example.com',
|
||||
email: "bob@example.com",
|
||||
user_id: 6,
|
||||
full_name: 'Bob van Roberts',
|
||||
full_name: "Bob van Roberts",
|
||||
};
|
||||
const cali = {
|
||||
email: 'cali@example.com',
|
||||
email: "cali@example.com",
|
||||
user_id: 7,
|
||||
full_name: 'Cali',
|
||||
full_name: "Cali",
|
||||
};
|
||||
people.add_active_user(alice);
|
||||
people.add_active_user(bob);
|
||||
@@ -58,46 +58,46 @@ people.add_active_user(cali);
|
||||
const message = {
|
||||
id: 1001,
|
||||
reactions: [
|
||||
{emoji_name: 'smile', user_id: 5, reaction_type: 'unicode_emoji', emoji_code: '263a'},
|
||||
{emoji_name: 'smile', user_id: 6, reaction_type: 'unicode_emoji', emoji_code: '263a'},
|
||||
{emoji_name: 'frown', user_id: 7, reaction_type: 'unicode_emoji', emoji_code: '1f641'},
|
||||
{emoji_name: 'inactive_realm_emoji', user_id: 5, reaction_type: 'realm_emoji',
|
||||
emoji_code: '992'},
|
||||
{emoji_name: "smile", user_id: 5, reaction_type: "unicode_emoji", emoji_code: "263a"},
|
||||
{emoji_name: "smile", user_id: 6, reaction_type: "unicode_emoji", emoji_code: "263a"},
|
||||
{emoji_name: "frown", user_id: 7, reaction_type: "unicode_emoji", emoji_code: "1f641"},
|
||||
{emoji_name: "inactive_realm_emoji", user_id: 5, reaction_type: "realm_emoji",
|
||||
emoji_code: "992"},
|
||||
|
||||
// add some bogus user_ids
|
||||
{emoji_name: 'octopus', user_id: 8888, reaction_type: 'unicode_emoji', emoji_code: '1f419'},
|
||||
{emoji_name: 'frown', user_id: 9999, reaction_type: 'unicode_emoji', emoji_code: '1f641'},
|
||||
{emoji_name: "octopus", user_id: 8888, reaction_type: "unicode_emoji", emoji_code: "1f419"},
|
||||
{emoji_name: "frown", user_id: 9999, reaction_type: "unicode_emoji", emoji_code: "1f641"},
|
||||
],
|
||||
};
|
||||
|
||||
set_global('message_store', {
|
||||
set_global("message_store", {
|
||||
get: function (message_id) {
|
||||
assert.equal(message_id, 1001);
|
||||
return message;
|
||||
},
|
||||
});
|
||||
|
||||
set_global('current_msg_list', {
|
||||
set_global("current_msg_list", {
|
||||
selected_message: function () {
|
||||
return { sent_by_me: true };
|
||||
},
|
||||
selected_row: function () {
|
||||
return $('.selected-row');
|
||||
return $(".selected-row");
|
||||
},
|
||||
selected_id: function () {
|
||||
return 42;
|
||||
},
|
||||
});
|
||||
|
||||
run_test('open_reactions_popover', () => {
|
||||
$('.selected-row').set_find_results('.actions_hover', $('.target-action'));
|
||||
$('.selected-row').set_find_results('.reaction_button', $('.target-reaction'));
|
||||
run_test("open_reactions_popover", () => {
|
||||
$(".selected-row").set_find_results(".actions_hover", $(".target-action"));
|
||||
$(".selected-row").set_find_results(".reaction_button", $(".target-reaction"));
|
||||
|
||||
let called = false;
|
||||
emoji_picker.toggle_emoji_popover = function (target, id) {
|
||||
called = true;
|
||||
assert.equal(id, 42);
|
||||
assert.equal(target, $('.target-reaction')[0]);
|
||||
assert.equal(target, $(".target-reaction")[0]);
|
||||
};
|
||||
|
||||
assert(reactions.open_reactions_popover());
|
||||
@@ -109,65 +109,65 @@ run_test('open_reactions_popover', () => {
|
||||
emoji_picker.toggle_emoji_popover = function (target, id) {
|
||||
called = true;
|
||||
assert.equal(id, 42);
|
||||
assert.equal(target, $('.target-action')[0]);
|
||||
assert.equal(target, $(".target-action")[0]);
|
||||
};
|
||||
|
||||
assert(reactions.open_reactions_popover());
|
||||
assert(called);
|
||||
});
|
||||
|
||||
run_test('basics', () => {
|
||||
blueslip.expect('warn', 'Unknown user_id 8888 in reaction for message 1001');
|
||||
blueslip.expect('warn', 'Unknown user_id 9999 in reaction for message 1001');
|
||||
run_test("basics", () => {
|
||||
blueslip.expect("warn", "Unknown user_id 8888 in reaction for message 1001");
|
||||
blueslip.expect("warn", "Unknown user_id 9999 in reaction for message 1001");
|
||||
const result = reactions.get_message_reactions(message);
|
||||
assert(reactions.current_user_has_reacted_to_emoji(message, 'unicode_emoji,263a'));
|
||||
assert(!reactions.current_user_has_reacted_to_emoji(message, 'bogus'));
|
||||
assert(reactions.current_user_has_reacted_to_emoji(message, "unicode_emoji,263a"));
|
||||
assert(!reactions.current_user_has_reacted_to_emoji(message, "bogus"));
|
||||
|
||||
result.sort((a, b) => a.count - b.count);
|
||||
|
||||
const expected_result = [
|
||||
{
|
||||
emoji_name: 'frown',
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_code: '1f641',
|
||||
local_id: 'unicode_emoji,1f641',
|
||||
emoji_name: "frown",
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_code: "1f641",
|
||||
local_id: "unicode_emoji,1f641",
|
||||
count: 1,
|
||||
user_ids: [7],
|
||||
label: 'Cali reacted with :frown:',
|
||||
label: "Cali reacted with :frown:",
|
||||
emoji_alt_code: false,
|
||||
class: 'message_reaction',
|
||||
class: "message_reaction",
|
||||
},
|
||||
{
|
||||
emoji_name: 'inactive_realm_emoji',
|
||||
reaction_type: 'realm_emoji',
|
||||
emoji_code: '992',
|
||||
local_id: 'realm_emoji,992',
|
||||
emoji_name: "inactive_realm_emoji",
|
||||
reaction_type: "realm_emoji",
|
||||
emoji_code: "992",
|
||||
local_id: "realm_emoji,992",
|
||||
count: 1,
|
||||
user_ids: [5],
|
||||
label: 'You (click to remove) reacted with :inactive_realm_emoji:',
|
||||
label: "You (click to remove) reacted with :inactive_realm_emoji:",
|
||||
emoji_alt_code: false,
|
||||
is_realm_emoji: true,
|
||||
url: 'TBD',
|
||||
class: 'message_reaction reacted',
|
||||
url: "TBD",
|
||||
class: "message_reaction reacted",
|
||||
},
|
||||
{
|
||||
emoji_name: 'smile',
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_code: '263a',
|
||||
local_id: 'unicode_emoji,263a',
|
||||
emoji_name: "smile",
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_code: "263a",
|
||||
local_id: "unicode_emoji,263a",
|
||||
count: 2,
|
||||
user_ids: [5, 6],
|
||||
label: 'You (click to remove) and Bob van Roberts reacted with :smile:',
|
||||
label: "You (click to remove) and Bob van Roberts reacted with :smile:",
|
||||
emoji_alt_code: false,
|
||||
class: 'message_reaction reacted',
|
||||
class: "message_reaction reacted",
|
||||
},
|
||||
];
|
||||
assert.deepEqual(result, expected_result);
|
||||
});
|
||||
|
||||
run_test('sending', () => {
|
||||
run_test("sending", () => {
|
||||
const message_id = 1001; // see above for setup
|
||||
let emoji_name = 'smile'; // should be a current reaction
|
||||
let emoji_name = "smile"; // should be a current reaction
|
||||
|
||||
const orig_remove_reaction = reactions.remove_reaction;
|
||||
const orig_add_reaction = reactions.add_reaction;
|
||||
@@ -177,115 +177,115 @@ run_test('sending', () => {
|
||||
global.with_stub((stub) => {
|
||||
global.channel.del = stub.f;
|
||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||
const args = stub.get_args('args').args;
|
||||
assert.equal(args.url, '/json/messages/1001/reactions');
|
||||
const args = stub.get_args("args").args;
|
||||
assert.equal(args.url, "/json/messages/1001/reactions");
|
||||
assert.deepEqual(args.data, {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'smile',
|
||||
emoji_code: '263a',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "smile",
|
||||
emoji_code: "263a",
|
||||
});
|
||||
// args.success() does nothing; just make sure it doesn't crash
|
||||
args.success();
|
||||
|
||||
// similarly, we only exercise the failure codepath
|
||||
// Since this path calls blueslip.warn, we need to handle it.
|
||||
blueslip.expect('warn', 'XHR Error Message.');
|
||||
global.channel.xhr_error_message = function () {return 'XHR Error Message.';};
|
||||
blueslip.expect("warn", "XHR Error Message.");
|
||||
global.channel.xhr_error_message = function () {return "XHR Error Message.";};
|
||||
args.error();
|
||||
});
|
||||
emoji_name = 'alien'; // not set yet
|
||||
emoji_name = "alien"; // not set yet
|
||||
global.with_stub((stub) => {
|
||||
global.channel.post = stub.f;
|
||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||
const args = stub.get_args('args').args;
|
||||
assert.equal(args.url, '/json/messages/1001/reactions');
|
||||
const args = stub.get_args("args").args;
|
||||
assert.equal(args.url, "/json/messages/1001/reactions");
|
||||
assert.deepEqual(args.data, {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'alien',
|
||||
emoji_code: '1f47d',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "alien",
|
||||
emoji_code: "1f47d",
|
||||
});
|
||||
});
|
||||
|
||||
emoji_name = 'inactive_realm_emoji';
|
||||
emoji_name = "inactive_realm_emoji";
|
||||
global.with_stub((stub) => {
|
||||
// Test removing a deactivated realm emoji. An user can interact with a
|
||||
// deactivated realm emoji only by clicking on a reaction, hence, only
|
||||
// `process_reaction_click()` codepath supports deleting/adding a deactivated
|
||||
// realm emoji.
|
||||
global.channel.del = stub.f;
|
||||
reactions.process_reaction_click(message_id, 'realm_emoji,992');
|
||||
const args = stub.get_args('args').args;
|
||||
assert.equal(args.url, '/json/messages/1001/reactions');
|
||||
reactions.process_reaction_click(message_id, "realm_emoji,992");
|
||||
const args = stub.get_args("args").args;
|
||||
assert.equal(args.url, "/json/messages/1001/reactions");
|
||||
assert.deepEqual(args.data, {
|
||||
reaction_type: 'realm_emoji',
|
||||
emoji_name: 'inactive_realm_emoji',
|
||||
emoji_code: '992',
|
||||
reaction_type: "realm_emoji",
|
||||
emoji_name: "inactive_realm_emoji",
|
||||
emoji_code: "992",
|
||||
});
|
||||
});
|
||||
|
||||
emoji_name = 'zulip'; // Test adding zulip emoji.
|
||||
emoji_name = "zulip"; // Test adding zulip emoji.
|
||||
global.with_stub((stub) => {
|
||||
global.channel.post = stub.f;
|
||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||
const args = stub.get_args('args').args;
|
||||
assert.equal(args.url, '/json/messages/1001/reactions');
|
||||
const args = stub.get_args("args").args;
|
||||
assert.equal(args.url, "/json/messages/1001/reactions");
|
||||
assert.deepEqual(args.data, {
|
||||
reaction_type: 'zulip_extra_emoji',
|
||||
emoji_name: 'zulip',
|
||||
emoji_code: 'zulip',
|
||||
reaction_type: "zulip_extra_emoji",
|
||||
emoji_name: "zulip",
|
||||
emoji_code: "zulip",
|
||||
});
|
||||
});
|
||||
|
||||
emoji_name = 'unknown-emoji'; // Test sending an emoji unknown to frontend.
|
||||
blueslip.expect('warn', 'Bad emoji name: ' + emoji_name);
|
||||
emoji_name = "unknown-emoji"; // Test sending an emoji unknown to frontend.
|
||||
blueslip.expect("warn", "Bad emoji name: " + emoji_name);
|
||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||
reactions.add_reaction = orig_add_reaction;
|
||||
reactions.remove_reaction = orig_remove_reaction;
|
||||
});
|
||||
|
||||
run_test('set_reaction_count', () => {
|
||||
const count_element = $.create('count-stub');
|
||||
const reaction_element = $.create('reaction-stub');
|
||||
run_test("set_reaction_count", () => {
|
||||
const count_element = $.create("count-stub");
|
||||
const reaction_element = $.create("reaction-stub");
|
||||
|
||||
reaction_element.set_find_results('.message_reaction_count', count_element);
|
||||
reaction_element.set_find_results(".message_reaction_count", count_element);
|
||||
|
||||
reactions.set_reaction_count(reaction_element, 5);
|
||||
|
||||
assert.equal(count_element.text(), '5');
|
||||
assert.equal(count_element.text(), "5");
|
||||
});
|
||||
|
||||
run_test('get_reaction_section', () => {
|
||||
const message_table = $.create('.message_table');
|
||||
const message_row = $.create('some-message-row');
|
||||
const message_reactions = $.create('our-reactions-section');
|
||||
run_test("get_reaction_section", () => {
|
||||
const message_table = $.create(".message_table");
|
||||
const message_row = $.create("some-message-row");
|
||||
const message_reactions = $.create("our-reactions-section");
|
||||
|
||||
message_table.set_find_results("[zid='555']", message_row);
|
||||
message_row.set_find_results('.message_reactions', message_reactions);
|
||||
message_row.set_find_results(".message_reactions", message_reactions);
|
||||
|
||||
const section = reactions.get_reaction_section(555);
|
||||
|
||||
assert.equal(section, message_reactions);
|
||||
});
|
||||
|
||||
run_test('emoji_reaction_title', () => {
|
||||
run_test("emoji_reaction_title", () => {
|
||||
const message_id = 1001;
|
||||
const local_id = 'unicode_emoji,263a';
|
||||
const local_id = "unicode_emoji,263a";
|
||||
|
||||
assert.equal(reactions.get_reaction_title_data(message_id, local_id),
|
||||
"You (click to remove) and Bob van Roberts reacted with :smile:");
|
||||
});
|
||||
|
||||
run_test('add_and_remove_reaction', () => {
|
||||
run_test("add_and_remove_reaction", () => {
|
||||
// Insert 8ball for Alice.
|
||||
let alice_event = {
|
||||
message_id: 1001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: alice.user_id,
|
||||
};
|
||||
|
||||
const message_reactions = $.create('our-reactions');
|
||||
const message_reactions = $.create("our-reactions");
|
||||
|
||||
reactions.get_reaction_section = function (message_id) {
|
||||
assert.equal(message_id, 1001);
|
||||
@@ -293,24 +293,24 @@ run_test('add_and_remove_reaction', () => {
|
||||
};
|
||||
|
||||
message_reactions.find = function (selector) {
|
||||
assert.equal(selector, '.reaction_button');
|
||||
return 'reaction-button-stub';
|
||||
assert.equal(selector, ".reaction_button");
|
||||
return "reaction-button-stub";
|
||||
};
|
||||
|
||||
let template_called;
|
||||
global.stub_templates((template_name, data) => {
|
||||
template_called = true;
|
||||
assert.equal(template_name, 'message_reaction');
|
||||
assert.equal(data.class, 'message_reaction reacted');
|
||||
assert.equal(template_name, "message_reaction");
|
||||
assert.equal(data.class, "message_reaction reacted");
|
||||
assert(!data.is_realm_emoji);
|
||||
assert.equal(data.message_id, 1001);
|
||||
assert.equal(data.label, 'You (click to remove) reacted with :8ball:');
|
||||
return '<new reaction html>';
|
||||
assert.equal(data.label, "You (click to remove) reacted with :8ball:");
|
||||
return "<new reaction html>";
|
||||
});
|
||||
|
||||
let insert_called;
|
||||
$('<new reaction html>').insertBefore = function (element) {
|
||||
assert.equal(element, 'reaction-button-stub');
|
||||
$("<new reaction html>").insertBefore = function (element) {
|
||||
assert.equal(element, "reaction-button-stub");
|
||||
insert_called = true;
|
||||
};
|
||||
|
||||
@@ -319,7 +319,7 @@ run_test('add_and_remove_reaction', () => {
|
||||
assert(insert_called);
|
||||
|
||||
// Testing tooltip title data for added reaction.
|
||||
const local_id = 'unicode_emoji,1f3b1';
|
||||
const local_id = "unicode_emoji,1f3b1";
|
||||
assert.equal(reactions.get_reaction_title_data(alice_event.message_id, local_id),
|
||||
"You (click to remove) reacted with :8ball:");
|
||||
|
||||
@@ -334,15 +334,15 @@ run_test('add_and_remove_reaction', () => {
|
||||
|
||||
const bob_event = {
|
||||
message_id: 1001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: bob.user_id,
|
||||
};
|
||||
|
||||
const count_element = $.create('count-element');
|
||||
const reaction_element = $.create('reaction-element');
|
||||
reaction_element.set_find_results('.message_reaction_count', count_element);
|
||||
const count_element = $.create("count-element");
|
||||
const reaction_element = $.create("reaction-element");
|
||||
reaction_element.set_find_results(".message_reaction_count", count_element);
|
||||
|
||||
message_reactions.find = function (selector) {
|
||||
assert.equal(selector, "[data-reaction-id='unicode_emoji,1f3b1']");
|
||||
@@ -350,13 +350,13 @@ run_test('add_and_remove_reaction', () => {
|
||||
};
|
||||
|
||||
reactions.add_reaction(bob_event);
|
||||
assert.equal(count_element.text(), '2');
|
||||
assert.equal(count_element.text(), "2");
|
||||
|
||||
reactions.remove_reaction(bob_event);
|
||||
assert.equal(count_element.text(), '1');
|
||||
assert.equal(count_element.text(), "1");
|
||||
|
||||
let current_emojis = reactions.get_emojis_used_by_user_for_message_id(1001);
|
||||
assert.deepEqual(current_emojis, ['smile', 'inactive_realm_emoji', '8ball']);
|
||||
assert.deepEqual(current_emojis, ["smile", "inactive_realm_emoji", "8ball"]);
|
||||
|
||||
// Next, remove Alice's reaction, which exercises removing the
|
||||
// emoji icon.
|
||||
@@ -374,40 +374,40 @@ run_test('add_and_remove_reaction', () => {
|
||||
assert(!removed);
|
||||
|
||||
current_emojis = reactions.get_emojis_used_by_user_for_message_id(1001);
|
||||
assert.deepEqual(current_emojis, ['smile', 'inactive_realm_emoji']);
|
||||
assert.deepEqual(current_emojis, ["smile", "inactive_realm_emoji"]);
|
||||
|
||||
// Now add Cali's realm_emoji reaction.
|
||||
const cali_event = {
|
||||
message_id: 1001,
|
||||
reaction_type: 'realm_emoji',
|
||||
emoji_name: 'realm_emoji',
|
||||
emoji_code: '991',
|
||||
reaction_type: "realm_emoji",
|
||||
emoji_name: "realm_emoji",
|
||||
emoji_code: "991",
|
||||
user_id: cali.user_id,
|
||||
};
|
||||
|
||||
template_called = false;
|
||||
global.stub_templates((template_name, data) => {
|
||||
assert.equal(data.class, 'message_reaction');
|
||||
assert.equal(data.class, "message_reaction");
|
||||
assert(data.is_realm_emoji);
|
||||
template_called = true;
|
||||
return '<new reaction html>';
|
||||
return "<new reaction html>";
|
||||
});
|
||||
|
||||
message_reactions.find = function (selector) {
|
||||
assert.equal(selector, '.reaction_button');
|
||||
return 'reaction-button-stub';
|
||||
assert.equal(selector, ".reaction_button");
|
||||
return "reaction-button-stub";
|
||||
};
|
||||
|
||||
reactions.add_reaction(cali_event);
|
||||
assert(template_called);
|
||||
assert(!reaction_element.hasClass('reacted'));
|
||||
assert(!reaction_element.hasClass("reacted"));
|
||||
|
||||
// And then have Alice update it.
|
||||
alice_event = {
|
||||
message_id: 1001,
|
||||
reaction_type: 'realm_emoji',
|
||||
emoji_name: 'realm_emoji',
|
||||
emoji_code: '991',
|
||||
reaction_type: "realm_emoji",
|
||||
emoji_name: "realm_emoji",
|
||||
emoji_code: "991",
|
||||
user_id: alice.user_id,
|
||||
};
|
||||
|
||||
@@ -419,18 +419,18 @@ run_test('add_and_remove_reaction', () => {
|
||||
reactions.add_reaction(alice_event);
|
||||
|
||||
const result = reactions.get_message_reactions(message);
|
||||
assert(reaction_element.hasClass('reacted'));
|
||||
const realm_emoji_data = result.filter((v) => v.emoji_name === 'realm_emoji')[0];
|
||||
assert(reaction_element.hasClass("reacted"));
|
||||
const realm_emoji_data = result.filter((v) => v.emoji_name === "realm_emoji")[0];
|
||||
|
||||
assert.equal(realm_emoji_data.count, 2);
|
||||
assert.equal(realm_emoji_data.is_realm_emoji, true);
|
||||
|
||||
// And then remove Alice's reaction.
|
||||
reactions.remove_reaction(alice_event);
|
||||
assert(!reaction_element.hasClass('reacted'));
|
||||
assert(!reaction_element.hasClass("reacted"));
|
||||
});
|
||||
|
||||
run_test('with_view_stubs', () => {
|
||||
run_test("with_view_stubs", () => {
|
||||
// This function tests reaction events by mocking out calls to
|
||||
// the view.
|
||||
|
||||
@@ -456,9 +456,9 @@ run_test('with_view_stubs', () => {
|
||||
}
|
||||
|
||||
reactions.view = {
|
||||
insert_new_reaction: add_call_func('insert_new_reaction'),
|
||||
update_existing_reaction: add_call_func('update_existing_reaction'),
|
||||
remove_reaction: add_call_func('remove_reaction'),
|
||||
insert_new_reaction: add_call_func("insert_new_reaction"),
|
||||
update_existing_reaction: add_call_func("update_existing_reaction"),
|
||||
remove_reaction: add_call_func("remove_reaction"),
|
||||
};
|
||||
|
||||
test_params.run_code();
|
||||
@@ -468,25 +468,25 @@ run_test('with_view_stubs', () => {
|
||||
|
||||
const alice_8ball_event = {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: alice.user_id,
|
||||
};
|
||||
|
||||
const bob_8ball_event = {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: bob.user_id,
|
||||
};
|
||||
|
||||
const cali_airplane_event = {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'airplane',
|
||||
emoji_code: '2708',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "airplane",
|
||||
emoji_code: "2708",
|
||||
user_id: cali.user_id,
|
||||
};
|
||||
|
||||
@@ -496,12 +496,12 @@ run_test('with_view_stubs', () => {
|
||||
},
|
||||
expected_view_calls: [
|
||||
{
|
||||
name: 'insert_new_reaction',
|
||||
name: "insert_new_reaction",
|
||||
opts: {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: alice.user_id,
|
||||
},
|
||||
},
|
||||
@@ -514,12 +514,12 @@ run_test('with_view_stubs', () => {
|
||||
},
|
||||
expected_view_calls: [
|
||||
{
|
||||
name: 'update_existing_reaction',
|
||||
name: "update_existing_reaction",
|
||||
opts: {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: bob.user_id,
|
||||
user_list: [alice.user_id, bob.user_id],
|
||||
},
|
||||
@@ -533,12 +533,12 @@ run_test('with_view_stubs', () => {
|
||||
},
|
||||
expected_view_calls: [
|
||||
{
|
||||
name: 'insert_new_reaction',
|
||||
name: "insert_new_reaction",
|
||||
opts: {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'airplane',
|
||||
emoji_code: '2708',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "airplane",
|
||||
emoji_code: "2708",
|
||||
user_id: cali.user_id,
|
||||
},
|
||||
},
|
||||
@@ -551,12 +551,12 @@ run_test('with_view_stubs', () => {
|
||||
},
|
||||
expected_view_calls: [
|
||||
{
|
||||
name: 'remove_reaction',
|
||||
name: "remove_reaction",
|
||||
opts: {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: bob.user_id,
|
||||
user_list: [alice.user_id],
|
||||
},
|
||||
@@ -570,12 +570,12 @@ run_test('with_view_stubs', () => {
|
||||
},
|
||||
expected_view_calls: [
|
||||
{
|
||||
name: 'remove_reaction',
|
||||
name: "remove_reaction",
|
||||
opts: {
|
||||
message_id: 2001,
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: '8ball',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "8ball",
|
||||
emoji_code: "1f3b1",
|
||||
user_id: alice.user_id,
|
||||
user_list: [],
|
||||
},
|
||||
@@ -585,18 +585,18 @@ run_test('with_view_stubs', () => {
|
||||
|
||||
});
|
||||
|
||||
run_test('error_handling', () => {
|
||||
run_test("error_handling", () => {
|
||||
global.message_store.get = function () {
|
||||
return;
|
||||
};
|
||||
|
||||
blueslip.expect('error', 'reactions: Bad message id: 55');
|
||||
blueslip.expect("error", "reactions: Bad message id: 55");
|
||||
|
||||
const bogus_event = {
|
||||
message_id: 55,
|
||||
reaction_type: 'realm_emoji',
|
||||
emoji_name: 'realm_emoji',
|
||||
emoji_code: '991',
|
||||
reaction_type: "realm_emoji",
|
||||
emoji_name: "realm_emoji",
|
||||
emoji_code: "991",
|
||||
user_id: 99,
|
||||
};
|
||||
|
||||
@@ -612,14 +612,14 @@ run_test('error_handling', () => {
|
||||
|
||||
message_store.get = () => message;
|
||||
|
||||
run_test('remove spurious user', () => {
|
||||
run_test("remove spurious user", () => {
|
||||
// get coverage for removing non-user (it should just
|
||||
// silently fail)
|
||||
|
||||
const event = {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'frown',
|
||||
emoji_code: '1f641',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "frown",
|
||||
emoji_code: "1f641",
|
||||
message_id: message.id,
|
||||
user_id: alice.user_id,
|
||||
};
|
||||
@@ -627,7 +627,7 @@ run_test('remove spurious user', () => {
|
||||
reactions.remove_reaction(event);
|
||||
});
|
||||
|
||||
run_test('remove last user', () => {
|
||||
run_test("remove last user", () => {
|
||||
function assert_names(names) {
|
||||
assert.deepEqual(
|
||||
reactions.get_message_reactions(message).map((r) => r.emoji_name),
|
||||
@@ -635,34 +635,34 @@ run_test('remove last user', () => {
|
||||
);
|
||||
}
|
||||
|
||||
assert_names(['smile', 'frown', 'inactive_realm_emoji', 'realm_emoji']);
|
||||
assert_names(["smile", "frown", "inactive_realm_emoji", "realm_emoji"]);
|
||||
|
||||
const event = {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'frown',
|
||||
emoji_code: '1f641',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "frown",
|
||||
emoji_code: "1f641",
|
||||
message_id: message.id,
|
||||
user_id: cali.user_id,
|
||||
};
|
||||
reactions.remove_reaction(event);
|
||||
|
||||
assert_names(['smile', 'inactive_realm_emoji', 'realm_emoji']);
|
||||
assert_names(["smile", "inactive_realm_emoji", "realm_emoji"]);
|
||||
});
|
||||
|
||||
run_test('local_reaction_id', () => {
|
||||
run_test("local_reaction_id", () => {
|
||||
const reaction_info = {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_code: '1f44d',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_code: "1f44d",
|
||||
};
|
||||
const local_id = reactions.get_local_reaction_id(reaction_info);
|
||||
assert.equal(local_id, 'unicode_emoji,1f44d');
|
||||
assert.equal(local_id, "unicode_emoji,1f44d");
|
||||
});
|
||||
|
||||
run_test('process_reaction_click', () => {
|
||||
run_test("process_reaction_click", () => {
|
||||
const message_id = 1001;
|
||||
let expected_reaction_info = {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_code: '1f3b1',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_code: "1f3b1",
|
||||
};
|
||||
global.message_store.get = function (message_id) {
|
||||
assert.equal(message_id, 1001);
|
||||
@@ -670,28 +670,28 @@ run_test('process_reaction_click', () => {
|
||||
};
|
||||
|
||||
expected_reaction_info = {
|
||||
reaction_type: 'unicode_emoji',
|
||||
emoji_name: 'smile',
|
||||
emoji_code: '263a',
|
||||
reaction_type: "unicode_emoji",
|
||||
emoji_name: "smile",
|
||||
emoji_code: "263a",
|
||||
};
|
||||
global.with_stub((stub) => {
|
||||
global.channel.del = stub.f;
|
||||
reactions.process_reaction_click(message_id, 'unicode_emoji,263a');
|
||||
const args = stub.get_args('args').args;
|
||||
assert.equal(args.url, '/json/messages/1001/reactions');
|
||||
reactions.process_reaction_click(message_id, "unicode_emoji,263a");
|
||||
const args = stub.get_args("args").args;
|
||||
assert.equal(args.url, "/json/messages/1001/reactions");
|
||||
assert.deepEqual(args.data, expected_reaction_info);
|
||||
});
|
||||
});
|
||||
|
||||
run_test('warnings', () => {
|
||||
run_test("warnings", () => {
|
||||
// Clean the slate
|
||||
delete message.clean_reactions;
|
||||
blueslip.expect('warn', 'Unknown user_id 8888 in reaction for message 1001');
|
||||
blueslip.expect('warn', 'Unknown user_id 9999 in reaction for message 1001');
|
||||
blueslip.expect("warn", "Unknown user_id 8888 in reaction for message 1001");
|
||||
blueslip.expect("warn", "Unknown user_id 9999 in reaction for message 1001");
|
||||
reactions.get_message_reactions(message);
|
||||
});
|
||||
|
||||
run_test('code coverage', () => {
|
||||
run_test("code coverage", () => {
|
||||
/*
|
||||
We just silently fail in a few places in the reaction
|
||||
code, since events may come for messages that we don't
|
||||
@@ -713,28 +713,28 @@ run_test('code coverage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
run_test('duplicates', () => {
|
||||
run_test("duplicates", () => {
|
||||
const dup_reaction_message = {
|
||||
id: 1001,
|
||||
reactions: [
|
||||
{emoji_name: 'smile', user_id: 5, reaction_type: 'unicode_emoji', emoji_code: '263a'},
|
||||
{emoji_name: 'smile', user_id: 5, reaction_type: 'unicode_emoji', emoji_code: '263a'},
|
||||
{emoji_name: "smile", user_id: 5, reaction_type: "unicode_emoji", emoji_code: "263a"},
|
||||
{emoji_name: "smile", user_id: 5, reaction_type: "unicode_emoji", emoji_code: "263a"},
|
||||
],
|
||||
};
|
||||
|
||||
blueslip.expect(
|
||||
'error',
|
||||
'server sent duplicate reactions for user 5 (key=unicode_emoji,263a)');
|
||||
"error",
|
||||
"server sent duplicate reactions for user 5 (key=unicode_emoji,263a)");
|
||||
reactions.set_clean_reactions(dup_reaction_message);
|
||||
});
|
||||
|
||||
run_test('process_reaction_click errors', () => {
|
||||
run_test("process_reaction_click errors", () => {
|
||||
global.message_store.get = () => undefined;
|
||||
blueslip.expect('error', 'reactions: Bad message id: 55');
|
||||
blueslip.expect('error', 'message_id for reaction click is unknown: 55');
|
||||
reactions.process_reaction_click(55, 'whatever');
|
||||
blueslip.expect("error", "reactions: Bad message id: 55");
|
||||
blueslip.expect("error", "message_id for reaction click is unknown: 55");
|
||||
reactions.process_reaction_click(55, "whatever");
|
||||
|
||||
global.message_store.get = () => message;
|
||||
blueslip.expect('error', 'Data integrity problem for reaction bad-local-id (message some-msg-id)');
|
||||
reactions.process_reaction_click('some-msg-id', 'bad-local-id');
|
||||
blueslip.expect("error", "Data integrity problem for reaction bad-local-id (message some-msg-id)");
|
||||
reactions.process_reaction_click("some-msg-id", "bad-local-id");
|
||||
});
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const rs = zrequire('recent_senders');
|
||||
const rs = zrequire("recent_senders");
|
||||
|
||||
let next_id = 0;
|
||||
const messages = [];
|
||||
|
||||
set_global('message_util', {
|
||||
set_global("message_util", {
|
||||
get_messages_in_topic: (stream_id, topic) => messages.filter((x) => x.stream_id === stream_id &&
|
||||
x.topic.toLowerCase() === topic.toLowerCase()),
|
||||
});
|
||||
|
||||
run_test('process_message_for_senders', () => {
|
||||
run_test("process_message_for_senders", () => {
|
||||
const stream1 = 1;
|
||||
const stream2 = 2;
|
||||
const stream3 = 3;
|
||||
@@ -130,7 +130,7 @@ run_test('process_message_for_senders', () => {
|
||||
rs.compare_by_recency({user_id: sender2}, {user_id: sender1}, stream3, topic3) < 0,
|
||||
true);
|
||||
|
||||
assert.equal(rs.compare_by_recency({}, {}, next_id += 1, ''), 0);
|
||||
assert.equal(rs.compare_by_recency({}, {}, next_id += 1, ""), 0);
|
||||
|
||||
// new message in topic2
|
||||
const message9 = {
|
||||
@@ -145,10 +145,10 @@ run_test('process_message_for_senders', () => {
|
||||
|
||||
// Test topic change
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), '3',
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), "3",
|
||||
);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream3, topic2).toString(), '2,3',
|
||||
rs.get_topic_recent_senders(stream3, topic2).toString(), "2,3",
|
||||
);
|
||||
|
||||
// message7's topic was changed by user
|
||||
@@ -156,36 +156,36 @@ run_test('process_message_for_senders', () => {
|
||||
|
||||
rs.process_topic_edit(stream3, topic2, topic3);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), '2,3',
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3",
|
||||
);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream3, topic2).toString(), '3',
|
||||
rs.get_topic_recent_senders(stream3, topic2).toString(), "3",
|
||||
);
|
||||
|
||||
// Test stream change
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), '2,3',
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3",
|
||||
);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), '',
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), "",
|
||||
);
|
||||
// stream of topic3 was changed to stream4.
|
||||
messages[6].stream_id = stream4; // message7's topic is topic3
|
||||
messages[7].stream_id = stream4;
|
||||
rs.process_topic_edit(stream3, topic3, topic3, stream4);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), '',
|
||||
rs.get_topic_recent_senders(stream3, topic3).toString(), "",
|
||||
);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), '2,3',
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3",
|
||||
);
|
||||
|
||||
// Test stream & topic change
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), '2,3',
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3",
|
||||
);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream5, topic4).toString(), '',
|
||||
rs.get_topic_recent_senders(stream5, topic4).toString(), "",
|
||||
);
|
||||
// stream of topic3 was changed to stream5 and topic was changed to topic4.
|
||||
messages[6].stream_id = stream5;
|
||||
@@ -194,24 +194,24 @@ run_test('process_message_for_senders', () => {
|
||||
messages[7].topic = topic4;
|
||||
rs.process_topic_edit(stream4, topic3, topic4, stream5);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), '',
|
||||
rs.get_topic_recent_senders(stream4, topic3).toString(), "",
|
||||
);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream5, topic4).toString(), '2,3',
|
||||
rs.get_topic_recent_senders(stream5, topic4).toString(), "2,3",
|
||||
);
|
||||
|
||||
set_global('message_store', {
|
||||
set_global("message_store", {
|
||||
get: () => message1,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream1, topic1).toString(), '2,1',
|
||||
rs.get_topic_recent_senders(stream1, topic1).toString(), "2,1",
|
||||
);
|
||||
// delete message1 and message5 sent by sender1
|
||||
messages.splice(4, 1);
|
||||
messages.splice(0, 1);
|
||||
rs.update_topics_of_message_ids([message1.id, message5.id]);
|
||||
assert.equal(
|
||||
rs.get_topic_recent_senders(stream1, topic1).toString(), '2',
|
||||
rs.get_topic_recent_senders(stream1, topic1).toString(), "2",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
zrequire('message_util');
|
||||
zrequire("message_util");
|
||||
|
||||
const noop = () => {};
|
||||
set_global('$', global.make_zjquery({
|
||||
set_global("$", global.make_zjquery({
|
||||
silent: true,
|
||||
}));
|
||||
set_global('hashchange', {
|
||||
set_global("hashchange", {
|
||||
exit_overlay: noop,
|
||||
});
|
||||
set_global('overlays', {
|
||||
set_global("overlays", {
|
||||
open_overlay: (opts) => {
|
||||
overlays.close_callback = opts.on_close;
|
||||
},
|
||||
recent_topics_open: () => true,
|
||||
});
|
||||
set_global('people', {
|
||||
set_global("people", {
|
||||
is_my_user_id: function (id) {
|
||||
return id === 1;
|
||||
},
|
||||
sender_info_with_small_avatar_urls_for_sender_ids: (ids) => ids,
|
||||
});
|
||||
set_global('XDate', zrequire('XDate', 'xdate'));
|
||||
set_global('timerender', {
|
||||
set_global("XDate", zrequire("XDate", "xdate"));
|
||||
set_global("timerender", {
|
||||
last_seen_status_from_date: () => "Just now",
|
||||
get_full_datetime: () => ({
|
||||
date: "date",
|
||||
time: "time",
|
||||
}),
|
||||
});
|
||||
set_global('unread', {
|
||||
set_global("unread", {
|
||||
unread_topic_counter: {
|
||||
get: (stream_id, topic) => {
|
||||
if (stream_id === 1 && topic === "topic-1") {
|
||||
@@ -38,14 +38,14 @@ set_global('unread', {
|
||||
},
|
||||
},
|
||||
});
|
||||
set_global('hash_util', {
|
||||
set_global("hash_util", {
|
||||
by_stream_uri: () => "https://www.example.com",
|
||||
by_stream_topic_uri: () => "https://www.example.com",
|
||||
});
|
||||
set_global('recent_senders', {
|
||||
set_global("recent_senders", {
|
||||
get_topic_recent_senders: () => [1, 2],
|
||||
});
|
||||
set_global('list_render', {
|
||||
set_global("list_render", {
|
||||
modifier: noop,
|
||||
create: (container, mapped_topic_values, opts) => {
|
||||
const formatted_topics = [];
|
||||
@@ -91,7 +91,7 @@ const topic8 = "topic-8";
|
||||
const topic9 = "topic-9";
|
||||
const topic10 = "topic-10";
|
||||
|
||||
set_global('muting', {
|
||||
set_global("muting", {
|
||||
is_topic_muted: (stream_id, topic) => {
|
||||
if (stream_id === stream1 && topic === topic7) {
|
||||
return true;
|
||||
@@ -107,17 +107,17 @@ const sender2 = 2;
|
||||
|
||||
const messages = [];
|
||||
|
||||
set_global('message_list', {
|
||||
set_global("message_list", {
|
||||
all: {
|
||||
all_messages: function () {
|
||||
return messages;
|
||||
},
|
||||
},
|
||||
});
|
||||
set_global('message_store', {
|
||||
set_global("message_store", {
|
||||
get: (msg_id) => messages[msg_id - 1],
|
||||
});
|
||||
set_global('stream_data', {
|
||||
set_global("stream_data", {
|
||||
get_sub_by_id: (stream) => {
|
||||
if (stream === stream5) {
|
||||
// No data is available for deactivated streams
|
||||
@@ -141,102 +141,102 @@ let id = 0;
|
||||
|
||||
messages[0] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic1,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[1] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic2,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[2] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic2,
|
||||
sender_id: sender2,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[3] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic3,
|
||||
sender_id: sender2,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[4] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic4,
|
||||
sender_id: sender2,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[5] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic5,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[6] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic5,
|
||||
sender_id: sender2,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[7] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic6,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[8] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic6,
|
||||
sender_id: sender2,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
messages[9] = {
|
||||
stream_id: stream1,
|
||||
stream: 'stream1',
|
||||
stream: "stream1",
|
||||
id: id += 1,
|
||||
topic: topic7,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
// a message of stream4
|
||||
messages[10] = {
|
||||
stream_id: stream4,
|
||||
stream: 'stream4',
|
||||
stream: "stream4",
|
||||
id: id += 1,
|
||||
topic: topic10,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
};
|
||||
|
||||
function get_topic_key(stream_id, topic) {
|
||||
@@ -251,7 +251,7 @@ function generate_topic_data(topic_info_array) {
|
||||
const selectors = [];
|
||||
|
||||
for (const [stream_id, topic, unread_count, muted, participated] of topic_info_array) {
|
||||
const topic_selector = $.create('#recent_topic:' + get_topic_key(stream_id, topic));
|
||||
const topic_selector = $.create("#recent_topic:" + get_topic_key(stream_id, topic));
|
||||
topic_selector.data = function () {
|
||||
return {
|
||||
participated: participated,
|
||||
@@ -265,19 +265,19 @@ function generate_topic_data(topic_info_array) {
|
||||
other_senders_count: 0,
|
||||
invite_only: false,
|
||||
is_web_public: true,
|
||||
last_msg_time: 'Just now',
|
||||
last_msg_time: "Just now",
|
||||
full_last_msg_date_time: "date time",
|
||||
senders: [
|
||||
1,
|
||||
2,
|
||||
],
|
||||
stream: 'stream' + stream_id,
|
||||
stream_color: '',
|
||||
stream: "stream" + stream_id,
|
||||
stream_color: "",
|
||||
stream_id: stream_id,
|
||||
stream_url: 'https://www.example.com',
|
||||
stream_url: "https://www.example.com",
|
||||
topic: topic,
|
||||
topic_key: get_topic_key(stream_id, topic),
|
||||
topic_url: 'https://www.example.com',
|
||||
topic_url: "https://www.example.com",
|
||||
unread_count: unread_count,
|
||||
muted: muted,
|
||||
topic_muted: muted,
|
||||
@@ -289,7 +289,7 @@ function generate_topic_data(topic_info_array) {
|
||||
|
||||
function verify_topic_data(all_topics, stream, topic, last_msg_id,
|
||||
participated) {
|
||||
const topic_data = all_topics.get(stream + ':' + topic);
|
||||
const topic_data = all_topics.get(stream + ":" + topic);
|
||||
assert.equal(topic_data.last_msg_id, last_msg_id);
|
||||
assert.equal(topic_data.participated, participated);
|
||||
}
|
||||
@@ -302,20 +302,20 @@ run_test("test_recent_topics_launch", () => {
|
||||
filter_participated: false,
|
||||
filter_unread: false,
|
||||
filter_muted: false,
|
||||
search_val: '',
|
||||
search_val: "",
|
||||
};
|
||||
|
||||
global.stub_templates((template_name, data) => {
|
||||
if (template_name === 'recent_topics_table') {
|
||||
if (template_name === "recent_topics_table") {
|
||||
assert.deepEqual(data, expected);
|
||||
} else if (template_name === 'recent_topics_filters') {
|
||||
} else if (template_name === "recent_topics_filters") {
|
||||
assert.equal(data.filter_unread, expected.filter_unread);
|
||||
assert.equal(data.filter_participated, expected.filter_participated);
|
||||
}
|
||||
return '<recent_topics table stub>';
|
||||
return "<recent_topics table stub>";
|
||||
});
|
||||
|
||||
const rt = zrequire('recent_topics');
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.process_messages(messages);
|
||||
|
||||
rt.launch();
|
||||
@@ -324,10 +324,10 @@ run_test("test_recent_topics_launch", () => {
|
||||
overlays.close_callback();
|
||||
|
||||
// incorrect topic_key
|
||||
assert.equal(rt.inplace_rerender('stream_unknown:topic_unknown'), false);
|
||||
assert.equal(rt.inplace_rerender("stream_unknown:topic_unknown"), false);
|
||||
});
|
||||
|
||||
run_test('test_filter_all', () => {
|
||||
run_test("test_filter_all", () => {
|
||||
// Just tests inplace rerender of a message
|
||||
// in All topics filter.
|
||||
const expected = {
|
||||
@@ -339,200 +339,200 @@ run_test('test_filter_all', () => {
|
||||
let row_data;
|
||||
let i;
|
||||
global.stub_templates((template_name, data) => {
|
||||
if (template_name === 'recent_topic_row') {
|
||||
if (template_name === "recent_topic_row") {
|
||||
// All the row will be processed.
|
||||
i -= 1;
|
||||
assert.deepEqual(data, row_data[i]);
|
||||
} else if (template_name === 'recent_topics_table') {
|
||||
} else if (template_name === "recent_topics_table") {
|
||||
assert.deepEqual(data, expected);
|
||||
}
|
||||
return '<recent_topics row stub>';
|
||||
return "<recent_topics row stub>";
|
||||
});
|
||||
|
||||
// topic is not muted
|
||||
row_data = generate_topic_data([[1, 'topic-1', 0, false, true]]);
|
||||
row_data = generate_topic_data([[1, "topic-1", 0, false, true]]);
|
||||
i = row_data.length;
|
||||
const rt = zrequire('recent_topics');
|
||||
rt.set_filter('all');
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.set_filter("all");
|
||||
rt.process_messages([messages[0]]);
|
||||
|
||||
row_data = row_data.concat(generate_topic_data([[1, 'topic-7', 1, true, true]]));
|
||||
row_data = row_data.concat(generate_topic_data([[1, "topic-7", 1, true, true]]));
|
||||
i = row_data.length;
|
||||
// topic is muted (=== hidden)
|
||||
rt.process_messages([messages[9]]);
|
||||
|
||||
// Test search
|
||||
expected.search_val = "topic-1";
|
||||
row_data = generate_topic_data([[1, 'topic-1', 0, false, true]]);
|
||||
row_data = generate_topic_data([[1, "topic-1", 0, false, true]]);
|
||||
const search_element = $.create("#recent_topics_search");
|
||||
search_element.val('topic-3');
|
||||
search_element.val("topic-3");
|
||||
i = row_data.length;
|
||||
assert.equal(rt.inplace_rerender('1:topic-1'), true);
|
||||
assert.equal(rt.inplace_rerender("1:topic-1"), true);
|
||||
});
|
||||
|
||||
run_test('test_filter_unread', () => {
|
||||
run_test("test_filter_unread", () => {
|
||||
// Tests rerender of all topics when filter changes to "unread".
|
||||
const expected = {
|
||||
filter_participated: false,
|
||||
filter_unread: true,
|
||||
filter_muted: false,
|
||||
search_val: '',
|
||||
search_val: "",
|
||||
};
|
||||
|
||||
const row_data = generate_topic_data([
|
||||
// stream_id, topic, unread_count, muted, participated
|
||||
[4, 'topic-10', 1, false, true],
|
||||
[1, 'topic-7', 1, true, true],
|
||||
[1, 'topic-6', 1, false, true],
|
||||
[1, 'topic-5', 1, false, true],
|
||||
[1, 'topic-4', 1, false, false],
|
||||
[1, 'topic-3', 1, false, false],
|
||||
[1, 'topic-2', 1, false, true],
|
||||
[1, 'topic-1', 0, false, true],
|
||||
[4, "topic-10", 1, false, true],
|
||||
[1, "topic-7", 1, true, true],
|
||||
[1, "topic-6", 1, false, true],
|
||||
[1, "topic-5", 1, false, true],
|
||||
[1, "topic-4", 1, false, false],
|
||||
[1, "topic-3", 1, false, false],
|
||||
[1, "topic-2", 1, false, true],
|
||||
[1, "topic-1", 0, false, true],
|
||||
]);
|
||||
let i = 0;
|
||||
|
||||
const rt = zrequire('recent_topics');
|
||||
const rt = zrequire("recent_topics");
|
||||
|
||||
global.stub_templates(() => '<recent_topics table stub>');
|
||||
global.stub_templates(() => "<recent_topics table stub>");
|
||||
rt.process_messages(messages);
|
||||
assert.equal(rt.inplace_rerender('1:topic-1'), true);
|
||||
assert.equal(rt.inplace_rerender("1:topic-1"), true);
|
||||
|
||||
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
||||
$("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
|
||||
global.stub_templates((template_name, data) => {
|
||||
assert.equal(template_name, 'recent_topics_filters');
|
||||
assert.equal(template_name, "recent_topics_filters");
|
||||
assert.equal(data.filter_unread, expected.filter_unread);
|
||||
assert.equal(data.filter_participated, expected.filter_participated);
|
||||
return '<recent_topics table stub>';
|
||||
return "<recent_topics table stub>";
|
||||
});
|
||||
|
||||
rt.set_filter('unread');
|
||||
rt.set_filter("unread");
|
||||
rt.update_filters_view();
|
||||
|
||||
global.stub_templates((template_name, data) => {
|
||||
if (template_name === 'recent_topic_row') {
|
||||
if (template_name === "recent_topic_row") {
|
||||
// All the row will be processed.
|
||||
assert.deepEqual(data, row_data[i]);
|
||||
i += 1;
|
||||
} else if (template_name === 'recent_topics_table') {
|
||||
} else if (template_name === "recent_topics_table") {
|
||||
assert.deepEqual(data, expected);
|
||||
}
|
||||
return '<recent_topics row stub>';
|
||||
return "<recent_topics row stub>";
|
||||
});
|
||||
rt.process_messages([messages[0]]);
|
||||
|
||||
// Unselect "unread" filter by clicking twice.
|
||||
expected.filter_unread = false;
|
||||
$('#recent_topics_filter_buttons').addClass('btn-recent-selected');
|
||||
rt.set_filter('unread');
|
||||
$("#recent_topics_filter_buttons").addClass("btn-recent-selected");
|
||||
rt.set_filter("unread");
|
||||
|
||||
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
||||
$("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
|
||||
// reselect "unread" filter
|
||||
rt.set_filter('unread');
|
||||
rt.set_filter("unread");
|
||||
|
||||
// Now clicking "all" filter should have no change to expected data.
|
||||
rt.set_filter('all');
|
||||
rt.set_filter("all");
|
||||
});
|
||||
|
||||
run_test('test_filter_participated', () => {
|
||||
run_test("test_filter_participated", () => {
|
||||
// Tests rerender of all topics when filter changes to "unread".
|
||||
const expected = {
|
||||
filter_participated: true,
|
||||
filter_unread: false,
|
||||
filter_muted: false,
|
||||
search_val: '',
|
||||
search_val: "",
|
||||
};
|
||||
|
||||
const row_data = generate_topic_data([
|
||||
// stream_id, topic, unread_count, muted, participated
|
||||
[4, 'topic-10', 1, false, true],
|
||||
[1, 'topic-7', 1, true, true],
|
||||
[1, 'topic-6', 1, false, true],
|
||||
[1, 'topic-5', 1, false, true],
|
||||
[1, 'topic-4', 1, false, false],
|
||||
[1, 'topic-3', 1, false, false],
|
||||
[1, 'topic-2', 1, false, true],
|
||||
[1, 'topic-1', 0, false, true],
|
||||
[4, "topic-10", 1, false, true],
|
||||
[1, "topic-7", 1, true, true],
|
||||
[1, "topic-6", 1, false, true],
|
||||
[1, "topic-5", 1, false, true],
|
||||
[1, "topic-4", 1, false, false],
|
||||
[1, "topic-3", 1, false, false],
|
||||
[1, "topic-2", 1, false, true],
|
||||
[1, "topic-1", 0, false, true],
|
||||
]);
|
||||
let i = 0;
|
||||
|
||||
const rt = zrequire('recent_topics');
|
||||
const rt = zrequire("recent_topics");
|
||||
|
||||
global.stub_templates(() => '<recent_topics table stub>');
|
||||
global.stub_templates(() => "<recent_topics table stub>");
|
||||
rt.process_messages(messages);
|
||||
assert.equal(rt.inplace_rerender('1:topic-4'), true);
|
||||
assert.equal(rt.inplace_rerender("1:topic-4"), true);
|
||||
|
||||
// Set muted filter
|
||||
rt.set_filter('muted');
|
||||
assert.equal(rt.inplace_rerender('1:topic-7'), true);
|
||||
rt.set_filter("muted");
|
||||
assert.equal(rt.inplace_rerender("1:topic-7"), true);
|
||||
|
||||
// remove muted filter
|
||||
rt.set_filter('muted');
|
||||
rt.set_filter("muted");
|
||||
|
||||
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
||||
$("#recent_topics_filter_buttons").removeClass("btn-recent-selected");
|
||||
global.stub_templates((template_name, data) => {
|
||||
assert.equal(template_name, 'recent_topics_filters');
|
||||
assert.equal(template_name, "recent_topics_filters");
|
||||
assert.equal(data.filter_unread, expected.filter_unread);
|
||||
assert.equal(data.filter_participated, expected.filter_participated);
|
||||
return '<recent_topics table stub>';
|
||||
return "<recent_topics table stub>";
|
||||
});
|
||||
rt.set_filter('participated');
|
||||
rt.set_filter("participated");
|
||||
rt.update_filters_view();
|
||||
|
||||
|
||||
global.stub_templates((template_name, data) => {
|
||||
if (template_name === 'recent_topic_row') {
|
||||
if (template_name === "recent_topic_row") {
|
||||
// All the row will be processed.
|
||||
assert.deepEqual(data, row_data[i]);
|
||||
i += 1;
|
||||
} else if (template_name === 'recent_topics_table') {
|
||||
} else if (template_name === "recent_topics_table") {
|
||||
assert.deepEqual(data, expected);
|
||||
}
|
||||
return '<recent_topics row stub>';
|
||||
return "<recent_topics row stub>";
|
||||
});
|
||||
rt.process_messages([messages[4]]);
|
||||
|
||||
expected.filter_participated = false;
|
||||
rt.set_filter('all');
|
||||
rt.set_filter("all");
|
||||
});
|
||||
|
||||
run_test('test_update_unread_count', () => {
|
||||
const rt = zrequire('recent_topics');
|
||||
rt.set_filter('all');
|
||||
global.stub_templates(() => '<recent_topics table stub>');
|
||||
run_test("test_update_unread_count", () => {
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.set_filter("all");
|
||||
global.stub_templates(() => "<recent_topics table stub>");
|
||||
rt.process_messages(messages);
|
||||
|
||||
// update a message
|
||||
generate_topic_data([[1, 'topic-7', 1, false, true]]);
|
||||
generate_topic_data([[1, "topic-7", 1, false, true]]);
|
||||
rt.update_topic_unread_count(messages[9]);
|
||||
});
|
||||
|
||||
// template rendering is tested in test_recent_topics_launch.
|
||||
global.stub_templates(() => '<recent_topics table stub>');
|
||||
global.stub_templates(() => "<recent_topics table stub>");
|
||||
|
||||
run_test('basic assertions', () => {
|
||||
const rt = zrequire('recent_topics');
|
||||
rt.set_filter('all');
|
||||
run_test("basic assertions", () => {
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.set_filter("all");
|
||||
rt.process_messages(messages);
|
||||
let all_topics = rt.get();
|
||||
|
||||
// update a message
|
||||
generate_topic_data([[1, 'topic-7', 1, false, true]]);
|
||||
generate_topic_data([[1, "topic-7", 1, false, true]]);
|
||||
rt.process_messages([messages[9]]);
|
||||
// Check for expected lengths.
|
||||
// total 8 topics, 1 muted
|
||||
assert.equal(all_topics.size, 8);
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1');
|
||||
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
|
||||
|
||||
rt.process_message({
|
||||
type: 'private',
|
||||
type: "private",
|
||||
});
|
||||
|
||||
// Private msgs are not processed.
|
||||
assert.equal(all_topics.size, 8);
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1');
|
||||
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
|
||||
|
||||
// participated
|
||||
verify_topic_data(all_topics, stream1, topic1, messages[0].id, true);
|
||||
@@ -549,12 +549,12 @@ run_test('basic assertions', () => {
|
||||
id: id += 1,
|
||||
topic: topic3,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
});
|
||||
|
||||
all_topics = rt.get();
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'1:topic-3,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1');
|
||||
"1:topic-3,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1");
|
||||
verify_topic_data(all_topics, stream1, topic3, id, true);
|
||||
|
||||
// Send new message to topic7 (muted)
|
||||
@@ -564,12 +564,12 @@ run_test('basic assertions', () => {
|
||||
id: id += 1,
|
||||
topic: topic7,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
});
|
||||
|
||||
all_topics = rt.get();
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'1:topic-7,1:topic-3,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1');
|
||||
"1:topic-7,1:topic-3,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1");
|
||||
|
||||
// update_topic_is_muted now relies on external libraries completely
|
||||
// so we don't need to check anythere here.
|
||||
@@ -579,9 +579,9 @@ run_test('basic assertions', () => {
|
||||
assert.equal(rt.update_topic_is_muted(stream1, "topic-10"), false);
|
||||
});
|
||||
|
||||
run_test('test_reify_local_echo_message', () => {
|
||||
const rt = zrequire('recent_topics');
|
||||
rt.set_filter('all');
|
||||
run_test("test_reify_local_echo_message", () => {
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.set_filter("all");
|
||||
rt.process_messages(messages);
|
||||
|
||||
rt.process_message({
|
||||
@@ -589,7 +589,7 @@ run_test('test_reify_local_echo_message', () => {
|
||||
id: 1000.01,
|
||||
topic: topic7,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
});
|
||||
|
||||
assert.equal(rt.reify_message_id_if_available({
|
||||
@@ -602,7 +602,7 @@ run_test('test_reify_local_echo_message', () => {
|
||||
id: 1001.01,
|
||||
topic: topic7,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
});
|
||||
|
||||
// A new message arrived in the same topic before we could reify the message_id
|
||||
@@ -611,7 +611,7 @@ run_test('test_reify_local_echo_message', () => {
|
||||
id: 1003,
|
||||
topic: topic7,
|
||||
sender_id: sender1,
|
||||
type: 'stream',
|
||||
type: "stream",
|
||||
});
|
||||
|
||||
assert.equal(rt.reify_message_id_if_available({
|
||||
@@ -621,12 +621,12 @@ run_test('test_reify_local_echo_message', () => {
|
||||
});
|
||||
|
||||
|
||||
run_test('test_delete_messages', () => {
|
||||
const rt = zrequire('recent_topics');
|
||||
rt.set_filter('all');
|
||||
run_test("test_delete_messages", () => {
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.set_filter("all");
|
||||
rt.process_messages(messages);
|
||||
|
||||
set_global('message_list', {
|
||||
set_global("message_list", {
|
||||
all: {
|
||||
all_messages: function () {
|
||||
// messages[0] was removed.
|
||||
@@ -639,14 +639,14 @@ run_test('test_delete_messages', () => {
|
||||
|
||||
let all_topics = rt.get();
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1');
|
||||
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
|
||||
rt.update_topics_of_message_ids([messages[0].id]);
|
||||
|
||||
all_topics = rt.get();
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2');
|
||||
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2");
|
||||
|
||||
set_global('message_list', {
|
||||
set_global("message_list", {
|
||||
all: {
|
||||
all_messages: function () {
|
||||
// messages[0], messages[1] and message[2] were removed.
|
||||
@@ -661,11 +661,11 @@ run_test('test_delete_messages', () => {
|
||||
|
||||
all_topics = rt.get();
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3');
|
||||
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3");
|
||||
});
|
||||
|
||||
run_test('test_topic_edit', () => {
|
||||
set_global('message_list', {
|
||||
run_test("test_topic_edit", () => {
|
||||
set_global("message_list", {
|
||||
all: {
|
||||
all_messages: function () {
|
||||
return messages;
|
||||
@@ -673,19 +673,19 @@ run_test('test_topic_edit', () => {
|
||||
},
|
||||
});
|
||||
// NOTE: This test should always run in the end as it modified the messages data.
|
||||
const rt = zrequire('recent_topics');
|
||||
rt.set_filter('all');
|
||||
const rt = zrequire("recent_topics");
|
||||
rt.set_filter("all");
|
||||
rt.process_messages(messages);
|
||||
|
||||
let all_topics = rt.get();
|
||||
assert.equal(Array.from(all_topics.keys()).toString(),
|
||||
'4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1');
|
||||
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1");
|
||||
|
||||
////////////////// test change topic //////////////////
|
||||
verify_topic_data(all_topics, stream1, topic6, messages[8].id, true);
|
||||
assert.equal(all_topics.get(get_topic_key(stream1, topic8)), undefined);
|
||||
|
||||
let topic_selector = $.create('#recent_topic:' + get_topic_key(stream1, topic8));
|
||||
let topic_selector = $.create("#recent_topic:" + get_topic_key(stream1, topic8));
|
||||
topic_selector.data = function () {
|
||||
return {
|
||||
participated: true,
|
||||
@@ -706,7 +706,7 @@ run_test('test_topic_edit', () => {
|
||||
verify_topic_data(all_topics, stream1, topic1, messages[0].id, true);
|
||||
assert.equal(all_topics.get(get_topic_key(stream2, topic1)), undefined);
|
||||
|
||||
topic_selector = $.create('#recent_topic:' + get_topic_key(stream2, topic1));
|
||||
topic_selector = $.create("#recent_topic:" + get_topic_key(stream2, topic1));
|
||||
topic_selector.data = function () {
|
||||
return {
|
||||
participated: true,
|
||||
@@ -725,7 +725,7 @@ run_test('test_topic_edit', () => {
|
||||
verify_topic_data(all_topics, stream2, topic1, messages[0].id, true);
|
||||
assert.equal(all_topics.get(get_topic_key(stream3, topic9)), undefined);
|
||||
|
||||
topic_selector = $.create('#recent_topic:' + get_topic_key(stream3, topic9));
|
||||
topic_selector = $.create("#recent_topic:" + get_topic_key(stream3, topic9));
|
||||
topic_selector.data = function () {
|
||||
return {
|
||||
participated: false,
|
||||
@@ -746,41 +746,41 @@ run_test('test_topic_edit', () => {
|
||||
messages[0].topic = topic8;
|
||||
rt.process_topic_edit(stream3, topic9, topic8, stream5);
|
||||
all_topics = rt.get();
|
||||
assert.equal(rt.filters_should_hide_topic(all_topics.get('5:topic-8')), true);
|
||||
assert.equal(rt.filters_should_hide_topic(all_topics.get("5:topic-8")), true);
|
||||
});
|
||||
|
||||
run_test('test_search', () => {
|
||||
const rt = zrequire('recent_topics');
|
||||
assert.equal(rt.topic_in_search_results('t', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('T', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('to', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('top', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('ToP', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('Topi', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('tOpi', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('toPic', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('Topic', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('topic', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('recent', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('RECENT', 'general', 'Recent Topic'), true);
|
||||
run_test("test_search", () => {
|
||||
const rt = zrequire("recent_topics");
|
||||
assert.equal(rt.topic_in_search_results("t", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("T", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("to", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("top", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("ToP", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("Topi", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("tOpi", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("toPic", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("Topic", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("topic", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("recent", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("RECENT", "general", "Recent Topic"), true);
|
||||
|
||||
// match in any order of words
|
||||
assert.equal(rt.topic_in_search_results('topic recent', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results("topic recent", "general", "Recent Topic"), true);
|
||||
|
||||
// Matches any sequence of words.
|
||||
assert.equal(rt.topic_in_search_results('o', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('nt to', 'general', 'Recent Topic'), true);
|
||||
assert.equal(rt.topic_in_search_results('z', 'general', 'Recent Topic'), false);
|
||||
assert.equal(rt.topic_in_search_results("o", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("nt to", "general", "Recent Topic"), true);
|
||||
assert.equal(rt.topic_in_search_results("z", "general", "Recent Topic"), false);
|
||||
|
||||
assert.equal(rt.topic_in_search_results('?', 'general', 'Recent Topic'), false);
|
||||
assert.equal(rt.topic_in_search_results("?", "general", "Recent Topic"), false);
|
||||
|
||||
// Test special character match
|
||||
assert.equal(rt.topic_in_search_results('.*+?^${}()[]\\', 'general', 'Recent Topic'), false);
|
||||
assert.equal(rt.topic_in_search_results('?', 'general', 'not-at-start?'), true);
|
||||
assert.equal(rt.topic_in_search_results(".*+?^${}()[]\\", "general", "Recent Topic"), false);
|
||||
assert.equal(rt.topic_in_search_results("?", "general", "not-at-start?"), true);
|
||||
|
||||
assert.equal(rt.topic_in_search_results('?', 'general', '?'), true);
|
||||
assert.equal(rt.topic_in_search_results('?', 'general', '\\?'), true);
|
||||
assert.equal(rt.topic_in_search_results("?", "general", "?"), true);
|
||||
assert.equal(rt.topic_in_search_results("?", "general", "\\?"), true);
|
||||
|
||||
assert.equal(rt.topic_in_search_results('\\', 'general', '\\'), true);
|
||||
assert.equal(rt.topic_in_search_results('\\', 'general', '\\\\'), true);
|
||||
assert.equal(rt.topic_in_search_results("\\", "general", "\\"), true);
|
||||
assert.equal(rt.topic_in_search_results("\\", "general", "\\\\"), true);
|
||||
});
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
const rm = zrequire('rendered_markdown');
|
||||
set_global('moment', zrequire('moment', 'moment-timezone'));
|
||||
zrequire('people');
|
||||
zrequire('user_groups');
|
||||
zrequire('stream_data');
|
||||
zrequire('timerender');
|
||||
set_global('$', global.make_zjquery());
|
||||
const rm = zrequire("rendered_markdown");
|
||||
set_global("moment", zrequire("moment", "moment-timezone"));
|
||||
zrequire("people");
|
||||
zrequire("user_groups");
|
||||
zrequire("stream_data");
|
||||
zrequire("timerender");
|
||||
set_global("$", global.make_zjquery());
|
||||
|
||||
set_global('rtl', {
|
||||
get_direction: () => 'ltr',
|
||||
set_global("rtl", {
|
||||
get_direction: () => "ltr",
|
||||
});
|
||||
|
||||
const iago = {
|
||||
email: 'iago@zulip.com',
|
||||
email: "iago@zulip.com",
|
||||
user_id: 30,
|
||||
full_name: 'Iago',
|
||||
full_name: "Iago",
|
||||
};
|
||||
|
||||
const cordelia = {
|
||||
email: 'cordelia@zulup.com',
|
||||
email: "cordelia@zulup.com",
|
||||
user_id: 31,
|
||||
full_name: 'Cordelia',
|
||||
full_name: "Cordelia",
|
||||
};
|
||||
people.init();
|
||||
people.add_active_user(iago);
|
||||
@@ -27,12 +27,12 @@ people.add_active_user(cordelia);
|
||||
people.initialize_current_user(iago.user_id);
|
||||
|
||||
const group_me = {
|
||||
name: 'my user group',
|
||||
name: "my user group",
|
||||
id: 1,
|
||||
members: [iago.user_id, cordelia.user_id],
|
||||
};
|
||||
const group_other = {
|
||||
name: 'other user group',
|
||||
name: "other user group",
|
||||
id: 2,
|
||||
members: [cordelia.user_id],
|
||||
};
|
||||
@@ -42,8 +42,8 @@ user_groups.initialize({
|
||||
|
||||
const stream = {
|
||||
subscribed: true,
|
||||
color: 'yellow',
|
||||
name: 'test',
|
||||
color: "yellow",
|
||||
name: "test",
|
||||
stream_id: 3,
|
||||
is_muted: true,
|
||||
invite_only: false,
|
||||
@@ -59,96 +59,96 @@ const $array = (array) => {
|
||||
return {each};
|
||||
};
|
||||
|
||||
set_global('page_params', { emojiset: 'apple' });
|
||||
set_global("page_params", { emojiset: "apple" });
|
||||
|
||||
const get_content_element = () => {
|
||||
$.clear_all_elements();
|
||||
const $content = $.create('.rendered_markdown');
|
||||
$content.set_find_results('.user-mention', $array([]));
|
||||
$content.set_find_results('.user-group-mention', $array([]));
|
||||
$content.set_find_results('a.stream', $array([]));
|
||||
$content.set_find_results('a.stream-topic', $array([]));
|
||||
$content.set_find_results('time', $array([]));
|
||||
$content.set_find_results('span.timestamp-error', $array([]));
|
||||
$content.set_find_results('.emoji', $array([]));
|
||||
$content.set_find_results('div.spoiler-header', $array([]));
|
||||
const $content = $.create(".rendered_markdown");
|
||||
$content.set_find_results(".user-mention", $array([]));
|
||||
$content.set_find_results(".user-group-mention", $array([]));
|
||||
$content.set_find_results("a.stream", $array([]));
|
||||
$content.set_find_results("a.stream-topic", $array([]));
|
||||
$content.set_find_results("time", $array([]));
|
||||
$content.set_find_results("span.timestamp-error", $array([]));
|
||||
$content.set_find_results(".emoji", $array([]));
|
||||
$content.set_find_results("div.spoiler-header", $array([]));
|
||||
return $content;
|
||||
};
|
||||
|
||||
run_test('misc_helpers', () => {
|
||||
const elem = $.create('.user-mention');
|
||||
rm.set_name_in_mention_element(elem, 'Aaron');
|
||||
assert.equal(elem.text(), '@Aaron');
|
||||
elem.addClass('silent');
|
||||
rm.set_name_in_mention_element(elem, 'Aaron, but silent');
|
||||
assert.equal(elem.text(), 'Aaron, but silent');
|
||||
run_test("misc_helpers", () => {
|
||||
const elem = $.create(".user-mention");
|
||||
rm.set_name_in_mention_element(elem, "Aaron");
|
||||
assert.equal(elem.text(), "@Aaron");
|
||||
elem.addClass("silent");
|
||||
rm.set_name_in_mention_element(elem, "Aaron, but silent");
|
||||
assert.equal(elem.text(), "Aaron, but silent");
|
||||
});
|
||||
|
||||
run_test('user-mention', () => {
|
||||
run_test("user-mention", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $iago = $.create('.user-mention(iago)');
|
||||
$iago.set_find_results('.highlight', false);
|
||||
$iago.attr('data-user-id', iago.user_id);
|
||||
const $cordelia = $.create('.user-mention(cordelia)');
|
||||
$cordelia.set_find_results('.highlight', false);
|
||||
$cordelia.attr('data-user-id', cordelia.user_id);
|
||||
$content.set_find_results('.user-mention', $array([$iago, $cordelia]));
|
||||
const $iago = $.create(".user-mention(iago)");
|
||||
$iago.set_find_results(".highlight", false);
|
||||
$iago.attr("data-user-id", iago.user_id);
|
||||
const $cordelia = $.create(".user-mention(cordelia)");
|
||||
$cordelia.set_find_results(".highlight", false);
|
||||
$cordelia.attr("data-user-id", cordelia.user_id);
|
||||
$content.set_find_results(".user-mention", $array([$iago, $cordelia]));
|
||||
|
||||
// Initial asserts
|
||||
assert(!$iago.hasClass('user-mention-me'));
|
||||
assert.equal($iago.text(), 'never-been-set');
|
||||
assert.equal($cordelia.text(), 'never-been-set');
|
||||
assert(!$iago.hasClass("user-mention-me"));
|
||||
assert.equal($iago.text(), "never-been-set");
|
||||
assert.equal($cordelia.text(), "never-been-set");
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
// Final asserts
|
||||
assert($iago.hasClass('user-mention-me'));
|
||||
assert($iago.hasClass("user-mention-me"));
|
||||
assert.equal($iago.text(), `@${iago.full_name}`);
|
||||
assert.equal($cordelia.text(), `@${cordelia.full_name}`);
|
||||
});
|
||||
|
||||
|
||||
run_test('user-group-mention', () => {
|
||||
run_test("user-group-mention", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $group_me = $.create('.user-group-mention(me)');
|
||||
$group_me.set_find_results('.highlight', false);
|
||||
$group_me.attr('data-user-group-id', group_me.id);
|
||||
const $group_other = $.create('.user-group-mention(other)');
|
||||
$group_other.set_find_results('.highlight', false);
|
||||
$group_other.attr('data-user-group-id', group_other.id);
|
||||
$content.set_find_results('.user-group-mention', $array([$group_me, $group_other]));
|
||||
const $group_me = $.create(".user-group-mention(me)");
|
||||
$group_me.set_find_results(".highlight", false);
|
||||
$group_me.attr("data-user-group-id", group_me.id);
|
||||
const $group_other = $.create(".user-group-mention(other)");
|
||||
$group_other.set_find_results(".highlight", false);
|
||||
$group_other.attr("data-user-group-id", group_other.id);
|
||||
$content.set_find_results(".user-group-mention", $array([$group_me, $group_other]));
|
||||
|
||||
// Initial asserts
|
||||
assert(!$group_me.hasClass('user-mention-me'));
|
||||
assert.equal($group_me.text(), 'never-been-set');
|
||||
assert.equal($group_other.text(), 'never-been-set');
|
||||
assert(!$group_me.hasClass("user-mention-me"));
|
||||
assert.equal($group_me.text(), "never-been-set");
|
||||
assert.equal($group_other.text(), "never-been-set");
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
// Final asserts
|
||||
assert($group_me.hasClass('user-mention-me'));
|
||||
assert($group_me.hasClass("user-mention-me"));
|
||||
assert.equal($group_me.text(), `@${group_me.name}`);
|
||||
assert.equal($group_other.text(), `@${group_other.name}`);
|
||||
});
|
||||
|
||||
run_test('stream-links', () => {
|
||||
run_test("stream-links", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $stream = $.create('a.stream');
|
||||
$stream.set_find_results('.highlight', false);
|
||||
$stream.attr('data-stream-id', stream.stream_id);
|
||||
const $stream_topic = $.create('a.stream-topic');
|
||||
$stream_topic.set_find_results('.highlight', false);
|
||||
$stream_topic.attr('data-stream-id', stream.stream_id);
|
||||
$stream_topic.text('#random>topic name');
|
||||
$content.set_find_results('a.stream', $array([$stream]));
|
||||
$content.set_find_results('a.stream-topic', $array([$stream_topic]));
|
||||
const $stream = $.create("a.stream");
|
||||
$stream.set_find_results(".highlight", false);
|
||||
$stream.attr("data-stream-id", stream.stream_id);
|
||||
const $stream_topic = $.create("a.stream-topic");
|
||||
$stream_topic.set_find_results(".highlight", false);
|
||||
$stream_topic.attr("data-stream-id", stream.stream_id);
|
||||
$stream_topic.text("#random>topic name");
|
||||
$content.set_find_results("a.stream", $array([$stream]));
|
||||
$content.set_find_results("a.stream-topic", $array([$stream_topic]));
|
||||
|
||||
// Initial asserts
|
||||
assert.equal($stream.text(), 'never-been-set');
|
||||
assert.equal($stream_topic.text(), '#random>topic name');
|
||||
assert.equal($stream.text(), "never-been-set");
|
||||
assert.equal($stream_topic.text(), "#random>topic name");
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
@@ -157,110 +157,110 @@ run_test('stream-links', () => {
|
||||
assert.equal($stream_topic.text(), `#${stream.name} > topic name`);
|
||||
});
|
||||
|
||||
run_test('timestamp', () => {
|
||||
run_test("timestamp", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $timestamp = $.create('timestamp(valid)');
|
||||
$timestamp.attr('datetime', '1970-01-01T00:00:01Z');
|
||||
const $timestamp_invalid = $.create('timestamp(invalid)');
|
||||
$timestamp_invalid.attr('datetime', 'invalid');
|
||||
$content.set_find_results('time', $array([$timestamp, $timestamp_invalid]));
|
||||
blueslip.expect('error', 'Moment could not parse datetime supplied by backend: invalid');
|
||||
const $timestamp = $.create("timestamp(valid)");
|
||||
$timestamp.attr("datetime", "1970-01-01T00:00:01Z");
|
||||
const $timestamp_invalid = $.create("timestamp(invalid)");
|
||||
$timestamp_invalid.attr("datetime", "invalid");
|
||||
$content.set_find_results("time", $array([$timestamp, $timestamp_invalid]));
|
||||
blueslip.expect("error", "Moment could not parse datetime supplied by backend: invalid");
|
||||
|
||||
// Initial asserts
|
||||
assert.equal($timestamp.text(), 'never-been-set');
|
||||
assert.equal($timestamp_invalid.text(), 'never-been-set');
|
||||
assert.equal($timestamp.text(), "never-been-set");
|
||||
assert.equal($timestamp_invalid.text(), "never-been-set");
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
// Final asserts
|
||||
assert.equal($timestamp.text(), 'Thu, Jan 1 1970, 12:00 AM');
|
||||
assert.equal($timestamp.attr('title'), "This time is in your timezone. Original text was 'never-been-set'.");
|
||||
assert.equal($timestamp_invalid.text(), 'never-been-set');
|
||||
assert.equal($timestamp.text(), "Thu, Jan 1 1970, 12:00 AM");
|
||||
assert.equal($timestamp.attr("title"), "This time is in your timezone. Original text was 'never-been-set'.");
|
||||
assert.equal($timestamp_invalid.text(), "never-been-set");
|
||||
});
|
||||
|
||||
run_test('timestamp-twenty-four-hour-time', () => {
|
||||
run_test("timestamp-twenty-four-hour-time", () => {
|
||||
const $content = get_content_element();
|
||||
const $timestamp = $.create('timestamp');
|
||||
$timestamp.attr('datetime', '2020-07-15T20:40:00Z');
|
||||
$content.set_find_results('time', $array([$timestamp]));
|
||||
const $timestamp = $.create("timestamp");
|
||||
$timestamp.attr("datetime", "2020-07-15T20:40:00Z");
|
||||
$content.set_find_results("time", $array([$timestamp]));
|
||||
|
||||
// We will temporarily change the 24h setting for this test.
|
||||
const old_page_params = global.page_params;
|
||||
|
||||
set_global('page_params', { ...old_page_params, twenty_four_hour_time: true });
|
||||
set_global("page_params", { ...old_page_params, twenty_four_hour_time: true });
|
||||
rm.update_elements($content);
|
||||
assert.equal($timestamp.text(), 'Wed, Jul 15 2020, 20:40');
|
||||
assert.equal($timestamp.text(), "Wed, Jul 15 2020, 20:40");
|
||||
|
||||
set_global('page_params', { ...old_page_params, twenty_four_hour_time: false });
|
||||
set_global("page_params", { ...old_page_params, twenty_four_hour_time: false });
|
||||
rm.update_elements($content);
|
||||
assert.equal($timestamp.text(), 'Wed, Jul 15 2020, 8:40 PM');
|
||||
assert.equal($timestamp.text(), "Wed, Jul 15 2020, 8:40 PM");
|
||||
|
||||
// Set page_params back to its original value.
|
||||
set_global('page_params', old_page_params);
|
||||
set_global("page_params", old_page_params);
|
||||
});
|
||||
|
||||
run_test('timestamp-error', () => {
|
||||
run_test("timestamp-error", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $timestamp_error = $.create('timestamp-error');
|
||||
$timestamp_error.text('Invalid time format: the-time-format');
|
||||
$content.set_find_results('span.timestamp-error', $array([$timestamp_error]));
|
||||
const $timestamp_error = $.create("timestamp-error");
|
||||
$timestamp_error.text("Invalid time format: the-time-format");
|
||||
$content.set_find_results("span.timestamp-error", $array([$timestamp_error]));
|
||||
|
||||
// Initial assert
|
||||
assert.equal($timestamp_error.text(), 'Invalid time format: the-time-format');
|
||||
assert.equal($timestamp_error.text(), "Invalid time format: the-time-format");
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
// Final assert
|
||||
assert.equal($timestamp_error.text(), 'translated: Invalid time format: the-time-format');
|
||||
assert.equal($timestamp_error.text(), "translated: Invalid time format: the-time-format");
|
||||
});
|
||||
|
||||
run_test('emoji', () => {
|
||||
run_test("emoji", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $emoji = $.create('.emoji');
|
||||
$emoji.attr('title', 'tada');
|
||||
const $emoji = $.create(".emoji");
|
||||
$emoji.attr("title", "tada");
|
||||
let called = false;
|
||||
$emoji.replaceWith = (f) => {
|
||||
const text = f.call($emoji);
|
||||
assert.equal(':tada:', text);
|
||||
assert.equal(":tada:", text);
|
||||
called = true;
|
||||
};
|
||||
$content.set_find_results('.emoji', $emoji);
|
||||
page_params.emojiset = 'text';
|
||||
$content.set_find_results(".emoji", $emoji);
|
||||
page_params.emojiset = "text";
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
assert(called);
|
||||
|
||||
// Set page paramaters back so that test run order is independent
|
||||
page_params.emojiset = 'apple';
|
||||
page_params.emojiset = "apple";
|
||||
});
|
||||
|
||||
run_test('spoiler-header', () => {
|
||||
run_test("spoiler-header", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $header = $.create('div.spoiler-header');
|
||||
$content.set_find_results('div.spoiler-header', $array([$header]));
|
||||
const $header = $.create("div.spoiler-header");
|
||||
$content.set_find_results("div.spoiler-header", $array([$header]));
|
||||
|
||||
// Test that the show/hide button gets added to a spoiler header.
|
||||
const label = 'My Spoiler Header';
|
||||
const label = "My Spoiler Header";
|
||||
const toggle_button_html = '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
|
||||
$header.html(label);
|
||||
rm.update_elements($content);
|
||||
assert.equal(toggle_button_html + label, $header.html());
|
||||
});
|
||||
|
||||
run_test('spoiler-header-empty-fill', () => {
|
||||
run_test("spoiler-header-empty-fill", () => {
|
||||
// Setup
|
||||
const $content = get_content_element();
|
||||
const $header = $.create('div.spoiler-header');
|
||||
$content.set_find_results('div.spoiler-header', $array([$header]));
|
||||
const $header = $.create("div.spoiler-header");
|
||||
$content.set_find_results("div.spoiler-header", $array([$header]));
|
||||
|
||||
// Test that an empty header gets the default text applied (through i18n filter).
|
||||
const toggle_button_html = '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
|
||||
$header.html('');
|
||||
$header.html("");
|
||||
rm.update_elements($content);
|
||||
assert.equal(toggle_button_html + '<p>translated: Spoiler</p>', $header.html());
|
||||
assert.equal(toggle_button_html + "<p>translated: Spoiler</p>", $header.html());
|
||||
});
|
||||
|
||||
@@ -1,83 +1,83 @@
|
||||
const rtl = zrequire('rtl');
|
||||
const rtl = zrequire("rtl");
|
||||
|
||||
run_test('get_direction', () => {
|
||||
run_test("get_direction", () => {
|
||||
// These characters are strong R or AL: ا ب پ ج ض و د ؛
|
||||
// These characters are not strong: ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰
|
||||
|
||||
assert.equal(rtl.get_direction('abcابپ'), 'ltr');
|
||||
assert.equal(rtl.get_direction('ابپabc'), 'rtl');
|
||||
assert.equal(rtl.get_direction('123abc'), 'ltr');
|
||||
assert.equal(rtl.get_direction('۱۲۳abc'), 'ltr');
|
||||
assert.equal(rtl.get_direction('123؛بپ'), 'rtl');
|
||||
assert.equal(rtl.get_direction('۱۲۳ابپ'), 'rtl');
|
||||
assert.equal(rtl.get_direction('۱۲جg'), 'rtl');
|
||||
assert.equal(rtl.get_direction('12gج'), 'ltr');
|
||||
assert.equal(rtl.get_direction('۱۲۳'), 'ltr');
|
||||
assert.equal(rtl.get_direction('1234'), 'ltr');
|
||||
assert.equal(rtl.get_direction("abcابپ"), "ltr");
|
||||
assert.equal(rtl.get_direction("ابپabc"), "rtl");
|
||||
assert.equal(rtl.get_direction("123abc"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲۳abc"), "ltr");
|
||||
assert.equal(rtl.get_direction("123؛بپ"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲۳ابپ"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲جg"), "rtl");
|
||||
assert.equal(rtl.get_direction("12gج"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲۳"), "ltr");
|
||||
assert.equal(rtl.get_direction("1234"), "ltr");
|
||||
|
||||
const supp_plane_ltr_char = '\ud800\udfa0';
|
||||
const supp_plane_rtl_char = '\ud802\udc40';
|
||||
const supp_plane_ltr_char = "\ud800\udfa0";
|
||||
const supp_plane_rtl_char = "\ud802\udc40";
|
||||
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char), 'rtl');
|
||||
assert.equal(rtl.get_direction('123' + supp_plane_ltr_char), 'ltr');
|
||||
assert.equal(rtl.get_direction('123' + supp_plane_rtl_char), 'rtl');
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + supp_plane_rtl_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + supp_plane_ltr_char), 'rtl');
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + ' ' + supp_plane_rtl_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + ' ' + supp_plane_ltr_char), 'rtl');
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + 'ج' + supp_plane_rtl_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + 'ج' + supp_plane_ltr_char), 'rtl');
|
||||
assert.equal(rtl.get_direction('پ' + supp_plane_ltr_char + '.' + supp_plane_rtl_char), 'rtl');
|
||||
assert.equal(rtl.get_direction('پ' + supp_plane_rtl_char + '.' + supp_plane_ltr_char), 'rtl');
|
||||
assert.equal(rtl.get_direction('b' + supp_plane_ltr_char + '.' + supp_plane_rtl_char), 'ltr');
|
||||
assert.equal(rtl.get_direction('b' + supp_plane_rtl_char + '.' + supp_plane_ltr_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char), "rtl");
|
||||
assert.equal(rtl.get_direction("123" + supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction("123" + supp_plane_rtl_char), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + " " + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + " " + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + "ج" + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + "ج" + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction("پ" + supp_plane_ltr_char + "." + supp_plane_rtl_char), "rtl");
|
||||
assert.equal(rtl.get_direction("پ" + supp_plane_rtl_char + "." + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction("b" + supp_plane_ltr_char + "." + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction("b" + supp_plane_rtl_char + "." + supp_plane_ltr_char), "ltr");
|
||||
|
||||
const unmatched_surrogate_1 = '\ud800';
|
||||
const unmatched_surrogate_2 = '\udf00';
|
||||
const unmatched_surrogate_1 = "\ud800";
|
||||
const unmatched_surrogate_2 = "\udf00";
|
||||
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + ' '), 'ltr');
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + ' '), 'ltr');
|
||||
assert.equal(rtl.get_direction(' ' + unmatched_surrogate_1), 'ltr');
|
||||
assert.equal(rtl.get_direction(' ' + unmatched_surrogate_2), 'ltr');
|
||||
assert.equal(rtl.get_direction(' ' + unmatched_surrogate_1 + ' '), 'ltr');
|
||||
assert.equal(rtl.get_direction(' ' + unmatched_surrogate_2 + ' '), 'ltr');
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_ltr_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_rtl_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_ltr_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_rtl_char), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_1), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_2), 'ltr');
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_1), 'rtl');
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_2), 'rtl');
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_1), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_2), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_1 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_2 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_1), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_2), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_1), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_2), "rtl");
|
||||
|
||||
// Testing with some isolate initiators and PDIs.
|
||||
const i_chars = '\u2066\u2067\u2068';
|
||||
const pdi = '\u2069';
|
||||
const i_chars = "\u2066\u2067\u2068";
|
||||
const pdi = "\u2069";
|
||||
|
||||
assert.equal(rtl.get_direction('aa' + i_chars.charAt(0) + 'bb' + pdi + 'cc'), 'ltr');
|
||||
assert.equal(rtl.get_direction('دد' + i_chars.charAt(0) + 'bb' + pdi + 'cc'), 'rtl');
|
||||
assert.equal(rtl.get_direction('12' + i_chars.charAt(0) + 'bb' + pdi + 'جج'), 'rtl');
|
||||
assert.equal(rtl.get_direction('۱۲' + i_chars.charAt(0) + 'جج' + pdi + 'cc'), 'ltr');
|
||||
assert.equal(rtl.get_direction('aa' + i_chars.charAt(0) + 'ج؛ج'), 'ltr');
|
||||
assert.equal(rtl.get_direction('12' + i_chars.charAt(0) + 'ج؛ج'), 'ltr');
|
||||
assert.equal(rtl.get_direction('۱۲' + i_chars.charAt(0) + 'aaa'), 'ltr');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(0) + 'bb' + i_chars.charAt(0) + 'جج' + pdi + 'ضض' + pdi + '..'), 'ltr');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(0) + 'bb' + i_chars.charAt(0) + 'جج' + pdi + 'ضض' + pdi + 'وو'), 'rtl');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(0) + 'bb' + pdi + '33' + pdi + '..'), 'ltr');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(0) + 'bb' + pdi + '12' + pdi + 'وو'), 'rtl');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(0) + 'ضج' + pdi + '12' + pdi + 'ff'), 'ltr');
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(0) + "bb" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("دد" + i_chars.charAt(0) + "bb" + pdi + "cc"), "rtl");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(0) + "bb" + pdi + "جج"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(0) + "جج" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(0) + "ج؛ج"), "ltr");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(0) + "ج؛ج"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(0) + "aaa"), "ltr");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + ".."), "ltr");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + "وو"), "rtl");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "33" + pdi + ".."), "ltr");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "12" + pdi + "وو"), "rtl");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(0) + "ضج" + pdi + "12" + pdi + "ff"), "ltr");
|
||||
|
||||
assert.equal(rtl.get_direction('aa' + i_chars.charAt(1) + 'bb' + pdi + 'cc'), 'ltr');
|
||||
assert.equal(rtl.get_direction('دد' + i_chars.charAt(2) + 'bb' + pdi + 'cc'), 'rtl');
|
||||
assert.equal(rtl.get_direction('12' + i_chars.charAt(1) + 'bb' + pdi + 'جج'), 'rtl');
|
||||
assert.equal(rtl.get_direction('۱۲' + i_chars.charAt(2) + 'جج' + pdi + 'cc'), 'ltr');
|
||||
assert.equal(rtl.get_direction('aa' + i_chars.charAt(1) + 'ججج'), 'ltr');
|
||||
assert.equal(rtl.get_direction('12' + i_chars.charAt(2) + 'ججج'), 'ltr');
|
||||
assert.equal(rtl.get_direction('۱۲' + i_chars.charAt(1) + 'aaa'), 'ltr');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(1) + 'bb' + i_chars.charAt(2) + 'جج' + pdi + 'ضض' + pdi + '..'), 'ltr');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(2) + 'bb' + i_chars.charAt(1) + '؛ج' + pdi + 'ضض' + pdi + 'وو'), 'rtl');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(1) + 'bb' + pdi + '33' + pdi + '..'), 'ltr');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(2) + 'bb' + pdi + '12' + pdi + 'وو'), 'rtl');
|
||||
assert.equal(rtl.get_direction(',,' + i_chars.charAt(1) + 'ضج' + pdi + '12' + pdi + 'ff'), 'ltr');
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(1) + "bb" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("دد" + i_chars.charAt(2) + "bb" + pdi + "cc"), "rtl");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(1) + "bb" + pdi + "جج"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(2) + "جج" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(1) + "ججج"), "ltr");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(2) + "ججج"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(1) + "aaa"), "ltr");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(1) + "bb" + i_chars.charAt(2) + "جج" + pdi + "ضض" + pdi + ".."), "ltr");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(2) + "bb" + i_chars.charAt(1) + "؛ج" + pdi + "ضض" + pdi + "وو"), "rtl");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(1) + "bb" + pdi + "33" + pdi + ".."), "ltr");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(2) + "bb" + pdi + "12" + pdi + "وو"), "rtl");
|
||||
assert.equal(rtl.get_direction(",," + i_chars.charAt(1) + "ضج" + pdi + "12" + pdi + "ff"), "ltr");
|
||||
});
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
zrequire('schema');
|
||||
zrequire("schema");
|
||||
|
||||
run_test('basics', () => {
|
||||
assert.equal(schema.check_string('x', 'fred'), undefined);
|
||||
assert.equal(schema.check_string('x', [1, 2]), 'x is not a string');
|
||||
run_test("basics", () => {
|
||||
assert.equal(schema.check_string("x", "fred"), undefined);
|
||||
assert.equal(schema.check_string("x", [1, 2]), "x is not a string");
|
||||
|
||||
const fields = {
|
||||
foo: schema.check_string,
|
||||
bar: schema.check_string,
|
||||
};
|
||||
|
||||
const check_rec = (val) => schema.check_record('my_rec', val, fields);
|
||||
const check_rec = (val) => schema.check_record("my_rec", val, fields);
|
||||
|
||||
assert.equal(
|
||||
check_rec({foo: 'apple', bar: 'banana'}),
|
||||
check_rec({foo: "apple", bar: "banana"}),
|
||||
undefined,
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
check_rec('bogus'),
|
||||
'my_rec is not a record',
|
||||
check_rec("bogus"),
|
||||
"my_rec is not a record",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
check_rec({foo: 'apple'}),
|
||||
'in my_rec bar is missing',
|
||||
check_rec({foo: "apple"}),
|
||||
"in my_rec bar is missing",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
check_rec({}),
|
||||
'in my_rec bar is missing, foo is missing',
|
||||
"in my_rec bar is missing, foo is missing",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
check_rec({foo: 'apple', bar: 42}),
|
||||
'in my_rec bar is not a string',
|
||||
check_rec({foo: "apple", bar: 42}),
|
||||
"in my_rec bar is not a string",
|
||||
);
|
||||
|
||||
const check_array = (val) => schema.check_array('lst', val, schema.check_string);
|
||||
const check_array = (val) => schema.check_array("lst", val, schema.check_string);
|
||||
|
||||
assert.equal(
|
||||
check_array(['foo', 'bar']),
|
||||
check_array(["foo", "bar"]),
|
||||
undefined,
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
check_array('foo'),
|
||||
'lst is not an array',
|
||||
check_array("foo"),
|
||||
"lst is not an array",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
check_array(['foo', 3]),
|
||||
'in lst we found an item where item is not a string',
|
||||
check_array(["foo", 3]),
|
||||
"in lst we found an item where item is not a string",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
zrequire('scroll_util');
|
||||
set_global('ui', {
|
||||
zrequire("scroll_util");
|
||||
set_global("ui", {
|
||||
get_scroll_element: (element) => element,
|
||||
});
|
||||
|
||||
run_test('scroll_delta', () => {
|
||||
run_test("scroll_delta", () => {
|
||||
// If we are entirely on-screen, don't scroll
|
||||
assert.equal(0, scroll_util.scroll_delta({
|
||||
elem_top: 1,
|
||||
@@ -57,7 +57,7 @@ run_test('scroll_delta', () => {
|
||||
|
||||
});
|
||||
|
||||
run_test('scroll_element_into_container', () => {
|
||||
run_test("scroll_element_into_container", () => {
|
||||
const container = (function () {
|
||||
let top = 3;
|
||||
return {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
search_pills_enabled: true,
|
||||
});
|
||||
zrequire('search');
|
||||
zrequire('search_pill');
|
||||
zrequire('Filter', 'js/filter');
|
||||
zrequire('tab_bar');
|
||||
zrequire("search");
|
||||
zrequire("search_pill");
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("tab_bar");
|
||||
|
||||
const noop = () => {};
|
||||
const return_true = () => true;
|
||||
const return_false = () => false;
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('narrow_state', {filter: return_false});
|
||||
set_global('search_suggestion', {});
|
||||
set_global('ui_util', {
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("narrow_state", {filter: return_false});
|
||||
set_global("search_suggestion", {});
|
||||
set_global("ui_util", {
|
||||
change_tab_to: noop,
|
||||
place_caret_at_end: noop,
|
||||
});
|
||||
set_global('narrow', {});
|
||||
set_global('search_pill_widget', {
|
||||
set_global("narrow", {});
|
||||
set_global("search_pill_widget", {
|
||||
widget: {
|
||||
getByID: return_true,
|
||||
},
|
||||
@@ -27,68 +27,68 @@ set_global('search_pill_widget', {
|
||||
search_pill.append_search_string = noop;
|
||||
search_pill.get_search_string_for_current_filter = noop;
|
||||
|
||||
global.patch_builtin('setTimeout', (func) => func());
|
||||
global.patch_builtin("setTimeout", (func) => func());
|
||||
|
||||
run_test('clear_search_form', () => {
|
||||
$('#search_query').val('noise');
|
||||
$('#search_query').focus();
|
||||
$('.search_button').prop('disabled', false);
|
||||
run_test("clear_search_form", () => {
|
||||
$("#search_query").val("noise");
|
||||
$("#search_query").focus();
|
||||
$(".search_button").prop("disabled", false);
|
||||
|
||||
search.clear_search_form();
|
||||
|
||||
assert.equal($('#search_query').is_focused(), false);
|
||||
assert.equal($('#search_query').val(), '');
|
||||
assert.equal($('.search_button').prop('disabled'), true);
|
||||
assert.equal($("#search_query").is_focused(), false);
|
||||
assert.equal($("#search_query").val(), "");
|
||||
assert.equal($(".search_button").prop("disabled"), true);
|
||||
});
|
||||
|
||||
run_test('update_button_visibility', () => {
|
||||
const search_query = $('#search_query');
|
||||
const search_button = $('.search_button');
|
||||
run_test("update_button_visibility", () => {
|
||||
const search_query = $("#search_query");
|
||||
const search_button = $(".search_button");
|
||||
|
||||
search_query.is = return_false;
|
||||
search_query.val('');
|
||||
search_query.val("");
|
||||
narrow_state.active = return_false;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(search_button.prop('disabled'));
|
||||
assert(search_button.prop("disabled"));
|
||||
|
||||
search_query.is = return_true;
|
||||
search_query.val('');
|
||||
search_query.val("");
|
||||
narrow_state.active = return_false;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
search_query.is = return_false;
|
||||
search_query.val('Test search term');
|
||||
search_query.val("Test search term");
|
||||
narrow_state.active = return_false;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
search_query.is = return_false;
|
||||
search_query.val('');
|
||||
search_query.val("");
|
||||
narrow_state.active = return_true;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
});
|
||||
|
||||
run_test('initialize', () => {
|
||||
const search_query_box = $('#search_query');
|
||||
const searchbox_form = $('#searchbox_form');
|
||||
const search_button = $('.search_button');
|
||||
const searchbox = $('#searchbox');
|
||||
run_test("initialize", () => {
|
||||
const search_query_box = $("#search_query");
|
||||
const searchbox_form = $("#searchbox_form");
|
||||
const search_button = $(".search_button");
|
||||
const searchbox = $("#searchbox");
|
||||
|
||||
searchbox_form.on = (event, func) => {
|
||||
assert.equal(event, 'compositionend');
|
||||
assert.equal(event, "compositionend");
|
||||
search.is_using_input_method = false;
|
||||
func();
|
||||
assert(search.is_using_input_method);
|
||||
};
|
||||
|
||||
search_pill.get_search_string_for_current_filter = function () {
|
||||
return 'is:starred';
|
||||
return "is:starred";
|
||||
};
|
||||
|
||||
search_suggestion.max_num_of_search_results = 99;
|
||||
@@ -104,29 +104,29 @@ run_test('initialize', () => {
|
||||
{
|
||||
const search_suggestions = {
|
||||
lookup_table: new Map([
|
||||
['stream:Verona', {
|
||||
description: 'Stream <strong>Ver</strong>ona',
|
||||
search_string: 'stream:Verona',
|
||||
["stream:Verona", {
|
||||
description: "Stream <strong>Ver</strong>ona",
|
||||
search_string: "stream:Verona",
|
||||
}],
|
||||
['ver', {
|
||||
description: 'Search for ver',
|
||||
search_string: 'ver',
|
||||
["ver", {
|
||||
description: "Search for ver",
|
||||
search_string: "ver",
|
||||
}],
|
||||
]),
|
||||
strings: ['ver', 'stream:Verona'],
|
||||
strings: ["ver", "stream:Verona"],
|
||||
};
|
||||
|
||||
/* Test source */
|
||||
search_suggestion.get_suggestions = () => search_suggestions;
|
||||
const expected_source_value = search_suggestions.strings;
|
||||
const source = opts.source('ver');
|
||||
const source = opts.source("ver");
|
||||
assert.equal(source, expected_source_value);
|
||||
|
||||
/* Test highlighter */
|
||||
let expected_value = 'Search for ver';
|
||||
let expected_value = "Search for ver";
|
||||
assert.equal(opts.highlighter(source[0]), expected_value);
|
||||
|
||||
expected_value = 'Stream <strong>Ver</strong>ona';
|
||||
expected_value = "Stream <strong>Ver</strong>ona";
|
||||
assert.equal(opts.highlighter(source[1]), expected_value);
|
||||
|
||||
/* Test sorter */
|
||||
@@ -154,37 +154,37 @@ run_test('initialize', () => {
|
||||
};
|
||||
narrow.activate = (raw_operators, options) => {
|
||||
assert.deepEqual(raw_operators, operators);
|
||||
assert.deepEqual(options, {trigger: 'search'});
|
||||
assert.deepEqual(options, {trigger: "search"});
|
||||
};
|
||||
search_pill.get_search_string_for_current_filter = () => search_box_val;
|
||||
};
|
||||
|
||||
operators = [{
|
||||
negated: false,
|
||||
operator: 'search',
|
||||
operand: 'ver',
|
||||
operator: "search",
|
||||
operand: "ver",
|
||||
}];
|
||||
_setup('ver');
|
||||
_setup("ver");
|
||||
|
||||
assert.equal(opts.updater('ver'), 'ver');
|
||||
assert.equal(opts.updater("ver"), "ver");
|
||||
assert(!is_blurred);
|
||||
assert(is_append_search_string_called);
|
||||
|
||||
operators = [{
|
||||
negated: false,
|
||||
operator: 'stream',
|
||||
operand: 'Verona',
|
||||
operator: "stream",
|
||||
operand: "Verona",
|
||||
}];
|
||||
_setup('stream:Verona');
|
||||
_setup("stream:Verona");
|
||||
|
||||
assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
|
||||
assert.equal(opts.updater("stream:Verona"), "stream:Verona");
|
||||
assert(!is_blurred);
|
||||
assert(is_append_search_string_called);
|
||||
|
||||
search.is_using_input_method = true;
|
||||
_setup('stream:Verona');
|
||||
_setup("stream:Verona");
|
||||
|
||||
assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
|
||||
assert.equal(opts.updater("stream:Verona"), "stream:Verona");
|
||||
assert(!is_blurred);
|
||||
assert(is_append_search_string_called);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ run_test('initialize', () => {
|
||||
|
||||
const _setup = (search_box_val) => {
|
||||
is_blurred = false;
|
||||
search_button.prop('disabled', false);
|
||||
search_button.prop("disabled", false);
|
||||
search_query_box.val(search_box_val);
|
||||
Filter.parse = (search_string) => {
|
||||
assert.equal(search_string, search_box_val);
|
||||
@@ -226,76 +226,76 @@ run_test('initialize', () => {
|
||||
};
|
||||
narrow.activate = (raw_operators, options) => {
|
||||
assert.deepEqual(raw_operators, operators);
|
||||
assert.deepEqual(options, {trigger: 'search'});
|
||||
assert.deepEqual(options, {trigger: "search"});
|
||||
};
|
||||
search_pill.get_search_string_for_current_filter = () => search_box_val;
|
||||
};
|
||||
|
||||
operators = [{
|
||||
negated: false,
|
||||
operator: 'search',
|
||||
operand: '',
|
||||
operator: "search",
|
||||
operand: "",
|
||||
}];
|
||||
_setup('');
|
||||
_setup("");
|
||||
|
||||
ev.which = 15;
|
||||
search_query_box.is = return_false;
|
||||
func(ev);
|
||||
|
||||
assert(!is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
ev.which = 13;
|
||||
search_query_box.is = return_false;
|
||||
func(ev);
|
||||
|
||||
assert(!is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
ev.which = 13;
|
||||
search_query_box.is = return_true;
|
||||
func(ev);
|
||||
assert(is_blurred);
|
||||
|
||||
_setup('ver');
|
||||
_setup("ver");
|
||||
search.is_using_input_method = true;
|
||||
func(ev);
|
||||
// No change on enter keyup event when using input tool
|
||||
assert(!is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
_setup('ver');
|
||||
_setup("ver");
|
||||
ev.which = 13;
|
||||
search_query_box.is = return_true;
|
||||
func(ev);
|
||||
assert(is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
};
|
||||
|
||||
const search_pill_stub = $.create('.pill');
|
||||
const search_pill_stub = $.create(".pill");
|
||||
search_pill_stub.closest = () => ({ data: noop });
|
||||
const stub_event = {
|
||||
relatedTarget: search_pill_stub,
|
||||
};
|
||||
search_query_box.on = (event, callback) => {
|
||||
if (event === 'focus') {
|
||||
search_button.prop('disabled', true);
|
||||
if (event === "focus") {
|
||||
search_button.prop("disabled", true);
|
||||
callback();
|
||||
assert(!search_button.prop('disabled'));
|
||||
} else if (event === 'blur') {
|
||||
assert(!search_button.prop("disabled"));
|
||||
} else if (event === "blur") {
|
||||
search_query_box.val("test string");
|
||||
narrow_state.search_string = () => 'ver';
|
||||
narrow_state.search_string = () => "ver";
|
||||
callback(stub_event);
|
||||
assert.equal(search_query_box.val(), 'test string');
|
||||
assert.equal(search_query_box.val(), "test string");
|
||||
}
|
||||
};
|
||||
|
||||
searchbox.on = (event, callback) => {
|
||||
if (event === 'focusin') {
|
||||
if (event === "focusin") {
|
||||
searchbox.css({"box-shadow": "unset"});
|
||||
callback();
|
||||
assert.deepEqual(searchbox.css(), {"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
|
||||
} else if (event === 'focusout') {
|
||||
} else if (event === "focusout") {
|
||||
searchbox.css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
|
||||
callback();
|
||||
assert.deepEqual(searchbox.css(), {"box-shadow": "unset"});
|
||||
@@ -305,7 +305,7 @@ run_test('initialize', () => {
|
||||
search.initialize();
|
||||
});
|
||||
|
||||
run_test('initiate_search', () => {
|
||||
run_test("initiate_search", () => {
|
||||
// open typeahead and select text when navbar is open
|
||||
// this implicitly expects the code to used the chained
|
||||
// function calls, which is something to keep in mind if
|
||||
@@ -313,11 +313,11 @@ run_test('initiate_search', () => {
|
||||
let typeahead_forced_open = false;
|
||||
let is_searchbox_text_selected = false;
|
||||
let is_searchbox_focused = false;
|
||||
$('#search_query').focus = () => {
|
||||
$("#search_query").focus = () => {
|
||||
is_searchbox_focused = true;
|
||||
};
|
||||
$('#search_query').select = noop;
|
||||
$('#search_query').typeahead = (lookup) => {
|
||||
$("#search_query").select = noop;
|
||||
$("#search_query").typeahead = (lookup) => {
|
||||
if (lookup === "lookup") {
|
||||
typeahead_forced_open = true;
|
||||
return {
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
set_global('page_params', {
|
||||
set_global("page_params", {
|
||||
search_pills_enabled: false,
|
||||
});
|
||||
zrequire('search');
|
||||
zrequire('tab_bar');
|
||||
zrequire("search");
|
||||
zrequire("tab_bar");
|
||||
|
||||
const noop = () => {};
|
||||
const return_true = () => true;
|
||||
const return_false = () => false;
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('narrow_state', {});
|
||||
set_global('search_suggestion', {});
|
||||
set_global('ui_util', {
|
||||
set_global("$", global.make_zjquery());
|
||||
set_global("narrow_state", {});
|
||||
set_global("search_suggestion", {});
|
||||
set_global("ui_util", {
|
||||
change_tab_to: noop,
|
||||
});
|
||||
set_global('narrow', {});
|
||||
set_global('Filter', {});
|
||||
set_global("narrow", {});
|
||||
set_global("Filter", {});
|
||||
|
||||
global.patch_builtin('setTimeout', (func) => func());
|
||||
global.patch_builtin("setTimeout", (func) => func());
|
||||
|
||||
run_test('update_button_visibility', () => {
|
||||
const search_query = $('#search_query');
|
||||
const search_button = $('.search_button');
|
||||
run_test("update_button_visibility", () => {
|
||||
const search_query = $("#search_query");
|
||||
const search_button = $(".search_button");
|
||||
|
||||
search_query.is = return_false;
|
||||
search_query.val('');
|
||||
search_query.val("");
|
||||
narrow_state.active = return_false;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(search_button.prop('disabled'));
|
||||
assert(search_button.prop("disabled"));
|
||||
|
||||
search_query.is = return_true;
|
||||
search_query.val('');
|
||||
search_query.val("");
|
||||
narrow_state.active = return_false;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
search_query.is = return_false;
|
||||
search_query.val('Test search term');
|
||||
search_query.val("Test search term");
|
||||
narrow_state.active = return_false;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
search_query.is = return_false;
|
||||
search_query.val('');
|
||||
search_query.val("");
|
||||
narrow_state.active = return_true;
|
||||
search_button.prop('disabled', true);
|
||||
search_button.prop("disabled", true);
|
||||
search.update_button_visibility();
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
});
|
||||
|
||||
run_test('initialize', () => {
|
||||
const search_query_box = $('#search_query');
|
||||
const searchbox_form = $('#searchbox_form');
|
||||
const search_button = $('.search_button');
|
||||
run_test("initialize", () => {
|
||||
const search_query_box = $("#search_query");
|
||||
const searchbox_form = $("#searchbox_form");
|
||||
const search_button = $(".search_button");
|
||||
|
||||
searchbox_form.on = (event, func) => {
|
||||
assert.equal(event, 'compositionend');
|
||||
assert.equal(event, "compositionend");
|
||||
search.is_using_input_method = false;
|
||||
func();
|
||||
assert(search.is_using_input_method);
|
||||
@@ -75,29 +75,29 @@ run_test('initialize', () => {
|
||||
{
|
||||
const search_suggestions = {
|
||||
lookup_table: new Map([
|
||||
['stream:Verona', {
|
||||
description: 'Stream <strong>Ver</strong>ona',
|
||||
search_string: 'stream:Verona',
|
||||
["stream:Verona", {
|
||||
description: "Stream <strong>Ver</strong>ona",
|
||||
search_string: "stream:Verona",
|
||||
}],
|
||||
['ver', {
|
||||
description: 'Search for ver',
|
||||
search_string: 'ver',
|
||||
["ver", {
|
||||
description: "Search for ver",
|
||||
search_string: "ver",
|
||||
}],
|
||||
]),
|
||||
strings: ['ver', 'stream:Verona'],
|
||||
strings: ["ver", "stream:Verona"],
|
||||
};
|
||||
|
||||
/* Test source */
|
||||
search_suggestion.get_suggestions = () => search_suggestions;
|
||||
const expected_source_value = search_suggestions.strings;
|
||||
const source = opts.source('ver');
|
||||
const source = opts.source("ver");
|
||||
assert.equal(source, expected_source_value);
|
||||
|
||||
/* Test highlighter */
|
||||
let expected_value = 'Search for ver';
|
||||
let expected_value = "Search for ver";
|
||||
assert.equal(opts.highlighter(source[0]), expected_value);
|
||||
|
||||
expected_value = 'Stream <strong>Ver</strong>ona';
|
||||
expected_value = "Stream <strong>Ver</strong>ona";
|
||||
assert.equal(opts.highlighter(source[1]), expected_value);
|
||||
|
||||
/* Test sorter */
|
||||
@@ -120,31 +120,31 @@ run_test('initialize', () => {
|
||||
};
|
||||
narrow.activate = (raw_operators, options) => {
|
||||
assert.deepEqual(raw_operators, operators);
|
||||
assert.deepEqual(options, {trigger: 'search'});
|
||||
assert.deepEqual(options, {trigger: "search"});
|
||||
};
|
||||
};
|
||||
|
||||
operators = [{
|
||||
negated: false,
|
||||
operator: 'search',
|
||||
operand: 'ver',
|
||||
operator: "search",
|
||||
operand: "ver",
|
||||
}];
|
||||
_setup('ver');
|
||||
assert.equal(opts.updater('ver'), 'ver');
|
||||
_setup("ver");
|
||||
assert.equal(opts.updater("ver"), "ver");
|
||||
assert(is_blurred);
|
||||
|
||||
operators = [{
|
||||
negated: false,
|
||||
operator: 'stream',
|
||||
operand: 'Verona',
|
||||
operator: "stream",
|
||||
operand: "Verona",
|
||||
}];
|
||||
_setup('stream:Verona');
|
||||
assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
|
||||
_setup("stream:Verona");
|
||||
assert.equal(opts.updater("stream:Verona"), "stream:Verona");
|
||||
assert(is_blurred);
|
||||
|
||||
search.is_using_input_method = true;
|
||||
_setup('stream:Verona');
|
||||
assert.equal(opts.updater('stream:Verona'), 'stream:Verona');
|
||||
_setup("stream:Verona");
|
||||
assert.equal(opts.updater("stream:Verona"), "stream:Verona");
|
||||
assert(!is_blurred);
|
||||
}
|
||||
};
|
||||
@@ -177,7 +177,7 @@ run_test('initialize', () => {
|
||||
|
||||
const _setup = (search_box_val) => {
|
||||
is_blurred = false;
|
||||
search_button.prop('disabled', false);
|
||||
search_button.prop("disabled", false);
|
||||
search_query_box.val(search_box_val);
|
||||
Filter.parse = (search_string) => {
|
||||
assert.equal(search_string, search_box_val);
|
||||
@@ -185,68 +185,68 @@ run_test('initialize', () => {
|
||||
};
|
||||
narrow.activate = (raw_operators, options) => {
|
||||
assert.deepEqual(raw_operators, operators);
|
||||
assert.deepEqual(options, {trigger: 'search'});
|
||||
assert.deepEqual(options, {trigger: "search"});
|
||||
};
|
||||
};
|
||||
|
||||
operators = [{
|
||||
negated: false,
|
||||
operator: 'search',
|
||||
operand: '',
|
||||
operator: "search",
|
||||
operand: "",
|
||||
}];
|
||||
_setup('');
|
||||
_setup("");
|
||||
|
||||
ev.which = 15;
|
||||
search_query_box.is = return_false;
|
||||
func(ev);
|
||||
|
||||
assert(!is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
ev.which = 13;
|
||||
search_query_box.is = return_false;
|
||||
func(ev);
|
||||
|
||||
assert(!is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
ev.which = 13;
|
||||
search_query_box.is = return_true;
|
||||
func(ev);
|
||||
assert(is_blurred);
|
||||
|
||||
_setup('ver');
|
||||
_setup("ver");
|
||||
search.is_using_input_method = true;
|
||||
func(ev);
|
||||
// No change on enter keyup event when using input tool
|
||||
assert(!is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
|
||||
_setup('ver');
|
||||
_setup("ver");
|
||||
ev.which = 13;
|
||||
search_query_box.is = return_true;
|
||||
func(ev);
|
||||
assert(is_blurred);
|
||||
assert(!search_button.prop('disabled'));
|
||||
assert(!search_button.prop("disabled"));
|
||||
};
|
||||
|
||||
search_query_box.on = (event, callback) => {
|
||||
if (event === 'focus') {
|
||||
search_button.prop('disabled', true);
|
||||
if (event === "focus") {
|
||||
search_button.prop("disabled", true);
|
||||
callback();
|
||||
assert(!search_button.prop('disabled'));
|
||||
} else if (event === 'blur') {
|
||||
assert(!search_button.prop("disabled"));
|
||||
} else if (event === "blur") {
|
||||
search_query_box.val("test string");
|
||||
narrow_state.search_string = () => 'ver';
|
||||
narrow_state.search_string = () => "ver";
|
||||
callback();
|
||||
assert.equal(search_query_box.val(), 'test string');
|
||||
assert.equal(search_query_box.val(), "test string");
|
||||
}
|
||||
};
|
||||
|
||||
search.initialize();
|
||||
});
|
||||
|
||||
run_test('initiate_search', () => {
|
||||
run_test("initiate_search", () => {
|
||||
// open typeahead and select text when navbar is open
|
||||
// this implicitly expects the code to used the chained
|
||||
// function calls, which is something to keep in mind if
|
||||
@@ -254,8 +254,8 @@ run_test('initiate_search', () => {
|
||||
narrow_state.filter = () => ({is_search: return_true});
|
||||
let typeahead_forced_open = false;
|
||||
let is_searchbox_text_selected = false;
|
||||
$('#search_query').select = noop;
|
||||
$('#search_query').typeahead = (lookup) => {
|
||||
$("#search_query").select = noop;
|
||||
$("#search_query").typeahead = (lookup) => {
|
||||
if (lookup === "lookup") {
|
||||
typeahead_forced_open = true;
|
||||
return {
|
||||
@@ -268,10 +268,10 @@ run_test('initiate_search', () => {
|
||||
search.initiate_search();
|
||||
assert(typeahead_forced_open);
|
||||
assert(is_searchbox_text_selected);
|
||||
assert.equal($('#search_query').val(), "ver");
|
||||
assert.equal($("#search_query").val(), "ver");
|
||||
|
||||
// test that we append space for user convenience
|
||||
narrow_state.filter = () => ({is_search: return_false});
|
||||
search.initiate_search();
|
||||
assert.equal($('#search_query').val(), "ver ");
|
||||
assert.equal($("#search_query").val(), "ver ");
|
||||
});
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
zrequire('search_pill');
|
||||
zrequire('input_pill');
|
||||
zrequire('Filter', 'js/filter');
|
||||
set_global('Handlebars', global.make_handlebars());
|
||||
zrequire("search_pill");
|
||||
zrequire("input_pill");
|
||||
zrequire("Filter", "js/filter");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
|
||||
const is_starred_item = {
|
||||
display_value: 'is:starred',
|
||||
description: 'starred messages',
|
||||
display_value: "is:starred",
|
||||
description: "starred messages",
|
||||
};
|
||||
|
||||
const is_private_item = {
|
||||
display_value: 'is:private',
|
||||
description: 'private messages',
|
||||
display_value: "is:private",
|
||||
description: "private messages",
|
||||
};
|
||||
|
||||
run_test('create_item', () => {
|
||||
run_test("create_item", () => {
|
||||
|
||||
function test_create_item(search_string, current_items, expected_item) {
|
||||
const item = search_pill.create_item_from_search_string(search_string, current_items);
|
||||
assert.deepEqual(item, expected_item);
|
||||
}
|
||||
|
||||
test_create_item('is:starred', [], is_starred_item);
|
||||
test_create_item("is:starred", [], is_starred_item);
|
||||
});
|
||||
|
||||
run_test('get_search_string', () => {
|
||||
assert.equal(search_pill.get_search_string_from_item(is_starred_item), 'is:starred');
|
||||
run_test("get_search_string", () => {
|
||||
assert.equal(search_pill.get_search_string_from_item(is_starred_item), "is:starred");
|
||||
});
|
||||
|
||||
run_test('append', () => {
|
||||
run_test("append", () => {
|
||||
let appended;
|
||||
let cleared;
|
||||
|
||||
@@ -51,7 +51,7 @@ run_test('append', () => {
|
||||
assert(cleared);
|
||||
});
|
||||
|
||||
run_test('get_items', () => {
|
||||
run_test("get_items", () => {
|
||||
const items = [is_starred_item, is_private_item];
|
||||
|
||||
const pill_widget = {
|
||||
@@ -59,18 +59,18 @@ run_test('get_items', () => {
|
||||
};
|
||||
|
||||
assert.deepEqual(search_pill.get_search_string_for_current_filter(pill_widget),
|
||||
is_starred_item.display_value + ' ' + is_private_item.display_value);
|
||||
is_starred_item.display_value + " " + is_private_item.display_value);
|
||||
});
|
||||
|
||||
run_test('create_pills', () => {
|
||||
run_test("create_pills", () => {
|
||||
let input_pill_create_called = false;
|
||||
|
||||
input_pill.create = function () {
|
||||
input_pill_create_called = true;
|
||||
return {dummy: 'dummy'};
|
||||
return {dummy: "dummy"};
|
||||
};
|
||||
|
||||
const pills = search_pill.create_pills({});
|
||||
assert(input_pill_create_called);
|
||||
assert.deepEqual(pills, {dummy: 'dummy'});
|
||||
assert.deepEqual(pills, {dummy: "dummy"});
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,51 +1,51 @@
|
||||
const noop = function () {};
|
||||
|
||||
set_global('document', {});
|
||||
set_global('addEventListener', noop);
|
||||
set_global("document", {});
|
||||
set_global("addEventListener", noop);
|
||||
global.stub_out_jquery();
|
||||
|
||||
zrequire('message_store');
|
||||
zrequire('server_events_dispatch');
|
||||
zrequire('server_events');
|
||||
zrequire('sent_messages');
|
||||
zrequire("message_store");
|
||||
zrequire("server_events_dispatch");
|
||||
zrequire("server_events");
|
||||
zrequire("sent_messages");
|
||||
|
||||
set_global('channel', {});
|
||||
set_global('home_msg_list', {
|
||||
set_global("channel", {});
|
||||
set_global("home_msg_list", {
|
||||
select_id: noop,
|
||||
selected_id: function () {return 1;},
|
||||
});
|
||||
set_global('page_params', {test_suite: false});
|
||||
set_global('reload_state', {
|
||||
set_global("page_params", {test_suite: false});
|
||||
set_global("reload_state", {
|
||||
is_in_progress: function () {return false;},
|
||||
});
|
||||
|
||||
// we also directly write to pointer
|
||||
set_global('pointer', {});
|
||||
set_global("pointer", {});
|
||||
|
||||
set_global('echo', {
|
||||
set_global("echo", {
|
||||
process_from_server: function (messages) {
|
||||
return messages;
|
||||
},
|
||||
update_realm_filter_rules: noop,
|
||||
});
|
||||
set_global('ui_report', {
|
||||
set_global("ui_report", {
|
||||
hide_error: function () { return false; },
|
||||
show_error: function () { return false; },
|
||||
});
|
||||
|
||||
server_events.home_view_loaded();
|
||||
|
||||
run_test('message_event', () => {
|
||||
run_test("message_event", () => {
|
||||
const event = {
|
||||
type: 'message',
|
||||
type: "message",
|
||||
message: {
|
||||
content: 'hello',
|
||||
content: "hello",
|
||||
},
|
||||
flags: [],
|
||||
};
|
||||
|
||||
let inserted;
|
||||
set_global('message_events', {
|
||||
set_global("message_events", {
|
||||
insert_new_messages: function (messages) {
|
||||
assert.equal(messages[0].content, event.message.content);
|
||||
inserted = true;
|
||||
@@ -60,69 +60,69 @@ run_test('message_event', () => {
|
||||
|
||||
const setup = function () {
|
||||
server_events.home_view_loaded();
|
||||
set_global('message_events', {
|
||||
set_global("message_events", {
|
||||
insert_new_messages: function () {
|
||||
throw Error('insert error');
|
||||
throw Error("insert error");
|
||||
},
|
||||
update_messages: function () {
|
||||
throw Error('update error');
|
||||
throw Error("update error");
|
||||
},
|
||||
});
|
||||
set_global('stream_events', {
|
||||
set_global("stream_events", {
|
||||
update_property: function () {
|
||||
throw Error('subs update error');
|
||||
throw Error("subs update error");
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
run_test('event_dispatch_error', () => {
|
||||
run_test("event_dispatch_error", () => {
|
||||
setup();
|
||||
|
||||
const data = {events: [{type: 'stream', op: 'update', id: 1, other: 'thing'}]};
|
||||
const data = {events: [{type: "stream", op: "update", id: 1, other: "thing"}]};
|
||||
global.channel.get = function (options) {
|
||||
options.success(data);
|
||||
};
|
||||
|
||||
blueslip.expect('error', 'Failed to process an event\nsubs update error');
|
||||
blueslip.expect("error", "Failed to process an event\nsubs update error");
|
||||
|
||||
server_events.restart_get_events();
|
||||
|
||||
const logs = blueslip.get_test_logs('error');
|
||||
const logs = blueslip.get_test_logs("error");
|
||||
assert.equal(logs.length, 1);
|
||||
assert.equal(logs[0].more_info.event.type, 'stream');
|
||||
assert.equal(logs[0].more_info.event.op, 'update');
|
||||
assert.equal(logs[0].more_info.event.type, "stream");
|
||||
assert.equal(logs[0].more_info.event.op, "update");
|
||||
assert.equal(logs[0].more_info.event.id, 1);
|
||||
assert.equal(logs[0].more_info.other, undefined);
|
||||
});
|
||||
|
||||
run_test('event_new_message_error', () => {
|
||||
run_test("event_new_message_error", () => {
|
||||
setup();
|
||||
|
||||
const data = {events: [{type: 'message', id: 1, other: 'thing', message: {}}]};
|
||||
const data = {events: [{type: "message", id: 1, other: "thing", message: {}}]};
|
||||
global.channel.get = function (options) {
|
||||
options.success(data);
|
||||
};
|
||||
|
||||
blueslip.expect('error', 'Failed to insert new messages\ninsert error');
|
||||
blueslip.expect("error", "Failed to insert new messages\ninsert error");
|
||||
|
||||
server_events.restart_get_events();
|
||||
|
||||
const logs = blueslip.get_test_logs('error');
|
||||
const logs = blueslip.get_test_logs("error");
|
||||
assert.equal(logs.length, 1);
|
||||
assert.equal(logs[0].more_info, undefined);
|
||||
});
|
||||
|
||||
run_test('event_edit_message_error', () => {
|
||||
run_test("event_edit_message_error", () => {
|
||||
setup();
|
||||
const data = {events: [{type: 'update_message', id: 1, other: 'thing'}]};
|
||||
const data = {events: [{type: "update_message", id: 1, other: "thing"}]};
|
||||
global.channel.get = function (options) {
|
||||
options.success(data);
|
||||
};
|
||||
blueslip.expect('error', 'Failed to update messages\nupdate error');
|
||||
blueslip.expect("error", "Failed to update messages\nupdate error");
|
||||
|
||||
server_events.restart_get_events();
|
||||
|
||||
const logs = blueslip.get_test_logs('error');
|
||||
const logs = blueslip.get_test_logs("error");
|
||||
assert.equal(logs.length, 1);
|
||||
assert.equal(logs[0].more_info, undefined);
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user