Refactor/migrate/autocomplete database speabase specs to ts (#27837)
* 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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
073d4ff959
Коммит
84f10a8773
41
e2e-tests/cypress/tests/support/ui/suggestion_list.d.ts
поставляемый
41
e2e-tests/cypress/tests/support/ui/suggestion_list.d.ts
поставляемый
@@ -1,41 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
// ***************************************************************
|
||||
// Each command should be properly documented using JSDoc.
|
||||
// See https://jsdoc.app/index.html for reference.
|
||||
// Basic requirements for documentation are the following:
|
||||
// - Meaningful description
|
||||
// - Each parameter with `@params`
|
||||
// - Return value with `@returns`
|
||||
// - Example usage with `@example`
|
||||
// Custom command should follow naming convention of having `ui` prefix, e.g. `uiCheckLicenseExists`.
|
||||
// ***************************************************************
|
||||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
|
||||
/**
|
||||
* Verify user's at-mention in the suggestion list
|
||||
* @param {UserProfile} user - user object
|
||||
* @param {boolean} isSelected - check if user is selected with false as default
|
||||
* @param {string} sectionDividerName - name of the section in suggestion list, ex. "Channel Members"
|
||||
*
|
||||
* @example
|
||||
* cy.uiVerifyAtMentionInSuggestionList(user, true, 'Channel Members');
|
||||
*/
|
||||
uiVerifyAtMentionInSuggestionList(user: UserProfile, isSelected: boolean, sectionDividerName?: string): Chainable;
|
||||
|
||||
/**
|
||||
* Verify user's at-mention suggestion
|
||||
* @param {UserProfile} user - user object
|
||||
* @param {boolean} isSelected - check if user is selected with false as default
|
||||
*
|
||||
* @example
|
||||
* cy.uiVerifyAtMentionSuggestion(user, true);
|
||||
*/
|
||||
uiVerifyAtMentionSuggestion(user: UserProfile, isSelected?: boolean): Chainable;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
Cypress.Commands.add('uiVerifyAtMentionInSuggestionList', (user, isSelected = false, sectionDividerName = null) => {
|
||||
// * Verify that the suggestion list is open and visible
|
||||
return cy.get('#suggestionList').should('be.visible').within(() => {
|
||||
if (sectionDividerName) {
|
||||
// * Verify the section name is as expected
|
||||
cy.get('.suggestion-list__divider').findByText(sectionDividerName).should('be.visible');
|
||||
cy.get('.suggestion-list__divider').next().findByTestId(`mentionSuggestion_${user.username}`).should('be.visible');
|
||||
}
|
||||
|
||||
// * Verify that the user is selected
|
||||
return cy.uiVerifyAtMentionSuggestion(user, isSelected);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiVerifyAtMentionSuggestion', (user, isSelected = false) => {
|
||||
const {
|
||||
username,
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
nickname,
|
||||
} = user;
|
||||
|
||||
// * Verify that the user is selected
|
||||
cy.findByTestId(`mentionSuggestion_${username}`).as('selectedMentionSuggestion').should('be.visible');
|
||||
if (isSelected) {
|
||||
cy.get('@selectedMentionSuggestion').should('have.class', 'suggestion--selected');
|
||||
}
|
||||
|
||||
cy.get('@selectedMentionSuggestion').findByText(`@${username}`).should('be.visible');
|
||||
cy.get('@selectedMentionSuggestion').findByText(`${firstName} ${lastName} (${nickname})`).should('be.visible');
|
||||
|
||||
return cy.findByTestId(`mentionSuggestion_${username}`);
|
||||
});
|
||||
69
e2e-tests/cypress/tests/support/ui/suggestion_list.ts
Обычный файл
69
e2e-tests/cypress/tests/support/ui/suggestion_list.ts
Обычный файл
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {SimpleUser} from 'tests/integration/channels/autocomplete/helpers';
|
||||
import {ChainableT} from 'tests/types';
|
||||
|
||||
/**
|
||||
* Verify user's at-mention in the suggestion list
|
||||
* @param {SimpleUser} user - user object
|
||||
* @param {boolean} isSelected - check if user is selected with false as default
|
||||
* @param {string} sectionDividerName - name of the section in suggestion list, ex. "Channel Members"
|
||||
*
|
||||
* @example
|
||||
* cy.uiVerifyAtMentionInSuggestionList(user, true, 'Channel Members');
|
||||
*/
|
||||
function uiVerifyAtMentionInSuggestionList(user: SimpleUser, isSelected = false, sectionDividerName: string = null): ChainableT {
|
||||
// * Verify that the suggestion list is open and visible
|
||||
return cy.get('#suggestionList').should('be.visible').within(() => {
|
||||
if (sectionDividerName) {
|
||||
// * Verify the section name is as expected
|
||||
cy.get('.suggestion-list__divider').findByText(sectionDividerName).should('be.visible');
|
||||
cy.get('.suggestion-list__divider').next().findByTestId(`mentionSuggestion_${user.username}`).should('be.visible');
|
||||
}
|
||||
|
||||
// * Verify that the user is selected
|
||||
return cy.uiVerifyAtMentionSuggestion(user, isSelected);
|
||||
});
|
||||
}
|
||||
Cypress.Commands.add('uiVerifyAtMentionInSuggestionList', uiVerifyAtMentionInSuggestionList);
|
||||
|
||||
/**
|
||||
* Verify user's at-mention suggestion
|
||||
* @param {SimpleUser} user - user object
|
||||
* @param {boolean} isSelected - check if user is selected with false as default
|
||||
*
|
||||
* @example
|
||||
* cy.uiVerifyAtMentionSuggestion(user, true);
|
||||
*/
|
||||
function uiVerifyAtMentionSuggestion(user: SimpleUser, isSelected = false): ChainableT {
|
||||
const {
|
||||
username,
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
nickname,
|
||||
} = user;
|
||||
|
||||
// * Verify that the user is selected
|
||||
cy.findByTestId(`mentionSuggestion_${username}`).as('selectedMentionSuggestion').should('be.visible');
|
||||
if (isSelected) {
|
||||
cy.get('@selectedMentionSuggestion').should('have.class', 'suggestion--selected');
|
||||
}
|
||||
|
||||
cy.get('@selectedMentionSuggestion').findByText(`@${username}`).should('be.visible');
|
||||
cy.get('@selectedMentionSuggestion').findByText(`${firstName} ${lastName} (${nickname})`).should('be.visible');
|
||||
|
||||
return cy.findByTestId(`mentionSuggestion_${username}`);
|
||||
}
|
||||
|
||||
Cypress.Commands.add('uiVerifyAtMentionSuggestion', uiVerifyAtMentionSuggestion);
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
uiVerifyAtMentionInSuggestionList: typeof uiVerifyAtMentionInSuggestionList;
|
||||
uiVerifyAtMentionSuggestion: typeof uiVerifyAtMentionSuggestion;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user