From e64059de79d847e2d9993b4c15cdc1d65e5289df Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 8 Apr 2020 13:50:00 +0000 Subject: [PATCH] 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. --- frontend_tests/node_tests/activity.js | 1 - frontend_tests/node_tests/buddy_data.js | 2 -- frontend_tests/node_tests/channel.js | 3 --- frontend_tests/node_tests/compose.js | 1 - frontend_tests/node_tests/emoji.js | 1 - frontend_tests/node_tests/input_pill.js | 3 --- frontend_tests/node_tests/lightbox.js | 2 -- frontend_tests/node_tests/markdown.js | 2 -- frontend_tests/node_tests/message_list_data.js | 1 - frontend_tests/node_tests/people.js | 4 ---- frontend_tests/node_tests/people_errors.js | 12 ------------ frontend_tests/node_tests/poll_widget.js | 1 - frontend_tests/node_tests/reactions.js | 5 ----- frontend_tests/node_tests/settings_user_groups.js | 1 - frontend_tests/node_tests/stream_data.js | 3 --- frontend_tests/node_tests/topic_generator.js | 1 - frontend_tests/node_tests/user_groups.js | 3 --- frontend_tests/node_tests/vdom.js | 1 - frontend_tests/node_tests/widgetize.js | 1 - frontend_tests/node_tests/zblueslip.js | 3 --- 20 files changed, 51 deletions(-) diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js index de9e211318..21b30a5d1c 100644 --- a/frontend_tests/node_tests/activity.js +++ b/frontend_tests/node_tests/activity.js @@ -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(); }); diff --git a/frontend_tests/node_tests/buddy_data.js b/frontend_tests/node_tests/buddy_data.js index 5099ece3e8..573ec38035 100644 --- a/frontend_tests/node_tests/buddy_data.js +++ b/frontend_tests/node_tests/buddy_data.js @@ -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); }); diff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.js index 9a3beb0864..b6308e5bd8 100644 --- a/frontend_tests/node_tests/channel.js +++ b/frontend_tests/node_tests/channel.js @@ -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(); }); diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index 7f7896adaf..1f8058cbc3 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -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. diff --git a/frontend_tests/node_tests/emoji.js b/frontend_tests/node_tests/emoji.js index 388c92803b..009818a4ea 100644 --- a/frontend_tests/node_tests/emoji.js +++ b/frontend_tests/node_tests/emoji.js @@ -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(); }); diff --git a/frontend_tests/node_tests/input_pill.js b/frontend_tests/node_tests/input_pill.js index e7a1f47635..de72ffbcd5 100644 --- a/frontend_tests/node_tests/input_pill.js +++ b/frontend_tests/node_tests/input_pill.js @@ -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; diff --git a/frontend_tests/node_tests/lightbox.js b/frontend_tests/node_tests/lightbox.js index 29a2f39100..177e05a6e7 100644 --- a/frontend_tests/node_tests/lightbox.js +++ b/frontend_tests/node_tests/lightbox.js @@ -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); }); diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index 037cf2d078..88b7fbad43 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -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(); }); diff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.js index d8726803b8..47a869cc72 100644 --- a/frontend_tests/node_tests/message_list_data.js +++ b/frontend_tests/node_tests/message_list_data.js @@ -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); }); diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js index a68a8e5aea..e05ea4499a 100644 --- a/frontend_tests/node_tests/people.js +++ b/frontend_tests/node_tests/people.js @@ -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(); }); diff --git a/frontend_tests/node_tests/people_errors.js b/frontend_tests/node_tests/people_errors.js index b5be8c4723..1c289eebfa 100644 --- a/frontend_tests/node_tests/people_errors.js +++ b/frontend_tests/node_tests/people_errors.js @@ -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'); diff --git a/frontend_tests/node_tests/poll_widget.js b/frontend_tests/node_tests/poll_widget.js index ef4db2dcb9..1f9f7eace9 100644 --- a/frontend_tests/node_tests/poll_widget.js +++ b/frontend_tests/node_tests/poll_widget.js @@ -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'); diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js index b10209e12c..e014c742f6 100644 --- a/frontend_tests/node_tests/reactions.js +++ b/frontend_tests/node_tests/reactions.js @@ -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; diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js index abcdb4768f..8ddb3b1160 100644 --- a/frontend_tests/node_tests/settings_user_groups.js +++ b/frontend_tests/node_tests/settings_user_groups.js @@ -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); diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js index b8fed55103..725b3e5c06 100644 --- a/frontend_tests/node_tests/stream_data.js +++ b/frontend_tests/node_tests/stream_data.js @@ -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); diff --git a/frontend_tests/node_tests/topic_generator.js b/frontend_tests/node_tests/topic_generator.js index 8a44e5fe8a..bf90ce095a 100644 --- a/frontend_tests/node_tests/topic_generator.js +++ b/frontend_tests/node_tests/topic_generator.js @@ -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(); }); diff --git a/frontend_tests/node_tests/user_groups.js b/frontend_tests/node_tests/user_groups.js index 2dd2316bbf..a3a40f1247 100644 --- a/frontend_tests/node_tests/user_groups.js +++ b/frontend_tests/node_tests/user_groups.js @@ -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(); }); diff --git a/frontend_tests/node_tests/vdom.js b/frontend_tests/node_tests/vdom.js index efc7aa8666..0549221143 100644 --- a/frontend_tests/node_tests/vdom.js +++ b/frontend_tests/node_tests/vdom.js @@ -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', diff --git a/frontend_tests/node_tests/widgetize.js b/frontend_tests/node_tests/widgetize.js index 491ec5b60d..6e1bca4661 100644 --- a/frontend_tests/node_tests/widgetize.js +++ b/frontend_tests/node_tests/widgetize.js @@ -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(); diff --git a/frontend_tests/node_tests/zblueslip.js b/frontend_tests/node_tests/zblueslip.js index e56e240095..bd8575678f 100644 --- a/frontend_tests/node_tests/zblueslip.js +++ b/frontend_tests/node_tests/zblueslip.js @@ -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(); });