Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
S14672 Search "in:[username]" returns results in DMs (#2846)
Browse files Browse the repository at this point in the history
* S14672 Search "in:[username]" returns results in DMs

* addressing review comments

* addressing review comments
  • Loading branch information
composednitin authored and saturninoabril committed May 29, 2019
1 parent 37a8efd commit b843a6c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/sidebar/channel_create.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default class ChannelCreate extends React.PureComponent {
<button
className='add-channel-btn cursor--pointer style--none'
onClick={this.props.createDirectMessage}
id='addDirectChannel'
>
{'+'}
</button>
Expand Down
62 changes: 62 additions & 0 deletions cypress/integration/search/search_user_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// ***************************************************************
// - [number] indicates a test step (e.g. 1. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

/*eslint max-nested-callbacks: ["error", 3]*/

import users from '../../fixtures/users.json';

/**
* create new DM channel
* @param {String} text - DM channel name
*/
function createNewDMChannel(channelname) {
cy.get('#addDirectChannel').scrollIntoView().click();

cy.get('#selectItems').within(() => {
cy.get('input[type="text"]').scrollIntoView().type(channelname, {force: true});
});

cy.contains('.more-modal__description', channelname).click({force: true});
cy.get('#saveItems').click();
}

describe('Search in DMs', () => {
it('S14672 Search "in:[username]" returns results in DMs', () => {
// # Login and navigate to the app
cy.apiLogin('user-1');
cy.visit('/');
const message = 'Hello' + Date.now();

// # Ensure Direct Message is visible in LHS sidebar
cy.get('#directChannel').scrollIntoView().should('be.visible');

// # Create new DM channel with user's email
createNewDMChannel(users['user-2'].email);

// # Post message to user
cy.postMessage(message + '{enter}');

// # Type `in:` in searchbox
cy.get('#searchBox').type('in:');

// # Select user from suggestion list
cy.contains('.search-autocomplete__item', `@${users['user-2'].username}`).click();

// # Validate searchbox contains the username
cy.get('#searchBox').should('have.value', 'in:@' + users['user-2'].username + ' ');

// # Press Enter in searchbox
cy.get('#searchBox').type(message).type('{enter}');

// # Search message in each filtered result
cy.get('#search-items-container').find('.search-highlight').each(($el) => {
cy.wrap($el).should('have.text', message);
});
});
});

0 comments on commit b843a6c

Please sign in to comment.