diff --git a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category.d.ts b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category.d.ts deleted file mode 100644 index 1498743408..0000000000 --- a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -/// - -// *************************************************************** -// 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. `uiOpenFilePreviewModal`. -// *************************************************************** - -declare namespace Cypress { - interface Chainable { - - /** - * Create a new category - * - * @param [categoryName] category's name - * - * @example - * cy.uiCreateSidebarCategory(); - */ - uiCreateSidebarCategory(categoryName?: string): Chainable; - - /** - * Move a channel to a category. - * Open the channel menu, select Move to, and click either New Category or on the category. - * - * @param channelName channel's name - * @param categoryName category's name - * @param [newCategory=false] create a new category to move into - * @param [isChannelId=false] whether channelName is a channel ID - * - * @example - * cy.uiMoveChannelToCategory('Town Square', 'Favorites'); - */ - uiMoveChannelToCategory(channelName: string, categoryName: string, newCategory: boolean = false, isChannelId: boolean = false): Chainable; - } -} diff --git a/e2e-tests/cypress/tests/support/ui/channel_sidebar.js b/e2e-tests/cypress/tests/support/ui/channel_sidebar.ts similarity index 61% rename from e2e-tests/cypress/tests/support/ui/channel_sidebar.js rename to e2e-tests/cypress/tests/support/ui/channel_sidebar.ts index 930337ae81..b279fc77ca 100644 --- a/e2e-tests/cypress/tests/support/ui/channel_sidebar.js +++ b/e2e-tests/cypress/tests/support/ui/channel_sidebar.ts @@ -1,9 +1,18 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {ChainableT} from 'tests/types'; import {getRandomId} from '../../utils'; -Cypress.Commands.add('uiCreateSidebarCategory', (categoryName = `category-${getRandomId()}`) => { +/** + * Create a new category + * + * @param [categoryName] category's name + * + * @example + * cy.uiCreateSidebarCategory(); + */ +function uiCreateSidebarCategory(categoryName: string = `category-${getRandomId()}`): ChainableT { // # Click the New Category/Channel Dropdown button cy.uiGetLHSAddChannelButton().click(); @@ -21,9 +30,23 @@ Cypress.Commands.add('uiCreateSidebarCategory', (categoryName = `category-${getR cy.contains('.SidebarChannelGroup', categoryName, {matchCase: false}); return cy.wrap({displayName: categoryName}); -}); +} -Cypress.Commands.add('uiMoveChannelToCategory', (channelName, categoryName, newCategory = false, isChannelId = false) => { +Cypress.Commands.add('uiCreateSidebarCategory', uiCreateSidebarCategory); + +/** + * Move a channel to a category. + * Open the channel menu, select Move to, and click either New Category or on the category. + * + * @param channelName channel's name + * @param categoryName category's name + * @param [newCategory=false] create a new category to move into + * @param [isChannelId=false] whether channelName is a channel ID + * + * @example + * cy.uiMoveChannelToCategory('Town Square', 'Favorites'); + */ +function uiMoveChannelToCategory(channelName: string, categoryName: string, newCategory = false, isChannelId = false): ChainableT { // # Open the channel menu, select Move to cy.uiGetChannelSidebarMenu(channelName, isChannelId).within(() => { cy.findByText('Move to...').should('be.visible').trigger('mouseover'); @@ -48,4 +71,16 @@ Cypress.Commands.add('uiMoveChannelToCategory', (channelName, categoryName, newC } return cy.wrap({displayName: categoryName}); -}); +} + +Cypress.Commands.add('uiMoveChannelToCategory', uiMoveChannelToCategory); + +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace Cypress { + interface Chainable { + uiCreateSidebarCategory: typeof uiCreateSidebarCategory; + uiMoveChannelToCategory: typeof uiMoveChannelToCategory; + } + } +}