# Isolated native review

The review targets are separate from the production applications. They accept
only a loopback fixture, use real magic-link sign-in followed by the shared
native approval/exchange, and never access a production account. The Go test
creates and removes its own database. Mac credentials travel over stdin;
simulator credentials use a mode-0600 `Documents/review.json` that the fixture
removes after success or failure.

From the repository root, build the simulator review app and UI test runner:

```sh
xcodegen generate --spec native/ios/project.yml
xcodebuild -project native/ios/SheetsPhone.xcodeproj \
  -scheme SheetsReviewPhone -sdk iphonesimulator \
  -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath native/build/review-ios CODE_SIGNING_ALLOWED=NO build-for-testing
```

Set `NATIVE_REVIEW_SIMULATOR` to a booted iPhone or iPad simulator UUID, then run:

```sh
xcrun simctl install "$NATIVE_REVIEW_SIMULATOR" \
  native/build/review-ios/Build/Products/Debug-iphonesimulator/SheetsReviewPhone.app
NATIVE_REVIEW_UI_TESTS=1 NATIVE_REVIEW_OUTPUT=/tmp/sheets-native-review.png \
  go test ./internal/sheets -run '^TestNativeReview$' -count=1 -timeout 8m
```

The UI cases create a sheet, enter `=2+3`, check `5`, select the cell to read its
formula, change it to `=7*6`, and check `42`. They then exercise fill down,
range copy/paste, number formatting, own input undo and version-history restore.
A separate case injects one HTTP 503 for the exact synthetic formula `=6*7`,
checks that its draft remains visible and protected, and retries it. Export
opens the real system destination picker and cancels; the fixture verifies
the export request reached the server and no staged XLSX remains afterward.
It does not test saving a file to an external destination.
A fresh authenticated server read verifies the resulting raw formulas and
computed values. To isolate a case, set `NATIVE_REVIEW_UI_ONLY` to
`NativeUITests/testCreateAndEditFormula`,
`NativeUITests/testFailedCellEditCanBeRetriedWithoutLosingDraft`, or
`NativeUITests/testExportWorkbookOpensNativeDestinationAndCancels`.
The fixture exports the test's screenshot attachment to `NATIVE_REVIEW_OUTPUT`.
Its xcodebuild log is stored under the operating system temporary directory
as `sheets-native-ui-<simulator UUID>.log`.

For a Mac window capture:

```sh
swift build --package-path native/apple --product SheetsReview
NATIVE_REVIEW_BINARY="$PWD/native/apple/.build/debug/SheetsReview" \
  NATIVE_REVIEW_OUTPUT=/tmp/sheets-native-mac.png \
  go test ./internal/sheets -run '^TestNativeReview$' -count=1 -timeout 90s
```

Mac window capture requires existing macOS screen-recording access. The helper
checks access and does not request it automatically. On 2026-09-13, the review
executable compiled and authenticated, but this environment lacked capture
access; no Mac screenshot was accepted as verification.

On 2026-09-13 the initial formula UI flow and server persistence check passed on iPhone 17 Pro
and iPad Pro 13-inch (M5), iOS 26.5. The same test first exposed compact-screen
navigation and cell-selection failures before their fixes. This exercises the
named flow, not every feature in the parity inventory.
The expanded three-case iPad UI suite passed after exposing a blank history
panel and an export filename crash. Its combined Xcode result finalization
then timed out; separate fixture runs distinguish UI assertions from complete
server-persistence and cleanup verification. The isolated export case passed
including its server and temporary-file checks.
The isolated expanded editing case subsequently passed in 192.565 seconds,
including its fresh 2×2 formula/format/history checks; the isolated refused-write
retry passed in 45.066 seconds, including verification that `=6*7` persisted.
The final export stores the workbook under its title inside a private unique
directory. Its isolated test passed in 58.071 seconds after a simulator restart,
including removal of that directory after cancellation. The screenshot was
visually checked: the system picker displays “Native review workbook”.
