Commit a8d0e41
chore(ci): extract helpers from brev-e2e beforeAll and fix worktree installer detection (#1888)
## Summary
Addresses all three items from #1390, plus a bonus installer fix
discovered while running the pre-push hooks.
### Issue #1390 — Brev E2E cleanup
- **Extract helpers from the monolithic beforeAll**: The ~350-line
`beforeAll` block is now ~50 lines of high-level orchestration calling
named helpers: `cleanupLeftoverInstance()`, `createBrevInstance()`,
`refreshAndWaitForSsh()`, `bootstrapLaunchable()`,
`pollForSandboxReady()`, `writeManualRegistry()`.
- **Deduplicate brev create + error recovery**: The deploy-cli and
launchable paths shared duplicated `brev refresh` + `waitForSsh`
patterns, now consolidated into `refreshAndWaitForSsh()`.
- **Remove phantom `version: 1`** from the manual registry write. The
`SandboxRegistry` interface in `src/lib/registry.ts` has no version
field; `registerSandbox()` doesn't write one either.
Additional cleanup:
- `bootstrapLaunchable()` returns `{ remoteDir, needsOnboard }` instead
of mutating module-level state as a hidden side-effect.
- `instanceCreated` is set at call sites in `beforeAll`, not hidden
inside `createBrevInstance()`.
- Dead `sleep()` helper removed.
Pure refactoring — no behavior changes. `// @ts-nocheck` pragma
preserved.
### Installer worktree fix
`scripts/install.sh` used `-d "${repo_root}/.git"` to detect source
checkouts, but in a git worktree `.git` is a file, not a directory. This
caused `is_source_checkout()` to return false, falling through to the
GitHub clone path. Fixed by using `-e` (exists) instead of `-d` (is
directory). This resolved 12 pre-existing test failures in
`test/install-preflight.test.ts`.
## Related Issue
Closes #1390
## Note
PR #1791 also touches `test/e2e/brev-e2e.test.ts` (appends a new
`vm-backend` test case). Clean merge — whoever merges second rebases
trivially.
## Type of Change
- [x] Code change for a new feature, bug fix, or refactor.
## Testing
- [x] `npx prek run --all-files` passes (all pre-commit and pre-push
hooks green).
- [x] `npx vitest run --project cli` — 1213 passed, 0 failed (was 12
failed before installer fix).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Enhanced end-to-end test infrastructure and setup orchestration for
improved test reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Aaron Erickson <aerickson@nvidia.com>1 parent fcdfeed commit a8d0e41
1 file changed
Lines changed: 346 additions & 312 deletions
0 commit comments