about summary refs log tree commit diff
path: root/__e2e__/util.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2024-05-13 08:43:13 -0700
committerGitHub <noreply@github.com>2024-05-13 08:43:13 -0700
commitd49b93dc7e77962c143e4798344c8e35ab8a637e (patch)
treeb893fa4388413cbd1cf139c4cd848c91d1cc13b0 /__e2e__/util.ts
parent5cd4ac3a34f629945ccb86e451fbf20dd06e6863 (diff)
downloadvoidsky-d49b93dc7e77962c143e4798344c8e35ab8a637e.tar.zst
Replace e2e tests with Maestro (#3983)
* Setup maestro tests and convert some initial tests

* Remove detox

* Replace all tests with maestro
Diffstat (limited to '__e2e__/util.ts')
-rw-r--r--__e2e__/util.ts141
1 files changed, 0 insertions, 141 deletions
diff --git a/__e2e__/util.ts b/__e2e__/util.ts
deleted file mode 100644
index 70fbdb601..000000000
--- a/__e2e__/util.ts
+++ /dev/null
@@ -1,141 +0,0 @@
-import {execSync} from 'child_process'
-import {resolveConfig} from 'detox/internals'
-import http from 'http'
-
-const platform = device.getPlatform()
-
-export async function openApp(opts: any) {
-  opts = opts || {}
-  const config = await resolveConfig()
-
-  if (device.getPlatform() === 'ios') {
-    // disable password autofill
-    execSync(
-      `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles/UserSettings.plist`,
-    )
-    execSync(
-      `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Library/UserConfigurationProfiles/EffectiveUserSettings.plist`,
-    )
-    execSync(
-      `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Library/UserConfigurationProfiles/PublicInfo/PublicEffectiveUserSettings.plist`,
-    )
-  }
-  if (config.configurationName.split('.').includes('debug')) {
-    return await openAppForDebugBuild(platform, opts)
-  } else {
-    return await device.launchApp({
-      ...opts,
-      newInstance: true,
-    })
-  }
-}
-
-export async function isVisible(id: string) {
-  try {
-    await expect(element(by.id(id))).toBeVisible()
-    return true
-  } catch (e) {
-    return false
-  }
-}
-
-export async function login(
-  service: string,
-  username: string,
-  password: string,
-  {takeScreenshots} = {takeScreenshots: false},
-) {
-  await element(by.id('signInButton')).tap()
-  if (takeScreenshots) {
-    await device.takeScreenshot('1- opened sign-in screen')
-  }
-  if (await isVisible('chooseAccountForm')) {
-    await element(by.id('chooseNewAccountBtn')).tap()
-  }
-  await element(by.id('selectServiceButton')).tap()
-  if (takeScreenshots) {
-    await device.takeScreenshot('2- opened service selector')
-  }
-  await element(by.id('customSelectBtn')).tap()
-  await element(by.id('customServerTextInput')).typeText(service)
-  await element(by.id('customServerTextInput')).tapReturnKey()
-  await element(by.id('doneBtn')).tap()
-  if (takeScreenshots) {
-    await device.takeScreenshot('3- input custom service')
-  }
-  await element(by.id('loginUsernameInput')).typeText(username)
-  await element(by.id('loginPasswordInput')).typeText(password)
-  if (takeScreenshots) {
-    await device.takeScreenshot('4- entered username and password')
-  }
-  await element(by.id('loginNextButton')).tap()
-}
-
-export async function loginAsAlice() {
-  await element(by.id('e2eSignInAlice')).tap()
-}
-
-export async function loginAsBob() {
-  await element(by.id('e2eSignInBob')).tap()
-}
-
-async function openAppForDebugBuild(platform: string, opts: any) {
-  const deepLinkUrl = // Local testing with packager
-    /*process.env.EXPO_USE_UPDATES
-    ? // Testing latest published EAS update for the test_debug channel
-      getDeepLinkUrl(getLatestUpdateUrl())
-    : */ getDeepLinkUrl(getDevLauncherPackagerUrl(platform))
-
-  if (platform === 'ios') {
-    await device.launchApp({
-      ...opts,
-      newInstance: true,
-    })
-    sleep(3000)
-    await device.openURL({
-      url: deepLinkUrl,
-    })
-  } else {
-    await device.launchApp({
-      ...opts,
-      newInstance: true,
-      url: deepLinkUrl,
-    })
-  }
-
-  await sleep(3000)
-}
-
-export async function createServer(path = ''): Promise<string> {
-  return new Promise(function (resolve, reject) {
-    var req = http.request(
-      {
-        method: 'POST',
-        host: 'localhost',
-        port: 1986,
-        path: `/${path}`,
-      },
-      function (res) {
-        const body: Buffer[] = []
-        res.on('data', chunk => body.push(chunk))
-        res.on('end', function () {
-          try {
-            resolve(Buffer.concat(body).toString())
-          } catch (e) {
-            reject(e)
-          }
-        })
-      },
-    )
-    req.on('error', reject)
-    req.end()
-  })
-}
-
-const getDeepLinkUrl = (url: string) =>
-  `expo+bluesky://expo-development-client/?url=${encodeURIComponent(url)}`
-
-const getDevLauncherPackagerUrl = (platform: string) =>
-  `http://localhost:8081/index.bundle?platform=${platform}&dev=true&minify=false&disableOnboarding=1`
-
-export const sleep = (t: number) => new Promise(res => setTimeout(res, t))