From bc69521caa242b12437b9f16fd539d4c6ef26ce8 Mon Sep 17 00:00:00 2001 From: YashRE42 <33805964+YashRE42@users.noreply.github.com> Date: Sat, 20 Jun 2020 19:14:09 +0000 Subject: [PATCH] server_events_dispatch: Throw from "subscription" based on event.op. --- frontend_tests/node_tests/dispatch.js | 6 ++++++ static/js/server_events_dispatch.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index 290ec29bda..587e6de9ae 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -5,6 +5,7 @@ const {strict: assert} = require("assert"); const {mock_cjs, mock_esm, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); +const blueslip = require("../zjsunit/zblueslip"); const $ = require("../zjsunit/zjquery"); const noop = () => {}; @@ -875,3 +876,8 @@ run_test("realm_export", (override) => { const args = stub.get_args("exports"); assert.equal(args.exports, event.exports); }); + +run_test("server_event_dispatch_op_errors", () => { + blueslip.expect("error", "Unexpected event type subscription/other"); + server_events_dispatch.dispatch_normal_event({type: "subscription", op: "other"}); +}); diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js index 924becaa84..bce34ec450 100644 --- a/static/js/server_events_dispatch.js +++ b/static/js/server_events_dispatch.js @@ -471,6 +471,9 @@ export function dispatch_normal_event(event) { case "update": stream_events.update_property(event.stream_id, event.property, event.value); break; + default: + blueslip.error("Unexpected event type subscription/" + event.op); + break; } break; case "typing":