forked from oxen-io/session-appium
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Miki-Session/consistent-account-colors
Consistent avatar colors
- Loading branch information
Showing
10 changed files
with
530 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { bothPlatformsIt } from '../../types/sessionIt'; | ||
import { USERNAME } from '../../types/testing'; | ||
import { newUser } from './utils/create_account'; | ||
import { newContact } from './utils/create_contact'; | ||
import { SupportedPlatformsType, closeApp, openAppTwoDevices } from './utils/open_app'; | ||
import { isSameColor } from './utils/check_colour'; | ||
import { UserSettings } from './locators/settings'; | ||
import { ConversationItem } from './locators/home'; | ||
import { ConversationAvatar, ConversationSettings } from './locators/conversation'; | ||
|
||
bothPlatformsIt('Avatar color', 'medium', avatarColor); | ||
|
||
async function avatarColor(platform: SupportedPlatformsType) { | ||
const { device1, device2 } = await openAppTwoDevices(platform); | ||
const [userA, userB] = await Promise.all([ | ||
newUser(device1, USERNAME.ALICE), | ||
newUser(device2, USERNAME.BOB), | ||
]); | ||
await newContact(platform, device1, userA, device2, userB); | ||
await Promise.all([device1.navigateBack(), device2.navigateBack()]); | ||
// Get Alice's avatar color on device 1 (Home Screen avatar) and turn it into a hex value | ||
const device1PixelColor = await device1.getElementPixelColor(new UserSettings(device1)); | ||
// Get Alice's avatar color on device 2 and turn it into a hex value | ||
await device2.clickOnElementAll(new ConversationItem(device2)); | ||
let device2PixelColor; | ||
// The conversation screen looks slightly different per platform so we're grabbing the avatar from different locators | ||
// On iOS the avatar doubles as the Conversation Settings button on the right | ||
// On Android, the avatar is a separate, non-interactable element on the left (and the settings has the 3-dot icon) | ||
if (platform === 'ios') { | ||
device2PixelColor = await device2.getElementPixelColor(new ConversationSettings(device2)); | ||
} else { | ||
device2PixelColor = await device2.getElementPixelColor(new ConversationAvatar(device2)); | ||
} | ||
// Color matching devices 1 and 2 | ||
const colorMatch = isSameColor(device1PixelColor, device2PixelColor); | ||
if (!colorMatch) { | ||
throw new Error( | ||
`The avatar color of ${userA.userName} does not match across devices. The colors are ${device1PixelColor} and ${device2PixelColor}` | ||
); | ||
} | ||
await closeApp(device1, device2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { bothPlatformsIt } from '../../types/sessionIt'; | ||
import { USERNAME } from '../../types/testing'; | ||
import { linkedDevice } from './utils/link_device'; | ||
import { SupportedPlatformsType, closeApp, openAppTwoDevices } from './utils/open_app'; | ||
import { isSameColor } from './utils/check_colour'; | ||
import { UserSettings } from './locators/settings'; | ||
|
||
bothPlatformsIt('Avatar color linked device', 'medium', avatarColorLinkedDevice); | ||
|
||
async function avatarColorLinkedDevice(platform: SupportedPlatformsType) { | ||
const { device1, device2 } = await openAppTwoDevices(platform); | ||
const userA = await linkedDevice(device1, device2, USERNAME.ALICE); | ||
// Get Alice's avatar color on device 1 (Home Screen avatar) and turn it into a hex value | ||
const device1PixelColor = await device1.getElementPixelColor(new UserSettings(device1)); | ||
// Get Alice's avatar color on the linked device (Home Screen avatar) and turn it into a hex value | ||
const device2PixelColor = await device2.getElementPixelColor(new UserSettings(device2)); | ||
// Color matching devices 1 and 2 | ||
const colorMatch = isSameColor(device1PixelColor, device2PixelColor); | ||
if (!colorMatch) { | ||
throw new Error( | ||
`The avatar color of ${userA.userName} does not match across devices. The colors are ${device1PixelColor} and ${device2PixelColor}` | ||
); | ||
} | ||
await closeApp(device1, device2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.