* refactor: migrate database/users_spec.js to ts - migrate file autocomplete/database/users_spec.js to typescripts - udpate system.d.ts data type adding type for shouldHaveElasticsearchDisabled * refactor: migrate users_in_channel_switcher_spec.js - migrate file users_in_channel_switcher_spec to typescript - fix issue with data type on file autocomplete/helpers.ts function verifySuggestionAtChannelSwitcher - fix issue with data type on file autocomplete/common_test.ts function doTestQuickChannelSwitcher * refactor: migrate users_in_message_input_box_spec to ts - migrate file database/users_in_message_input_box_spec.js to typescript - migrate file support/ui/suggestion_list.js to typescript and update docs and type definitions - update references to doTestPostextbox function - update references to verifySuggestionAtPostTextbox function --------- Co-authored-by: Mattermost Build <build@mattermost.com>
103 строки
3.3 KiB
TypeScript
103 строки
3.3 KiB
TypeScript
// 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.
|
|
// ***************************************************************
|
|
|
|
import {
|
|
getPostTextboxInput,
|
|
getQuickChannelSwitcherInput,
|
|
SimpleUser,
|
|
startAtMention,
|
|
verifySuggestionAtChannelSwitcher,
|
|
verifySuggestionAtPostTextbox,
|
|
} from './helpers';
|
|
|
|
export function doTestPostextbox(mention: string, ...suggestion: SimpleUser[]) {
|
|
getPostTextboxInput();
|
|
startAtMention(mention);
|
|
verifySuggestionAtPostTextbox(...suggestion);
|
|
}
|
|
|
|
export function doTestQuickChannelSwitcher(mention: string, ...suggestion: SimpleUser[]) {
|
|
getQuickChannelSwitcherInput();
|
|
startAtMention(mention);
|
|
verifySuggestionAtChannelSwitcher(...suggestion);
|
|
}
|
|
|
|
export function doTestUserChannelSection(prefix: string, testTeam: Cypress.Team, testUsers: Record<string, SimpleUser>) {
|
|
const thor = testUsers.thor;
|
|
const loki = testUsers.loki;
|
|
|
|
// # Create new channel and add user to channel
|
|
const channelName = 'new-channel';
|
|
cy.apiCreateChannel(testTeam.id, channelName, channelName).then(({channel}) => {
|
|
cy.apiGetUserByEmail(thor.email).then(({user}) => {
|
|
cy.apiAddUserToChannel(channel.id, user.id);
|
|
});
|
|
|
|
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
|
|
});
|
|
|
|
// # Start an at mention that should return 2 users (in this case, the users share a last name)
|
|
cy.uiGetPostTextBox().
|
|
as('input').
|
|
clear().
|
|
type(`@${prefix}odinson`);
|
|
|
|
// * Thor should be a channel member
|
|
cy.uiVerifyAtMentionInSuggestionList(thor, true);
|
|
|
|
// * Loki should NOT be a channel member
|
|
cy.uiVerifyAtMentionInSuggestionList(loki, false);
|
|
}
|
|
|
|
export function doTestDMChannelSidebar(testUsers: Record<string, SimpleUser>) {
|
|
const thor = testUsers.thor;
|
|
|
|
// # Open of the add direct message modal
|
|
cy.uiAddDirectMessage().click({force: true});
|
|
|
|
// # Type username into input
|
|
cy.get('.more-direct-channels').
|
|
find('input').
|
|
should('exist').
|
|
type(thor.username, {force: true});
|
|
|
|
cy.intercept({
|
|
method: 'POST',
|
|
url: '/api/v4/users/search',
|
|
}).as('searchUsers');
|
|
|
|
cy.wait('@searchUsers').then((interception) => {
|
|
expect(interception.response.body.length === 1);
|
|
});
|
|
|
|
// * There should only be one result
|
|
cy.get('#moreDmModal').find('.more-modal__row').
|
|
as('result').
|
|
its('length').
|
|
should('equal', 1);
|
|
|
|
// * Result should have appropriate text
|
|
cy.get('@result').
|
|
find('.more-modal__name').
|
|
should('have.text', `@${thor.username} - ${thor.first_name} ${thor.last_name} (${thor.nickname})`);
|
|
|
|
cy.get('@result').
|
|
find('.more-modal__description').
|
|
should('have.text', thor.email);
|
|
|
|
// # Click on the result to add user
|
|
cy.get('@result').click({force: true});
|
|
|
|
// # Click "Go"
|
|
cy.uiGetButton('Go').click();
|
|
|
|
// # Should land on direct message channel for that user
|
|
cy.get('#channelHeaderTitle').should('have.text', thor.username + ' ');
|
|
}
|