@@ -660,6 +660,22 @@ export class ChannelContextMenu {
660660 await tab . click ( )
661661 }
662662
663+ async openAddMembersModal ( ) {
664+ const tab = this . driver . wait (
665+ until . elementLocated ( By . xpath ( '//div[@data-testid="contextMenuItemAdd_members"]' ) ) ,
666+ 15_000 ,
667+ `Channel context menu channel add members tab couldn't be located within timeout` ,
668+ 500
669+ )
670+ await this . driver . wait (
671+ until . elementIsVisible ( tab ) ,
672+ 15_000 ,
673+ `Channel context menu channel add members tab was not visibile within timeout` ,
674+ 500
675+ )
676+ await tab . click ( )
677+ }
678+
663679 // TODO: replace sleep
664680 async deleteChannel ( ) {
665681 const button = this . driver . wait (
@@ -677,6 +693,43 @@ export class ChannelContextMenu {
677693 await button . click ( )
678694 await sleep ( 5000 )
679695 }
696+
697+ // TODO: replace sleep
698+ async addMembersToChannel ( channelName : string , memberNames : string [ ] ) {
699+ const autoCompleteInput = this . driver . wait (
700+ until . elementLocated ( By . xpath ( `//*[@data-testid="${ channelName } -add-members-autocomplete"]` ) ) ,
701+ 20_000 ,
702+ `Channel add members autocomplete input couldn't be located within timeout` ,
703+ 500
704+ )
705+ await this . driver . wait (
706+ until . elementIsVisible ( autoCompleteInput ) ,
707+ 15_000 ,
708+ `Channel context menu channel add members autocomplete input was not visibile within timeout` ,
709+ 500
710+ )
711+
712+ for ( const memberName of memberNames ) {
713+ await autoCompleteInput . click ( )
714+ autoCompleteInput . sendKeys ( memberName )
715+ autoCompleteInput . sendKeys ( Key . ENTER )
716+ }
717+
718+ const button = this . driver . wait (
719+ until . elementLocated ( By . xpath ( '//button[@data-testid="addMembersChannelButton"]' ) ) ,
720+ 20_000 ,
721+ `Channel add members button couldn't be located within timeout` ,
722+ 500
723+ )
724+ await this . driver . wait (
725+ until . elementIsVisible ( button ) ,
726+ 15_000 ,
727+ `Channel context menu channel add members button was not visibile within timeout` ,
728+ 500
729+ )
730+ await button . click ( )
731+ await sleep ( 5000 )
732+ }
680733}
681734
682735export class UserProfileContextMenu {
@@ -1199,6 +1252,15 @@ export class Channel {
11991252 )
12001253 }
12011254
1255+ get lock ( ) {
1256+ return this . driver . wait (
1257+ until . elementLocated ( By . xpath ( `//svg[@data-testid='channelTitle-private']` ) ) ,
1258+ 10_000 ,
1259+ `Channel title element for ${ this . name } couldn't be found within timeout` ,
1260+ 500
1261+ )
1262+ }
1263+
12021264 get messagesList ( ) {
12031265 return this . driver . wait (
12041266 until . elementLocated ( By . xpath ( '//ul[@id="messages-scroll"]' ) ) ,
@@ -2013,7 +2075,7 @@ export class Sidebar {
20132075 return channel
20142076 }
20152077
2016- async addNewChannel ( name : string ) : Promise < Channel > {
2078+ async addNewChannel ( name : string , isPublic : boolean = true ) : Promise < Channel > {
20172079 const button = await this . driver . wait (
20182080 until . elementLocated ( By . xpath ( '//button[@data-testid="addChannelButton"]' ) ) ,
20192081 5_000 ,
@@ -2032,6 +2094,23 @@ export class Sidebar {
20322094 await this . driver . wait ( until . elementIsVisible ( channelNameInput ) , 5_000 )
20332095 await this . driver . wait ( until . elementIsEnabled ( channelNameInput ) , 5_000 )
20342096 await channelNameInput . sendKeys ( name )
2097+
2098+ const channelPrivateToggle = await this . driver . wait (
2099+ until . elementLocated ( By . xpath ( '//span[@data-testid="createChannel-private-form-control-toggle"]' ) ) ,
2100+ 5_000 ,
2101+ `Channel private toggle couldn't be found within timeout` ,
2102+ 500
2103+ )
2104+ await this . driver . wait ( until . elementIsVisible ( channelPrivateToggle ) , 5_000 )
2105+ if ( ( await channelPrivateToggle . getAttribute ( 'class' ) ) . includes ( 'checked' ) ) {
2106+ throw new Error ( 'Channel privacy toggle was enabled before clicking' )
2107+ }
2108+ if ( ! isPublic ) {
2109+ await channelPrivateToggle . click ( )
2110+ if ( ! ( await channelPrivateToggle . getAttribute ( 'class' ) ) . includes ( 'checked' ) ) {
2111+ throw new Error ( 'Channel privacy toggle was disabled after clicking' )
2112+ }
2113+ }
20352114 const channelNameButton = await this . driver . wait (
20362115 until . elementLocated ( By . xpath ( '//button[@data-testid="channelNameSubmit"]' ) ) ,
20372116 5_000 ,
0 commit comments