mattermost/e2e-tests/cypress/tests/support/ui/search.ts
Angel Mendez a358bef3cd
MM-47287 Refactor/migrate bot accounts to typescript (#28347)
* refactor: convert bot_api_1_spec.js to typescript

- convert file bot_accounts/bot_api_1_spec.js to typescript
- update related data types in order to fix argument issues

* refactor: convert bot_api_not_cloud_spec.js to ts

- convert file bot_accounts/bot_api_not_cloud_spec.js to typescript
- update related data types in order to fix argument issues

* refactor: convert bot_channel_intro_spec.js to ts

- convert file bot_accounts/bot_channel_intro_spec.js to typescript
- convert support/api/bots.js to typescript
- remove data type bot.d.ts and include docs and definitions in
 support/api/bots.ts

* refactor: convert bot_accounts files to ts

- convert files from js to typescript
- move declaration files to ts
- update js docs
- fix lint and type errors

Related to #21303

* fix: replace params undefined on client.createUser

- replace undefined params with empty strings as suggested in review

* fix: add types to variables on spec tags_spec.ts

- add types to variables

* fix: update args for apiCreateBot on api/bots.ts

- update args so that lint issue is fixed

* Apply suggestions from code review

update assertion to 401

---------

Co-authored-by: Saturnino Abril <5334504+saturninoabril@users.noreply.github.com>
2024-10-28 17:03:21 +08:00

39 lines
1.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {ChainableT} from 'tests/types';
function uiSearchPosts(searchTerm: string) {
// # Enter the search terms and hit enter to start the search
cy.get('#searchFormContainer').should('be.visible').click();
cy.get('#searchBox').find('input').clear().type(searchTerm).type('{enter}');
// * Wait for the RHS to open and the search results to appear
cy.contains('.sidebar--right__header', 'Search Results').should('be.visible');
cy.get('#searchContainer .LoadingSpinner').should('not.exist');
}
Cypress.Commands.add('uiSearchPosts', uiSearchPosts);
function uiJumpToSearchResult(postId: string) {
// # Find the post in the search results and click Jump
cy.get(`#searchResult_${postId}`).contains('a', 'Jump').click();
// * Verify the URL changes to the permalink URL
cy.url().should((url) => url.endsWith(`/${postId}`));
// * Verify that the permalinked post is highlighted in the center channel
cy.get(`#post_${postId}.post--highlight`).should('be.visible');
}
Cypress.Commands.add('uiJumpToSearchResult', uiJumpToSearchResult);
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
uiSearchPosts(searchTerm: string): ChainableT<void>;
uiJumpToSearchResult(postId: string): ChainableT<void>;
}
}
}