Этот коммит содержится в:
Mario Vitale
2023-03-27 16:28:42 +02:00
родитель da7a6825ce
Коммит ba6b97fb62
1142 изменённых файлов: 44 добавлений и 44 удалений

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

@@ -0,0 +1,67 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
import * as TIMEOUTS from '../../../fixtures/timeouts';
import * as MESSAGES from '../../../fixtures/messages';
describe('Search', () => {
before(() => {
// # Login as test user and visit off-topic
cy.apiInitSetup({loginAfter: true}).then(({offTopicUrl}) => {
cy.visit(offTopicUrl);
});
});
it('QuickInput clear X', () => {
// * X should not be visible on empty input
cy.uiGetSearchContainer().find('.input-clear-x').should('not.exist');
// # Write something on the input
cy.uiGetSearchBox().clear().type('abc');
// * The input should contain what we wrote
cy.uiGetSearchBox().should('have.value', 'abc');
// * The X should be visible
// # Then click X to clear the input field
cy.uiGetSearchContainer().
find('.input-clear-x').
should('be.visible').
click({force: true});
// * The X should not be visible since the input is cleared
cy.uiGetSearchContainer().find('.input-clear-x').should('not.exist');
// * The value of the input is empty
cy.uiGetSearchBox().should('have.value', '');
});
it('MM-T368 - Text in search box should not clear when Pinned or Saved posts icon is clicked', () => {
const searchText = MESSAGES.SMALL;
// * Verify search input field exists and not search button, as inputs contains placeholder not buttons/icons
// and then type in a search text
cy.uiGetSearchBox().click().wait(TIMEOUTS.HALF_SEC).type(searchText);
// # Click on the pinned post button from the header
cy.uiGetChannelPinButton().click();
// * Verify the pinned post RHS is open
cy.uiGetRHS().should('contain', 'Pinned Posts');
// # Now click on the saved post button from the header
cy.uiGetSavedPostButton().click();
// * Verify the pinned post RHS is open
cy.uiGetRHS().should('contain', 'Saved posts');
});
});

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

@@ -0,0 +1,55 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Search', () => {
const term = 'London';
before(() => {
// # Login as test user and visit off-topic
cy.apiInitSetup({loginAfter: true}).then(({offTopicUrl}) => {
cy.visit(offTopicUrl);
cy.postMessage(term);
cy.uiWaitUntilMessagePostedIncludes(term);
});
});
it('MM-T352 - Cleared search term should not reappear as RHS is opened and closed', () => {
// # Place the focus on the search box and search for something
cy.uiGetSearchContainer().should('be.visible').click();
cy.uiGetSearchBox().
type(`${term}{enter}`).
wait(TIMEOUTS.ONE_SEC).
clear();
cy.get('#searchbar-help-popup').should('be.visible');
cy.uiGetSearchContainer().type('{esc}');
// # Verify the Search side bar opens up
cy.uiGetRHS().should('contain', 'Search Results');
// # Close the search sidebar
// * Verify it is closed
cy.uiCloseRHS();
cy.uiGetRHS({visible: false});
// # Verify that the cleared search text does not appear on the search box
cy.uiGetSearchBox().should('be.empty');
// # Click the pin icon to open the pinned posts RHS
cy.uiGetChannelPinButton().click();
cy.uiGetRHS().should('contain', 'Pinned Posts');
// # Verify that the Search term input box is still cleared and search term does not reappear when RHS opens
cy.uiGetSearchBox().and('be.empty');
});
});

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

@@ -0,0 +1,82 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
function openSidebarMenu() {
// # Open the sidebar menu
cy.get('button.menu-toggle').click();
// * Verify the sidebar menu is open
cy.get('#sidebar-menu').should('be.visible');
}
function verifyLoadingSpinnerIsGone() {
// * Verify that the RHS is open
cy.get('#sidebar-right').should('be.visible');
// * Verify that the loading spinner is eventually gone
cy.get('#loadingSpinner').should('not.exist');
}
describe('Mobile Search', () => {
let townsquareLink;
before(() => {
// # Login as test user
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
townsquareLink = `/${team.name}/channels/town-square`;
});
});
beforeEach(() => {
// # Resize window to mobile view
cy.viewport('iphone-6');
// # Visit town-square
cy.visit(townsquareLink);
});
it('Opening the Recent Mentions eventually loads the results', () => {
// # Open the sidebar menu
openSidebarMenu();
// # Click the Recent Mentions button
cy.get('#recentMentions').click();
// * Verify that the loading spinner is eventually gone
verifyLoadingSpinnerIsGone();
});
it('Opening the Saved Posts eventually loads the results', () => {
// # Open the sidebar menu
openSidebarMenu();
// # Click the Saved Posts button
cy.get('#flaggedPosts').click();
// * Verify that the loading spinner is eventually gone
verifyLoadingSpinnerIsGone();
});
it('Searching eventually loads the results', () => {
// * Open the search box
cy.get('button.navbar-search').click();
// * Verify that the search box is open
cy.get('#sbrSearchBox').should('be.visible');
// # Type any string and hit Enter
cy.get('#sbrSearchBox').type('test').type('{enter}');
// * Verify that the loading spinner is eventually gone
verifyLoadingSpinnerIsGone();
});
});

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

@@ -0,0 +1,90 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search @not_cloud
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Search', () => {
before(() => {
cy.shouldNotRunOnCloudEdition();
cy.apiUpdateConfig({
ServiceSettings: {
EnableTesting: true,
},
});
});
beforeEach(() => {
cy.apiAdminLogin();
cy.apiInitSetup({loginAfter: true}).then(({offTopicUrl}) => {
cy.visit(offTopicUrl);
});
});
it('MM-T350 - Searching displays results in RHS', () => {
const testSearch = '/test url test-search';
// # Post a message
cy.postMessage(testSearch);
// # Search the world 'hello' that is generated by /test command
cy.get('#searchBox').click().type('hello{enter}').wait(TIMEOUTS.HALF_SEC).should('have.value', 'hello');
// # RHS should be visible with search results
cy.get('#search-items-container').should('be.visible');
// * Verify different display formatting of the search results
cy.get('[data-testid="search-item-container"]').first().then(($result) => {
cy.wrap($result).contains('Basic word search: Hello world!');
cy.wrap($result).get('h5.markdown__heading').contains('Hello');
cy.wrap($result).get('.post-code.post-code--wrap code').contains('Hello');
cy.wrap($result).contains('#hello');
// # Jump to conversation
cy.wrap($result).get('a.search-item__jump').first().click();
// * Search query clear icon is still present
cy.get('.input-clear.visible').should('be.visible');
// # Hover search query clear icon
cy.get('.input-clear-x').first().trigger('mouseover', {force: true}).then(($span) => {
// * Assert that tooltip has shown
cy.wrap($span).should('have.attr', 'aria-describedby', 'InputClearTooltip');
// # Click the clear query icon
cy.wrap($span).click({force: true});
// * Assert search results are intact
cy.get('[data-testid="search-item-container"]').should('be.visible');
});
});
});
it('MM-T2286 - Clicking a hashtag from a message opens messages with that hashtag on RHS', () => {
const testSearch = '/test url test-search';
// # Post message
cy.postMessage(testSearch);
// # Expand the test-search message
cy.get('#showMoreButton').click().wait(TIMEOUTS.HALF_SEC);
// # Click the #hello on the test-search message
cy.get('[data-hashtag="#hello"]').first().click().wait(TIMEOUTS.HALF_SEC);
// # RHS should be visible with search results
cy.get('#search-items-container').should('be.visible');
// * Assert search results are present and correct
cy.get('[data-testid="search-item-container"]').should('be.visible').should('contain.text', '#hello');
});
});

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

@@ -0,0 +1,201 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Search', () => {
let testTeam;
let testUser;
before(() => {
// Initialize a user.
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
});
});
beforeEach(() => {
cy.apiAdminLogin();
// Visit town square as an admin
cy.visit(`/${testTeam.name}/channels/town-square`);
});
it('MM-T353 After clearing search query, search options display', () => {
const searchWord = 'Hello';
// # Post a message
cy.postMessage(searchWord);
// * Search word in searchBox and validate searchWord
cy.get('#searchBox').click().type(searchWord + '{enter}').should('have.value', searchWord);
// # Click on "x" displayed on searchbox
cy.get('#searchbarContainer').should('be.visible').within(() => {
cy.get('#searchFormContainer').find('.input-clear-x').wait(TIMEOUTS.ONE_SEC).click({force: true});
cy.get('#searchbar-help-popup').should('be.visible');
cy.get('#searchBox').type('{esc}');
});
// # RHS should be visible with search results
cy.get('#search-items-container').should('be.visible');
// # Click on searchbox
cy.get('#searchbarContainer').should('be.visible').within(() => {
cy.get('#searchBox').click();
});
assertSearchHintFilesOrMessages();
});
it('MM-T376 - From:user search, using autocomplete', () => {
const testMessage = 'Hello World';
const testSearch = `FROM:${testUser.username.substring(0, 5)}`;
cy.apiCreateUser().then(({user}) => {
cy.apiAddUserToTeam(testTeam.id, user.id);
cy.apiLogin(user);
cy.apiGetChannelByName(testTeam.name, 'Off-Topic').then(({channel}) => {
// # Have another user send a post
cy.postMessageAs({sender: testUser, message: testMessage, channelId: channel.id});
});
// # Visit town-square.
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Search for posts from that user
cy.get('#searchBox').click().type(testSearch, {force: true});
// # Select user from suggestion list
cy.contains('.suggestion-list__item', `@${testUser.username}`).scrollIntoView().click({force: true});
// # Verify that search box has the updated query
cy.get('#searchBox').should('have.value', `FROM:${testUser.username} `);
// # Perform search
cy.get('#searchBox').click().type('{enter}').wait(TIMEOUTS.HALF_SEC);
// * Assert that RHS should be visible with search results
cy.get('#search-items-container').should('be.visible');
// * Search query clear icon is still present
cy.get('.input-clear.visible').should('be.visible');
// # Hover search query clear icon
cy.get('.input-clear-x').first().trigger('mouseover', {force: true}).then(($span) => {
// * Assert that tooltip has shown
cy.wrap($span).should('have.attr', 'aria-describedby', 'InputClearTooltip');
// # Click the clear query icon
cy.wrap($span).click({force: true});
// * Assert search results are intact
cy.get('[data-testid="search-item-container"]').should('be.visible');
});
});
});
it('MM-T1450 - Autocomplete behaviour', () => {
// # Post message in town-square
cy.postMessage('hello');
// # Click on searchbox
cy.get('#searchbarContainer').should('be.visible').within(() => {
cy.get('input#searchBox').should('be.visible').click();
});
// * Check the contents in search options
assertSearchHintFilesOrMessages();
// # Search for search term in:
cy.get('#searchBox').click().type('in:');
// # Select option from suggestion list
cy.get('.suggestion-list__item').first().click({force: true});
// * Assert suggestions are not present after selecting item
cy.get('.suggestion-list__item').should('not.exist');
// # Clear search box
cy.get('.input-clear-x').first().click({force: true}).wait(TIMEOUTS.HALF_SEC);
// # Search for search term in:town-square{space}
cy.get('#searchBox').click().type('in:town-square ').wait(TIMEOUTS.HALF_SEC);
// * Check the hint contents are now visible
assertSearchHint();
// # Clear search box
cy.get('.input-clear-x').first().click({force: true}).wait(TIMEOUTS.HALF_SEC);
// # Search for search term in:town-square{enter}
cy.get('#searchBox').click().type('in:town-square').wait(TIMEOUTS.HALF_SEC);
// * Assert that channel name displays appropriately
cy.get('.suggestion-list__item').first().should('contain.text', 'Town Square~town-square');
// # Press enter to register search term
cy.get('#searchBox').click().type('{enter}');
// * Check the hint contents are now visible
assertSearchHint();
// * Assert that searchBox now includes a trailing space
cy.get('#searchBox').should('have.value', 'in:town-square ');
// # Perform the search
cy.get('#searchBox').click().type('{enter}').wait(TIMEOUTS.HALF_SEC);
// * Assert autocomplete list is gone
cy.get('.suggestion-list__item').should('not.exist');
});
it('MM-T2291 - Wildcard Search', () => {
const testMessage = 'Hello World!!!';
// # Post message
cy.postMessage(testMessage);
// # Search for `Hell*`
cy.get('input#searchBox').click().type('Hell*{enter}').wait(TIMEOUTS.HALF_SEC);
// # RHS should be visible with search results
cy.get('#search-items-container').should('be.visible');
// * Assert search results are present and correct
cy.get('[data-testid="search-item-container"]').should('be.visible');
cy.get('.search-highlight').first().should('contain.text', 'Hell');
});
});
const assertSearchHintFilesOrMessages = () => {
cy.get('#searchbar-help-popup').should('be.visible').within(() => {
cy.get('div span').first().should('have.text', 'What are you searching for?');
cy.get('div button:first-child span').first().should('have.text', 'Messages');
cy.get('div button:last-child span').first().should('have.text', 'Files');
});
};
const assertSearchHint = () => {
cy.get('#searchbar-help-popup').should('be.visible').within(() => {
cy.get('div span').first().should('have.text', 'Search options');
cy.get('div ul li').first().should('have.text', 'From:Messages from a user');
cy.get('div ul li').eq(1).should('have.text', 'In:Messages in a channel');
cy.get('div ul li').eq(2).should('have.text', 'On:Messages on a date');
cy.get('div ul li').eq(3).should('have.text', 'Before:Messages before a date');
cy.get('div ul li').eq(4).should('have.text', 'After:Messages after a date');
cy.get('div ul li').eq(5).should('have.text', '—Exclude search terms');
cy.get('div ul li').last().should('have.text', '""Messages with phrases');
});
};

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

@@ -0,0 +1,69 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
import {getRandomId} from '../../../utils';
describe('Search', () => {
before(() => {
// # Login as test user and visit off-topic
cy.apiInitSetup({loginAfter: true}).then(({offTopicUrl}) => {
cy.visit(offTopicUrl);
// # Post several messages of similar format to add complexity in searching
Cypress._.times(5, () => {
cy.postMessage(`asparagus${getRandomId()}`);
});
});
});
it('MM-T373 Search results Right-Hand-Side: Post a comment', () => {
const message = `asparagus${getRandomId()}`;
const comment = 'Replying to asparagus';
// # Post a new message
cy.postMessage(message);
// # Search for the text we just entered
cy.uiSearchPosts(message);
// # Get last postId
cy.getLastPostId().then((postId) => {
const postMessageText = `#rhsPostMessageText_${postId}`;
// * Search results should have our original message
cy.get('#search-items-container').find(postMessageText).should('have.text', `${message}`);
// # Click on the reply button on the search result
cy.clickPostCommentIcon(postId, 'SEARCH');
// # Reply with a comment
cy.postMessageReplyInRHS(comment);
// * Verify sidebar is still open and the original message is in the RHS
cy.uiGetRHS().
find(postMessageText).
should('have.text', `${message}`);
});
// # Get the comment id
cy.getLastPostId().then((commentId) => {
const rhsCommentText = `#rhsPostMessageText_${commentId}`;
const mainCommentText = `#postMessageText_${commentId}`;
// * Verify comment in RHS
cy.uiGetRHS().find(rhsCommentText).should('have.text', `${comment}`);
// * Verify comment main thread
cy.get('#postListContent').find(mainCommentText).should('have.text', `${comment}`);
});
});
});

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

@@ -0,0 +1,64 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
import {getRandomId} from '../../../utils';
describe('Search', () => {
before(() => {
// # Login as test user and visit Off-Topic
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
cy.visit(`/${team.name}/channels/off-topic`);
// # Post several messages of similar format to add complexity in searching
Cypress._.times(5, () => {
cy.postMessage(`apple${getRandomId()}`);
cy.postMessage(`banana${getRandomId()}`);
});
});
});
it('S19944 Highlighting does not change to what is being typed in the search input box', () => {
const apple = `apple${getRandomId()}`;
const banana = `banana${getRandomId()}`;
const message = apple + ' ' + banana;
// # Post a message as "apple" and "banana"
cy.postMessage(message);
// # Search for "apple"
cy.get('#searchBox').should('be.visible').type(apple).type('{enter}');
// # Get last postId
cy.getLastPostId().as('lastPostId');
// * Search result should return one post with highlight on apple
cy.get('@lastPostId').then((postId) => {
verifySearchResult(1, postId, message, apple);
});
// * Type banana on search box but don't hit search
cy.get('#searchBox').clear({force: true}).type(banana, {force: true});
// * Search result should not change and remain as one result with highlight still on apple
cy.get('@lastPostId').then((postId) => {
verifySearchResult(1, postId, message, apple);
});
});
});
function verifySearchResult(results, postId, fullMessage, highlightedTerm) {
cy.findAllByTestId('search-item-container').should('have.length', results).within(() => {
cy.get(`#rhsPostMessageText_${postId}`).should('have.text', `${fullMessage}`);
cy.get('.search-highlight').should('be.visible').and('have.text', highlightedTerm);
});
}

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

@@ -0,0 +1,70 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search
describe('Search', () => {
before(() => {
// # Login as test user and visit off-topic
cy.apiInitSetup({loginAfter: true}).then(({offTopicUrl}) => {
cy.visit(offTopicUrl);
});
});
it('MM-T4945_1 - Search bar popup should be visible when focus changes to one of its buttons', () => {
//# clicks on the search box
cy.uiGetSearchBox().click();
//* search bar popup should be visibl
cy.get('#searchbar-help-popup').should('be.visible');
//# moves the focus to the next button (in this case Messages)
cy.focused().tab();
//* search bar popup should be visible
cy.get('#searchbar-help-popup').should('be.visible');
});
it('MM-T4945_2 - Search bar popup should be hidden when focus is out of search bar items', () => {
//# clicks on the search box
cy.uiGetSearchBox().click();
//* search bar popup should be visibl
cy.get('#searchbar-help-popup').should('be.visible');
//# press tab three times to move focus out of the search bar componment
cy.focused().tab();
cy.focused().tab();
cy.focused().tab();
//* now the popup should be closed
cy.get('#searchbar-help-popup').should('not.be.visible');
});
it('MM-T4945_3 - Search bar popup should be open when focus back to search box', () => {
//# clicks on the search box
cy.uiGetSearchBox().click();
//* search bar popup should be visibl
cy.get('#searchbar-help-popup').should('be.visible');
//# moves the focus to the next button (in this case Messages)
cy.focused().tab();
//* search bar popup should be visible
cy.get('#searchbar-help-popup').should('be.visible');
//# moves the focus back to the search box
cy.focused().tab({shift: true});
//* search bar popup should still be visible
cy.get('#searchbar-help-popup').should('be.visible');
});
});

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

@@ -0,0 +1,122 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @search @filesearch
describe('Search', () => {
let testTeam;
let testUser;
let userOne;
let userTwo;
let userThree;
before(() => {
// # Create new team and users
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser({prefix: 'aaa'}).then(({user: user1}) => {
userOne = user1;
cy.apiAddUserToTeam(testTeam.id, userOne.id);
});
cy.apiCreateUser({prefix: 'bbb'}).then(({user: user2}) => {
userTwo = user2;
cy.apiAddUserToTeam(testTeam.id, userTwo.id);
});
cy.apiCreateUser({prefix: 'ccc'}).then(({user: user3}) => {
userThree = user3;
cy.apiAddUserToTeam(testTeam.id, userThree.id);
});
cy.apiLogin(testUser);
});
});
it('S14673 - Search "in:[username]" returns results in GMs', () => {
const groupMembers = [testUser, userOne, userTwo, userThree];
cy.apiCreateGroupChannel(groupMembers.map((member) => member.id)).then(({channel}) => {
cy.visit(`/${testTeam.name}/messages/${channel.name}`);
const message = `hello${Date.now()}`;
// # Post a message
cy.postMessage(message);
//# Type "in:" text in search input
cy.get('#searchBox').type('in:');
const sortedUsernames = groupMembers.
map((member) => member.username).
sort((a, b) => a.localeCompare(b, 'en', {numeric: true}));
//# Search group members in the menu
cy.get('#search-autocomplete__popover').should('be.visible').within(() => {
cy.findAllByTestId('listItem').contains(sortedUsernames.join(',')).click();
});
//# Press enter to select
cy.get('#searchBox').type('{enter}');
//# Search for the message
cy.get('#searchbarContainer').should('be.visible').within(() => {
cy.get('#searchBox').clear().type(`${message}{enter}`);
});
// * Should return exactly one result from the group channel and matches the message
cy.findAllByTestId('search-item-container').should('be.visible').and('have.length', 1).within(() => {
cy.get('.search-channel__name').should('be.visible').and('have.text', sortedUsernames.filter((username) => username !== testUser.username).join(', '));
cy.get('.search-highlight').should('be.visible').and('have.text', message);
});
});
});
it('Search "in:[username]" returns results file in GMs', () => {
const groupMembers = [testUser, userOne, userTwo, userThree];
cy.apiCreateGroupChannel(groupMembers.map((member) => member.id)).then(({channel}) => {
cy.visit(`/${testTeam.name}/messages/${channel.name}`);
// # Post file to group
cy.get('#advancedTextEditorCell').find('#fileUploadInput').attachFile('word-file.doc');
cy.get('.post-image__thumbnail').should('be.visible');
cy.uiGetPostTextBox().clear().type('{enter}');
//# Type "in:" text in search input
cy.get('#searchBox').type('in:');
const sortedUsernames = groupMembers.
map((member) => member.username).
sort((a, b) => a.localeCompare(b, 'en', {numeric: true}));
//# Search group members in the menu
cy.get('#search-autocomplete__popover').should('be.visible').within(() => {
cy.findAllByTestId('listItem').contains(sortedUsernames.join(',')).click();
});
//# Press enter to select
cy.get('#searchBox').type('{enter}');
//# Search for the message
cy.get('#searchbarContainer').should('be.visible').within(() => {
cy.get('#searchBox').type(' word-file{enter}');
});
// # Click the files tab
cy.get('.files-tab').should('be.visible').click();
// * Should return exactly one result from the group channel and matches the message
cy.findAllByTestId('search-item-container').should('be.visible').and('have.length', 1).within(() => {
cy.get('.Tag').should('be.visible').and('have.text', 'Group Message');
cy.get('.fileDataName').should('be.visible').and('have.text', 'word-file.doc');
});
});
});
});

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

@@ -0,0 +1,80 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @search @smoke @filesearch
/**
* create new DM channel
* @param {String} text - DM channel name
*/
function createNewDMChannel(channelname) {
cy.uiAddDirectMessage().scrollIntoView().click();
cy.get('#selectItems input').typeWithForce(channelname);
cy.contains('.more-modal__description', channelname).click({force: true});
cy.get('#saveItems').click();
}
describe('Search in DMs', () => {
let otherUser;
before(() => {
// # Log in as test user and visit test channel
cy.apiInitSetup().then(({team, channel, user: testUser}) => {
Cypress._.times(5, (i) => {
cy.apiCreateUser().then(({user}) => {
if (i === 0) {
otherUser = user;
}
cy.apiAddUserToTeam(team.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
});
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/${channel.name}`);
});
});
it('Search "in:[username]" returns file results in DMs', () => {
// # Ensure Direct Message is visible in LHS sidebar
cy.uiGetLhsSection('DIRECT MESSAGES').should('be.visible');
// # Create new DM channel with user's email
createNewDMChannel(otherUser.email);
// # Post file to user
cy.get('#advancedTextEditorCell').find('#fileUploadInput').attachFile('word-file.doc');
cy.get('.post-image__thumbnail').should('be.visible');
cy.uiGetPostTextBox().clear().type('{enter}');
// # Type `in:` in searchbox
cy.get('#searchBox').type('in:');
// # Select user from suggestion list
cy.contains('.suggestion-list__item', `@${otherUser.username}`).scrollIntoView().click();
// # Validate searchbox contains the username
cy.get('#searchBox').should('have.value', 'in:@' + otherUser.username + ' ');
// # Press Enter in searchbox
cy.get('#searchBox').type('word-file.doc').type('{enter}');
// # Click the files tab
cy.get('.files-tab').should('be.visible').click();
// # Search message in each filtered result
cy.get('#search-items-container').find('.fileDataName').each(($el) => {
cy.wrap($el).should('have.text', 'word-file.doc');
});
});
});

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

@@ -0,0 +1,78 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @search @smoke
/**
* create new DM channel
* @param {String} text - DM channel name
*/
function createNewDMChannel(channelname) {
cy.uiAddDirectMessage().scrollIntoView().click();
cy.get('#selectItems input').typeWithForce(channelname);
cy.contains('.more-modal__description', channelname).click({force: true});
cy.get('#saveItems').click();
}
describe('Search in DMs', () => {
let otherUser;
before(() => {
// # Log in as test user and visit test channel
cy.apiInitSetup().then(({team, channel, user: testUser}) => {
Cypress._.times(5, (i) => {
cy.apiCreateUser().then(({user}) => {
if (i === 0) {
otherUser = user;
}
cy.apiAddUserToTeam(team.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
});
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/${channel.name}`);
});
});
it('MM-T358 Search "in:[username]" returns results in DMs', () => {
const message = 'Hello' + Date.now();
// # Ensure Direct Message is visible in LHS sidebar
cy.uiGetLhsSection('DIRECT MESSAGES').should('be.visible');
// # Create new DM channel with user's email
createNewDMChannel(otherUser.email);
// # Post message to user
cy.postMessage(message);
// # Type `in:` in searchbox
cy.get('#searchBox').type('in:');
// # Select user from suggestion list
cy.contains('.suggestion-list__item', `@${otherUser.username}`).scrollIntoView().click();
// # Validate searchbox contains the username
cy.get('#searchBox').should('have.value', 'in:@' + otherUser.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);
});
});
});