diff --git a/browser/components/loop/content/js/conversation.js b/browser/components/loop/content/js/conversation.js index 7875c430fb6f..ec9eab2278e6 100644 --- a/browser/components/loop/content/js/conversation.js +++ b/browser/components/loop/content/js/conversation.js @@ -400,9 +400,12 @@ loop.conversation = (function(mozL10n) { return; } - if (progressData.reason === "timeout" && - (previousState === "init" || previousState === "alerting")) { - this._abortIncomingCall(); + if (progressData.reason === "timeout") { + if (previousState === "init" || previousState === "alerting") { + this._abortIncomingCall(); + } else { + this.setState({callFailed: true, callStatus: "end"}); + } } }, diff --git a/browser/components/loop/content/js/conversation.jsx b/browser/components/loop/content/js/conversation.jsx index 4ba0840f8a91..54e913042dca 100644 --- a/browser/components/loop/content/js/conversation.jsx +++ b/browser/components/loop/content/js/conversation.jsx @@ -400,9 +400,12 @@ loop.conversation = (function(mozL10n) { return; } - if (progressData.reason === "timeout" && - (previousState === "init" || previousState === "alerting")) { - this._abortIncomingCall(); + if (progressData.reason === "timeout") { + if (previousState === "init" || previousState === "alerting") { + this._abortIncomingCall(); + } else { + this.setState({callFailed: true, callStatus: "end"}); + } } }, diff --git a/browser/components/loop/standalone/content/js/webapp.js b/browser/components/loop/standalone/content/js/webapp.js index fca7986f1f7e..3dc44757a2b5 100644 --- a/browser/components/loop/standalone/content/js/webapp.js +++ b/browser/components/loop/standalone/content/js/webapp.js @@ -833,7 +833,9 @@ loop.webapp = (function($, _, OT, mozL10n) { * Handles ending a call by resetting the view to the start state. */ _endCall: function() { - this.setState({callStatus: "end"}); + if (this.state.callStatus !== "failure") { + this.setState({callStatus: "end"}); + } }, }); diff --git a/browser/components/loop/standalone/content/js/webapp.jsx b/browser/components/loop/standalone/content/js/webapp.jsx index 9a5523ee0e05..ca683dd98195 100644 --- a/browser/components/loop/standalone/content/js/webapp.jsx +++ b/browser/components/loop/standalone/content/js/webapp.jsx @@ -833,7 +833,9 @@ loop.webapp = (function($, _, OT, mozL10n) { * Handles ending a call by resetting the view to the start state. */ _endCall: function() { - this.setState({callStatus: "end"}); + if (this.state.callStatus !== "failure") { + this.setState({callStatus: "end"}); + } }, }); diff --git a/browser/components/loop/test/desktop-local/conversation_test.js b/browser/components/loop/test/desktop-local/conversation_test.js index cab1bd455356..f22cc229d86a 100644 --- a/browser/components/loop/test/desktop-local/conversation_test.js +++ b/browser/components/loop/test/desktop-local/conversation_test.js @@ -39,7 +39,7 @@ describe("loop.conversation", function() { return "en-US"; }, setLoopCharPref: sinon.stub(), - getLoopCharPref: sinon.stub().returns(null), + getLoopCharPref: sinon.stub().returns("http://fakeurl"), getLoopBoolPref: sinon.stub(), getCallData: sinon.stub(), releaseCallData: sinon.stub(), @@ -410,6 +410,8 @@ describe("loop.conversation", function() { describe("WebSocket Events", function() { describe("Call cancelled or timed out before acceptance", function() { beforeEach(function() { + // Mounting the test component automatically calls the required + // setup functions icView = mountTestComponent(); promise = new Promise(function(resolve, reject) { resolve(); @@ -539,6 +541,22 @@ describe("loop.conversation", function() { }); }); }); + + describe("progress - terminated - timeout (previousState not init" + + " nor alerting)", + function() { + it("should set the state to end", function(done) { + promise.then(function() { + icView._websocket.trigger("progress", { + state: "terminated", + reason: "timeout" + }, "connecting"); + + expect(icView.state.callStatus).eql("end"); + done(); + }); + }); + }); }); }); }); diff --git a/browser/components/loop/test/standalone/webapp_test.js b/browser/components/loop/test/standalone/webapp_test.js index 2c33bca17dc4..dab16d448b46 100644 --- a/browser/components/loop/test/standalone/webapp_test.js +++ b/browser/components/loop/test/standalone/webapp_test.js @@ -308,12 +308,24 @@ describe("loop.webapp", function() { }); describe("session:ended", function() { - it("should set display the StartConversationView", function() { + it("should display the StartConversationView", function() { conversation.trigger("session:ended"); TestUtils.findRenderedComponentWithType(ocView, loop.webapp.EndedConversationView); }); + + it("should display the FailedConversationView if callStatus is failure", + function() { + ocView.setState({ + callStatus: "failure" + }); + conversation.trigger("session:ended"); + + var failedView = TestUtils.findRenderedComponentWithType(ocView, + loop.webapp.FailedConversationView); + expect(failedView).to.not.equal(null); + }); }); describe("session:peer-hungup", function() {