Migration typescript/team.js (#25811)

* refactor: convert file team.js to ts

- convert file to typescript
- create types in file

* refactor: use optional chaining operator for link.click

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Angel Mendez 2024-02-19 05:07:54 -06:00 committed by GitHub
parent a777e12055
commit 19d6a2c47d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,14 +1,18 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
Cypress.Commands.add('uiInviteMemberToCurrentTeam', (username) => { /**
* Invites a member to the current team
* @param {string} username - the username
*/
function uiInviteMemberToCurrentTeam(username: string) {
// # Open member invite screen // # Open member invite screen
cy.uiOpenTeamMenu('Invite People'); cy.uiOpenTeamMenu('Invite People');
// # Open members section if licensed for guest accounts // # Open members section if licensed for guest accounts
cy.findByTestId('invitationModal'). cy.findByTestId('invitationModal').
then((container) => container.find('[data-testid="inviteMembersLink"]')). then((container) => container.find('[data-testid="inviteMembersLink"]')).
then((link) => link && link.click()); then((link) => link?.click());
// # Enter bot username and submit // # Enter bot username and submit
cy.get('.users-emails-input__control input').typeWithForce(username).as('input'); cy.get('.users-emails-input__control input').typeWithForce(username).as('input');
@ -23,4 +27,16 @@ Cypress.Commands.add('uiInviteMemberToCurrentTeam', (username) => {
// # Close, return // # Close, return
cy.findByTestId('confirm-done').click(); cy.findByTestId('confirm-done').click();
}); }
Cypress.Commands.add('uiInviteMemberToCurrentTeam', uiInviteMemberToCurrentTeam);
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
uiInviteMemberToCurrentTeam: typeof uiInviteMemberToCurrentTeam;
}
}
}
export {};