From 1add930d40d09e3fed43e49272b1d937cc3c4c63 Mon Sep 17 00:00:00 2001 From: Ahsan Ali Date: Sat, 14 Nov 2026 14:51:54 +0000 Subject: [PATCH 1/2] E2E: same flows as the native SDKs Ports the native Android and iOS SDK e2e rows to the wrapper, driven by one environment table (e2e/e2e-env.json) and one flow table (e2e/e2e-flows.json): custom-domain and subdomain click-token installs, probabilistic installs, the link-type matrix (general, campaign, influencer, partner) with per_install reward checks, re-engagement on link-type links (openCount, no second reward), and the per_event / rev_share event-reward rows. Prod is the default; links a run's environment doesn't have are skipped with a notice. e2e/targets.py resolves the tables for the runners and validates them, e2e/verify.py holds the backend rules (as the native scripts/e2e-verify.py). The example app's e2e panel gains a deny-consent and a track-install button and a kickflip://e2e/events hook for the reward rows (e2e builds only). --- .github/workflows/e2e.yml | 83 +++- .gitignore | 4 + TESTING.md | 116 +++-- e2e/android.sh | 136 +++--- e2e/e2e-env.json | 60 +++ e2e/e2e-flows.json | 23 + e2e/flows/android/deferred_allow.yaml | 15 +- e2e/flows/android/deferred_deny.yaml | 12 +- .../android/deferred_problistic_allow.yaml | 17 + .../android/deferred_problistic_deny.yaml | 13 + e2e/flows/android/reengagement.yaml | 17 +- e2e/flows/android/reengagement_type.yaml | 20 + e2e/flows/android/send_events.yaml | 11 + e2e/flows/ios/_stage_click.yaml | 3 +- e2e/flows/ios/deferred_allow.yaml | 16 +- e2e/flows/ios/deferred_deny.yaml | 6 +- e2e/flows/ios/deferred_problistic_allow.yaml | 17 + e2e/flows/ios/deferred_problistic_deny.yaml | 14 + e2e/flows/ios/reengagement.yaml | 16 +- e2e/flows/ios/reengagement_type.yaml | 21 + e2e/flows/ios/send_events.yaml | 12 + e2e/ios.sh | 117 +++--- e2e/lib.sh | 316 ++++++++++---- e2e/targets.py | 397 ++++++++++++++++++ e2e/tests/test_e2e.py | 213 ++++++++++ e2e/verify.py | 361 ++++++++++++++++ example/App.tsx | 1 + example/src/attribution.ts | 21 +- example/src/e2e/E2EPanel.tsx | 28 +- example/src/e2e/config.d.ts | 2 + example/src/e2e/hooks.ts | 66 +++ example/src/e2e/recorder.ts | 25 +- 32 files changed, 1862 insertions(+), 317 deletions(-) create mode 100644 e2e/e2e-env.json create mode 100644 e2e/e2e-flows.json create mode 100644 e2e/flows/android/deferred_problistic_allow.yaml create mode 100644 e2e/flows/android/deferred_problistic_deny.yaml create mode 100644 e2e/flows/android/reengagement_type.yaml create mode 100644 e2e/flows/android/send_events.yaml create mode 100644 e2e/flows/ios/deferred_problistic_allow.yaml create mode 100644 e2e/flows/ios/deferred_problistic_deny.yaml create mode 100644 e2e/flows/ios/reengagement_type.yaml create mode 100644 e2e/flows/ios/send_events.yaml create mode 100644 e2e/targets.py create mode 100644 e2e/tests/test_e2e.py create mode 100644 e2e/verify.py create mode 100644 example/src/e2e/hooks.ts diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 08c433c..6b91cb4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,20 +1,34 @@ name: E2E -# Maestro smoke e2e for the React Native wrapper, on the example app built from the local wrapper -# source (see TESTING.md): -# native-versions pinned native SDK versions vs the latest published (report-only for now) +# Maestro e2e for the React Native wrapper, on the example app built from the local wrapper source, +# with the same flows as the native SDK suites (see TESTING.md). GitHub-hosted runners only. +# config e2e/e2e-env.json + e2e/e2e-flows.json + the flow files agree; unit tests; shellcheck +# native-versions pinned native SDK versions vs the latest published # android ubuntu + KVM emulator (API 35) -# ios self-hosted Mac simulator, serialised by e2e/sim-lock.sh +# ios macOS simulator # -# Secrets: LINKTRAIL_KEY (workspace SDK key) and E2E_TOKEN (X-E2E-Token for the private backend -# check). Without both, only the offline flows run and the real ones are skipped with a notice. -# Pull requests from forks get no secrets, and never run on the self-hosted Mac. +# Environment: prod by default (LINKTRAIL_ENV); a manual run can pick dev and the link types. +# Secrets: LINKTRAIL_KEY (prod workspace SDK key), LINKTRAIL_TEST_KEY (dev workspace SDK key, dev +# runs only) and E2E_TOKEN (X-E2E-Token for the private backend check). Without the environment's +# key and E2E_TOKEN only the offline flow runs and the real ones are skipped with a notice (pull +# requests from forks get no secrets). # Variables (optional): # NATIVE_VERSION_STRICT 'false' to only warn on native SDK drift (default: fail) +# E2E_ENV the environment of pull request runs (default prod) on: pull_request: workflow_dispatch: + inputs: + environment: + description: 'Backend + links (e2e/e2e-env.json)' + type: choice + options: [prod, dev] + default: prod + link_types: + description: 'Link-type rows: all, none, or a comma list (general,partner)' + type: string + default: all permissions: contents: read @@ -23,7 +37,24 @@ concurrency: group: e2e-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} +env: + LINKTRAIL_ENV: ${{ inputs.environment || vars.E2E_ENV || 'prod' }} + E2E_LINK_TYPES: ${{ inputs.link_types || 'all' }} + jobs: + config: + name: E2E config + scripts + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - name: Validate the targets and the flow table + run: python3 -I e2e/targets.py validate + - name: Unit tests (e2e/targets.py, e2e/verify.py) + run: python3 -I -m unittest discover -s e2e/tests -v + - name: shellcheck + run: shellcheck -x e2e/*.sh + native-versions: name: Native SDK versions runs-on: ubuntu-latest @@ -37,14 +68,10 @@ jobs: android: name: Android e2e (Maestro) runs-on: ubuntu-latest - timeout-minutes: 75 + timeout-minutes: 150 env: API_LEVEL: 35 - HAVE_SECRETS: ${{ secrets.LINKTRAIL_KEY != '' && secrets.E2E_TOKEN != '' }} steps: - - name: Secrets notice - if: env.HAVE_SECRETS != 'true' - run: echo "::notice title=e2e::LINKTRAIL_KEY / E2E_TOKEN not available — only the offline flows run." - uses: actions/checkout@v4 @@ -78,6 +105,7 @@ jobs: - name: Build the example APK env: LINKTRAIL_KEY: ${{ secrets.LINKTRAIL_KEY }} + LINKTRAIL_TEST_KEY: ${{ secrets.LINKTRAIL_TEST_KEY }} E2E_TOKEN: ${{ secrets.E2E_TOKEN }} BUILD_ONLY: '1' run: bash e2e/android.sh @@ -119,9 +147,10 @@ jobs: script: echo "Generated AVD snapshot for caching." - name: E2E — Maestro - timeout-minutes: 30 + timeout-minutes: 120 env: LINKTRAIL_KEY: ${{ secrets.LINKTRAIL_KEY }} + LINKTRAIL_TEST_KEY: ${{ secrets.LINKTRAIL_TEST_KEY }} E2E_TOKEN: ${{ secrets.E2E_TOKEN }} SKIP_BUILD: '1' uses: reactivecircus/android-emulator-runner@v2 @@ -138,6 +167,15 @@ jobs: emulator-boot-timeout: 900 script: sleep 45 && bash e2e/android.sh + - name: Upload the e2e results + if: always() + uses: actions/upload-artifact@v4 + with: + name: e2e-results-android + path: e2e/results-android.jsonl + retention-days: 14 + if-no-files-found: ignore + - name: Upload Maestro debug output if: failure() uses: actions/upload-artifact@v4 @@ -153,15 +191,11 @@ jobs: # manual runs only, because the job uses the repo's e2e secrets. if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository runs-on: macos-latest - timeout-minutes: 120 + timeout-minutes: 210 env: LANG: en_US.UTF-8 LC_ALL: en_US.UTF-8 - HAVE_SECRETS: ${{ secrets.LINKTRAIL_KEY != '' && secrets.E2E_TOKEN != '' }} steps: - - name: Secrets notice - if: env.HAVE_SECRETS != 'true' - run: echo "::notice title=e2e::LINKTRAIL_KEY / E2E_TOKEN not available — only the offline flows run." - uses: actions/checkout@v4 @@ -191,6 +225,7 @@ jobs: - name: Build the example app env: LINKTRAIL_KEY: ${{ secrets.LINKTRAIL_KEY }} + LINKTRAIL_TEST_KEY: ${{ secrets.LINKTRAIL_TEST_KEY }} E2E_TOKEN: ${{ secrets.E2E_TOKEN }} run: | set -euo pipefail @@ -213,13 +248,23 @@ jobs: xcrun simctl bootstatus "$UDID" -b >/dev/null 2>&1 || true - name: E2E — Maestro - timeout-minutes: 45 + timeout-minutes: 160 env: LINKTRAIL_KEY: ${{ secrets.LINKTRAIL_KEY }} + LINKTRAIL_TEST_KEY: ${{ secrets.LINKTRAIL_TEST_KEY }} E2E_TOKEN: ${{ secrets.E2E_TOKEN }} SKIP_BUILD: '1' run: DEVICE="$SIM_UDID" bash e2e/ios.sh + - name: Upload the e2e results + if: always() + uses: actions/upload-artifact@v4 + with: + name: e2e-results-ios + path: e2e/results-ios.jsonl + retention-days: 14 + if-no-files-found: ignore + - name: Upload Maestro debug output if: failure() uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index ab9b8e5..a56c1ee 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ coverage/ *.jks example/android/upload-keystore.jks example/ios/build-e2e/ + +# e2e run output +e2e/results-*.jsonl +__pycache__/ diff --git a/TESTING.md b/TESTING.md index 1b528ad..3d00203 100644 --- a/TESTING.md +++ b/TESTING.md @@ -6,54 +6,96 @@ `.github/workflows/ci.yml`, plus a JS bundle and an Android build of the example app; `.github/workflows/ios.yml` builds the example for the iOS simulator. -## Smoke e2e (Maestro) +## E2E (Maestro) -`.github/workflows/e2e.yml` runs a small Maestro suite on the example app (`example/`), which uses -the wrapper from source (`"linktrail-react-native": "file:.."`) and the native SDKs it pins -(`LinkTrailSDK` from CocoaPods, `io.linktrail:sdk` from Maven Central). It runs on pull requests -and on manual dispatch. +`.github/workflows/e2e.yml` runs Maestro on the example app (`example/`), which uses the wrapper +from source (`"linktrail-react-native": "file:.."`) and the native SDKs it pins (`LinkTrailSDK` +from CocoaPods, `io.linktrail:sdk` from Maven Central). It runs the same flows as the native SDK +suites, through the wrapper, on GitHub-hosted runners, on pull requests and on manual dispatch. App ids: Android `io.linktrail.demo.store` (the `applicationId`; the Kotlin namespace stays `com.kickflip`), iOS `io.linktrail.kickflipdemo`. Both must be in the backend's `E2E_APP_IDENTIFIERS` for the verify check. -| Flow | Android | iOS | Needs secrets | -| --- | --- | --- | --- | -| `consent_prompt` | consent gate shows; Deny persists across a relaunch | gate shows; Skip stays undecided; a grant persists | no | -| `deferred_allow` | real click, fake Play referrer, Allow | Safari stages the click token on the clipboard, Allow + Paste | yes | -| `deferred_deny` | the same with Deny | the same with Deny | yes | -| `reengagement` | https App Link while installed | `kickflip://e2e/open?url=` → `handleDeepLink` | yes | -| `track_event` | `trackEvent("e2e_purchase", { value: 9.99, currency: "USD" })` | the same | yes | - -The deferred and re-engagement flows assert that the JS `onLink` listener fired **exactly once**, -with the linked `path` (`/products/aj1`), `source` and `customData` (`voucher=SUMMER25`). The -values are read off an on-screen diagnostics panel (testIDs `e2e-link-count`, `e2e-link-path`, -`e2e-link-source`, `e2e-link-custom-data`, `e2e-consent`, `e2e-attribution`, `e2e-event`) that -only e2e builds show. +### Data-driven, like the native suites -After each deferred flow the runner asks the backend what it recorded for that flow's own click -token (`GET /v1/e2e/clicks/`, header `X-E2E-Token`): +- `e2e/e2e-env.json`: the one place for backend URLs, hosts and slugs per environment (`prod`, the + default, and `dev`), the link-type links, the reward links and which newer backend checks each + environment has deployed (`backend_checks`). A link type or reward link with no entry for the + run's environment is **skipped with a notice**, never failed (prod has no `e2e-event` link yet). +- `e2e/e2e-flows.json`: the one table of rows (run order, kind, link slot, consent, link-type + matrix, what each asserts). Each row runs on both platforms from `e2e/flows//.yaml`. +- `e2e/targets.py` resolves both for the runners (`resolve`, `jobs`) and checks they agree with the + flow files (`validate`); `e2e/verify.py` holds the backend rules (same as the native + `scripts/e2e-verify.py`). The `config` job runs `validate`, `e2e/tests` and shellcheck. -- allow: `installRecorded`, `attributed`, `matchType == "click_token"`, `installCount == 1`; -- deny: `installRecorded == false`, `installCount == 0`, held for the whole polling window. +### Rows -### Secrets and variables +| Row | Kind | Link (prod) | Asserts | +| --- | --- | --- | --- | +| `consent_prompt` | offline | none | consent gate; the decision persists across a relaunch | +| `reengagement_allow` / `_deny` | open | subdomain | onLink once (reengagement) with path + voucher; deny is route-only | +| `track_event` | event | none | `trackEvent("e2e_purchase", { value: 9.99, currency: "USD" })` is acknowledged | +| `deferred_custom_allow` / `_deny` | click | custom domain (`summer-sale`) | allow: onLink once (deferred), path + voucher, 1 counted `click_token` install, not fraud; deny: nothing recorded | +| `deferred_subdomain_allow` / `_deny` | click | subdomain (`discounted-product`) | the same | +| `deferred_{custom,subdomain}_{allow,deny}_problistic` | problistic | `custom-problistic`, `ios-problistic` | a real click but no token: the install is answered (allow: attributed or organic; deny: never attributed) | +| `deferred_custom_{allow,deny}__` | click | `e2e-general`, `e2e-campaign`, `e2e-influencer`, `e2e-partner` | as `deferred_custom_*`, plus `linkType` / `source` in customData; the backend's `linkType`, and the reward: per_install earned on `influencer` / `partner` allow, nothing on deny, `reward: null` on the others | +| `reengagement_type_{allow,deny}__` | reopen | the type's link | installed through the link, then opened again: `openCount` +1 (allow) / unchanged (deny), `installCount` and earning unchanged | +| `deferred_event_allow` / `_deny` | reward | `e2e-event` (dev only; skipped on prod) | per_event: the reward's event x2 + one other event; earning 2 x `reward.amountMinor`; deny earns 0 | +| `deferred_revshare_allow` / `_deny` | reward | `e2e-revshare` | rev_share: one revenue event (+ the same in another currency); earning `floor(revenue x rateBps / 10000)`; deny earns 0 | + +Left out on purpose: the Android Play Store install-referrer flows (they stay in the private Android +SDK repo) and the native suites' simulated / custom-scheme flows (they test the native example app's +own simulator, not the SDK). The wrapper exposes no SDK device id, so the probabilistic rows can't +run the native device lookup: they assert the install's answer only (the report says so). + +How the rows stage their click: + +- Android: a real click with an Android Chrome UA; its `lt_click` (from the Play Store redirect) is + staged through the SDK's debug-only fake referrer (`setprop debug.linktrail.referrer`, a + debuggable app). Probabilistic rows stage nothing. Re-engagement opens the https App Link when the + manifest claims the host, else `kickflip://e2e/open?url=`. +- iOS: Safari opens the link (`_stage_click.yaml`) and the interstitial stages the token on the + clipboard, which the consent prompt's Paste control reads. Probabilistic rows clear the clipboard + and call `trackInstall()` from the e2e panel. Re-engagement uses `kickflip://e2e/open?url=` + (an unsigned simulator build has no Associated Domains). +- Reward rows send their events through `kickflip://e2e/events?list=`, which the example app + sends with `trackEvent` and counts on the panel (`e2e-events`). + +All values are read off an on-screen diagnostics panel that only e2e builds show (testIDs +`e2e-link-count`, `e2e-link-path`, `e2e-link-source`, `e2e-link-custom-data`, `e2e-consent`, +`e2e-attribution`, `e2e-event`, `e2e-install`, `e2e-events`; buttons `e2e-grant-consent`, +`e2e-deny-consent`, `e2e-track-event`, `e2e-track-install`). + +After a click row the runner asks the backend what it recorded for that row's own click token +(`GET /v1/e2e/clicks/`, header `X-E2E-Token`): allow polls until it matches; deny holds the +whole window, so a late install shows. A check an environment hasn't deployed +(`backend_checks: false`) is noted as skipped on the row, never passed or failed. Each run writes +`e2e/results-.jsonl` and a table in the job summary. + +### Environments, secrets and variables | Name | Kind | Purpose | | --- | --- | --- | -| `LINKTRAIL_KEY` | secret | Workspace SDK key, bundled into the e2e build only | +| `LINKTRAIL_KEY` | secret | SDK key of the prod workspace, bundled into the e2e build only | +| `LINKTRAIL_TEST_KEY` | secret | SDK key of the dev workspace (dev runs only) | | `E2E_TOKEN` | secret | `X-E2E-Token` for the backend check | +| `E2E_ENV` | variable | environment of pull request runs (default `prod`) | | `NATIVE_VERSION_STRICT` | variable | `false` to only warn on native SDK drift (the CI check fails on drift by default) | -Without both secrets (for example on a pull request from a fork) only `consent_prompt` runs and the -other flows are skipped with a notice. Fork pull requests never run on the self-hosted Mac. +A manual run picks the environment (`prod` | `dev`) and the link types (`all`, `none` or a comma +list). Without the environment's key and `E2E_TOKEN` (for example on a pull request from a fork) +only `consent_prompt` runs and the other rows are skipped with a notice. `dev` points the Android +debug app at the dev backend (`setprop debug.linktrail.base`); the iOS wrapper ships the binary SDK, +which has no backend override, so iOS skips the real rows on `dev` with a notice. ### How the key reaches the build -The runners write the key to `example/e2e.config.local.json` (gitignored, removed when the run -ends). `example/metro.config.js` resolves the `kickflip-e2e-config` module to that file when it -exists and to `example/src/e2e/config.default.json` (e2e off, placeholder key) otherwise. The key is -never passed on a command line or printed; curl reads the secret headers from stdin. +The runners write the key and the environment's link hosts to `example/e2e.config.local.json` +(gitignored, removed when the run ends). `example/metro.config.js` resolves the +`kickflip-e2e-config` module to that file when it exists and to +`example/src/e2e/config.default.json` (e2e off, placeholder key) otherwise. The key is never passed +on a command line or printed; curl reads the secret headers from stdin. The Android build bundles the JS into the **debug** APK (`-PbundleDebugJs`) so it runs without Metro and stays debuggable, which the SDK's fake referrer requires. iOS builds **Release** for the @@ -63,18 +105,24 @@ simulator, which bundles the JS. ```sh npm ci && (cd example && npm install && bundle install) +python3 -I e2e/targets.py validate # config + flow table + flow files +python3 -I -m unittest discover -s e2e/tests # the runners' rules +python3 -I e2e/targets.py jobs --platform ios # what a run would do # Android: a booted emulator (e.g. LinkTrail_API35) -bash e2e/android.sh # all flows; real ones only with the secrets set -bash e2e/android.sh consent_prompt # one flow +bash e2e/android.sh # all rows; real ones only with the secrets set +bash e2e/android.sh consent_prompt # one row +bash e2e/android.sh deferred_custom_allow__partner # one link-type row +bash e2e/android.sh reward # one kind # iOS: a booted simulator bash e2e/ios.sh DEVICE= bash e2e/ios.sh consent_prompt ``` -`LINKTRAIL_KEY=… E2E_TOKEN=… bash e2e/android.sh` runs the real flows. They make real clicks on -production links, so prefer CI for them. `SKIP_BUILD=1` reuses the last build. +`LINKTRAIL_KEY=… E2E_TOKEN=… bash e2e/android.sh` runs the real rows (`LINKTRAIL_ENV=dev` with +`LINKTRAIL_TEST_KEY` for dev). They make real clicks on real links, so prefer CI for them. +`SKIP_BUILD=1` reuses the last build; `E2E_LINK_TYPES=none` skips the link-type rows. On a Mac shared with other simulator jobs, take the lock first: `pid="$(bash e2e/sim-lock.sh acquire)"; …; bash e2e/sim-lock.sh release "$pid"`. diff --git a/e2e/android.sh b/e2e/android.sh index 20f6cc1..f17b3c3 100755 --- a/e2e/android.sh +++ b/e2e/android.sh @@ -1,39 +1,37 @@ #!/usr/bin/env bash # -# Android smoke e2e for the React Native wrapper: builds the example app (wrapper from source, -# native io.linktrail:sdk from Maven) with the JS bundled in, then runs the Maestro flows in -# e2e/flows/android on a booted emulator. +# Android e2e for the React Native wrapper: builds the example app (wrapper from source, native +# io.linktrail:sdk from Maven) with the JS bundled in, then runs the rows of e2e/e2e-flows.json from +# e2e/flows/android on a booted emulator, against the links of e2e/e2e-env.json (see TESTING.md). # -# consent_prompt offline: the consent gate shows, Deny persists across a relaunch. -# deferred_allow real click → fake Play referrer → Allow → onLink once (path + customData), -# then the backend recorded 1 attributed click_token install. -# deferred_deny the same with Deny → the backend recorded nothing. -# reengagement https App Link while installed → onLink (source reengagement). -# track_event trackEvent with a value → resolved by the backend. +# Click rows make a real click with an Android Chrome UA, take lt_click from the Play Store redirect +# and stage it through the SDK's debug-only fake referrer (setprop debug.linktrail.referrer, a +# debuggable app); the probabilistic rows stage nothing. An environment with override_backend points +# the debug app at its backend (setprop debug.linktrail.base). Re-engagement opens the https App Link +# when the app's manifest claims the host (approved for the app first), else kickflip://e2e/open. # -# The deferred flows stage the click through the SDK's debug-only fake referrer -# (adb shell setprop debug.linktrail.referrer "lt_click="), which needs a debuggable app -# (io.linktrail:sdk 0.1.0 or later). -# -# Usage: bash e2e/android.sh [flow…] -# Env: LINKTRAIL_KEY, E2E_TOKEN (see e2e/lib.sh), RETRIES (3), CLICK_WAIT (60), -# SKIP_BUILD=1 to reuse the last APK, BUILD_ONLY=1 to only -# build it (CI builds before booting the emulator). +# Usage: bash e2e/android.sh [row|flow|kind…] +# Env: see e2e/lib.sh; SKIP_BUILD=1 reuses the last APK, BUILD_ONLY=1 only builds it (CI builds +# before booting the emulator). set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" +PLATFORM=android # shellcheck source=e2e/lib.sh source "$ROOT/e2e/lib.sh" APP_ID="io.linktrail.demo.store" FLOW_DIR="$ROOT/e2e/flows/android" APK="$ROOT/example/android/app/build/outputs/apk/debug/app-debug.apk" -CLICK_WAIT="${CLICK_WAIT:-60}" +MANIFEST="$ROOT/example/android/app/src/main/AndroidManifest.xml" # Android Chrome UA: the redirect sends Android clicks to the Play Store with &referrer=lt_click=. ANDROID_UA="Mozilla/5.0 (Linux; Android 15; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36" -reset_props() { adb shell setprop debug.linktrail.referrer "''" >/dev/null 2>&1 || true; } -cleanup() { remove_config; [ "${BUILD_ONLY:-0}" = 1 ] || reset_props; } +reset_props() { + adb shell setprop debug.linktrail.referrer "''" >/dev/null 2>&1 || true + adb shell setprop debug.linktrail.base "''" >/dev/null 2>&1 || true +} +cleanup() { cleanup_lib; [ "${BUILD_ONLY:-0}" = 1 ] || reset_props; } trap cleanup EXIT if [ "${SKIP_BUILD:-0}" != 1 ]; then @@ -49,82 +47,54 @@ command -v maestro >/dev/null 2>&1 || { echo "ERROR: maestro not found (curl -Ls command -v adb >/dev/null 2>&1 || { echo "ERROR: adb not found (Android platform-tools)"; exit 1; } adb get-state >/dev/null 2>&1 || { echo "ERROR: no booted emulator/device (adb devices)"; exit 1; } -if [ "$#" -gt 0 ]; then - FLOWS=(); for f in "$@"; do FLOWS+=("$(basename "${f%.yaml}")"); done -else - FLOWS=(consent_prompt deferred_allow deferred_deny reengagement track_event) -fi +MAESTRO=(maestro) +[ -n "${ANDROID_SERIAL:-}" ] && MAESTRO+=(--device "$ANDROID_SERIAL") +run_maestro() { local label="$1"; shift; echo " maestro: $label"; "${MAESTRO[@]}" test "$@"; } -reset_maestro() { +reset_driver() { adb forward --remove-all >/dev/null 2>&1 || true adb uninstall dev.mobile.maestro >/dev/null 2>&1 || true adb uninstall dev.mobile.maestro.test >/dev/null 2>&1 || true + sleep 3 } -# Slow CI emulators raise "System UI isn't responding" over the app; hide ANR dialogs. -settle_device() { +install_fresh() { + adb uninstall "$APP_ID" >/dev/null 2>&1 || true + [ -n "$TOKEN" ] || adb shell setprop debug.linktrail.referrer "''" >/dev/null 2>&1 || true + if [ -n "$BASE_OVERRIDE" ]; then adb shell setprop debug.linktrail.base "$BASE_OVERRIDE" + else adb shell setprop debug.linktrail.base "''" >/dev/null 2>&1 || true; fi + adb install -t "$APK" >/dev/null || return 1 + # Approve the link hosts for the app so an https App Link opens it, not the browser (Android 12+). + adb shell pm set-app-links-user-selection --user 0 --package "$APP_ID" true "$SUBDOMAIN_HOST" "$CUSTOM_HOST" >/dev/null 2>&1 || true + # Slow CI emulators raise "System UI isn't responding" over the app; hide ANR dialogs. adb shell settings put global hide_error_dialogs 1 >/dev/null 2>&1 || true adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS >/dev/null 2>&1 || true } -# real_click: a real click with an Android UA; prints the lt_click token from the Play redirect. -real_click() { +# stage_click : a real click with an Android UA; token: wait until the backend +# knows it and stage it as the fake Play referrer. +stage_click() { local redirect token - redirect="$(curl -sS -o /dev/null -A "$ANDROID_UA" -w '%{redirect_url}' "$LINK_URL")" || return 1 + adb shell setprop debug.linktrail.referrer "''" >/dev/null 2>&1 || true + redirect="$(curl -sS -o /dev/null -A "$ANDROID_UA" -w '%{redirect_url}' "$1" 2>/dev/null || true)" token="$(printf '%s' "$redirect" | grep -oE 'lt_click(%3D|=)[0-9a-f]{32}' | head -1 | grep -oE '[0-9a-f]{32}$' || true)" - [ -n "$token" ] || { echo " no lt_click token in the redirect for $LINK_URL" >&2; return 1; } - printf '%s' "$token" -} - -# wait_click : until GET /v1/events/click/ answers 200 for this workspace's key. -wait_click() { - local code="" waited=0 - while [ "$waited" -lt "$CLICK_WAIT" ]; do - code="$(printf 'header = "X-API-Key: %s"\n' "$LINKTRAIL_KEY" \ - | curl -sS -o /dev/null -w '%{http_code}' --max-time 10 --config - "$BACKEND_URL/v1/events/click/$1" 2>/dev/null || true)" - [ "$code" = 200 ] && return 0 - sleep 2; waited=$((waited + 2)) - done - echo " click not visible to this key after ${CLICK_WAIT}s (last status: ${code:-none})" >&2 - return 1 -} - -# run_once : fresh install, stage what the flow needs, run it, check the backend. -run_once() { - local name="$1" token="" - adb uninstall "$APP_ID" >/dev/null 2>&1 || true - reset_props - if [[ "$name" == deferred_* ]]; then - token="$(real_click)" || return 1 - echo " click ${token:0:8}… made; waiting for the backend" - wait_click "$token" || return 1 - adb shell setprop debug.linktrail.referrer "lt_click=$token" + if [ -z "$token" ]; then + FAIL_STEP="real click"; FAIL_ERROR="no lt_click in the Play Store redirect for $1" + [ "$(curl -sS -o /dev/null -w '%{http_code}' "$1" 2>/dev/null || true)" = 404 ] && FAIL_ERROR="$LINKTRAIL_ENV link ${1##*/} not created" + return 1 fi - adb install -t "$APK" >/dev/null - if [ "$name" = reengagement ]; then - # Approve the link host for the app so the https link opens it, not the browser (Android 12+). - adb shell pm set-app-links-user-selection --user 0 --package "$APP_ID" true "$LINK_HOST" >/dev/null 2>&1 || true - fi - settle_device - maestro test -e LINK_URL="$LINK_URL" "$FLOW_DIR/$name.yaml" || return 1 - verify_click "$name" "$token" + echo " click ${token:0:8}… made" + wait_click "$token" || return 1 + [ "$2" = token ] || return 0 + TOKEN="$token" + adb shell setprop debug.linktrail.referrer "lt_click=$token" } -fail=0 -for name in "${FLOWS[@]}"; do - [ -f "$FLOW_DIR/$name.yaml" ] || { echo "ERROR: no flow $FLOW_DIR/$name.yaml"; fail=1; continue; } - if flow_needs_backend "$name" && [ "$HAVE_SECRETS" != 1 ]; then - notice "android/$name skipped: LINKTRAIL_KEY and E2E_TOKEN are not set"; continue - fi - ok=0 - for attempt in $(seq 1 "$RETRIES"); do - echo "==> android/$name (attempt $attempt/$RETRIES)" - if run_once "$name"; then ok=1; break; fi - echo " attempt failed; resetting the Maestro driver" - reset_maestro; sleep 3 - done - if [ "$ok" = 1 ]; then echo "OK: android/$name"; else echo "FAILED: android/$name"; fail=1; fi -done +# open_url_for : the https App Link when the manifest claims its host, else the e2e hook. +open_url_for() { + local host="${1#https://}"; host="${host%%/*}" + if [ -n "$host" ] && grep -q "android:host=\"$host\"" "$MANIFEST"; then printf '%s' "$1" + else printf 'kickflip://e2e/open?url=%s' "$(python3 -I -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$1")"; fi +} -[ "$fail" = 0 ] || { echo "==> Some Android e2e flows failed"; exit 1; } -echo "==> All Android e2e flows passed" +run_all "$@" diff --git a/e2e/e2e-env.json b/e2e/e2e-env.json new file mode 100644 index 0000000..be24bd1 --- /dev/null +++ b/e2e/e2e-env.json @@ -0,0 +1,60 @@ +{ + "_comment": "The ONE place for e2e hosts, slugs and backend URLs, in the same shape as the native SDKs' scripts/e2e-env.json. e2e/targets.py resolves it for e2e/android.sh and e2e/ios.sh; nothing else names a host or slug. 'links': the four link slots (host names the environment field the slug is served on). 'expect': what the click-token flows must show (path regex + voucher in customData). 'link_types': one dedicated link per type and environment; a type with no entry for the run's environment is skipped with a notice, never failed. 'link_type_expect': what those links route to (path, voucher, and customData source next to linkType == the type). 'rewarded_link_types': the types whose link pays per_install: an allow install must earn reward.amountMinor, a deny install nothing; the other types must have reward null. 'reward_links': the event-reward links (model -> environment -> link, plus the link's type); an environment without one skips those rows. 'reward_events': what the reward flows send after the install. 'backend_checks': which verify-endpoint fields that environment's backend has deployed (earning: reward + earning on the click; open_count: openCount for the re-engagement rows; events: the click's events field). A false check is recorded as skipped, never pass or fail. 'override_backend': point the debug app at backend_url (Android: debug.linktrail.base; the iOS wrapper ships the binary SDK, which has no override, so iOS skips the real flows on such an environment).", + "default_environment": "prod", + "aliases": { "test": "dev" }, + "environments": { + "prod": { + "backend_url": "https://backend.linktrail.io", + "key_secret": "LINKTRAIL_KEY", + "subdomain_host": "kick.linktrail.io", + "custom_host": "link.kynxlabs.com", + "override_backend": false, + "backend_checks": { "earning": true, "open_count": true, "events": false } + }, + "dev": { + "backend_url": "https://linktrail-backend-k9zl.onrender.com", + "key_secret": "LINKTRAIL_TEST_KEY", + "subdomain_host": "kick.test.linktrail.io", + "custom_host": "dev-test.kynxlabs.com", + "override_backend": true, + "backend_checks": { "earning": true, "open_count": true, "events": false } + } + }, + "links": { + "custom_link": { "host": "custom_host", "slug": "summer-sale" }, + "subdomain_link": { "host": "subdomain_host", "slug": "discounted-product" }, + "custom_problistic_link": { "host": "custom_host", "slug": "custom-problistic" }, + "subdomain_problistic_link": { "host": "subdomain_host", "slug": "ios-problistic" } + }, + "expect": { "path": "/products/.+", "voucher": "SUMMER25" }, + "link_types": { + "general": { + "prod": { "host": "custom_host", "slug": "e2e-general" }, + "dev": { "host": "custom_host", "slug": "e2e-general" } + }, + "campaign": { + "prod": { "host": "custom_host", "slug": "e2e-campaign" }, + "dev": { "host": "custom_host", "slug": "e2e-campaign" } + }, + "influencer": { + "prod": { "host": "custom_host", "slug": "e2e-influencer" }, + "dev": { "host": "custom_host", "slug": "e2e-influencer" } + }, + "partner": { + "prod": { "host": "custom_host", "slug": "e2e-partner" }, + "dev": { "host": "custom_host", "slug": "e2e-partner" } + } + }, + "link_type_expect": { "path": "/products/aj1", "voucher": "SUMMER25", "source": "e2e" }, + "rewarded_link_types": ["influencer", "partner"], + "reward_links": { + "per_event": { + "dev": { "host": "custom_host", "slug": "e2e-event", "link_type": "influencer" } + }, + "rev_share": { + "prod": { "host": "custom_host", "slug": "e2e-revshare", "link_type": "partner" }, + "dev": { "host": "custom_host", "slug": "e2e-revshare", "link_type": "partner" } + } + }, + "reward_events": { "revenue_minor": 1999, "other_event": "e2e_other" } +} diff --git a/e2e/e2e-flows.json b/e2e/e2e-flows.json new file mode 100644 index 0000000..2153864 --- /dev/null +++ b/e2e/e2e-flows.json @@ -0,0 +1,23 @@ +{ + "_comment": "The ONE table of e2e flows (run order + report rows; the rows that install without a click run first, before this run's clicks could give the backend an IP match for them), the wrapper's take on the native SDKs' scripts/e2e-flows.json. Each row runs on both platforms from e2e/flows//.yaml. 'kind': offline (no key, no backend), click (real click; Android stages its lt_click through the fake Play referrer, iOS through Safari + Paste; then the backend install check), problistic (a real click but no token: only the backend's IP match can attribute; the wrapper has no device id API, so the device lookup is not checkable and only the app's install answer is asserted), open (re-engagement on the installed app; no click token, no backend check), reopen (install through the type's link, backend baseline, then the re-engagement open; openCount +1 on allow, unchanged on deny, installCount and earning unchanged), reward (as click, then the reward's events through kickflip://e2e/events and the earning of the contract formula), event (trackEvent with a value). 'slot' is a link slot in e2e/e2e-env.json. 'link_type_matrix': the row also runs once per link type of the run's environment, as __ on that type's link; 'link_type_only': only those rows. 'reward': the reward_links model; an environment without that link skips the row. The Play Store install-referrer flows stay in the private Android SDK repo.", + "flows": [ + { "flow": "consent_prompt", "yaml": "consent_prompt", "kind": "offline", "consent": "deny", "expected": "consent gate; the decision persists across a relaunch; onLink never fires" }, + { "flow": "reengagement_allow", "yaml": "reengagement", "kind": "open", "slot": "subdomain_link", "consent": "allow", "expected": "onLink once (reengagement) with the linked path + voucher" }, + { "flow": "reengagement_deny", "yaml": "reengagement", "kind": "open", "slot": "subdomain_link", "consent": "deny", "expected": "onLink once (reengagement) with the linked path + voucher, route only" }, + { "flow": "track_event", "yaml": "track_event", "kind": "event", "consent": "allow", "expected": "trackEvent with a value is acknowledged by the backend" }, + { "flow": "deferred_custom_allow", "yaml": "deferred_allow", "kind": "click", "slot": "custom_link", "consent": "allow", "link_type_matrix": true, "expected": "onLink once (deferred) with the linked path + voucher; counted click_token install, not fraud; link-type rows also linkType/source in customData and the reward (per_install on rewarded types)" }, + { "flow": "deferred_custom_deny", "yaml": "deferred_deny", "kind": "click", "slot": "custom_link", "consent": "deny", "link_type_matrix": true, "expected": "not attributed; no install recorded; link-type rows earn nothing" }, + { "flow": "deferred_subdomain_allow", "yaml": "deferred_allow", "kind": "click", "slot": "subdomain_link", "consent": "allow", "expected": "onLink once (deferred) with the linked path + voucher; counted click_token install, not fraud" }, + { "flow": "deferred_subdomain_deny", "yaml": "deferred_deny", "kind": "click", "slot": "subdomain_link", "consent": "deny", "expected": "not attributed; no install recorded" }, + { "flow": "deferred_custom_allow_problistic", "yaml": "deferred_problistic_allow", "kind": "problistic", "slot": "custom_problistic_link", "consent": "allow", "expected": "no click token; the install is answered (attributed or organic)" }, + { "flow": "deferred_custom_deny_problistic", "yaml": "deferred_problistic_deny", "kind": "problistic", "slot": "custom_problistic_link", "consent": "deny", "expected": "no click token; the install is answered, not attributed" }, + { "flow": "deferred_subdomain_allow_problistic", "yaml": "deferred_problistic_allow", "kind": "problistic", "slot": "subdomain_problistic_link", "consent": "allow", "expected": "no click token; the install is answered (attributed or organic)" }, + { "flow": "deferred_subdomain_deny_problistic", "yaml": "deferred_problistic_deny", "kind": "problistic", "slot": "subdomain_problistic_link", "consent": "deny", "expected": "no click token; the install is answered, not attributed" }, + { "flow": "reengagement_type_allow", "yaml": "reengagement_type", "kind": "reopen", "slot": "custom_link", "consent": "allow", "link_type_matrix": true, "link_type_only": true, "expected": "counted install through the type's link, then the open routes again; openCount +1, installCount and earning unchanged" }, + { "flow": "reengagement_type_deny", "yaml": "reengagement_type", "kind": "reopen", "slot": "custom_link", "consent": "deny", "link_type_matrix": true, "link_type_only": true, "expected": "uncounted install through the type's link, then the open routes again; openCount, installCount and earning unchanged" }, + { "flow": "deferred_event_allow", "yaml": "deferred_allow", "kind": "reward", "reward": "per_event", "consent": "allow", "expected": "counted install, then reward event x2 + 1 other event, all attributed; earning 2 x reward.amountMinor" }, + { "flow": "deferred_event_deny", "yaml": "deferred_deny", "kind": "reward", "reward": "per_event", "consent": "deny", "expected": "no install recorded; the SDK drops the events; earning 0" }, + { "flow": "deferred_revshare_allow", "yaml": "deferred_allow", "kind": "reward", "reward": "rev_share", "consent": "allow", "expected": "counted install, then 1 revenue event (+1 in another currency), attributed; earning floor(revenue x rateBps / 10000)" }, + { "flow": "deferred_revshare_deny", "yaml": "deferred_deny", "kind": "reward", "reward": "rev_share", "consent": "deny", "expected": "no install recorded; the SDK drops the events; earning 0" } + ] +} diff --git a/e2e/flows/android/deferred_allow.yaml b/e2e/flows/android/deferred_allow.yaml index bb5e558..1b70e64 100644 --- a/e2e/flows/android/deferred_allow.yaml +++ b/e2e/flows/android/deferred_allow.yaml @@ -1,15 +1,20 @@ -# Deferred · consent ALLOW (real). Before this flow e2e/android.sh makes a real click on $LINK_URL, -# stages its lt_click token through the fake Play referrer (setprop debug.linktrail.referrer) and -# installs the app fresh. Afterwards it checks the backend recorded 1 attributed click_token install. +# Deferred · consent ALLOW (real). Rows: deferred_custom_allow, deferred_subdomain_allow, their +# link-type rows (deferred_custom_allow__), the reward rows (deferred_event_allow, +# deferred_revshare_allow) and the install step of reengagement_type_allow__. +# Before this flow e2e/android.sh makes a real click on $LINK_URL, stages its lt_click token through +# the fake Play referrer (setprop debug.linktrail.referrer) and installs the app fresh. Afterwards it +# checks the backend recorded 1 attributed click_token install (and the reward, see e2e/verify.py). +# E2E_PATH_RE / E2E_CUSTOM_DATA_RE come from e2e/targets.py (expect / link_type_expect in +# e2e/e2e-env.json; a link-type row also matches linkType + source in customData). appId: io.linktrail.demo.store --- - launchApp - extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } - tapOn: { id: "consent-allow" } - tapOn: { id: "consent-continue" } -- extendedWaitUntil: { visible: { id: "e2e-link-path", text: "path: /products/aj1" }, timeout: 30000 } +- extendedWaitUntil: { visible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" }, timeout: 30000 } - assertVisible: { id: "e2e-link-source", text: "source: deferred" } -- assertVisible: { id: "e2e-link-custom-data", text: '.*"voucher":"SUMMER25".*' } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } - assertVisible: { id: "e2e-consent", text: "consent: granted" } # Exactly once: give a duplicate delivery time to arrive, then check the count. - extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } diff --git a/e2e/flows/android/deferred_deny.yaml b/e2e/flows/android/deferred_deny.yaml index 49ccf7a..124da18 100644 --- a/e2e/flows/android/deferred_deny.yaml +++ b/e2e/flows/android/deferred_deny.yaml @@ -1,15 +1,17 @@ -# Deferred · consent DENY (real). Same staging as deferred_allow. Consent gates what is recorded, -# not routing: the link still routes once, and afterwards e2e/android.sh checks the backend -# recorded no install for this click. +# Deferred · consent DENY (real). Rows: deferred_custom_deny, deferred_subdomain_deny, their +# link-type rows, the reward rows (deferred_event_deny, deferred_revshare_deny) and the install step +# of reengagement_type_deny__. Same staging as deferred_allow. Consent gates what is recorded, +# not routing: the link still routes once, and afterwards e2e/android.sh checks the backend recorded +# no install for this click (and no earning). appId: io.linktrail.demo.store --- - launchApp - extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } - tapOn: { id: "consent-deny" } - tapOn: { id: "consent-continue" } -- extendedWaitUntil: { visible: { id: "e2e-link-path", text: "path: /products/aj1" }, timeout: 30000 } +- extendedWaitUntil: { visible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" }, timeout: 30000 } - assertVisible: { id: "e2e-link-source", text: "source: deferred" } -- assertVisible: { id: "e2e-link-custom-data", text: '.*"voucher":"SUMMER25".*' } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } - assertVisible: { id: "e2e-consent", text: "consent: denied" } - assertNotVisible: { id: "e2e-attribution", text: "attribution: attributed=true" } - extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } diff --git a/e2e/flows/android/deferred_problistic_allow.yaml b/e2e/flows/android/deferred_problistic_allow.yaml new file mode 100644 index 0000000..7fc9223 --- /dev/null +++ b/e2e/flows/android/deferred_problistic_allow.yaml @@ -0,0 +1,17 @@ +# Deferred · probabilistic · consent ALLOW (real). Rows: deferred_custom_allow_problistic, +# deferred_subdomain_allow_problistic. e2e/android.sh makes a real click on $LINK_URL from the runner +# (same public IP as the emulator) and installs the app fresh with NO referrer staged, so only the +# backend's IP + platform match can attribute the install. The match may or may not happen, so the +# flow asserts the install was answered (attributed or organic), not where the app lands. The +# wrapper exposes no SDK device id, so the native suites' device lookup is not checkable here. +appId: io.linktrail.demo.store +--- +- launchApp +- extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } +- tapOn: { id: "consent-allow" } +- tapOn: { id: "consent-continue" } +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: granted" }, timeout: 10000 } +# trackInstall() joins (or returns) the auto-tracked install: its answer is the install's. +- tapOn: { id: "e2e-track-install" } +- extendedWaitUntil: { visible: { id: "e2e-install", text: "install: ok attributed=(true|false)" }, timeout: 30000 } +- assertNotVisible: { id: "e2e-link-count", text: "onLink: [2-9].*" } diff --git a/e2e/flows/android/deferred_problistic_deny.yaml b/e2e/flows/android/deferred_problistic_deny.yaml new file mode 100644 index 0000000..b5ce7ae --- /dev/null +++ b/e2e/flows/android/deferred_problistic_deny.yaml @@ -0,0 +1,13 @@ +# Deferred · probabilistic · consent DENY (real). Rows: deferred_custom_deny_problistic, +# deferred_subdomain_deny_problistic. Staged as deferred_problistic_allow (a real click, no +# referrer). The denied install goes out with consent false: answered, never attributed. +appId: io.linktrail.demo.store +--- +- launchApp +- extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } +- tapOn: { id: "consent-deny" } +- tapOn: { id: "consent-continue" } +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: denied" }, timeout: 10000 } +- tapOn: { id: "e2e-track-install" } +- extendedWaitUntil: { visible: { id: "e2e-install", text: "install: ok attributed=false" }, timeout: 30000 } +- assertNotVisible: { id: "e2e-attribution", text: "attribution: attributed=true" } diff --git a/e2e/flows/android/reengagement.yaml b/e2e/flows/android/reengagement.yaml index 1ee84a0..f60a339 100644 --- a/e2e/flows/android/reengagement.yaml +++ b/e2e/flows/android/reengagement.yaml @@ -1,16 +1,19 @@ -# Re-engagement (real): the app is installed and running; an https App Link for $LINK_URL opens it -# (e2e/android.sh approves the host for the app first) and onLink fires once as a re-engagement. +# Re-engagement (real). Rows: reengagement_allow, reengagement_deny (E2E_CONSENT allow | deny). The +# app is installed fresh and running; $E2E_OPEN_URL opens it: the https App Link for $LINK_URL when +# the manifest claims the host (e2e/android.sh approves it for the app first), else +# kickflip://e2e/open?url=. onLink fires once as a re-engagement; without consent the SDK +# resolves the link route-only (nothing recorded). appId: io.linktrail.demo.store --- - launchApp - extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } -- tapOn: { id: "consent-allow" } +- tapOn: { id: "consent-${E2E_CONSENT}" } - tapOn: { id: "consent-continue" } -- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: granted" }, timeout: 10000 } +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: ${E2E_CONSENT_STATE}" }, timeout: 10000 } - assertVisible: { id: "e2e-link-count", text: "onLink: 0" } -- openLink: ${LINK_URL} +- openLink: ${E2E_OPEN_URL} - extendedWaitUntil: { visible: { id: "e2e-link-source", text: "source: reengagement" }, timeout: 30000 } -- assertVisible: { id: "e2e-link-path", text: "path: /products/aj1" } -- assertVisible: { id: "e2e-link-custom-data", text: '.*"voucher":"SUMMER25".*' } +- assertVisible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } - extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } - assertVisible: { id: "e2e-link-count", text: "onLink: 1" } diff --git a/e2e/flows/android/reengagement_type.yaml b/e2e/flows/android/reengagement_type.yaml new file mode 100644 index 0000000..dd84f4f --- /dev/null +++ b/e2e/flows/android/reengagement_type.yaml @@ -0,0 +1,20 @@ +# Re-engagement on a link-type link (real). Rows: reengagement_type_allow__, +# reengagement_type_deny__. Before this flow e2e/android.sh installs the app through the +# type's link (real click + fake referrer + deferred_allow / deferred_deny) and reads the backend's +# baseline for that click. This flow restarts the app (it keeps its consent answer) and opens the +# same link again. Afterwards the script checks the backend: openCount +1 on allow, unchanged on +# deny; installCount and earning unchanged (no second reward). +appId: io.linktrail.demo.store +--- +- stopApp +- launchApp +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: ${E2E_CONSENT_STATE}" }, timeout: 30000 } +- assertNotVisible: "Allow tracking?" +# onLink counts are per launch: the deferred delivery of the install step is not repeated. +- assertVisible: { id: "e2e-link-count", text: "onLink: 0" } +- openLink: ${E2E_OPEN_URL} +- extendedWaitUntil: { visible: { id: "e2e-link-source", text: "source: reengagement" }, timeout: 30000 } +- assertVisible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } +- extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } +- assertVisible: { id: "e2e-link-count", text: "onLink: 1" } diff --git a/e2e/flows/android/send_events.yaml b/e2e/flows/android/send_events.yaml new file mode 100644 index 0000000..2a7d5e4 --- /dev/null +++ b/e2e/flows/android/send_events.yaml @@ -0,0 +1,11 @@ +# Helper of the reward rows (deferred_event_*, deferred_revshare_*), run right after the install +# flow on the running app. e2e/verify.py plan-events builds $E2E_EVENTS_URL from the reward in the +# install's backend response: kickflip://e2e/events?list= (per_event: the reward's eventName +# twice + one other event; rev_share: one revenue event in the reward's currency + one in another). +# The example app's e2e hook sends each through LinkTrail.trackEvent and counts the answers: +# allow: every one attributed; deny: the SDK drops them (attributed=false), and the backend check +# afterwards finds no earning. +appId: io.linktrail.demo.store +--- +- openLink: ${E2E_EVENTS_URL} +- extendedWaitUntil: { visible: { id: "e2e-events", text: "events: done=${E2E_EVENTS_N} attributed=${E2E_EVENTS_ATTRIBUTED} failed=0" }, timeout: 45000 } diff --git a/e2e/flows/ios/_stage_click.yaml b/e2e/flows/ios/_stage_click.yaml index bd85a8e..7358fc5 100644 --- a/e2e/flows/ios/_stage_click.yaml +++ b/e2e/flows/ios/_stage_click.yaml @@ -1,4 +1,5 @@ -# Safari half of the iOS deferred flows (run by e2e/ios.sh before deferred_allow / deferred_deny): +# Safari half of the iOS click rows (run by e2e/ios.sh before every click, reward, reopen and +# probabilistic row): # open $LINK_URL; the LinkTrail interstitial makes a real click and stages lt_click= on the # clipboard. The script then reads the token off the simulator pasteboard for the backend check. appId: com.apple.mobilesafari diff --git a/e2e/flows/ios/deferred_allow.yaml b/e2e/flows/ios/deferred_allow.yaml index 4872c5e..19cd880 100644 --- a/e2e/flows/ios/deferred_allow.yaml +++ b/e2e/flows/ios/deferred_allow.yaml @@ -1,16 +1,20 @@ -# Deferred · consent ALLOW (real). e2e/ios.sh installs the app fresh and runs _stage_click.yaml -# first (Safari stages the click token on the clipboard). Here the user allows and taps Paste; -# onLink must fire once with the linked path + customData. Afterwards the script checks the backend -# recorded 1 attributed click_token install for that token. +# Deferred · consent ALLOW (real). Rows: deferred_custom_allow, deferred_subdomain_allow, their +# link-type rows (deferred_custom_allow__), the reward rows (deferred_event_allow, +# deferred_revshare_allow) and the install step of reengagement_type_allow__. +# e2e/ios.sh runs _stage_click.yaml first (Safari stages the click token on the clipboard) and +# installs the app fresh. Here the user allows and taps Paste; onLink must fire once with the linked +# path + customData. Afterwards the script checks the backend recorded 1 attributed click_token +# install (and the reward, see e2e/verify.py). E2E_PATH_RE / E2E_CUSTOM_DATA_RE come from +# e2e/targets.py (a link-type row also matches linkType + source in customData). appId: io.linktrail.kickflipdemo --- - launchApp - extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } - tapOn: { id: "consent-allow" } - tapOn: { text: "^Paste$" } -- extendedWaitUntil: { visible: { id: "e2e-link-path", text: "path: /products/aj1" }, timeout: 30000 } +- extendedWaitUntil: { visible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" }, timeout: 30000 } - assertVisible: { id: "e2e-link-source", text: "source: deferred" } -- assertVisible: { id: "e2e-link-custom-data", text: '.*"voucher":"SUMMER25".*' } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } - assertVisible: { id: "e2e-consent", text: "consent: granted" } - extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } - assertVisible: { id: "e2e-link-count", text: "onLink: 1" } diff --git a/e2e/flows/ios/deferred_deny.yaml b/e2e/flows/ios/deferred_deny.yaml index ff6728e..cba5815 100644 --- a/e2e/flows/ios/deferred_deny.yaml +++ b/e2e/flows/ios/deferred_deny.yaml @@ -1,6 +1,8 @@ -# Deferred · consent DENY (real). Same staging as deferred_allow; the user denies and taps Paste. +# Deferred · consent DENY (real). Rows: deferred_custom_deny, deferred_subdomain_deny, their +# link-type rows, the reward rows (deferred_event_deny, deferred_revshare_deny) and the install step +# of reengagement_type_deny__. Same staging as deferred_allow; the user denies and taps Paste. # Nothing may be attributed and onLink may fire at most once. Afterwards e2e/ios.sh checks the -# backend recorded no install for the staged token. +# backend recorded no install (and no earning) for the staged token. appId: io.linktrail.kickflipdemo --- - launchApp diff --git a/e2e/flows/ios/deferred_problistic_allow.yaml b/e2e/flows/ios/deferred_problistic_allow.yaml new file mode 100644 index 0000000..e0b2f60 --- /dev/null +++ b/e2e/flows/ios/deferred_problistic_allow.yaml @@ -0,0 +1,17 @@ +# Deferred · probabilistic · consent ALLOW (real). Rows: deferred_custom_allow_problistic, +# deferred_subdomain_allow_problistic. e2e/ios.sh opens $LINK_URL in Safari (_stage_click.yaml: the +# click) and clears the clipboard, so the install carries no click token: only the backend's IP + +# platform match can attribute it. The app uses clickTokenSource 'pasteButton' with +# autoTrackInstall off, so the e2e panel grants consent and calls trackInstall() (no paste). The +# match may or may not happen: the flow asserts the install was answered (attributed or organic). +# The wrapper exposes no SDK device id, so the native suites' device lookup is not checkable here. +appId: io.linktrail.kickflipdemo +--- +- launchApp +- extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } +- tapOn: { id: "consent-skip" } +- tapOn: { id: "e2e-grant-consent" } +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: granted" }, timeout: 10000 } +- tapOn: { id: "e2e-track-install" } +- extendedWaitUntil: { visible: { id: "e2e-install", text: "install: ok attributed=(true|false)" }, timeout: 30000 } +- assertNotVisible: { id: "e2e-link-count", text: "onLink: [2-9].*" } diff --git a/e2e/flows/ios/deferred_problistic_deny.yaml b/e2e/flows/ios/deferred_problistic_deny.yaml new file mode 100644 index 0000000..0a10c83 --- /dev/null +++ b/e2e/flows/ios/deferred_problistic_deny.yaml @@ -0,0 +1,14 @@ +# Deferred · probabilistic · consent DENY (real). Rows: deferred_custom_deny_problistic, +# deferred_subdomain_deny_problistic. Staged as deferred_problistic_allow. The e2e panel records a +# denial and calls trackInstall(): the install goes out with consent false, answered and never +# attributed. +appId: io.linktrail.kickflipdemo +--- +- launchApp +- extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } +- tapOn: { id: "consent-skip" } +- tapOn: { id: "e2e-deny-consent" } +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: denied" }, timeout: 10000 } +- tapOn: { id: "e2e-track-install" } +- extendedWaitUntil: { visible: { id: "e2e-install", text: "install: ok attributed=false" }, timeout: 30000 } +- assertNotVisible: { id: "e2e-attribution", text: "attribution: attributed=true" } diff --git a/e2e/flows/ios/reengagement.yaml b/e2e/flows/ios/reengagement.yaml index ae0b7d3..efb7bfe 100644 --- a/e2e/flows/ios/reengagement.yaml +++ b/e2e/flows/ios/reengagement.yaml @@ -1,18 +1,20 @@ -# Re-engagement (real): with the app running, kickflip://e2e/open?url= hands $LINK_URL to -# LinkTrail.handleDeepLink (an unsigned simulator build has no Associated Domains, so an https link -# would open Safari). The SDK resolves it and onLink fires once as a re-engagement. +# Re-engagement (real). Rows: reengagement_allow, reengagement_deny. With the app running, +# kickflip://e2e/open?url= ($E2E_OPEN_URL) hands $LINK_URL to LinkTrail.handleDeepLink (an +# unsigned simulator build has no Associated Domains, so an https link would open Safari). The SDK +# resolves it and onLink fires once as a re-engagement; without consent it resolves route-only. +# Consent comes from the e2e panel (E2E_CONSENT_BUTTON: e2e-grant-consent | e2e-deny-consent). appId: io.linktrail.kickflipdemo --- - launchApp - extendedWaitUntil: { visible: "Allow tracking?", timeout: 30000 } - tapOn: { id: "consent-skip" } -- tapOn: { id: "e2e-grant-consent" } -- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: granted" }, timeout: 10000 } +- tapOn: { id: "${E2E_CONSENT_BUTTON}" } +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: ${E2E_CONSENT_STATE}" }, timeout: 10000 } - assertVisible: { id: "e2e-link-count", text: "onLink: 0" } - openLink: ${E2E_OPEN_URL} - tapOn: { text: "Open", optional: true } - extendedWaitUntil: { visible: { id: "e2e-link-source", text: "source: reengagement" }, timeout: 30000 } -- assertVisible: { id: "e2e-link-path", text: "path: /products/aj1" } -- assertVisible: { id: "e2e-link-custom-data", text: '.*"voucher":"SUMMER25".*' } +- assertVisible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } - extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } - assertVisible: { id: "e2e-link-count", text: "onLink: 1" } diff --git a/e2e/flows/ios/reengagement_type.yaml b/e2e/flows/ios/reengagement_type.yaml new file mode 100644 index 0000000..1304519 --- /dev/null +++ b/e2e/flows/ios/reengagement_type.yaml @@ -0,0 +1,21 @@ +# Re-engagement on a link-type link (real). Rows: reengagement_type_allow__, +# reengagement_type_deny__. Before this flow e2e/ios.sh installs the app through the type's +# link (_stage_click + deferred_allow / deferred_deny) and reads the backend's baseline for that +# click. This flow restarts the app (it keeps its consent answer) and opens the same link again +# through kickflip://e2e/open. Afterwards the script checks the backend: openCount +1 on allow, +# unchanged on deny; installCount and earning unchanged (no second reward). +appId: io.linktrail.kickflipdemo +--- +- stopApp +- launchApp +- extendedWaitUntil: { visible: { id: "e2e-consent", text: "consent: ${E2E_CONSENT_STATE}" }, timeout: 30000 } +- assertNotVisible: "Allow tracking?" +# onLink counts are per launch: the deferred delivery of the install step is not repeated. +- assertVisible: { id: "e2e-link-count", text: "onLink: 0" } +- openLink: ${E2E_OPEN_URL} +- tapOn: { text: "Open", optional: true } +- extendedWaitUntil: { visible: { id: "e2e-link-source", text: "source: reengagement" }, timeout: 30000 } +- assertVisible: { id: "e2e-link-path", text: "path: ${E2E_PATH_RE}" } +- assertVisible: { id: "e2e-link-custom-data", text: "customData: ${E2E_CUSTOM_DATA_RE}" } +- extendedWaitUntil: { visible: "never-shown-e2e-pause", timeout: 5000, optional: true } +- assertVisible: { id: "e2e-link-count", text: "onLink: 1" } diff --git a/e2e/flows/ios/send_events.yaml b/e2e/flows/ios/send_events.yaml new file mode 100644 index 0000000..fbd2493 --- /dev/null +++ b/e2e/flows/ios/send_events.yaml @@ -0,0 +1,12 @@ +# Helper of the reward rows (deferred_event_*, deferred_revshare_*), run right after the install +# flow on the running app. e2e/verify.py plan-events builds $E2E_EVENTS_URL from the reward in the +# install's backend response: kickflip://e2e/events?list= (per_event: the reward's eventName +# twice + one other event; rev_share: one revenue event in the reward's currency + one in another). +# The example app's e2e hook sends each through LinkTrail.trackEvent and counts the answers: +# allow: every one attributed; deny: the SDK drops them (attributed=false), and the backend check +# afterwards finds no earning. +appId: io.linktrail.kickflipdemo +--- +- openLink: ${E2E_EVENTS_URL} +- tapOn: { text: "Open", optional: true } +- extendedWaitUntil: { visible: { id: "e2e-events", text: "events: done=${E2E_EVENTS_N} attributed=${E2E_EVENTS_ATTRIBUTED} failed=0" }, timeout: 45000 } diff --git a/e2e/ios.sh b/e2e/ios.sh index 26f5093..7a01e25 100755 --- a/e2e/ios.sh +++ b/e2e/ios.sh @@ -1,24 +1,25 @@ #!/usr/bin/env bash # -# iOS smoke e2e for the React Native wrapper: builds the example app (wrapper from source, -# native LinkTrailSDK from CocoaPods trunk) in Release for the simulator, so the JS is bundled and -# no Metro server is needed, then runs the Maestro flows in e2e/flows/ios on a booted simulator. +# iOS e2e for the React Native wrapper: builds the example app (wrapper from source, native +# LinkTrailSDK from CocoaPods trunk) in Release for the simulator, so the JS is bundled and no Metro +# server is needed, then runs the rows of e2e/e2e-flows.json from e2e/flows/ios on a booted +# simulator, against the links of e2e/e2e-env.json (see TESTING.md). # -# consent_prompt offline: the consent gate shows, Skip stays undecided, a grant persists. -# deferred_allow Safari stages a real click token on the clipboard → Allow + Paste → onLink once -# (path + customData), then the backend recorded 1 attributed click_token install. -# deferred_deny the same with Deny → the backend recorded nothing. -# reengagement kickflip://e2e/open?url= → handleDeepLink → onLink (source reengagement). -# track_event trackEvent with a value → resolved by the backend. +# Click rows open the link in Safari (_stage_click.yaml): the interstitial makes a real click and +# stages lt_click on the clipboard, which the app's Paste control reads. The probabilistic rows +# clear the clipboard after the click, so only the backend's IP match can attribute. Re-engagement +# opens kickflip://e2e/open?url= (an unsigned simulator build has no Associated Domains). +# The wrapper ships the binary LinkTrailSDK, which has no backend override, so an environment with +# override_backend (dev) skips the real rows with a notice. # -# Usage: bash e2e/ios.sh [flow…] -# Env: LINKTRAIL_KEY, E2E_TOKEN (see e2e/lib.sh), RETRIES (3), DEVICE (udid; default: first -# booted simulator), SKIP_BUILD=1 to reuse the last build, BUILD_ONLY=1 to only build, -# SKIP_PODS=1 to skip pod install. +# Usage: bash e2e/ios.sh [row|flow|kind…] +# Env: see e2e/lib.sh; DEVICE (udid; default: first booted simulator), SKIP_BUILD=1 to reuse +# the last build, BUILD_ONLY=1 to only build, SKIP_PODS=1 to skip pod install. set -euo pipefail export PATH="$HOME/.maestro/bin:$PATH:/opt/homebrew/bin:/usr/local/bin" # CI non-login shell; appended so a pinned Ruby (setup-ruby) wins ROOT="$(cd "$(dirname "$0")/.." && pwd)" +PLATFORM=ios # shellcheck source=e2e/lib.sh source "$ROOT/e2e/lib.sh" @@ -28,7 +29,7 @@ DERIVED="$ROOT/example/ios/build-e2e" APP="$DERIVED/Build/Products/Release-iphonesimulator/KickFlip.app" export MAESTRO_DRIVER_STARTUP_TIMEOUT="${MAESTRO_DRIVER_STARTUP_TIMEOUT:-120000}" -trap remove_config EXIT +trap cleanup_lib EXIT if [ "${SKIP_BUILD:-0}" != 1 ]; then if [ "${SKIP_PODS:-0}" != 1 ]; then @@ -55,55 +56,61 @@ DEVICE="${DEVICE:-$(xcrun simctl list devices booted | grep -oiE '[0-9a-f]{8}-([ [ -n "$DEVICE" ] || { echo "ERROR: no booted simulator (boot one, or set DEVICE)"; exit 1; } echo "-- device: $DEVICE" - -if [ "$#" -gt 0 ]; then - FLOWS=(); for f in "$@"; do FLOWS+=("$(basename "${f%.yaml}")"); done -else - FLOWS=(consent_prompt deferred_allow deferred_deny reengagement track_event) +if [ -n "$BASE_OVERRIDE" ]; then + REAL_SKIP="the iOS wrapper's binary SDK cannot point at the $LINKTRAIL_ENV backend (no LINKTRAIL_BASE in Release)" fi -# capture_token: the 32-hex lt_click token the interstitial staged on the clipboard, or nothing. -capture_token() { - { xcrun simctl pbpaste "$DEVICE" 2>/dev/null || true; } | grep -oE 'lt_click=[0-9a-fA-F]{32}' | head -1 | cut -d= -f2 || true +# The XCUITest driver on iOS sims can die mid-run and stays dead; a retry reinstalls it. +REINSTALL="" +run_maestro() { + local label="$1"; shift + echo " maestro: $label" + # shellcheck disable=SC2086 # $REINSTALL is empty or one flag + maestro $REINSTALL --device "$DEVICE" test "$@" + local rc=$? + REINSTALL="" + return $rc +} + +reset_driver() { + pkill -f 'XCTestRunner|WebDriverAgent' >/dev/null 2>&1 || true + REINSTALL="--reinstall-driver"; sleep 10 } -# run_once : fresh install, stage what the flow needs, run, check backend. -run_once() { - local name="$1" reinstall="$2" token="" open_url +install_fresh() { xcrun simctl uninstall "$DEVICE" "$APP_ID" >/dev/null 2>&1 || true xcrun simctl install "$DEVICE" "$APP" >/dev/null || return 1 + # Probabilistic rows (and rows without a click) start from an empty clipboard. + [ -n "$TOKEN" ] || printf '' | xcrun simctl pbcopy "$DEVICE" +} + +# stage_click : Safari opens ; the interstitial makes a real click and +# stages lt_click= on the clipboard. token: keep it there for the Paste control (TOKEN set). +stage_click() { + local token printf '' | xcrun simctl pbcopy "$DEVICE" - if [[ "$name" == deferred_* ]]; then - # shellcheck disable=SC2086 # $reinstall is empty or one flag - maestro $reinstall --device "$DEVICE" test -e LINK_URL="$LINK_URL" "$FLOW_DIR/_stage_click.yaml" || return 1 - token="$(capture_token)" - [ -n "$token" ] || { echo " no lt_click token on the clipboard after the Safari step" >&2; return 1; } - echo " click ${token:0:8}… staged" - reinstall="" + run_maestro "stage-click" -e LINK_URL="$1" "$FLOW_DIR/_stage_click.yaml" \ + || { FAIL_STEP="maestro: _stage_click"; FAIL_ERROR="Safari step failed"; return 1; } + token="$({ xcrun simctl pbpaste "$DEVICE" 2>/dev/null || true; } | grep -oE 'lt_click=[0-9a-fA-F]{32}' | head -1 | cut -d= -f2 || true)" + if [ "$2" != token ]; then + # Probabilistic: the click is the page load; whatever was staged is cleared, never pasted. + printf '' | xcrun simctl pbcopy "$DEVICE" + echo " click made${token:+ (${token:0:8}…, cleared)}" + [ -z "$token" ] || wait_click "$token" + return + fi + if [ -z "$token" ]; then + FAIL_STEP="real click"; FAIL_ERROR="no lt_click token on the clipboard after the Safari step" + [ "$(curl -sS -o /dev/null -w '%{http_code}' "$1" 2>/dev/null || true)" = 404 ] && FAIL_ERROR="$LINKTRAIL_ENV link ${1##*/} not created" + return 1 fi - open_url="kickflip://e2e/open?url=$(python3 -I -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$LINK_URL")" - # shellcheck disable=SC2086 - maestro $reinstall --device "$DEVICE" test -e LINK_URL="$LINK_URL" -e E2E_OPEN_URL="$open_url" "$FLOW_DIR/$name.yaml" || return 1 - verify_click "$name" "$token" + echo " click ${token:0:8}… staged" + wait_click "$token" || return 1 + TOKEN="$token" } -fail=0 -for name in "${FLOWS[@]}"; do - [ -f "$FLOW_DIR/$name.yaml" ] || { echo "ERROR: no flow $FLOW_DIR/$name.yaml"; fail=1; continue; } - if flow_needs_backend "$name" && [ "$HAVE_SECRETS" != 1 ]; then - notice "ios/$name skipped: LINKTRAIL_KEY and E2E_TOKEN are not set"; continue - fi - ok=0; reinstall="" - for attempt in $(seq 1 "$RETRIES"); do - echo "==> ios/$name (attempt $attempt/$RETRIES)" - if run_once "$name" "$reinstall"; then ok=1; break; fi - # The XCUITest driver on iOS sims can die mid-run and stays dead; restart it before a retry. - echo " attempt failed; restarting the Maestro driver" - pkill -f 'XCTestRunner|WebDriverAgent' >/dev/null 2>&1 || true - reinstall="--reinstall-driver"; sleep 10 - done - if [ "$ok" = 1 ]; then echo "OK: ios/$name"; else echo "FAILED: ios/$name"; fail=1; fi -done +open_url_for() { + printf 'kickflip://e2e/open?url=%s' "$(python3 -I -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$1")" +} -[ "$fail" = 0 ] || { echo "==> Some iOS e2e flows failed"; exit 1; } -echo "==> All iOS e2e flows passed" +run_all "$@" diff --git a/e2e/lib.sh b/e2e/lib.sh index 47d8b40..3448143 100644 --- a/e2e/lib.sh +++ b/e2e/lib.sh @@ -1,106 +1,270 @@ # shellcheck shell=bash # shellcheck disable=SC2034 # the variables here are read by the scripts that source this file # -# Shared helpers for e2e/android.sh and e2e/ios.sh. Sourced, not run. -# Expects ROOT (the repo root) from the caller. +# Shared runner for e2e/android.sh and e2e/ios.sh. Sourced, not run. The caller sets ROOT and +# PLATFORM and defines the platform steps: +# install_fresh uninstall + install the app (clean state) +# stage_click +# make a real click on ; with "token" stage its lt_click for +# the install and set TOKEN (no-token: the probabilistic rows) +# open_url_for the URL a re-engagement flow opens (prints it) +# run_maestro