Skip to content

test(test-app): add a sign-in sheet lab for the hosted web auth surface - #4708

Merged
thymikee merged 3 commits into
mainfrom
t3/t77-oauth-fixture-evidence
Nov 18, 2026
Merged

thymikee merged 3 commits into
mainfrom
t3/t77-oauth-fixture-evidence

Conversation

@thymikee

@thymikee thymikee commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a test-app fixture for #2449. iOS presents a real ASWebAuthenticationSession sheet in SafariViewService. The committed read-only Maestro flow verifies the form controls in place, covering the surface involved in #4593 and #2438.

Across 19 files, the PR adds the fixture, flow, and launcher. The launcher starts and closes a loopback provider in its own process. The manual provider serves fixture values with an optional first-request delay.

Validation

  • e551b09a852760a4c89ccb9ed9b7d6891d7cd0c5 and 806f73c8c7c3d16214d6aad2faa3435d6c51243e: pnpm test-app:maestro:auth:ios -- --udid <sim> passed once each on iPhone 18 Pro Max, iOS 27.0. Both runs exited 0 and left TCP 4593 without a listener.
  • At head, both launcher tests, fixture app typecheck, and manual provider checks passed.
  • The exact-head affected gate recorded 19 passes and 25 CI/manual skips, then stopped at affected-selector with 22 checks unrun. The command-group cancellation test timed out before startup (command-execution.test.ts:34). A standalone pnpm run check:affected:test passed 93/93 on both e551b09a and head. The original failure remains unexplained.
  • Prior device evidence at 7fcb66f6: read-only flow passed 3/3. Driving the form produced two snapshot invariant refusals and one XCTest timeout. The reporter's iOS 27.2 remains untested.

CI owns Coverage, native builds and device jobs, provider integration, and history-dependent checks. The fixture adds a test-app-build-cache fingerprint. Adding this OAuth lane to iOS CI is a #2449 follow-up.

Refs #2449
Refs #4593
Refs #2438


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

Present a real ASWebAuthenticationSession sheet from one fixture screen and read it in place. iOS hosts that sheet out of the app's process in com.apple.SafariViewService, so the sheet is the surface regular captures target while the app stays the accessibility primaryApp underneath it. The page comes from a fixture identity provider served over loopback, and it holds fixture values only, so the lane involves no real identity provider and no credential.

The committed Maestro flow reads the sheet's own page: its title, and the Email, Password, and LOGIN controls. Driving past that point is left to the manual lane, because on iOS 27.0 the same steps alternate between passing and refusing the capture, which is the intermittency #4593 reports. Three refusals were observed there, all from the iOS snapshot engine's invariants, and the viewport one carries no retriable detail, so the step's own stability re-capture does not poll and the step aborts.

Refs: #2449
Refs: #4593
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.40 MB 6.40 MB -701 B
Package (unpacked) 6.40 MB 6.40 MB -701 B
Package (download) 1.94 MB 1.94 MB -277 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.8 ms 40.6 ms +12.8 ms
CLI --help 57.1 ms 69.0 ms +11.9 ms

@thymikee

Copy link
Copy Markdown
Member Author

I found no blocking defect in e551b09, but the PR is not ready to merge until it has live evidence at head. The device run (3/3) was at 7fcb66f. The lane launcher was rewritten after that run, and the new version has only been checked on the host with stub CLIs. Please run pnpm test-app:maestro:auth:ios -- --udid <sim> once at head. It should show the sign-in sheet flow passing and no listener left on port 4593 afterwards. The fixture, module and flow are identical between 7fcb66f and head, so only the launcher needs the run.

23 of 24 checks pass; the remaining one is a review check, not a test job. There are no conflicts.

Could the fixture server run in the lane's own process? If you export startAuthIdpServer() next to renderAuthIdpPage, serve-auth-idp.mjs can stay a thin manual CLI over it, taking only --delay-ms. run-test-app-auth-session-lane.mjs then becomes listen, spawn the suite with --flow, and close in finally, plus the existing process-group cancellation. That would delete the stdout readiness parsing, the pipe drain, stopProvider and two of the four lane tests, roughly 120 lines. It would also remove the process boundary that caused the stdout-stall bug fixed since 7fcb66f. The fixture app, module and flow can stay as they are.

The README at line 372 says all three refusals come from invariants.ts. The 'main thread execution timed out' refusal comes from the XCTest runner (runner-failure-diagnostics.ts), so please attribute only the first two to invariants.ts. Also, serve-auth-idp.mjs accepts --host and --port, but the app always opens the hard-coded 127.0.0.1:4593. A port override serves a page the sheet never loads, and --host 0.0.0.0 widens exposure for no consumer. Please drop both and keep --delay-ms.

Not blocking, and you can take or leave these: the 'build without the module shows unavailable' sentence appears twice in the README section, and one 'That starts X, runs Y' clause is missing its conjunction. The flow YAML, serve script and fixture also carry long narration comments, and trimming them to the constraints code cannot show (such as native submit versus location.assign) would match the repo's comment rule. In addition, no workflow under .github/workflows references maestro-ios or test-app:maestro:auth, so the flow that should fail when the sheet is not served runs nowhere in CI. Either add the lane to the existing iOS test-app job, or note in the body that the CI lane is the follow-up for #2449.

@thymikee

Copy link
Copy Markdown
Member Author

Follow-up on the CoS review.

  • On e551b09a852760a4c89ccb9ed9b7d6891d7cd0c5, pnpm test-app:maestro:auth:ios -- --udid 1C2C9FD4-B720-4160-BAEB-7D4724D7B5F3 passed 1/1 in 23.9s on iPhone 18 Pro Max, iOS 27.0. Exit 0. No TCP listener on 4593 afterward.
  • On the pushed head 806f73c8c7c3d16214d6aad2faa3435d6c51243e, the same command passed 1/1 in 22.5s. Exit 0. No TCP listener on 4593 afterward.
  • The lane now awaits the in-process server and closes it in finally. The Node-only startAuthIdpServer() module sits beside the page renderer so the app can still import the renderer's fixture constants. The manual CLI accepts only --delay-ms and binds to 127.0.0.1:4593. I verified the delayed first response, immediate form on the next request, and shutdown on SIGTERM.
  • The README now attributes the first two refusals to invariants.ts and the main-thread timeout to XCTest. It also removes the duplicate unavailable sentence. The flow still reads through the form controls. CI wiring is a test(ios): committed ASWebAuthenticationSession fixture + CI lane #2449 follow-up.

Both launcher tests and the fixture app typecheck passed. The exact-head affected gate is queued on the shared validation lock.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 806f73c. The fixture server now runs inside the lane's own process, so the stdout readiness parsing, the pipe drain and stopProvider are gone. --host and --port are dropped, and the README attribution is fixed. The live lane run at this head passed (1/1, exit 0), and nothing was left listening on 4593. The code review found no problems.

Not blocking, and you can take or leave it: the AbortController and 15 s timeout around server.listen in auth-idp-server.mjs cannot fire on a loopback listen, so server.listen(port, host); await once(server, 'listening') would be enough. Wiring the lane into CI remains the stated #2449 follow-up.

23 of 24 checks pass; the remaining one is a review check, not a test job. The diff touches no production daemon or CLI route. There are no conflicts.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 806f73c

2 finding(s): 2 minor.

🟡 Minor (2)

Where Finding
examples/test-app/src/screens/AuthSessionLabScreen.tsx:29 Canceled sheet is reported as 'error', never 'canceled' (error.name is not the Exception name)
examples/test-app/src/screens/AuthSessionLabScreen.tsx:19 Duplicate openSheet taps leak a live sheet and surface a spurious error status

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (894c80ac681c).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on 806f73c. The verdict and the full list are in the summary comment.

Comment on lines +29 to +32
} catch (error) {
const canceled = error instanceof Error && error.name === 'AuthSessionCanceled';
setStatus(canceled ? 'canceled' : 'error');
setMessage(error instanceof Error ? error.message : String(error));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor · Canceled sheet is reported as 'error', never 'canceled' (error.name is not the Exception name)

Dismissing the sheet with Cancel shows status error instead of canceled, so the canceled branch is dead. The JS check reads error.name, but expo-modules-core delivers the Exception(name:description:) name via the code/Code field or a message prefix, not Error.name. This affects every rejection from the module, including AuthSessionAlreadyPresented and InvalidAuthURL, which also land on error.

⚠️ Check this patch before you commit it: the review doubted it would be right as written.

Suggested change
} catch (error) {
const canceled = error instanceof Error && error.name === 'AuthSessionCanceled';
setStatus(canceled ? 'canceled' : 'error');
setMessage(error instanceof Error ? error.message : String(error));
} catch (error) {
const code = (error as { code?: string; Code?: string } | null | undefined)?.code ??
(error as { Code?: string } | null | undefined)?.Code;
const canceled = error instanceof Error && code === 'AuthSessionCanceled';

Suggested change

Read the exception name from code or Code (or the message prefix) instead of error.name, or reject with an Exception carrying a code so the name propagates. Then verify on a device by canceling the sheet and asserting auth-session-status reports canceled.

Details

Also raised here

Also raised at this location by persona javascript: Canceled sheet reported as 'error': rejection name read from wrong field — Canceling the sheet (tap the sheet's Cancel, or xcrun simctl dismissal) sets auth-session-status to error instead of the canceled status the type declares, so any lane asserting on canceled never sees it. The native side rejects with Exception(name: "AuthSessionCanceled", description:), and expo-modules-core exposes that name to JavaScript as the rejection's code; error.name stays the default "Error", so the error.name === 'AuthSessionCanceled' test is false for every rejection, including the intentional-cancel case. No sibling screen in this app keys on error.name — AccessorySetupScreen and AutomationLabScreen use only error.message — so nothing here enforces the invariant that the name survives the bridge.

persona: swift-ios, javascript

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Comment on lines +19 to +33
const [message, setMessage] = useState('Ready to open the system sign-in sheet.');

async function openSheet() {
setStatus('presenting');
setMessage('Sign-in sheet requested.');

try {
const callbackUrl = await startFixtureSignInSession(AUTH_IDP_DEFAULT_URL);
setStatus('completed');
setMessage(`Signed in: ${callbackUrl}`);
} catch (error) {
const canceled = error instanceof Error && error.name === 'AuthSessionCanceled';
setStatus(canceled ? 'canceled' : 'error');
setMessage(error instanceof Error ? error.message : String(error));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor · Duplicate openSheet taps leak a live sheet and surface a spurious error status

Tapping SIGN IN twice while the first sheet is up sends a second startSignInAsync, which the native controller rejects with AuthSessionAlreadyPresented, and the catch in openSheet sets status to 'error' even though the first sheet is still presenting. The status also never returns to 'idle' after completion, so the only way back to a tappable 'idle' is leaving and re-entering the route. Guard the handler on status === 'presenting' or disable the ActionButton while presenting so a double tap cannot reach the module.

Details

Also raised here

Also raised at this location by persona maintainability: Repeated SIGN IN taps produce an inconsistent final status from two concurrent promises — Pressing the button while status is presenting launches a second openSheet call; the native side rejects the second immediately with AuthSessionAlreadyPresented, setting status to error, but the first promise is still pending. When the sheet eventually closes the first resolution overwrites error with completed, hiding the error from the user. Guard openSheet with an early return when status === 'presenting'.

persona: senior-developer, maintainability

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

@thymikee
thymikee merged commit 7c1934f into main Nov 18, 2026
24 checks passed
@thymikee
thymikee deleted the t3/t77-oauth-fixture-evidence branch November 18, 2026 17:09
@thymikee

Copy link
Copy Markdown
Member Author

Follow-up for the cancellation and duplicate-tap findings is in #4711. The fixture now reads Expo's typed cancellation code and ignores another tap while a sheet is active. A host probe covers both failures and confirms the sheet can be requested again after cancellation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant