1+ import { expect } from '@playwright/test' ;
2+
13import { englishStrippedStr } from '../localization/englishStrippedStr' ;
24import {
35 Conversation ,
@@ -7,13 +9,15 @@ import {
79 Settings ,
810} from './locators' ;
911import { test_Alice_1W_Bob_1W } from './setup/sessionTest' ;
12+ import { joinCommunity } from './utilities/join_community' ;
1013import { sendMessage } from './utilities/message' ;
1114import { sendNewMessage } from './utilities/send_message' ;
1215import {
1316 checkModalStrings ,
1417 clickOn ,
1518 clickOnMatchingText ,
1619 clickOnWithText ,
20+ grabTextFromElement ,
1721 waitForMatchingText ,
1822 waitForTestIdWithText ,
1923} from './utilities/utils' ;
@@ -164,3 +168,81 @@ test_Alice_1W_Bob_1W(
164168 ) ;
165169 } ,
166170) ;
171+
172+ test_Alice_1W_Bob_1W (
173+ 'Community message requests on' ,
174+ async ( { alice, aliceWindow1, bob, bobWindow1 } ) => {
175+ await clickOn ( bobWindow1 , LeftPane . settingsButton ) ;
176+ await clickOn ( bobWindow1 , Settings . privacyMenuItem ) ;
177+ await clickOn ( bobWindow1 , Settings . enableCommunityMessageRequests ) ;
178+ await clickOn ( bobWindow1 , Global . modalCloseButton ) ;
179+ await Promise . all ( [ joinCommunity ( aliceWindow1 ) , joinCommunity ( bobWindow1 ) ] ) ;
180+ const communityMsg = `I accept message requests + ${ Date . now ( ) } ` ;
181+ await sendMessage ( bobWindow1 , communityMsg ) ;
182+ await clickOn ( aliceWindow1 , Conversation . scrollToBottomButton ) ;
183+ // Using native methods to locate the author corresponding to the sent message
184+ await aliceWindow1
185+ . locator ( '.module-message__container' , { hasText : communityMsg } )
186+ . locator ( '..' ) // Go up to parent
187+ . locator ( 'svg' )
188+ . click ( ) ;
189+ const elText = await grabTextFromElement (
190+ aliceWindow1 ,
191+ 'data-testid' ,
192+ 'account-id' ,
193+ ) ;
194+ expect ( elText ) . toMatch ( / ^ 1 5 / ) ;
195+ await clickOn ( aliceWindow1 , HomeScreen . newMessageAccountIDInput ) ; // yes this is the actual locator for the 'Message' button
196+ await waitForTestIdWithText (
197+ aliceWindow1 ,
198+ 'header-conversation-name' ,
199+ bob . userName ,
200+ ) ;
201+ const messageRequestMsg = `${ alice . userName } to ${ bob . userName } ` ;
202+ const messageRequestResponse = `${ bob . userName } accepts message request` ;
203+ await sendMessage ( aliceWindow1 , messageRequestMsg ) ;
204+ await clickOn ( bobWindow1 , HomeScreen . messageRequestBanner ) ;
205+ // Select message request from User A
206+ await clickOnWithText (
207+ bobWindow1 ,
208+ HomeScreen . conversationItemName ,
209+ alice . userName ,
210+ ) ;
211+ await sendMessage ( bobWindow1 , messageRequestResponse ) ;
212+ // Check config message of message request acceptance
213+ await waitForTestIdWithText (
214+ bobWindow1 ,
215+ 'message-request-response-message' ,
216+ englishStrippedStr ( 'messageRequestYouHaveAccepted' )
217+ . withArgs ( {
218+ name : alice . userName ,
219+ } )
220+ . toString ( ) ,
221+ ) ;
222+ } ,
223+ ) ;
224+ test_Alice_1W_Bob_1W (
225+ 'Community message requests off' ,
226+ async ( { aliceWindow1, bobWindow1 } ) => {
227+ await Promise . all ( [ joinCommunity ( aliceWindow1 ) , joinCommunity ( bobWindow1 ) ] ) ;
228+ const communityMsg = `I do not accept message requests + ${ Date . now ( ) } ` ;
229+ await sendMessage ( bobWindow1 , communityMsg ) ;
230+ await clickOn ( aliceWindow1 , Conversation . scrollToBottomButton ) ;
231+ // Using native methods to locate the author corresponding to the sent message
232+ await aliceWindow1
233+ . locator ( '.module-message__container' , { hasText : communityMsg } )
234+ . locator ( '..' ) // Go up to parent
235+ . locator ( 'svg' )
236+ . click ( ) ;
237+ const elText = await grabTextFromElement (
238+ aliceWindow1 ,
239+ 'data-testid' ,
240+ 'account-id' ,
241+ ) ;
242+ expect ( elText ) . toMatch ( / ^ 1 5 / ) ;
243+ const messageButton = aliceWindow1 . getByTestId (
244+ HomeScreen . newMessageAccountIDInput . selector ,
245+ ) ;
246+ await expect ( messageButton ) . toHaveClass ( / d i s a b l e d / ) ;
247+ } ,
248+ ) ;
0 commit comments