14
14
* limitations under the License.
15
15
*/
16
16
17
- import { Locator , Page } from '@playwright/test' ;
17
+ import { FrameLocator , Locator , Page } from '@playwright/test' ;
18
18
import fetch from 'cross-fetch' ;
19
19
import { Credentials , getElementWebUrl , getSynapseUrl } from '../util' ;
20
20
import { CreateDirectMessagePage } from './createDirectMessagePage' ;
@@ -25,6 +25,7 @@ export class ElementWebPage {
25
25
private readonly navigationRegion : Locator ;
26
26
private readonly mainRegion : Locator ;
27
27
private readonly headerRegion : Locator ;
28
+ private readonly sendMessageTextbox : Locator ;
28
29
private readonly roomNameText : Locator ;
29
30
private readonly userMenuButton : Locator ;
30
31
private readonly startChatButton : Locator ;
@@ -33,6 +34,7 @@ export class ElementWebPage {
33
34
this . navigationRegion = page . getByRole ( 'navigation' ) ;
34
35
this . mainRegion = page . getByRole ( 'main' ) ;
35
36
this . headerRegion = this . mainRegion . locator ( 'header' ) ;
37
+ this . sendMessageTextbox = page . getByRole ( 'textbox' , { name : / m e s s a g e … / } ) ;
36
38
this . roomNameText = this . headerRegion . getByRole ( 'heading' ) ;
37
39
this . userMenuButton = this . navigationRegion . getByRole ( 'button' , {
38
40
name : 'User menu' ,
@@ -113,12 +115,45 @@ export class ElementWebPage {
113
115
await this . waitForRoom ( name ) ;
114
116
}
115
117
118
+ async acceptRoomInvitation ( ) {
119
+ await this . page . getByRole ( 'button' , { name : 'Accept' } ) . click ( ) ;
120
+ }
121
+
116
122
async joinRoom ( ) {
117
123
await this . page
118
124
. getByRole ( 'button' , { name : 'Join the discussion' } )
119
125
. click ( ) ;
120
126
}
121
127
128
+ async toggleRoomInfo ( ) {
129
+ await this . headerRegion . getByRole ( 'button' , { name : 'Room info' } ) . click ( ) ;
130
+ }
131
+
132
+ async sendMessage ( message : string ) {
133
+ // Both for encrypted and non-encrypted cases
134
+ await this . sendMessageTextbox . type ( message ) ;
135
+ await this . sendMessageTextbox . press ( 'Enter' ) ;
136
+ }
137
+
138
+ widgetByTitle ( title : string ) : FrameLocator {
139
+ return this . page . frameLocator ( `iframe[title="${ title } "]` ) ;
140
+ }
141
+
142
+ async setupWidget ( url : string ) {
143
+ await this . sendMessage ( `/addwidget ${ url } ` ) ;
144
+
145
+ await this . toggleRoomInfo ( ) ;
146
+ await this . page
147
+ . getByRole ( 'button' , { name : 'Custom' } )
148
+ . locator ( '..' )
149
+ . getByRole ( 'button' , { name : 'Pin' } )
150
+ . click ( ) ;
151
+
152
+ await this . page
153
+ . getByRole ( 'button' , { name : 'Set my room layout for everyone' } )
154
+ . click ( ) ;
155
+ }
156
+
122
157
async inviteUser ( username : string ) {
123
158
const roomId = this . getCurrentRoomId ( ) ;
124
159
0 commit comments