Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chat view when leaving current room #871

Merged
merged 5 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@
this.initGuestName();
}

this._sidebarView.listenTo(roomChannel, 'leaveCurrentCall', function() {
this._sidebarView.listenTo(roomChannel, 'leaveCurrentRoom', function() {
this.disable();
});

Expand All @@ -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));
},
Expand Down
2 changes: 1 addition & 1 deletion js/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion js/views/roomlistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
},
Expand Down
27 changes: 26 additions & 1 deletion tests/acceptance/features/bootstrap/ConversationListContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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");
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions tests/acceptance/features/bootstrap/TalkAppContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
}

/**
Expand Down
65 changes: 64 additions & 1 deletion tests/acceptance/features/conversation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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