Skip to content

Sign a Simulator into WordPress.com from a launch-argument token#25801

Draft
jkmassel wants to merge 5 commits into
trunkfrom
jkmassel/sim-wpcom-token-signin
Draft

Sign a Simulator into WordPress.com from a launch-argument token#25801
jkmassel wants to merge 5 commits into
trunkfrom
jkmassel/sim-wpcom-token-signin

Conversation

@jkmassel

@jkmassel jkmassel commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds Scripts/sim-signin.sh, a one-command wrapper around xcrun simctl launch that signs an iOS Simulator into WordPress.com with a bearer token.
  • Introduces the -wpcom-token launch argument (the legacy -ui-test-wpcom-token still works as a backward-compatibility shim).
  • Makes that launch argument finish sign-in automatically, instead of requiring a tap on "Continue with WordPress.com".

Background

trunk already reads a -ui-test-wpcom-token launch argument inside WordPressDotComAuthenticator.attemptSignIn — but only when the user taps "Continue with WordPress.com" on the login screen. Signing a Simulator in therefore still needed a manual tap. This is the launch-argument approach chosen over device-to-device session transfer.

Changes

1. Scripts/sim-signin.sh

Scripts/sim-signin.sh --wpcom-token <token>                 # Jetpack, booted simulator
Scripts/sim-signin.sh --app wordpress --wpcom-token <token> # WordPress
Scripts/sim-signin.sh --reset --wpcom-token <token>         # wipe existing state first

Takes the token via -t, --wpcom-token (or positionally), maps --app to the bundle id (com.automattic.jetpack / org.wordpress), defaults to the booted simulator, and — with --reset — runs a separate -ui-test-reset-everything launch first (the reset must not be combined with the credential arguments).

2. -wpcom-token launch argument

WordPressDotComAuthenticator.launchArgumentToken resolves the token from the new -wpcom-token argument, falling back to the legacy -ui-test-wpcom-token. Both the automatic sign-in and the existing attemptSignIn path read through it, so nothing still passing the old argument breaks.

3. Automatic sign-in

WordPressAppDelegate.autoSignInUITestWPComAccountIfNeeded() mirrors the existing autoSignInUITestSite() hook and is called from RootViewCoordinator.showSignInUI(). It no-ops unless the token argument is present and no account is signed in, then runs the real signIn(context: .default) flow and swaps the window root with windowManager.showUI().

Posting WPSigninDidFinishNotification alone creates the account but leaves the app on the login screen — the explicit windowManager.showUI() is what lands it on the app.

Test plan

  • Build and install the app on a booted Simulator.
  • Scripts/sim-signin.sh --wpcom-token <valid-token> → app signs in and lands on the site with no taps.
  • Launching with the legacy -ui-test-wpcom-token <token> still signs in.
  • --reset against a signed-in app → state is wiped, then re-signed-in.
  • Already-signed-in account → no-op, no duplicate sign-in.
  • --app wordpress targets org.wordpress.

Related

Add `Scripts/sim-signin.sh`, a one-command wrapper around `xcrun simctl
launch` that signs a Simulator into WordPress.com with a bearer token, and
make the existing `-ui-test-wpcom-token` launch argument finish sign-in
automatically instead of requiring a tap on "Continue with WordPress.com".

`autoSignInUITestWPComAccountIfNeeded()` mirrors the existing
`autoSignInUITestSite()` hook: it runs from `showSignInUI()`, no-ops unless
the token argument is present and no account is signed in, then runs the
real sign-in flow and swaps the window root with `windowManager.showUI()`.
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

jkmassel added 2 commits July 17, 2026 15:43
Add a named `-t, --wpcom-token <token>` option alongside the positional
form, and reject a missing option value instead of shifting past the end.
Introduce `WordPressDotComAuthenticator.launchArgumentToken`, which reads
the new `-wpcom-token` launch argument and falls back to the legacy
`-ui-test-wpcom-token`. Route both read sites — `attemptSignIn` and
`autoSignInUITestWPComAccountIfNeeded()` — through it, and switch the helper
script to pass `-wpcom-token`.
@wpmobilebot

wpmobilebot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33217
VersionPR #25801
Bundle IDorg.wordpress.alpha
Commit5b8b264
Installation URL29gpic3p7ivc0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33215
VersionPR #25801
Bundle IDcom.jetpack.alpha
Commitb022cf6
Installation URL15dhsndifd1e0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

jkmassel added 2 commits July 17, 2026 16:09
The launch argument is `-wpcom-token`, not UI-test-scoped, so
`autoSignInUITestWPComAccountIfNeeded()` was misleading. Rename it to
`autoSignInWPComAccountFromLaunchArgumentIfNeeded()`.
So the token can be set once instead of pasted every launch, sim-signin.sh
falls back to the WPCOM_TOKEN environment variable, then a ~/.wpcom-token
file, when neither --wpcom-token nor a positional token is given.
Precedence: flag > env var > file.
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.

3 participants