Skip to content

Add Playwright and Rust practice guides to the testing guide - #430

Merged
yansfil merged 2 commits into
mainfrom
docs/testing-practice-guides
Oct 5, 2026
Merged

yansfil merged 2 commits into
mainfrom
docs/testing-practice-guides

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #419 (재시도 분류와 nextest), 이어지는 lint PR(ci/test-lint)

Summary

docs/TESTING.md에 실습 절 두 개를 더했습니다. "Writing a Playwright e2e test"(9단계)와 "Writing a Rust test"(8단계)입니다.
각 단계는 무엇을 하는가, 왜, 저장소 안의 기준 예시 파일을 적습니다. 새 정책은 없고, 이미 있는 규칙을 작성 순서로 묶었습니다.
AGENTS.md의 테스트 줄과 docs/README.md의 소유 행이 두 절을 가리킵니다. 기존 "Choose what to test"의 "Herdr is not faked" 문장은 FakeHerdr 예외를 적어 한 곳으로 맞췄습니다.

Review

  • 판단해 주세요: 아직 머지되지 않은 것을 "Pending"으로 적었습니다. 이 방식이 괜찮은지, 머지 전까지 빼는 편이 나은지.
  • 판단해 주세요: 크기 상한은 숫자 없이 "lint가 들어오면 숫자를 적는다"로 뒀습니다. 숫자는 lint PR이 정합니다.
  • 조심해서 볼 파일: docs/TESTING.md - 아래 Pending 항목이 실제로 머지되면 같은 문장을 맞춰야 합니다.
  • 질문: 없음.

Evidence

  • 확인한 것: 인용한 파일 경로, 함수와 테스트 이름, data 속성, diagnostic kind를 원본에서 하나씩 대조했습니다(별도 검토에서 거짓 7건을 찾아 고쳤습니다).
  • 확인한 것: 문서 내 anchor 링크가 모두 풀립니다. scripts/tests 108개와 policy 불변식 스크립트가 통과합니다.
  • 확인하지 못한 것: page.clock을 쓰는 spec이 아직 없어 그 단계는 예시 파일 없이 규칙만 적었습니다. tokio::time::pause()는 test-util feature가 꺼져 있어, 처음 필요한 PR이 켠다고 적었습니다.
머지 뒤 맞출 곳 (Pending 항목)

@yansfil
yansfil merged commit 4df25a0 into main Oct 5, 2026
13 checks passed
@yansfil
yansfil deleted the docs/testing-practice-guides branch October 5, 2026 01:42
yansfil added a commit that referenced this pull request Oct 5, 2026
Related: #433 (retried interactions), #437 (Rust sleeps), #430 (guide),
#434 (clock injection and Rust waits), #429 (headless renderer), #438
(shared gate), #419 (retries)

## Summary

Playwright specs in `web/e2e` and `desktop/e2e` now pass
`eslint-plugin-playwright` plus two repository rules, an e2e test size
budget runs in the same `lint` script, and clippy refuses
`std::thread::sleep` in Rust.
All of it runs in the existing lanes (`web lint`, `desktop lint`,
`clippy`); no new job or workflow step.
Existing violations were fixed where a state exists to wait for, and the
rest carry a reasoned allow, listed below.

## Review

- **판단해 주세요**: `quietFor` is the only sleep an e2e spec may use for a
window in which something must not happen; its 30 call sites each state
the claim. Is a time window the right form for those, or should some
become a counted check?
- **판단해 주세요**: `no-conditional-in-test` (98 hits, mostly
`process.platform` and fold toggles) and `max-expects` (2409 hits at the
default of 5) are not enabled; the size budget replaces `max-expects`.
Enable either?
- **조심해서 볼 파일**: `web/eslint-rules/hide-e2e.mjs` - two hand-written
rules; `web/scripts/check-e2e-test-size.mjs` - the baseline logic;
`web/e2e/wait.ts` - the one `eslint-disable` for `waitForTimeout`.
- **조심해서 볼 파일**: `web/e2e/s3.spec.ts` (two draft recovery tests) - they
must not reload the page, so they carry a line allow with the reason;
adding `about:blank` made both fail.
- **조심해서 볼 파일**: `web/e2e/theme.spec.ts` - `networkidle` replaced by
asserting hided's empty 404 for `/gallery`;
`web/e2e/agent-tab-groups.spec.ts` - a 300 ms sleep between two `tab
focus` calls was removed (the CLI returns after Herdr applied it, events
reach the core in order; a probe showed the first focus changes nothing
visible); `web/e2e/s3.spec.ts` - the offline window now also asserts the
file was not written.
- **질문**: #434 merged first; this branch took main and dropped the
`#437` allows on the five functions it fixed (`hide-ai/src/router.rs`
x3, `usage.rs`, `live.rs`).

## Evidence

- **확인한 것**: `pnpm lint` in `web` and `desktop` pass (ESLint plus the
size budget); `cargo clippy --workspace --all-targets -- -D warnings`
and `cargo fmt --check` pass; `scripts/tests` 108 pass; the identity and
attribution checks pass.
- **확인한 것**: each rule fires on a planted violation (`waitForTimeout`,
an action inside `toPass`, `goto` of `#token=` after `restart()`); the
size budget fails when a baselined test grows (it caught this branch's
own 9-line addition to the Overview test, which moved into a helper).
- **확인한 것**: ran the changed specs against a local `hided` and the
pinned Herdr, all pass: theme (gallery and restart), start-panel,
agent-tab-groups external focus, sidebar-pr-start, cmdk recents, both s3
draft recovery tests, s6 Main/Overview (failed once on the first run at
the File Views open, passed on the immediate rerun; this PR only
relabels a wait in that test), and the Overview graph test.
- **확인한 것**: a reviewer found the labels above too loose in a first pass
(a settle wait named `quietFor`, native captures without
`compositorPresents`, Rust allows with the wrong reason); all were fixed
before this PR.
- **확인하지 못한 것**: known gaps in the new lint: `expect.soft(fn).toPass()`,
a poll that calls an action through a helper, and a `goto` through a
local `url` variable after `restart()` are not seen; a hand-written `new
Promise((r) => setTimeout(r, ms))` is not seen either (mobile.spec x2,
remote-workspace, browser, workspace-columns x2 exist today); clippy
covers `std::thread::sleep` only, not `park_timeout`, `wait_timeout` as
a delay or a spawned `sleep`. #437 lists the Rust gap.
- **확인하지 못한 것**: the other edited specs (digit, keys, browser,
terminal-links, session-labels, the macOS desktop specs) were not run;
desktop e2e needs the macOS lane. Windows and Linux lanes run in CI.
- **확인한 것**: macOS clippy does not compile `cfg(windows)` or Linux-only
code, which is how the two Windows named-pipe waits in
`hide-platform/src/ipc.rs` slipped through (found by the Windows OS
contract job). A source scan of every `sleep(` call in the tree,
regardless of cfg, now finds none outside an allowed function; a
Windows-target clippy run reached `hide-platform` and `hide-ai` before
`ring` failed to build on this Mac, so the Windows lane in CI is the
check for the rest.
- **확인하지 못한 것**: `Instant::now` and `SystemTime::now` bans in
clock-injected modules. Clippy cannot scope a method to a module and
#434 has injected no module yet; once it has, a per-crate `clippy.toml`
or a module-level `deny` with those two methods is the follow-up.

### Sleeps and waits, before and after

| | Before | After |
| --- | --- | --- |
| `waitForTimeout` in `web/e2e` and `desktop/e2e` | 53 | 1
(`web/e2e/wait.ts`, behind three named helpers) |
| `quietFor`: a window in which something must not happen | - | 30 |
| `compositorPresents`: native capture on macOS | - | 6 |
| `measureFor`: idle measurement and sample pacing | - | 5 |
| `animationsFinished`: waits for finite animations, not time | - | 10 |
| `unchangedForFrames`: waits until a value stops changing for 30
animation frames (bounded) | - | 3 |
| Waits on time removed or replaced by a state or a stronger assertion |
- | 3 (agent-tab-groups ordering sleep, `networkidle`, s3 offline
window) |
| `no-action-in-poll` allows, all #433 | - | 10 |
| `reopen-after-restart-through-blank` allows (reconnect is the subject)
| - | 2 |

| Rust allow (`#[allow(clippy::disallowed_methods)]`) | Count |
| --- | --- |
| Bounded polling helper or inline bounded poll (sleeps between
observations of a state, with a deadline) | 26 |
| The sleep is the subject (a slow fake peer or backend) | 1 |
| A child process kept alive for the test to kill | 6 |
| Production wait, not test code | 31 |
| Test that sleeps for a state, tracked in #437 | 59 |

The production waits are allowed line by line rather than by a
crate-root allow with `deny` in test modules: that form would leave
every new `mod tests` and `tests/*.rs` file unguarded until someone adds
the attribute, whereas the line allows fail closed.

### Size budget

`web/e2e/test-size-baseline.json` (20 tests; #447 split three of them)
and `desktop/e2e/test-size-baseline.json` (13) record the tests over 120
lines or 40 `expect` calls as a ceiling that only shrinks.

## Pending guide sentences

`docs/TESTING.md` names #429, #438 and #434 as pending, and #419 for
retries and nextest; each of those pull requests fixes its own sentence
when it takes main.

<details><summary>Verification record</summary>

Base `origin/main` 4df25a0. Local runs: `pnpm lint` (web, desktop),
`scripts/verify-cargo.sh clippy --workspace --all-targets -- -D
warnings`, `fmt-check`, `python3 -m unittest discover -s scripts/tests`,
Playwright specs listed above. Review by a separate reviewer: see the PR
comments.

</details>




Main merge (#434, #435, #431, #450): baselines were refreshed after it.
Two `browser-cdp.spec.ts` tests added by main were already over the
budget and are baselined (172 and 121 lines); the Overview test grew 9
lines on main and its ceiling moved with it. Rust allows: 123 in total
after the merge.
yansfil added a commit that referenced this pull request Nov 2, 2026
Related: #2011

## Summary

폰이 기본으로 Hide 중계를 통해 연결되고, 설정의 한 연결 줄에서 연결 상태와 다시 시도·업데이트·상한 거부를 확인합니다.
QR은 app.withhide.dev를 열며 5분 뒤 만료됩니다. Tailscale 직접 연결은 고급에서 고릅니다.
방법마다 페어링한 폰을 따로 유지하고, 끄기·해제 시 연결을 닫습니다.
폰 내용은 기기와 폰 사이에서 암호화합니다.
기존 Tailscale 설정은 그대로 이어 쓰고 새 설정은 중계로 시작합니다.

![Settings Mobile: encrypted relay connection, five-minute QR and
advanced
Tailscale](https://github.com/yansfil/pr-assets/blob/main/hide/feat-hided-relay/e8fa807/settings-qr.png?raw=true)

실제 Settings 컴포넌트의 격리 갤러리입니다.
연결 줄, QR 만료 안내, 접힌 고급 영역을 확인해 주세요.

![Settings Mobile: relay stays available when the old Tailscale setup
cannot be
removed](https://github.com/yansfil/pr-assets/blob/main/hide/feat-hided-relay/5eeb736/settings-cleanup.png?raw=true)

이전 Tailscale 연결을 정리할 CLI가 없어도 중계는 연결되고, 같은 한 줄에 정리 실패가 남습니다.

## Review

- **판단해 주세요**: 연결 상태와 암호화 설명의 길이, 고급 Tailscale의 발견성.
- **조심해서 볼 파일**: `hided/src/mobile/relay.rs`, `phone.rs` - 암호화 경계, 종료
순서, 취소와 큐 상한.
- **조심해서 볼 파일**: `mobile/mod.rs`, `phones.rs`, `store.rs` - 키 저장, 방식 전환과
기존 폰 보존, 재연결 후 요청 기록.
- **비용 검토**: 연결 1개, 폰 작업 8개, 폰당 수신 8프레임·공유 송신 32프레임; 상태 전환만 발행하며 core 잠금
안에서 네트워크 작업을 하지 않습니다.

## Evidence

- **확인한 것**: 실제 hided 중계 통합 6개가 macOS·Linux·Windows에서 암호화·재연결·방법별 폰
보존·해제·끄기·미인증 제한 시간을 확인합니다.
- **확인한 것**: 입력 중단 테스트가 연결을 끊고 같은 요청을 재시도할 때 영구 대기에 남지 않음을 확인합니다.
- **확인한 것**: Mobile UI 24개, 직접 연결 브라우저 5개와 격리 갤러리의 한글·영문·큰
글씨·dark/light·QR·고급 상태를 확인했습니다.
- **확인한 것**: 최신 커밋에서 로컬 lint·Rust 7,357개·web 2,471개·desktop 307개·빌드·디자인
계약과 GitHub CI가 통과했습니다.
- **재시도 이력**: 기존 기기 테스트 #430·#439는 최초 실패 후 로컬 단독 1회와 CI 작업 1회 재실행에서
통과했습니다. CI에는 기존 세션 복원 #419의 자동 재시도도 있습니다.
- **확인하지 못한 것**: 실제 폰·native 앱·운영 TLS와 실제 PTY 답장 재전송은 통합·배포 검증에 남아 있습니다.

<details><summary>Verification record</summary>

Head: `d75b9db7d9ef0287392452ad5fc77bfce605f26c`.
Base: `b1b25cde4`, including protocol #2011, Memory correction #2020,
relay server #2014 and hosted phone #2019.
Scope: mobile-relay B1-B10, hided B24, B28; hided transport, Settings
Mobile, owning architecture/UI guides.
The architecture merge preserves both the hosted phone WASM initiator
and the device responder/admission/authentication contract.
Cargo.lock and workspace-hack did not change in that merge; their shared
feature union was generated at `92620a992` and passes CI.
Caller tests use shared admission/routing types and real Noise sessions
without implementing a second relay service.
The interrupted-input test uses the real phone/Noise path and node
permission boundary; it does not claim an actual PTY write.
The original socket handler already detached its input task on
disconnect, so the original cancellation premise was not reproduced.
The follow-up additionally settles from the blocking operation with an
Uncertain drop guard; the caller test verifies disconnect/retry lifetime
rather than isolating that guard.
Independent re-review passed at `5eeb73668`; the additional live-peer
and unreaped-task bound at `744506a3e` was reviewed and accepted.
The QR screenshot was captured at `e8fa80774`; the cleanup screenshot
was captured at `5eeb73668`; the Settings product changes are unchanged
since that follow-up.
The five direct-mobile browser journeys passed at `6c2a6e338` without
weaker assertions or timeouts.
The Cursor fixture now explicitly selects Advanced > Use Tailscale
before enabling Mobile.

Current-head local verification ran on macOS under the shared mission
lock:

- `bash scripts/verify-cargo.sh lint`: PASS, 1m 10s.
- `bash scripts/verify-cargo.sh test-scoped`: core 3,929 passed, 1
failed, 20 ignored; stopped at the existing own_devices assertion in
`herdr-core/src/runtime/tests/own_devices.rs:158`.
- The only exact-test rerun on the same SHA passed in 0.27s; the initial
Kit/GuardrailPolicy assertion failure remains recorded, matching
[#430](with-hide/hide-private#430) and
[#439](with-hide/hide-private#439).
- `bash scripts/verify-cargo.sh test-scoped --workspace --exclude
herdr-core` then ran the crates the initial command had not reached:
3,427 passed, 149 ignored.
- Combined Rust coverage: 7,357 passed, 169 ignored, including the one
separately rerun test; this is a split completion after an initial
failure, not an uninterrupted green run.
- `bash scripts/verify-web.sh`: PASS; web 2,471 passed / 3 skipped,
desktop 307 passed / 4 skipped; type checks, lint and builds passed.
- `node scripts/check-design-contract.mjs`: PASS.

[GitHub CI run
41456834038](https://github.com/with-hide/hide/actions/runs/41456834038)
passed on attempt 2 after exactly one failed-job rerun:

- Attempt 1: Rust 7,338 passed / 1 failed / 166 skipped; own_devices
#430/#439 failed both automatic attempts.
- Attempt 2: Rust 7,339 passed / 166 skipped; own_devices passed on its
first attempt in 0.027s.
- Attempt 2 also includes one automatic retry of the existing
session-restore test
[#419](with-hide/hide-private#419); the first
failure remains in its job log.
- Linux and Windows each passed all six mobile_relay caller tests on
attempt 1; Windows job `125315707247` completed successfully.
- Linux browser shards and Windows E2E passed on attempt 1 without flaky
results.
- Cursor phone passed in shard 6 (`125317575438`, 6.6s); the
reopened-tab test tracked by #418 passed in shard 4 (`125317575230`,
3.3s), both on their first attempt.
- macOS desktop, protocol and packaging lanes passed; macOS hided mobile
evidence is the local run above.

Real phone/native-app interaction, production TLS and actual PTY replay
remain outside this PR's verified evidence.

</details>
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