Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates tests for Android point release 1.20.6 #21

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default tseslint.config(
},
{
rules: {
'no-unused-vars': 'off',
'no-unused-vars': 'off', // we have @typescript-eslint/no-unused-vars enabled below
'no-else-return': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand Down
2 changes: 1 addition & 1 deletion run/test/specs/group_message_delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function deleteMessageGroup(platform: SupportedPlatformsType) {
.onAndroid()
.checkModalStrings(
englishStripped('deleteMessage').withArgs({ count: 1 }).toString(),
englishStripped('deleteMessageConfirm').toString()
englishStripped('deleteMessageConfirm').withArgs({ count: 1 }).toString()
);
// Select 'Delete for me'
await device1.clickOnElementAll(new DeleteMessageLocally(device1));
Expand Down
2 changes: 1 addition & 1 deletion run/test/specs/group_message_unsend.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function unsendMessageGroup(platform: SupportedPlatformsType) {

await device1.checkModalStrings(
englishStripped('deleteMessage').withArgs({ count: 1 }).toString(),
englishStripped('deleteMessageConfirm').toString()
englishStripped('deleteMessageConfirm').withArgs({ count: 1 }).toString()
);

// Select 'Delete for me'
Expand Down
3 changes: 2 additions & 1 deletion run/test/specs/group_tests_add_contact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ async function addContactToGroup(platform: SupportedPlatformsType) {
await device1.clickOnElementAll(new EditGroup(device1));
await sleepFor(1000);
// Add contact to group
await device1.clickOnElementAll(new InviteContactsMenuItem(device1));
await device1.onIOS().clickOnElementAll(new InviteContactsMenuItem(device1));
await device1.onAndroid().clickOnElementAll(new InviteContactsButton(device1));
// Select new user
const addedContact = await device1.clickOnElementAll({
strategy: 'accessibility id',
Expand Down
4 changes: 2 additions & 2 deletions run/test/specs/linked_device_delete_message.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { newContact } from './utils/create_contact';
import { linkedDevice } from './utils/link_device';
import { SupportedPlatformsType, closeApp, openAppThreeDevices } from './utils/open_app';

bothPlatformsIt('Deleted message linked device', 'high', deletedMessageLinkedDevice);
bothPlatformsIt('Delete message linked device', 'high', deletedMessageLinkedDevice);

async function deletedMessageLinkedDevice(platform: SupportedPlatformsType) {
const { device1, device2, device3 } = await openAppThreeDevices(platform);
Expand All @@ -34,7 +34,7 @@ async function deletedMessageLinkedDevice(platform: SupportedPlatformsType) {
.onAndroid()
.checkModalStrings(
englishStripped('deleteMessage').withArgs({ count: 1 }).toString(),
englishStripped('deleteMessageConfirm').toString()
englishStripped('deleteMessageConfirm').withArgs({ count: 1 }).toString()
);

// Select delete for everyone
Expand Down
5 changes: 2 additions & 3 deletions run/test/specs/locators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,8 @@ export class InviteContactsButton extends LocatorsInterface {
switch (this.platform) {
case 'android':
return {
strategy: 'id',
selector: 'network.loki.messenger:id/title',
text: 'Invite Contacts',
strategy: 'accessibility id',
selector: 'Invite Contacts',
};
case 'ios':
return {
Expand Down
27 changes: 27 additions & 0 deletions run/test/specs/locators/onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StrategyExtractionObj } from '../../../types/testing';
import { LocatorsInterface } from './index';

// SHARED LOCATORS
Expand All @@ -20,6 +21,32 @@ export class ErrorMessage extends LocatorsInterface {
}
}

export class BackButton extends LocatorsInterface {
public build() {
switch (this.platform) {
case 'android':
return {
strategy: 'id',
selector: 'network.loki.messenger:id/back_button',
} as const;
case 'ios':
return {
strategy: 'accessibility id',
selector: 'Back',
} as const;
}
}
}

export class WarningModalQuitButton extends LocatorsInterface {
public build(): StrategyExtractionObj {
return {
strategy: 'id',
selector: 'Quit',
} as const;
}
}

// SPLASH SCREEN
export class CreateAccountButton extends LocatorsInterface {
public build() {
Expand Down
3 changes: 2 additions & 1 deletion run/test/specs/message_deletion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ async function deleteMessage(platform: SupportedPlatformsType) {
await device1.longPressMessage(sentMessage);
// Select Delete icon
await device1.clickOnByAccessibilityID('Delete message');
// There is no modal on iOS yet (to come)
await device1
.onAndroid()
.checkModalStrings(
englishStripped('deleteMessage').withArgs({ count: 1 }).toString(),
englishStripped('deleteMessageConfirm').toString()
englishStripped('deleteMessageConfirm').withArgs({ count: 1 }).toString()
);

// Select 'Delete on this device only'
Expand Down
3 changes: 2 additions & 1 deletion run/test/specs/message_link_preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ async function sendLinkAndroid(platform: SupportedPlatformsType) {
strategy: 'accessibility id',
selector: 'Enable',
});
// No preview on first send
//wait for preview to generate
await sleepFor(5000);
await device1.clickOnByAccessibilityID('Send message button');
await device1.waitForTextElementToBePresent({
strategy: 'accessibility id',
Expand Down
2 changes: 1 addition & 1 deletion run/test/specs/message_unsend.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function unsendMessage(platform: SupportedPlatformsType) {
.onAndroid()
.checkModalStrings(
englishStripped('deleteMessage').withArgs({ count: 1 }).toString(),
englishStripped('deleteMessageConfirm').toString()
englishStripped('deleteMessageConfirm').withArgs({ count: 1 }).toString()
);

// Select 'Delete for me and User B'
Expand Down
8 changes: 6 additions & 2 deletions run/test/specs/user_actions_delete_contact.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { englishStripped } from '../../localizer/i18n/localizedString';
import { bothPlatformsIt } from '../../types/sessionIt';
import { USERNAME } from '../../types/testing';
import { DeleteContactModalConfirm } from './locators/global';
Expand Down Expand Up @@ -36,8 +37,11 @@ async function deleteContact(platform: SupportedPlatformsType) {
await device1.onIOS().swipeLeft('Conversation list item', Bob.userName);
await device1.onAndroid().longPressConversation(Bob.userName);
await device1.clickOnElementAll({ strategy: 'accessibility id', selector: 'Delete' });
// TODO Fix once args checks are merged
// await device1.checkModalStrings('conversationsDelete', 'conversationsDeleteDescription');
await device1.checkModalStrings(
englishStripped('conversationsDelete').toString(),
englishStripped('conversationsDeleteDescription').withArgs({ name: USERNAME.BOB }).toString(),
true
);
await device1.clickOnElementAll(new DeleteContactModalConfirm(device1));
await Promise.all([
device1.doesElementExist({
Expand Down
4 changes: 2 additions & 2 deletions run/test/specs/user_actions_set_nickname.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { newUser } from './utils/create_account';
import { newContact } from './utils/create_contact';
import { SupportedPlatformsType, closeApp, openAppTwoDevices } from './utils/open_app';

iosIt('Create nickname', 'high', setNicknameIos);
androidIt('Create nickname', 'high', setNicknameAndroid);
iosIt('Set nickname', 'high', setNicknameIos);
androidIt('Set nickname', 'high', setNicknameAndroid);

async function setNicknameIos(platform: SupportedPlatformsType) {
const { device1, device2 } = await openAppTwoDevices(platform);
Expand Down
32 changes: 32 additions & 0 deletions run/test/specs/warning_modal_new_account.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { bothPlatformsIt } from '../../types/sessionIt';
import {
CreateAccountButton,
BackButton,
DisplayNameInput,
SlowModeRadio,
ContinueButton,
WarningModalQuitButton,
} from './locators/onboarding';
import { SupportedPlatformsType } from './utils/open_app';
import { openAppOnPlatformSingleDevice, closeApp } from './utils/open_app';
import { USERNAME } from '../../types/testing';

bothPlatformsIt('Warning modal new account', 'medium', warningModalNewAccount);

async function warningModalNewAccount(platform: SupportedPlatformsType) {
const { device } = await openAppOnPlatformSingleDevice(platform);
await device.clickOnElementAll(new CreateAccountButton(device));
await device.inputText(USERNAME.ALICE, new DisplayNameInput(device));
await device.clickOnElementAll(new ContinueButton(device));
// Checking that we're on the Message Notifications screen
await device.doesElementExist(new SlowModeRadio(device));
// Pressing Back on the Message Notifications screen
await device.clickOnElementAll(new BackButton(device));
// Verifying that pressing Back from the Message Notifications screen does not bring up a modal but instead shows the Display Name input field
await device.doesElementExist(new DisplayNameInput(device));
// Pressing Back on the Display Name screen to trigger the Warning modal
await device.clickOnElementAll(new BackButton(device));
await device.checkModalStrings('warning', 'onboardingBackAccountCreation');
await device.clickOnElementAll(new WarningModalQuitButton(device));
await closeApp(device);
}
29 changes: 29 additions & 0 deletions run/test/specs/warning_modal_restore_account.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { bothPlatformsIt } from '../../types/sessionIt';
import {
SeedPhraseInput,
BackButton,
SlowModeRadio,
ContinueButton,
AccountRestoreButton,
WarningModalQuitButton,
} from './locators/onboarding';
import { SupportedPlatformsType } from './utils/open_app';
import { openAppOnPlatformSingleDevice, closeApp } from './utils/open_app';

bothPlatformsIt('Warning modal restore account', 'medium', warningModalRestoreAccount);

async function warningModalRestoreAccount(platform: SupportedPlatformsType) {
const { device } = await openAppOnPlatformSingleDevice(platform);
const seedPhrase =
'eldest fazed hybrid buzzer nasty domestic digit pager unusual purged makeup assorted domestic';
await device.clickOnElementAll(new AccountRestoreButton(device));
await device.inputText(seedPhrase, new SeedPhraseInput(device));
await device.clickOnElementAll(new ContinueButton(device));
// Checking that we're on the Message Notifications screen
await device.doesElementExist(new SlowModeRadio(device).build());
// Pressing Back on the Message Notifications screen to trigger the Warning modal
await device.clickOnElementAll(new BackButton(device));
await device.checkModalStrings('warning', 'onboardingBackLoadAccount');
await device.clickOnElementAll(new WarningModalQuitButton(device));
await closeApp(device);
}
40 changes: 15 additions & 25 deletions run/types/DeviceWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
ReadReceiptsButton,
} from '../../run/test/specs/locators';
import { IOS_XPATHS } from '../constants';
import { englishStripped, TokenString } from '../localizer/i18n/localizedString';
import { LocalizerDictionary } from '../localizer/Localizer';
import { ModalDescription, ModalHeading } from '../test/specs/locators/global';
import { SaveProfilePictureButton, UserSettings } from '../test/specs/locators/settings';
import { clickOnCoordinates, sleepFor } from '../test/specs/utils';
import { getAdbFullPath } from '../test/specs/utils/binaries';
import { SupportedPlatformsType } from '../test/specs/utils/open_app';
import { isDeviceAndroid, isDeviceIOS, runScriptAndLog } from '../test/specs/utils/utilities';
import {
Expand All @@ -30,8 +30,6 @@ import {
User,
XPath,
} from './testing';
import { SaveProfilePictureButton, UserSettings } from '../test/specs/locators/settings';
import { getAdbFullPath } from '../test/specs/utils/binaries';

export type Coordinates = {
x: number;
Expand Down Expand Up @@ -1319,7 +1317,7 @@ export class DeviceWrapper {
}
if (this.isIOS()) {
const testMessage = 'Testing-document-1';
const spongebobsBirthday = '199905010700.00';
const spongeBobsBirthday = '199905010700.00';
await this.clickOnByAccessibilityID('Attachments button');
await sleepFor(100);
await clickOnCoordinates(this, InteractionPoints.DocumentKeyboardOpen);
Expand All @@ -1333,7 +1331,7 @@ export class DeviceWrapper {

if (!testDocument) {
await runScriptAndLog(
`touch -a -m -t ${spongebobsBirthday} 'run/test/specs/media/test_file.pdf'`
`touch -a -m -t ${spongeBobsBirthday} 'run/test/specs/media/test_file.pdf'`
);

await runScriptAndLog(
Expand Down Expand Up @@ -1428,7 +1426,7 @@ export class DeviceWrapper {
}

public async uploadProfilePicture() {
const spongebobsBirthday = '199805010700.00';
const spongeBobsBirthday = '199805010700.00';
await this.clickOnElementAll(new UserSettings(this));
// Click on Profile picture
await this.clickOnElementAll(new UserSettings(this));
Expand All @@ -1443,7 +1441,7 @@ export class DeviceWrapper {
});
if (!profilePicture) {
await runScriptAndLog(
`touch -a -m -t ${spongebobsBirthday} 'run/test/specs/media/profile_picture.jpg'`
`touch -a -m -t ${spongeBobsBirthday} 'run/test/specs/media/profile_picture.jpg'`
);

await runScriptAndLog(
Expand Down Expand Up @@ -1477,7 +1475,7 @@ export class DeviceWrapper {
// If no image, push file to this
if (!profilePicture) {
await runScriptAndLog(
`touch -a -m -t ${spongebobsBirthday} 'run/test/specs/media/profile_picture.jpg'`
`touch -a -m -t ${spongeBobsBirthday} 'run/test/specs/media/profile_picture.jpg'`
);

await runScriptAndLog(
Expand Down Expand Up @@ -1520,9 +1518,8 @@ export class DeviceWrapper {
maxWait: 500,
});
return Boolean(spaceBar);
} else {
console.log(`Not an iOS device: shouldn't use this function`);
}
console.log(`Not an iOS device: shouldn't use this function`);
}

public async mentionContact(platform: SupportedPlatformsType, contact: User) {
Expand Down Expand Up @@ -1741,16 +1738,15 @@ export class DeviceWrapper {
}

public async checkModalStrings(
expectedStringHeading: TokenString<LocalizerDictionary>,
expectedStringDescription: TokenString<LocalizerDictionary>,
expectedHeading: string,
expectedDescription: string,
oldModalAndroid?: boolean
) {
// Check modal heading is correct
function removeNewLines(input: string): string {
// return input.replace(/<br\s*\/?>/gi, '\nCR LF');
return input.replace(/\n/gi, '');
}
const expectedHeading = englishStripped(expectedStringHeading).toString();

let elHeading;
// Some modals in Android haven't been updated to compose yet therefore need different locators
if (!oldModalAndroid) {
Expand All @@ -1762,22 +1758,14 @@ export class DeviceWrapper {
});
}
const actualHeading = await this.getTextFromElement(elHeading);
if (expectedStringHeading === actualHeading) {
if (expectedHeading === actualHeading) {
console.log('Modal heading is correct');
} else {
throw new Error(
`Modal heading is incorrect. Expected heading: ${expectedHeading}, Actual heading: ${actualHeading}`
);
}
// Now check modal description
// let expectedDescription;
const expectedDescription = englishStripped(expectedStringDescription).toString();
// if (!args) {
// } else {
// expectedDescription = englishStripped(expectedStringDescription)
// .withArgs(args as any)
// .toString();
// }
let elDescription;
if (!oldModalAndroid) {
elDescription = await this.waitForTextElementToBePresent(new ModalDescription(this));
Expand All @@ -1792,8 +1780,10 @@ export class DeviceWrapper {
const formattedDescription = removeNewLines(actualDescription);
if (expectedDescription !== formattedDescription) {
throw new Error(
`Modal description is incorrect. Expected description: ${expectedStringDescription}, Actual description: ${formattedDescription}`
`Modal description is incorrect. Expected description: ${expectedDescription}, Actual description: ${formattedDescription}`
);
} else {
console.log('Modal description is correct');
}
}

Expand Down
6 changes: 3 additions & 3 deletions run/types/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ export type AccessibilityId =
| 'Error message'
| 'Open URL'
| 'Terms of Service'
| 'Terms of service button'
| 'Privacy Policy'
| 'Privacy policy button'
| 'TabBarItemTitle'
| 'URL';

Expand Down Expand Up @@ -366,6 +364,8 @@ export type Id =
| 'Terms of Service'
| 'Privacy Policy'
| 'com.android.chrome:id/signin_fre_dismiss_button'
| 'com.android.chrome:id/negative_button';
| 'com.android.chrome:id/negative_button'
| 'network.loki.messenger:id/back_button'
| 'Quit';

export type TestRisk = 'high' | 'medium' | 'low' | undefined;