Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions run/screenshots/ios/app_disguise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/conversation_alice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/conversation_bob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/landingpage_new_account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/landingpage_restore_account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/settings_appearance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/settings_conversations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/settings_notifications.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions run/screenshots/ios/settings_privacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion run/test/locators/global_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CancelSearchButton extends LocatorsInterface {
case 'ios':
return {
strategy: 'accessibility id',
selector: 'Cancel',
selector: 'Close',
};
}
}
Expand Down
28 changes: 28 additions & 0 deletions run/test/locators/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,34 @@ export class HideRecoveryPasswordButton extends LocatorsInterface {
}
}

export class LockAppOption extends LocatorsInterface {
public build() {
switch (this.platform) {
case 'android':
return {
strategy: 'id',
selector: 'preferences-option-lock-app',
} as const;
case 'ios':
throw new Error('Not implemented on iOS');
}
}
}

export class LockAppToggle extends LocatorsInterface {
public build() {
switch (this.platform) {
case 'android':
return {
strategy: 'id',
selector: 'preferences-option-lock-app-toggle',
} as const;
case 'ios':
throw new Error('Not implemented on iOS');
}
}
}

export class NotificationsMenuItem extends LocatorsInterface {
public build() {
switch (this.platform) {
Expand Down
2 changes: 1 addition & 1 deletion run/test/specs/community_requests_off.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bothPlatformsIt({
risk: 'medium',
testCb: blindedMessageRequests,
countOfDevicesNeeded: 2,
allureSuites: { parent: 'Settings', suite: 'Community Message Requests' },
allureSuites: { parent: 'Settings', suite: 'Privacy' },
allureDescription:
'Verifies that a message request cannot be sent when Community Message Requests are off.',
});
Expand Down
2 changes: 1 addition & 1 deletion run/test/specs/community_requests_on.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bothPlatformsIt({
risk: 'medium',
testCb: blindedMessageRequests,
countOfDevicesNeeded: 2,
allureSuites: { parent: 'Settings', suite: 'Community Message Requests' },
allureSuites: { parent: 'Settings', suite: 'Privacy' },
allureDescription:
'Verifies that a message request can be sent when Community Message Requests are on.',
allureLinks: {
Expand Down
2 changes: 1 addition & 1 deletion run/test/specs/message_requests_block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function blockedRequest(platform: SupportedPlatformsType, testInfo: TestIn
}),
device3.verifyElementNotPresent({
...new MessageRequestsBanner(device3).build(),
maxWait: 5_000,
maxWait: 10_000,
}),
]);
const blockedMessage = `"${alice.userName} to ${bob.userName} - shouldn't get through"`;
Expand Down
63 changes: 63 additions & 0 deletions run/test/specs/user_actions_lock_app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { test, type TestInfo } from '@playwright/test';

import { TestSteps } from '../../types/allure';
import { androidIt } from '../../types/sessionIt';
import { USERNAME } from '../../types/testing';
import { PlusButton } from '../locators/home';
import { LockAppOption, LockAppToggle, PrivacyMenuItem, UserSettings } from '../locators/settings';
import { newUser } from '../utils/create_account';
import { closeApp, openAppOnPlatformSingleDevice, SupportedPlatformsType } from '../utils/open_app';
import { forceStopAndRestart, runScriptAndLog } from '../utils/utilities';

// `xcrun simctl` doesn't support adding a pin like adb does so this is an Android only test
androidIt({
title: 'Lock app',
risk: 'high',
testCb: lockApp,
countOfDevicesNeeded: 1,
allureSuites: {
parent: 'Settings',
suite: 'Privacy',
},
allureDescription:
'Verifies the app can be locked with a PIN and that the system lock screen appears on app launch when enabled.',
});

async function lockApp(platform: SupportedPlatformsType, testInfo: TestInfo) {
const pin = '12345678';
const { device } = await test.step(TestSteps.SETUP.NEW_USER, async () => {
const { device } = await openAppOnPlatformSingleDevice(platform, testInfo);
await newUser(device, USERNAME.ALICE, { saveUserData: false });
return { device };
});
try {
await test.step('Set device PIN', async () => {
await runScriptAndLog(`adb -s ${device.udid} shell locksettings set-pin ${pin}`, true);
});
await test.step('Enable app lock', async () => {
await device.clickOnElementAll(new UserSettings(device));
await device.clickOnElementAll(new PrivacyMenuItem(device));
await device.clickOnElementAll(new LockAppOption(device));
await device.assertAttribute(new LockAppToggle(device), 'checked', 'true');
});
await test.step('Force stop and restart app', async () => {
await forceStopAndRestart(device, false);
// The unlock screen is not visible to appium so there's no real way to tell it appeared
// Other than waiting a long time to make sure the home screen (plus button) never appeared
// This prevents the false positive where we send key events to nowhere and the lock screen never appeared anyway
await device.verifyElementNotPresent({ ...new PlusButton(device).build(), maxWait: 10_000 });
});
await test.step('Enter PIN to unlock app', async () => {
await runScriptAndLog(`adb -s ${device.udid} shell input text ${pin}`, true);
await runScriptAndLog(`adb -s ${device.udid} shell input keyevent 66`, true);
});
await test.step('Verify home screen is visible', async () => {
await device.waitForTextElementToBePresent(new PlusButton(device));
});
await test.step(TestSteps.SETUP.CLOSE_APP, async () => {
await closeApp(device);
});
} finally {
await runScriptAndLog(`adb -s ${device.udid} shell locksettings clear --old ${pin}`, true);
}
}
9 changes: 3 additions & 6 deletions run/test/utils/device_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export type DeviceContext = {

export const deviceRegistry = new Map<string, DeviceContext>();

export function registryKey(testInfo: TestInfo, retry = testInfo.retry): string {
return `${testInfo.testId}-${testInfo.parallelIndex}-${testInfo.repeatEachIndex}-${retry}`;
export function registryKey(testInfo: TestInfo): string {
return `${testInfo.testId}-${testInfo.parallelIndex}-${testInfo.repeatEachIndex}`;
}

// Async because Android registration fetches per-device PID for scoped logcat on failure.
Expand Down Expand Up @@ -59,8 +59,5 @@ export async function registerDevicesForTest(
}

export function unregisterDevicesForTest(testInfo: TestInfo) {
// Clean up current attempt and any stale entries left by prior retry attempts
for (let r = 0; r <= testInfo.retry; r++) {
deviceRegistry.delete(registryKey(testInfo, r));
}
deviceRegistry.delete(registryKey(testInfo));
}
11 changes: 8 additions & 3 deletions run/test/utils/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ export async function clearStatusBarOverrides(device: DeviceWrapper): Promise<vo
}
}

export async function forceStopAndRestart(device: DeviceWrapper): Promise<void> {
export async function forceStopAndRestart(
device: DeviceWrapper,
waitForRestart: boolean = true
): Promise<void> {
if (device.isAndroid()) {
await runScriptAndLog(`adb -s ${device.udid} shell am force-stop ${androidAppPackage}`, true);
await sleepFor(1_000);
Expand All @@ -148,8 +151,10 @@ export async function forceStopAndRestart(device: DeviceWrapper): Promise<void>
await runScriptAndLog(`xcrun simctl launch ${device.udid} ${iOSBundleId}`, true);
await sleepFor(1_000);
}
// Ensure we're on the home screen again
await device.waitForTextElementToBePresent(new PlusButton(device));
// Ensure we're on the home screen again if desired
if (waitForRestart) {
await device.waitForTextElementToBePresent(new PlusButton(device));
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion run/types/allure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type AllureSuiteConfig =
| { parent: 'Session Pro' }
| {
parent: 'Settings';
suite: 'App Disguise' | 'Community Message Requests' | 'Notifications' | 'Recovery Password';
suite: 'App Disguise' | 'Notifications' | 'Privacy' | 'Recovery Password';
}
| {
parent: 'User Actions';
Expand Down
2 changes: 2 additions & 0 deletions run/types/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ export type Id =
| 'Open URL'
| 'preferences-dialog-option-enable'
| 'preferences-option-blocked-contacts'
| 'preferences-option-lock-app-toggle'
| 'preferences-option-lock-app'
| 'preferences-option-read-receipt'
| 'preferences-option-whitelist-toggle'
| 'preferred-display-name'
Expand Down
Loading