diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index e251c6026..70b27154f 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -244,6 +244,13 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): assert f.response.headers["bar"] == "baz" assert f.response.text == "resp" + upd = { + "request": {"trailers": [("foo", "baz")], }, + "response": {"trailers": [("foo", "baz")], }, + } + assert self.put_json("/flows/42", upd).code == 200 + assert f.request.trailers["foo"] == "baz" + f.revert() assert self.put_json("/flows/42", {"foo": 42}).code == 400 @@ -257,13 +264,6 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): body="!!" ).code == 400 - upd = { - "request": {"trailers": [("foo", "baz")],}, - "response": {"trailers": [("foo", "baz")],}, - } - assert self.put_json("/flows/42", upd).code == 200 - assert f.request.trailers["foo"] == "baz" - def test_flow_duplicate(self): resp = self.fetch("/flows/42/duplicate", method="POST") assert resp.code == 200 diff --git a/web/src/js/__tests__/backends/websocketSpec.tsx b/web/src/js/__tests__/backends/websocketSpec.tsx index aedc80c63..a8a416338 100644 --- a/web/src/js/__tests__/backends/websocketSpec.tsx +++ b/web/src/js/__tests__/backends/websocketSpec.tsx @@ -49,7 +49,17 @@ test("websocket backend", async () => { {type: "EVENTS_RECEIVE", cmd: "receive", data: [], resource: "events"}, connectionActions.connectionEstablished(), ])) + store.clearActions() expect(fetchMock.mock.calls).toHaveLength(4); + console.error = jest.fn(); + backend.onClose(new CloseEvent("Connection closed")); + expect(console.error).toBeCalledTimes(1); + expect(store.getActions()[0].type).toEqual(connectionActions.ConnectionState.ERROR); + store.clearActions(); + + backend.onError(null); + expect(console.error).toBeCalledTimes(2); + jest.restoreAllMocks(); });