Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
timestamp: Throw error if frontend cannot parse backend supplied time.
Rohitt Vashishtha1f765b41ced5
diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.jsindex f2a5e2988ad..0971f3bad89 100644--- a/frontend_tests/node_tests/rendered_markdown.js+++ b/frontend_tests/node_tests/rendered_markdown.js@@ -165,6 +165,7 @@ run_test('timestamp', () => {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 assertsassert.equal($timestamp.text(), 'never-been-set');@@ -175,7 +176,7 @@ run_test('timestamp', () => {// Final assertsassert.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(), 'translated: Could not parse timestamp.');+ assert.equal($timestamp_invalid.text(), 'never-been-set');});run_test('timestamp-error', () => {diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.jsindex a5cefa1796d..b573cd9cd36 100644--- a/static/js/rendered_markdown.js+++ b/static/js/rendered_markdown.js@@ -158,7 +158,8 @@ exports.update_elements = (content) => {$(this).text(rendered_time.text);$(this).attr('title', rendered_time.title);} else {- $(this).text(i18n.t('Could not parse timestamp.'));+ // This shouldn't happen. If it does, we're very interested in debugging it.+ blueslip.error(`Moment could not parse datetime supplied by backend: ${time_str}`);}});