Files
mobile/e2e/Helpers.ts
Vardan Hakobyan 32a5c0dcda chore: lint codebase according to @standardnotes/config (#594)
* refactor: extend TS configs from snjs and update codebase

* chore: run prettier

* chore: prettier

* chore: eslint

* chore: make file and folder names uppercase

* chore: make remaining file names pascal case

* fix: update custom paths in tsconfig

* fix: correct file name

* fix: set print width to 100
2022-04-20 19:06:35 +04:00

59 lines
1.6 KiB
TypeScript

// eslint-disable-next-line @typescript-eslint/no-var-requires
const faker = require('faker')
import { by, device, element, expect, waitFor } from 'detox'
export const expectToBeVisible = async (testedElement: Detox.IndexableNativeElement) => {
try {
await expect(testedElement).toBeVisible()
return true
} catch (e) {
return false
}
}
const checkAfterReinstall = async () => {
if (device.getPlatform() === 'ios') {
const alertElement = element(
by.label('Delete Local Data').and(by.type('_UIAlertControllerActionView'))
)
const alertVisible = await expectToBeVisible(alertElement)
if (alertVisible) {
await element(
by.label('Delete Local Data').and(by.type('_UIAlertControllerActionView'))
).tap()
}
}
}
export const openSettingsScreen = async () => {
await checkAfterReinstall()
await device.reloadReactNative()
// Opens the settings screen
await waitFor(element(by.id('rootView')))
.toBeVisible()
.withTimeout(2000)
await element(by.id('headerButton')).tap()
await element(by.id('settingsButton')).tap()
}
export const openComposeNewNoteScreen = async () => {
await device.reloadReactNative()
// Opens the screen to compose a new note
await waitFor(element(by.id('rootView')))
.toBeVisible()
.withTimeout(2000)
await waitFor(element(by.id('newNoteButton')))
.toBeVisible()
.withTimeout(2000)
await element(by.id('newNoteButton')).tap()
}
export const randomCredentials = {
email: faker.internet.exampleEmail(),
password: faker.internet.password(),
syncServerUrl: 'https://app-dev.standardnotes.com',
}