diff --git a/js/app.js b/js/app.js index 69fd3e3a2fc..400279ad2ae 100644 --- a/js/app.js +++ b/js/app.js @@ -560,7 +560,7 @@ this.initGuestName(); } - this._sidebarView.listenTo(roomChannel, 'leaveCurrentCall', function() { + this._sidebarView.listenTo(roomChannel, 'leaveCurrentRoom', function() { this.disable(); }); @@ -571,10 +571,15 @@ guestNameModel: this._localStorageModel }); - this._messageCollection.listenTo(roomChannel, 'leaveCurrentCall', function() { + this._messageCollection.listenTo(roomChannel, 'leaveCurrentRoom', function() { this.stopReceivingMessages(); }); + this.listenTo(roomChannel, 'leaveCurrentRoom', function() { + this._chatView.$el.detach(); + this._chatViewInMainView = false; + }); + $(document).on('click', this.onDocumentClick); OC.Util.History.addOnPopStateHandler(_.bind(this._onPopState, this)); }, diff --git a/js/connection.js b/js/connection.js index 7d19f333a3f..846978e1f7e 100644 --- a/js/connection.js +++ b/js/connection.js @@ -98,7 +98,7 @@ OC.Util.History.pushState({}, OC.generateUrl('/apps/spreed')); $('#app-content').removeClass('incall'); this.showRoomDeletedMessage(deleter); - roomsChannel.trigger('leaveCurrentCall'); + roomsChannel.trigger('leaveCurrentRoom'); }, joinCall: function(token) { if (this.app.signaling.currentCallToken === token) { diff --git a/js/views/roomlistview.js b/js/views/roomlistview.js index 67c9a019426..2668188fd16 100644 --- a/js/views/roomlistview.js +++ b/js/views/roomlistview.js @@ -210,7 +210,6 @@ return; } - OCA.SpreedMe.app._chatView.$el.detach(); OCA.SpreedMe.app.connection.leaveCurrentRoom(true); OC.Util.History.pushState({}, OC.generateUrl('/apps/spreed')); }, diff --git a/tests/acceptance/features/bootstrap/ConversationListContext.php b/tests/acceptance/features/bootstrap/ConversationListContext.php index 9ce5d01d220..ad6ff3c6a06 100644 --- a/tests/acceptance/features/bootstrap/ConversationListContext.php +++ b/tests/acceptance/features/bootstrap/ConversationListContext.php @@ -106,6 +106,13 @@ public static function removeConversationFromListMenuItemFor($conversation) { return self::conversationMenuItemFor($conversation, "Remove conversation from list"); } + /** + * @return Locator + */ + public static function deleteConversationMenuItemFor($conversation) { + return self::conversationMenuItemFor($conversation, "Delete conversation"); + } + /** * @Given I create a group conversation */ @@ -163,6 +170,14 @@ public function iRemoveTheConversationFromTheList($conversation) { $this->actor->find(self::removeConversationFromListMenuItemFor($conversation), 2)->click(); } + /** + * @Given I delete the :conversation conversation + */ + public function iDeleteTheConversation($conversation) { + $this->actor->find(self::conversationMenuButtonFor($conversation), 10)->click(); + $this->actor->find(self::deleteConversationMenuItemFor($conversation), 2)->click(); + } + /** * @Then I see that the :conversation conversation is not shown in the list */ @@ -179,7 +194,17 @@ public function iSeeThatTheConversationIsNotShownInTheList($conversation) { * @Then I see that the :conversation conversation is active */ public function iSeeThatTheConversationIsActive($conversation) { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::activeConversationListItemFor($conversation), 10)->isVisible()); + // The active conversation list item may be hidden but exist in the DOM + // during the lapse between removing the conversation and getting the + // updated conversation list from the server, so it has to be explictly + // waited for it to be visible instead of relying on the implicit wait + // made to find the element. + if (!WaitFor::elementToBeEventuallyShown( + $this->actor, + self::activeConversationListItemFor($conversation), + $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { + PHPUnit_Framework_Assert::fail("The $conversation conversation is not active yet after $timeout seconds"); + } } /** diff --git a/tests/acceptance/features/bootstrap/TalkAppContext.php b/tests/acceptance/features/bootstrap/TalkAppContext.php index 21b83ec6979..43ec5ce0f41 100644 --- a/tests/acceptance/features/bootstrap/TalkAppContext.php +++ b/tests/acceptance/features/bootstrap/TalkAppContext.php @@ -103,9 +103,9 @@ public function iSeeThatTheCurrentPageIsTheTalkApp() { } /** - * @Then I see that the empty content message is shown in the main view + * @Then I see that the :text empty content message is shown in the main view */ - public function iSeeThatTheEmptyContentMessageIsShownInTheMainView() { + public function iSeeThatTheEmptyContentMessageIsShownInTheMainView($text) { // The empty content always exists in the DOM, so it has to be explictly // waited for it to be visible instead of relying on the implicit wait // made to find the element. @@ -115,6 +115,8 @@ public function iSeeThatTheEmptyContentMessageIsShownInTheMainView() { $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { PHPUnit_Framework_Assert::fail("The empty content was not shown yet after $timeout seconds"); } + + PHPUnit_Framework_Assert::assertEquals($text, $this->actor->find(self::emptyContent())->getText()); } /** diff --git a/tests/acceptance/features/conversation.feature b/tests/acceptance/features/conversation.feature index 17e93316698..d41e6178669 100644 --- a/tests/acceptance/features/conversation.feature +++ b/tests/acceptance/features/conversation.feature @@ -51,5 +51,68 @@ Feature: conversation And I see that the "You" conversation is active When I remove the "You" conversation from the list Then I see that the "You" conversation is not shown in the list - And I see that the empty content message is shown in the main view + And I see that the "Join a conversation or start a new one" empty content message is shown in the main view And I see that the sidebar is closed + + Scenario: delete a one-to-one conversation + Given I act as John + And I am logged in + And I have opened the Talk app + And I create a one-to-one conversation with "admin" + And I see that the "admin" conversation is active + And I see that the chat is shown in the main view + And I see that the sidebar is open + And I act as Jane + And I am logged in as the admin + And I have opened the Talk app + And I open the "user0" conversation + And I see that the "user0" conversation is active + And I see that the chat is shown in the main view + And I see that the sidebar is open + When I act as John + And I delete the "admin" conversation + Then I see that the "admin" conversation is not shown in the list + And I see that the "Join a conversation or start a new one" empty content message is shown in the main view + And I see that the sidebar is closed + And I act as Jane + And I see that the "user0" conversation is not shown in the list + And I see that the "This call has ended" empty content message is shown in the main view + And I see that the sidebar is closed + + Scenario: create a new conversation after removing the active one + Given I am logged in + And I have opened the Talk app + And I create a group conversation + And I see that the "You" conversation is active + And I remove the "You" conversation from the list + And I see that the "You" conversation is not shown in the list + And I see that the "Join a conversation or start a new one" empty content message is shown in the main view + And I see that the sidebar is closed + When I create a group conversation + Then I see that the "You" conversation is active + And I see that the chat is shown in the main view + And I see that the sidebar is open + And I see that the number of participants shown in the list is "1" + And I see that "user0" is shown in the list of participants as a moderator + + Scenario: change to another conversation after removing the active one + Given I am logged in + And I have opened the Talk app + And I create a one-to-one conversation with "admin" + And I see that the "admin" conversation is active + And I see that the number of participants shown in the list is "2" + And I create a group conversation + And I see that the "admin" conversation is not active + And I see that the "You" conversation is active + And I see that the number of participants shown in the list is "1" + And I remove the "You" conversation from the list + And I see that the "You" conversation is not shown in the list + And I see that the "Join a conversation or start a new one" empty content message is shown in the main view + And I see that the sidebar is closed + When I open the "admin" conversation + Then I see that the "admin" conversation is active + And I see that the chat is shown in the main view + And I see that the sidebar is open + And I see that the number of participants shown in the list is "2" + And I see that "user0" is shown in the list of participants as a moderator + And I see that "admin" is shown in the list of participants as a moderator