# Document window smoke test

Run `python3 native/scripts/test-document-window.py` from a logged-in macOS
session. It opens a temporary app window and needs permission to become active.
No account, production service, or user document is used: a loopback HTTP server
serves the repository's synthetic letter seed.

The test exercises the public DocsWorkspace in a SwiftUI document scene. It waits
for the editor to load, opens/closes the inspector eight times through the native
menu, checks the editor gains/loses panel space, resizes the window, and verifies
that the same text view retains its content and selection.

Regression: Docs 0.1.1 (3) could crash opening its first document on macOS 27.
Restoring the `.inspector` container reproduces SIGTRAP with AppKit's “more Update
Constraints in Window passes than there are views” exception. The docked settings
panel avoids that container. The negative and fixed scene runs were verified on
macOS 27 build 26A5388g; the user report was build 26A428.

The typing regression now sends native key events and checks the actual
NSTextInsertionIndicator against glyph geometry and document bounds, including
repeated Enter presses. To exercise multiple pages (the short seeds do not):

```sh
cargo run --manifest-path native/crdt/Cargo.toml --example caret_fixture -- /tmp/docs-caret.bin
DOCS_SMOKE_UPDATE=/tmp/docs-caret.bin python3 native/scripts/test-document-window.py
```

The generated fixture has 60 independent paragraphs. Optional
`DOCS_SMOKE_SCREENSHOT=/tmp/docs-caret.png` captures the window after typing.
The same executable imports the real window command source through symlinks and
verifies Accounts/Sign out are in the app menu and Accounts reopens closed Home.

To exercise immediate untitled creation, use `DOCS_SMOKE_DRAFT=1 python3 native/scripts/test-document-window.py`.
The server deliberately waits two seconds. The test types before acknowledgement,
asserts the same text view and content survive attachment, and saves an actively
edited header title without pressing Return. Both modes then test Enter/caret
geometry, inspector resizing, and native account menus.

`python3 native/scripts/test-document-drafts.py` covers lost creation replies,
retry identity, pending edits and deletes across different document GUIDs,
rename during reconnect, oversized title retention, close-save, and discard.
