tests: Test the compose buttons in stream and private narrows.

Also add a test for the `narrow.is_in_private_narrow` function used by
the mobile compose popover.
This commit is contained in:
Marco Burstein 2018-08-13 14:17:45 -07:00 committed by Tim Abbott
parent 8673b4f4a6
commit 1490653e42
2 changed files with 24 additions and 0 deletions

View File

@ -1639,3 +1639,13 @@ run_test('nonexistent_stream_reply_error', () => {
assert.equal($("#compose-reply-error-msg").html(), 'There are no messages to reply to yet.');
assert(shown < hidden); // test shown before hidden
});
run_test('narrow_button_titles', () => {
util.is_mobile = () => { return false; };
compose.update_stream_button_for_private();
assert.equal($("#left_bar_compose_stream_button_big").text(), i18n.t("New stream message"));
compose.update_stream_button_for_stream();
assert.equal($("#left_bar_compose_stream_button_big").text(), i18n.t("New topic"));
});

View File

@ -25,6 +25,7 @@ set_global('search', {});
set_global('stream_list', {});
set_global('top_left_corner', {});
set_global('ui_util', {});
set_global('util', {});
set_global('unread_ops', {});
set_global('search_pill_widget', {
widget: {
@ -76,6 +77,7 @@ function test_helper() {
stub('compose_actions', 'on_narrow');
stub('hashchange', 'save_narrow');
stub('message_scroll', 'hide_indicators');
stub('message_scroll', 'show_loading_older');
stub('notifications', 'clear_compose_notifications');
stub('notifications', 'redraw_title');
stub('search', 'update_button_visibility');
@ -84,6 +86,7 @@ function test_helper() {
stub('ui_util', 'change_tab_to');
stub('unread_ops', 'process_visible');
stub('compose', 'update_stream_button_for_stream');
stub('compose', 'update_stream_button_for_private');
stub_trigger(() => { events.push('trigger event'); });
@ -200,6 +203,7 @@ run_test('basics', () => {
assert.equal(message_list.narrowed.selected_id, selected_id);
assert.equal(message_list.narrowed.view.offset, 25);
assert.equal(narrow_state.narrowed_to_pms(), false);
helper.assert_events([
'notifications.clear_compose_notifications',
@ -216,6 +220,16 @@ run_test('basics', () => {
'trigger event',
]);
current_msg_list.selected_id = () => { return -1; };
current_msg_list.get_row = () => { return row; };
util.sorted_ids = () => { return []; };
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');