mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
@@ -125,12 +125,20 @@ function expect_all_pm() {
|
||||
]);
|
||||
}
|
||||
|
||||
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');
|
||||
};
|
||||
}
|
||||
|
||||
function un_narrow() {
|
||||
casper.then(common.un_narrow);
|
||||
casper.then(expect_home);
|
||||
casper.then(check_narrow_title('home - Zulip Dev - Zulip'));
|
||||
}
|
||||
|
||||
|
||||
// Narrow by clicking links.
|
||||
|
||||
common.wait_for_receive(function () {
|
||||
@@ -141,6 +149,7 @@ common.wait_for_receive(function () {
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
expect_stream();
|
||||
});
|
||||
casper.then(check_narrow_title('Verona - Zulip Dev - Zulip'));
|
||||
un_narrow();
|
||||
|
||||
casper.waitUntilVisible('#zhome', function () {
|
||||
@@ -148,6 +157,7 @@ casper.waitUntilVisible('#zhome', function () {
|
||||
casper.test.info('Narrowing by clicking subject');
|
||||
casper.click('*[title="Narrow to stream \\\"Verona\\\", topic \\\"frontend test\\\""]');
|
||||
});
|
||||
casper.then(check_narrow_title('frontend test - Zulip Dev - Zulip'));
|
||||
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
expect_stream_subject();
|
||||
@@ -163,6 +173,7 @@ casper.waitUntilVisible('#zhome', function () {
|
||||
casper.click('*[title="Narrow to your private messages with Cordelia Lear, King Hamlet"]');
|
||||
});
|
||||
|
||||
casper.then(check_narrow_title('private - Zulip Dev - Zulip'));
|
||||
|
||||
casper.waitUntilVisible('#zfilt', function () {
|
||||
expect_huddle();
|
||||
@@ -205,32 +216,39 @@ function do_search(str, item) {
|
||||
});
|
||||
}
|
||||
|
||||
function search_and_check(str, item, check) {
|
||||
function search_and_check(str, item, check, narrow_title) {
|
||||
do_search(str, item);
|
||||
|
||||
casper.then(check);
|
||||
casper.then(check_narrow_title(narrow_title));
|
||||
un_narrow();
|
||||
}
|
||||
|
||||
casper.waitUntilVisible('#zhome', expect_home);
|
||||
|
||||
// Test stream / recipient autocomplete in the search bar
|
||||
search_and_check('Verona', 'Narrow to stream', expect_stream);
|
||||
search_and_check('Cordelia', 'Narrow to private', expect_1on1);
|
||||
search_and_check('Verona', 'Narrow to stream', expect_stream,
|
||||
'Verona - Zulip Dev - Zulip');
|
||||
search_and_check('Cordelia', 'Narrow to private', expect_1on1,
|
||||
'private - Zulip Dev - Zulip');
|
||||
|
||||
// Test operators
|
||||
search_and_check('stream:verona', 'Narrow', expect_stream);
|
||||
search_and_check('stream:verona subject:frontend+test', 'Narrow', expect_stream_subject);
|
||||
search_and_check('subject:frontend+test', 'Narrow', expect_subject);
|
||||
|
||||
search_and_check('stream:Verona', 'Narrow', expect_stream,
|
||||
'Verona - Zulip Dev - Zulip');
|
||||
search_and_check('stream:Verona subject:frontend+test', 'Narrow', expect_stream_subject,
|
||||
'frontend test - Zulip Dev - Zulip');
|
||||
search_and_check('subject:frontend+test', 'Narrow', expect_subject,
|
||||
'home - Zulip Dev - Zulip');
|
||||
|
||||
// Narrow by clicking the left sidebar.
|
||||
casper.then(function () {
|
||||
casper.test.info('Narrowing with left sidebar');
|
||||
});
|
||||
casper.thenClick('#stream_filters [data-name="Verona"] a', expect_stream);
|
||||
casper.then(check_narrow_title('Verona - Zulip Dev - Zulip'));
|
||||
casper.thenClick('#global_filters [data-name="home"] a', expect_home);
|
||||
casper.then(check_narrow_title('home - Zulip Dev - Zulip'));
|
||||
casper.thenClick('#global_filters [data-name="private"] a', expect_all_pm);
|
||||
casper.then(check_narrow_title('private - Zulip Dev - Zulip'));
|
||||
un_narrow();
|
||||
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ function report_unnarrow_time() {
|
||||
unnarrow_times = {};
|
||||
}
|
||||
|
||||
exports.narrow_title = "home";
|
||||
exports.activate = function (raw_operators, opts) {
|
||||
var start_time = new Date();
|
||||
var was_narrowed_already = exports.active();
|
||||
@@ -150,6 +151,23 @@ exports.activate = function (raw_operators, opts) {
|
||||
var filter = new Filter(raw_operators);
|
||||
var operators = filter.operators();
|
||||
|
||||
// Take the most detailed part of the narrow to use as the title.
|
||||
// If the operator is something other than "stream", "topic", or
|
||||
// "is", we shouldn't update the narrow title
|
||||
if (filter.has_operator("stream")) {
|
||||
if (filter.has_operator("topic")) {
|
||||
exports.narrow_title = filter.operands("topic")[0];
|
||||
} else {
|
||||
exports.narrow_title = filter.operands("stream")[0];
|
||||
}
|
||||
} else if (filter.has_operator("is")) {
|
||||
exports.narrow_title = filter.operands("is")[0];
|
||||
} else if (filter.has_operator("pm-with")) {
|
||||
exports.narrow_title = "private";
|
||||
}
|
||||
|
||||
notifications.redraw_title();
|
||||
|
||||
blueslip.debug("Narrowed", {operators: _.map(operators,
|
||||
function (e) { return e.operator; }),
|
||||
trigger: opts ? opts.trigger : undefined,
|
||||
@@ -477,6 +495,9 @@ exports.deactivate = function () {
|
||||
|
||||
$(document).trigger($.Event('narrow_deactivated.zulip', {msg_list: current_msg_list}));
|
||||
|
||||
exports.narrow_title = "home";
|
||||
notifications.redraw_title();
|
||||
|
||||
unnarrow_times.initial_core_time = new Date();
|
||||
setTimeout(function () {
|
||||
unnarrow_times.initial_free_time = new Date();
|
||||
|
||||
@@ -147,7 +147,9 @@ exports.redraw_title = function () {
|
||||
var n;
|
||||
|
||||
var new_title = (new_message_count ? ("(" + new_message_count + ") ") : "")
|
||||
+ page_params.realm_name + " - " + page_params.product_name;
|
||||
+ narrow.narrow_title + " - "
|
||||
+ page_params.realm_name + " - "
|
||||
+ page_params.product_name;
|
||||
|
||||
if (document.title === new_title) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user