mirror of https://github.com/zulip/zulip.git
node tests: Remove most test_log length assertions.
For all the places where we just make zero or one blueslip call, asserting for length is either unnecessary or overkill.
This commit is contained in:
parent
9943a07e8c
commit
e64059de79
|
@ -159,7 +159,6 @@ run_test('get_status', () => {
|
|||
run_test('reload_defaults', () => {
|
||||
blueslip.expect('warn', 'get_filter_text() is called before initialization');
|
||||
assert.equal(activity.get_filter_text(), '');
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -282,6 +282,4 @@ run_test('error handling', () => {
|
|||
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();
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
});
|
||||
|
|
|
@ -234,7 +234,6 @@ run_test('unexpected_403_response', () => {
|
|||
check_ajax_options: function (options) {
|
||||
blueslip.expect('error', 'Unexpected 403 response from server');
|
||||
options.simulate_error();
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
},
|
||||
});
|
||||
|
@ -265,7 +264,6 @@ run_test('retry', () => {
|
|||
},
|
||||
});
|
||||
|
||||
assert.equal(blueslip.get_test_logs('log').length, 1);
|
||||
assert.equal(blueslip.get_test_logs('log')[0].message, 'Retrying idempotent[object Object]');
|
||||
blueslip.reset();
|
||||
},
|
||||
|
@ -284,7 +282,6 @@ run_test('too_many_pending', () => {
|
|||
_.times(50, function () {
|
||||
channel.post({});
|
||||
});
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -1254,7 +1254,6 @@ run_test('on_events', () => {
|
|||
assert(!helper.container_was_removed());
|
||||
assert(!$("#compose_invite_users").visible());
|
||||
assert.equal($('#compose-error-msg').html(), "Stream no longer exists: no-stream");
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
// !sub will result in true here and we check the success code path.
|
||||
|
|
|
@ -45,7 +45,6 @@ run_test('get_canonical_name', () => {
|
|||
|
||||
blueslip.expect('error', 'Invalid emoji name: non_existent');
|
||||
emoji.get_canonical_name('non_existent');
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ run_test('basics', () => {
|
|||
|
||||
blueslip.expect('error', 'Pill needs container.');
|
||||
input_pill.create(config);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
const pill_input = $.create('pill_input');
|
||||
|
@ -61,13 +60,11 @@ run_test('basics', () => {
|
|||
blueslip.expect('error', 'Pill needs create_item_from_text');
|
||||
config.container = container;
|
||||
input_pill.create(config);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Pill needs get_text_from_item');
|
||||
config.create_item_from_text = noop;
|
||||
input_pill.create(config);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
config.get_text_from_item = noop;
|
||||
|
|
|
@ -41,7 +41,6 @@ run_test('pan_and_zoom', () => {
|
|||
$.stub_selector('.focused_table .message_inline_image img', []);
|
||||
|
||||
lightbox.open(img);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 0);
|
||||
|
||||
assert.equal(fetched_zid, 1234);
|
||||
});
|
||||
|
@ -76,5 +75,4 @@ run_test('youtube', () => {
|
|||
|
||||
lightbox.open(img);
|
||||
assert.equal($('.image-actions .open').attr('href'), href);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 0);
|
||||
});
|
||||
|
|
|
@ -583,7 +583,6 @@ run_test('python_to_js_filter', () => {
|
|||
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
|
||||
expected_value = [];
|
||||
assert.deepEqual(actual_value, expected_value);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
@ -592,7 +591,6 @@ run_test('katex_throws_unexpected_exceptions', () => {
|
|||
blueslip.expect('error', 'Error: some-exception');
|
||||
const message = { raw_content: '$$a$$' };
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -213,5 +213,4 @@ run_test('errors', () => {
|
|||
blueslip.expect('error', 'Duplicate message added to MessageListData');
|
||||
mld._hash.set(1, 'taken');
|
||||
mld._add_to_hash(make_msgs([1]));
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
});
|
||||
|
|
|
@ -155,7 +155,6 @@ run_test('basics', () => {
|
|||
// Invalid user ID returns false and warns.
|
||||
blueslip.expect('warn', 'Unexpectedly invalid user_id in user popover query: 123412');
|
||||
assert.equal(people.is_active_user_for_popover(123412), false);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
// We can still get their info for non-realm needs.
|
||||
|
@ -808,7 +807,6 @@ run_test('updates', () => {
|
|||
'FOO@example.com new email = bar@example.com');
|
||||
person = people.get_by_email(old_email);
|
||||
assert.equal(person.user_id, user_id);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
@ -914,7 +912,6 @@ run_test('track_duplicate_full_names', () => {
|
|||
|
||||
blueslip.expect('warn', 'get_mention_syntax called without user_id.');
|
||||
assert.equal(people.get_mention_syntax('Stephen King'), '@**Stephen King**');
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
assert.equal(people.get_mention_syntax('Stephen King', 601), '@**Stephen King|601**');
|
||||
assert.equal(people.get_mention_syntax('Stephen King', 602), '@**Stephen King|602**');
|
||||
|
@ -1061,6 +1058,5 @@ run_test('emails_strings_to_user_ids_array', function () {
|
|||
blueslip.expect('warn', 'Unknown emails: dummyuser@example.com');
|
||||
user_ids = people.emails_strings_to_user_ids_array('dummyuser@example.com');
|
||||
assert.equal(user_ids, undefined);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
|
|
@ -20,14 +20,11 @@ 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');
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
reload_state.is_in_progress = return_true;
|
||||
people.report_late_add(55, 'foo@example.com');
|
||||
assert.equal(blueslip.get_test_logs('log').length, 1);
|
||||
assert.equal(blueslip.get_test_logs('log')[0].message, 'Added user late: user_id=55 email=foo@example.com');
|
||||
assert.equal(blueslip.get_test_logs('error').length, 0);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
@ -47,17 +44,14 @@ run_test('blueslip', () => {
|
|||
|
||||
blueslip.expect('debug', 'User email operand unknown: ' + unknown_email);
|
||||
people.id_matches_email_operand(42, unknown_email);
|
||||
assert.equal(blueslip.get_test_logs('debug').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Unknown user_id: 9999');
|
||||
people.get_actual_name_from_user_id(9999);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Unknown email for get_user_id: ' + unknown_email);
|
||||
people.get_user_id(unknown_email);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('warn', 'No user_id provided for person@example.com');
|
||||
|
@ -67,23 +61,19 @@ run_test('blueslip', () => {
|
|||
full_name: 'Person Person',
|
||||
};
|
||||
people.add(person);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
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);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('warn', 'Unknown user ids: 1,2');
|
||||
people.user_ids_string_to_emails_string('1,2');
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('warn', 'Unknown emails: ' + unknown_email);
|
||||
people.email_list_to_user_ids_string([unknown_email]);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
let message = {
|
||||
|
@ -125,7 +115,6 @@ run_test('blueslip', () => {
|
|||
blueslip.expect('error', 'Unknown user id in message: 42');
|
||||
const reply_to = people.pm_reply_to(message);
|
||||
assert(reply_to.includes('?'));
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
people.pm_with_user_ids = function () { return [42]; };
|
||||
|
@ -133,7 +122,6 @@ run_test('blueslip', () => {
|
|||
blueslip.expect('error', 'Unknown people in message');
|
||||
const uri = people.pm_with_url({});
|
||||
assert.equal(uri.indexOf('unk'), uri.length - 3);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
blueslip.expect('error', 'Undefined field id');
|
||||
|
|
|
@ -92,7 +92,6 @@ run_test('poll_data_holder my question', () => {
|
|||
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();
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
const option_outbound_event = data_holder.handle.new_option.outbound('new option');
|
||||
|
|
|
@ -210,7 +210,6 @@ run_test('sending', () => {
|
|||
blueslip.expect('warn', 'XHR Error Message.');
|
||||
global.channel.xhr_error_message = function () {return 'XHR Error Message.';};
|
||||
args.error();
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
emoji_name = 'alien'; // not set yet
|
||||
|
@ -259,7 +258,6 @@ run_test('sending', () => {
|
|||
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);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
reactions.add_reaction = orig_add_reaction;
|
||||
reactions.remove_reaction = orig_remove_reaction;
|
||||
|
@ -641,15 +639,12 @@ run_test('error_handling', () => {
|
|||
const original_func = reactions.current_user_has_reacted_to_emoji;
|
||||
reactions.current_user_has_reacted_to_emoji = function () { return true; };
|
||||
reactions.toggle_emoji_reaction(55, bogus_event.emoji_name);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
reactions.current_user_has_reacted_to_emoji = original_func;
|
||||
blueslip.reset();
|
||||
|
||||
reactions.add_reaction(bogus_event);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 0);
|
||||
|
||||
reactions.remove_reaction(bogus_event);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 0);
|
||||
});
|
||||
|
||||
message_store.get = () => message;
|
||||
|
|
|
@ -320,7 +320,6 @@ run_test('populate_user_groups', () => {
|
|||
assert(user_groups_list_append_called);
|
||||
assert(get_by_user_id_called);
|
||||
assert(input_typeahead_called);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
test_create_item(create_item_handler);
|
||||
|
||||
|
|
|
@ -254,7 +254,6 @@ run_test('subscribers', () => {
|
|||
|
||||
blueslip.expect('warn', 'Undefined user_id passed to function is_user_subscribed');
|
||||
assert.equal(stream_data.is_user_subscribed('Rome', undefined), undefined);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
|
||||
// Verify noop for bad stream when removing subscriber
|
||||
const bad_stream = 'UNKNOWN';
|
||||
|
@ -591,7 +590,6 @@ run_test('delete_sub', () => {
|
|||
|
||||
blueslip.expect('warn', 'Failed to delete stream 99999');
|
||||
stream_data.delete_sub(99999);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
@ -605,7 +603,6 @@ run_test('get_subscriber_count', () => {
|
|||
|
||||
blueslip.expect('warn', 'We got a get_subscriber_count count call for a non-existent stream.');
|
||||
assert.equal(stream_data.get_subscriber_count('India'), undefined);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
stream_data.add_sub(india);
|
||||
|
|
|
@ -180,7 +180,6 @@ run_test('fchain', () => {
|
|||
ints = tg.list_generator([29, 43]);
|
||||
gen = tg.fchain(ints, undef);
|
||||
gen.next();
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -49,14 +49,12 @@ run_test('user_groups', () => {
|
|||
|
||||
blueslip.expect('error', 'Unknown group_id in get_user_group_from_id: ' + all.id);
|
||||
assert.equal(user_groups.get_user_group_from_id(all.id), undefined);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
user_groups.remove(students);
|
||||
|
||||
blueslip.expect('error', 'Unknown group_id in get_user_group_from_id: ' + students.id);
|
||||
assert.equal(user_groups.get_user_group_from_id(students.id), undefined);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
assert.equal(user_groups.get_user_group_from_name(all.name), undefined);
|
||||
|
@ -91,6 +89,5 @@ run_test('user_groups', () => {
|
|||
|
||||
blueslip.expect('error', 'Could not find user group with ID -1');
|
||||
assert.equal(user_groups.is_member_of(-1, 15), false);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
|
|
@ -285,7 +285,6 @@ run_test('error checking', () => {
|
|||
const ul = {opts: { attrs: [] }};
|
||||
|
||||
vdom.update(replace_content, find, ul, ul);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
|
||||
blueslip.expect(
|
||||
'error',
|
||||
|
|
|
@ -135,7 +135,6 @@ run_test('activate', () => {
|
|||
assert(!is_widget_elem_inserted);
|
||||
assert(!is_widget_activated);
|
||||
assert(!is_event_handled);
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
assert.equal(blueslip.get_test_logs('warn')[0].more_info, 'invalid_widget');
|
||||
blueslip.reset();
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ run_test('basics', () => {
|
|||
// throw an error.
|
||||
assert.throws(throw_an_error);
|
||||
// zblueslip logs all the calls made to it, and they can be used in asserts like:
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
|
||||
// Now, let's add our error to the list of expected errors.
|
||||
blueslip.expect('error', 'world');
|
||||
|
@ -49,7 +48,6 @@ run_test('basics', () => {
|
|||
// should be thrown directly by blueslip.
|
||||
blueslip.reset();
|
||||
assert.throws(throw_an_error);
|
||||
assert.equal(blueslip.get_test_logs('error').length, 1);
|
||||
blueslip.reset();
|
||||
|
||||
// Let's repeat the above procedue with warnings. Unlike errors,
|
||||
|
@ -68,6 +66,5 @@ run_test('basics', () => {
|
|||
// indeed had logged a warning, we can check the length of the warning logs
|
||||
blueslip.expect('warn', 'world');
|
||||
throw_a_warning();
|
||||
assert.equal(blueslip.get_test_logs('warn').length, 1);
|
||||
blueslip.reset();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue