Skip to content

Commit 6b2899d

Browse files
committed
feat: add blinded message request test
1 parent 6745af8 commit 6b2899d

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import { expect, TestInfo } from '@playwright/test';
2+
import { USERNAME } from '@session-foundation/qa-seeder';
3+
4+
import { testCommunityLink, testCommunityName } from '../../constants/community';
5+
import { englishStrippedStr } from '../../localizer/englishStrippedStr';
6+
import { bothPlatformsIt } from '../../types/sessionIt';
7+
import { CloseSettings } from './locators';
8+
import { ConversationHeaderName, MessageBody } from './locators/conversation';
9+
import { MessageRequestsBanner } from './locators/home';
10+
import { PrivacyMenuItem, UserSettings } from './locators/settings';
11+
import { newUser } from './utils/create_account';
12+
import { joinCommunity } from './utils/join_community';
13+
import { closeApp, openAppTwoDevices, SupportedPlatformsType } from './utils/open_app';
14+
15+
bothPlatformsIt({
16+
title: 'Blinded message request',
17+
risk: 'medium',
18+
testCb: blindedMessageRequests,
19+
countOfDevicesNeeded: 2,
20+
allureDescription:
21+
'Verifies that a message request can be sent when Community Message Requests are on.',
22+
allureLinks: {
23+
ios: 'SES-4722',
24+
},
25+
});
26+
27+
// TODO: tidy this up with neat locators
28+
async function blindedMessageRequests(platform: SupportedPlatformsType, testInfo: TestInfo) {
29+
const { device1, device2 } = await openAppTwoDevices(platform, testInfo);
30+
const [alice, bob] = await Promise.all([
31+
newUser(device1, USERNAME.ALICE, { saveUserData: false }),
32+
newUser(device2, USERNAME.BOB, { saveUserData: false }),
33+
]);
34+
await device2.clickOnElementAll(new UserSettings(device2));
35+
await device2.clickOnElementAll(new PrivacyMenuItem(device2));
36+
await device2.onAndroid().clickOnElementAll({
37+
strategy: '-android uiautomator',
38+
selector: 'new UiSelector().text("Community Message Requests")',
39+
});
40+
await device2.onIOS().clickOnElementAll({
41+
strategy: 'accessibility id',
42+
selector: 'Community Message Requests',
43+
});
44+
await device2.navigateBack();
45+
await device2.clickOnElementAll(new CloseSettings(device2));
46+
await Promise.all(
47+
[device1, device2].map(async device => {
48+
await joinCommunity(device, testCommunityLink, testCommunityName);
49+
})
50+
);
51+
const message = `I accept blinded message requests + ${platform} + ${Date.now()}`;
52+
await device2.sendMessage(message);
53+
await device2.navigateBack();
54+
// Click on profile picture (Android) or sender name (iOS)
55+
await device1
56+
.onAndroid()
57+
.clickOnElementXPath(
58+
`//android.view.ViewGroup[@resource-id='network.loki.messenger.qa:id/mainContainer'][.//android.widget.TextView[contains(@text,'${message}')]]//androidx.compose.ui.platform.ComposeView[@resource-id='network.loki.messenger.qa:id/profilePictureView']`
59+
);
60+
await device1
61+
.onIOS()
62+
.clickOnElementXPath(
63+
`//XCUIElementTypeCell[.//XCUIElementTypeOther[@name='Message body' and contains(@label,'${message}')]]//XCUIElementTypeStaticText[contains(@value,'(')]`
64+
);
65+
if (platform === 'android') {
66+
const el = await device1.waitForTextElementToBePresent({
67+
strategy: 'id',
68+
selector: 'account-id',
69+
});
70+
const elText = await device1.getTextFromElement(el);
71+
expect(elText).toMatch(/^15/);
72+
await device1.clickOnElementAll({
73+
strategy: '-android uiautomator',
74+
selector: 'new UiSelector().text("Message")',
75+
});
76+
} else {
77+
await device1.waitForTextElementToBePresent({
78+
strategy: 'accessibility id',
79+
selector: 'Blinded ID',
80+
});
81+
await device1.clickOnByAccessibilityID('Message');
82+
}
83+
84+
await device1.clickOnElementAll(new ConversationHeaderName(device1, bob.userName));
85+
const messageRequestPendingDescription = englishStrippedStr(
86+
'messageRequestPendingDescription'
87+
).toString();
88+
await device1.onIOS().waitForTextElementToBePresent({
89+
strategy: 'accessibility id',
90+
selector: 'Control message',
91+
text: messageRequestPendingDescription,
92+
});
93+
await device1.onAndroid().waitForTextElementToBePresent({
94+
strategy: 'id',
95+
selector: 'network.loki.messenger.qa:id/textSendAfterApproval',
96+
text: messageRequestPendingDescription,
97+
});
98+
await device1.sendMessage('Howdy partner');
99+
await device2.clickOnElementAll(new MessageRequestsBanner(device2));
100+
// Bob clicks on request conversation item
101+
await device2.clickOnByAccessibilityID('Message request');
102+
await device2.waitForTextElementToBePresent(new ConversationHeaderName(device2, alice.userName));
103+
const messageRequestsAcceptDescription = englishStrippedStr(
104+
'messageRequestsAcceptDescription'
105+
).toString();
106+
await device2.onIOS().waitForControlMessageToBePresent(messageRequestsAcceptDescription);
107+
await device2.onAndroid().waitForTextElementToBePresent({
108+
strategy: 'id',
109+
selector: 'network.loki.messenger.qa:id/sendAcceptsTextView',
110+
text: messageRequestsAcceptDescription,
111+
});
112+
113+
// Send message from Bob to Alice
114+
const acceptMessage = 'Howdy back';
115+
await device2.sendMessage(acceptMessage);
116+
await device1.waitForTextElementToBePresent(new MessageBody(device1, acceptMessage));
117+
await closeApp(device1, device2);
118+
}

run/test/specs/utils/capabilities_ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const sharediOSCapabilities: AppiumXCUITestCapabilities = {
3131
'appium:processArguments': {
3232
env: {
3333
debugDisappearingMessageDurations: 'true',
34-
communityPollLimit: 5,
34+
communityPollLimit: 3,
3535
},
3636
},
3737
} as AppiumXCUITestCapabilities;

run/types/testing.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export type XPath =
134134
| `//*[./*[@name='${DISAPPEARING_TIMES}']]/*[2]`
135135
| `//*[@resource-id='network.loki.messenger.qa:id/callTitle' and contains(@text, ':')]`
136136
| `//*[starts-with(@content-desc, "Photo taken on")]`
137+
| `//android.view.ViewGroup[@resource-id='network.loki.messenger.qa:id/mainContainer'][.//android.widget.TextView[contains(@text,'${string}')]]//androidx.compose.ui.platform.ComposeView[@resource-id='network.loki.messenger.qa:id/profilePictureView']`
137138
| `//android.view.ViewGroup[@resource-id="network.loki.messenger.qa:id/mainContainer"][.//android.widget.TextView[contains(@text,"${string}")]]//android.view.ViewGroup[@resource-id="network.loki.messenger.qa:id/layout_emoji_container"]`
138139
| `//android.view.ViewGroup[@resource-id="network.loki.messenger.qa:id/mainContainer"][.//android.widget.TextView[contains(@text,"${string}")]]//android.widget.TextView[@resource-id="network.loki.messenger.qa:id/reactions_pill_count"][@text="${string}"]`
139140
| `//android.widget.LinearLayout[.//android.widget.TextView[@content-desc="Conversation list item" and @text="${string}"]]//android.widget.TextView[@resource-id="network.loki.messenger.qa:id/snippetTextView" and @text="${string}"]`
@@ -144,6 +145,7 @@ export type XPath =
144145
| `//XCUIElementTypeButton[@name="Settings"]`
145146
| `//XCUIElementTypeCell[.//XCUIElementTypeOther[@label="${string}"]]//XCUIElementTypeStaticText[@value="😂"]`
146147
| `//XCUIElementTypeCell[.//XCUIElementTypeOther[@label="${string}"]]//XCUIElementTypeStaticText[@value="${string}"]`
148+
| `//XCUIElementTypeCell[.//XCUIElementTypeOther[@name='Message body' and contains(@label,'${string}')]]//XCUIElementTypeStaticText[contains(@value,'(')]`
147149
| `//XCUIElementTypeCell[@name="${string}"]`
148150
| `//XCUIElementTypeCell[@name="Conversation list item" and @label="${string}"]//XCUIElementTypeStaticText[@name="${string}"]`
149151
| `//XCUIElementTypeCell[@name="Session"]`
@@ -197,6 +199,7 @@ export type AccessibilityId =
197199
| 'Awaiting Recipient Answer... 4/6'
198200
| 'back'
199201
| 'Back'
202+
| 'Blinded ID'
200203
| 'Block'
201204
| 'Block contacts - Navigation'
202205
| 'blocked-banner'
@@ -212,6 +215,7 @@ export type AccessibilityId =
212215
| 'Close'
213216
| 'Close button'
214217
| 'Community invitation'
218+
| 'Community Message Requests'
215219
| 'Configuration message'
216220
| 'Confirm'
217221
| 'Confirm block'
@@ -313,6 +317,7 @@ export type AccessibilityId =
313317
| 'MeetingSE'
314318
| 'Meetings option'
315319
| 'Mentions list'
320+
| 'Message'
316321
| 'Message body'
317322
| 'Message composition'
318323
| 'Message input box'

0 commit comments

Comments
 (0)