Bug 1111011-loop panel should close on 'Start a Conversation' click, r=MattN

This commit is contained in:
Dan Mosedale 2014-12-12 13:30:20 -08:00
Родитель 8e700c9dee
Коммит 3c36af6c35
3 изменённых файлов: 17 добавлений и 8 удалений

Просмотреть файл

@ -696,7 +696,7 @@ loop.panel = (function(_, mozL10n) {
* Room list.
*/
var RoomList = React.createClass({displayName: 'RoomList',
mixins: [Backbone.Events],
mixins: [Backbone.Events, sharedMixins.WindowCloseMixin],
propTypes: {
store: React.PropTypes.instanceOf(loop.store.RoomStore).isRequired,
@ -738,6 +738,8 @@ loop.panel = (function(_, mozL10n) {
},
handleCreateButtonClick: function() {
this.closeWindow();
this.props.dispatcher.dispatch(new sharedActions.CreateRoom({
nameTemplate: mozL10n.get("rooms_default_room_name_template"),
roomOwner: this.props.userDisplayName

Просмотреть файл

@ -696,7 +696,7 @@ loop.panel = (function(_, mozL10n) {
* Room list.
*/
var RoomList = React.createClass({
mixins: [Backbone.Events],
mixins: [Backbone.Events, sharedMixins.WindowCloseMixin],
propTypes: {
store: React.PropTypes.instanceOf(loop.store.RoomStore).isRequired,
@ -738,6 +738,8 @@ loop.panel = (function(_, mozL10n) {
},
handleCreateButtonClick: function() {
this.closeWindow();
this.props.dispatcher.dispatch(new sharedActions.CreateRoom({
nameTemplate: mozL10n.get("rooms_default_room_name_template"),
roomOwner: this.props.userDisplayName

Просмотреть файл

@ -897,7 +897,7 @@ describe("loop.panel", function() {
});
describe("loop.panel.RoomList", function() {
var roomStore, dispatcher, fakeEmail;
var roomStore, dispatcher, fakeEmail, dispatch;
beforeEach(function() {
fakeEmail = "fakeEmail@example.com";
@ -911,6 +911,7 @@ describe("loop.panel", function() {
rooms: [],
error: undefined
});
dispatch = sandbox.stub(dispatcher, "dispatch");
});
function createTestComponent() {
@ -922,8 +923,6 @@ describe("loop.panel", function() {
}
it("should dispatch a GetAllRooms action on mount", function() {
var dispatch = sandbox.stub(dispatcher, "dispatch");
createTestComponent();
sinon.assert.calledOnce(dispatch);
@ -934,7 +933,6 @@ describe("loop.panel", function() {
"conversation button",
function() {
navigator.mozLoop.userProfile = {email: fakeEmail};
var dispatch = sandbox.stub(dispatcher, "dispatch");
var view = createTestComponent();
TestUtils.Simulate.click(view.getDOMNode().querySelector("button"));
@ -945,9 +943,17 @@ describe("loop.panel", function() {
}));
});
it("should close the panel when 'Start a Conversation' is clicked",
function() {
var view = createTestComponent();
TestUtils.Simulate.click(view.getDOMNode().querySelector("button"));
sinon.assert.calledOnce(fakeWindow.close);
});
it("should disable the create button when a creation operation is ongoing",
function() {
var dispatch = sandbox.stub(dispatcher, "dispatch");
roomStore.setStoreState({pendingCreation: true});
var view = createTestComponent();
@ -958,7 +964,6 @@ describe("loop.panel", function() {
it("should disable the create button when a list retrieval operation is pending",
function() {
var dispatch = sandbox.stub(dispatcher, "dispatch");
roomStore.setStoreState({pendingInitialRetrieval: true});
var view = createTestComponent();