Skip to content

test: Mobilewright Basic UI loop flow (fill, screenshot, back x20) - #15

Open
mobile-kevin wants to merge 1 commit into
mobile-next:mainfrom
mobile-kevin:test/mobilewright-playground-loop
Open

mobile-kevin wants to merge 1 commit into
mobile-next:mainfrom
mobile-kevin:test/mobilewright-playground-loop

Conversation

@mobile-kevin

Copy link
Copy Markdown
Collaborator

What this adds

A Mobilewright end-to-end test for the Playground Android app, plus the minimal Node/Mobilewright harness to run it:

  • tests/basic-ui-loop.spec.ts — the flow (see below)
  • mobilewright.config.ts — platform: android, bundleId: com.mobilenext.playground, HTML reporter
  • package.json / package-lock.json — mobilewright + @mobilewright/test 0.0.22, typescript
  • tsconfig.json — strict typecheck for the test dir
  • .gitignore — ignores node_modules/, test-results/, reports

The flow (one iteration)

  1. Relaunch the app (terminate + launch) so it starts on Home.
  2. Tap the Basic UI row and assert the screen rendered.
  3. Fill the first text field (text_field) with "hello world" and assert its value.
  4. Take a screenshot (saved to test-results/basic-ui-loop/iteration-N.png).
  5. Press Android back and assert we are back on Home.

It runs 20 iterations via test.describe + a loop. Assertions guard each step (Basic UI shown, field holds the text, back on Home).

Locators (grounded in the real layouts, not guessed)

  • Home nav row: screen.getByText('Basic UI') — the tappable btn_basic_ui row in activity_main.xml.
  • First text field: screen.getByTestId('text_field') — the first EditText in activity_basic_ui.xml (id="text_field", contentDescription="text_field", hint "Text Field"). Mobilewright derives a testId from the Android resource-id / content-description, so this is the highest-priority, deterministic locator.
  • "Back on Home" marker: getByText('Web View') — a Home row that does not appear on the Basic UI screen (the toolbar there is titled "Basic UI", so that string alone wouldn't distinguish the two screens).

Status — please run it, Gil

  • Typechecks under strict tsc and is discovered by mobilewright test --list (20 tests).
  • Not yet executed against a live emulator — I had no running Android emulator, so the runtime behavior (locator resolution, back semantics, toHaveValue on an Android EditText) is unvalidated. This is a correct, readable starting point for you to run and refine.

How to run

# 1. Build + install the app on a running emulator
make -C android
adb install -r android/app/build/outputs/apk/debug/app-debug.apk

# 2. Install test deps and run
npm install
npx mobilewright test

mobilewright 0.0.22's config has no installApps option, so app install is a documented prerequisite (step 1) rather than automated in config.

Follow-up (not in this PR)

  • Android-native variant (Espresso / UiAutomator) of the same flow — left as a TODO in the spec, intentionally not built. This PR is Mobilewright-first only.
  • If getByTestId('text_field') doesn't resolve on-device, the fallback is getByLabel('text_field') (contentDescription surfaces as the accessibility label on Android).

Opened from a fork (mobile-kevin/playground) — the shared bot account has read but not push access to the upstream repo.

Adds a Mobilewright end-to-end test plus the Node/Mobilewright harness
(package.json, mobilewright.config.ts, tsconfig.json) at the repo root.

The test, per iteration: relaunches the app, opens the Basic UI screen from
Home, fills the first text field (text_field) with 'hello world', asserts the
value, screenshots, presses Android back, and asserts it is back on Home.
Runs 20 iterations. Assertions guard each step.

Locators are grounded in the real layouts (getByText('Basic UI') for the Home
nav row, getByTestId('text_field') for the first EditText). Typechecks under
strict tsc and is discovered by 'mobilewright test --list' (20 tests).

Not yet run against a live emulator — a starting point for refinement.
An Android-native (Espresso/UiAutomator) variant is left as a TODO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant