mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
* chore: delete internal/agent package
* chore(build): remove sdk-android from gradle settings
* chore(makefile): remove sdk-android targets
* chore(ci): remove release-android job from release workflow
* chore(folio): remove sdk-android dependency
* chore(folio): remove SDK initialization from FolioApplication
* chore(folio): delete snapshot extractor files
* feat(folio): add balance to account card content description
* feat(folio): add hierarchy content descriptions to LedgerScreen
* refactor(folio): rewrite spec.ts to use ax extractors
* docs: remove in-app SDK from README
* feat(folio): add focused_input indicator to App
* docs: remove in-app SDK from index
* refactor(runner): remove agent SDK connection and snapshot step
* test(runner): update tests for SDK removal
* docs: remove Android SDK section from getting-started
* refactor(testrun): remove agent SDK connection setup
* docs: remove snapshots from writing-specs
* docs: remove in-app SDK from architecture doc
* docs(folio): update README for SDK removal
* docs: update per-step cycle diagram in architecture doc
* fix(folio): detect screens from unique element presence, not id: selectors
testTag() in Compose is not exposed as resource-id without testTagsAsResourceId.
Use desc: selectors for elements unique to each screen instead of id: path queries.
* feat(folio): add screen root contentDescription for scoped ax selection
Each screen root gets semantics { contentDescription = "ScreenName" } so
sanderling specs can scope element lookups through the screen: desc:LoginScreen > desc:login_submit.
* fix(folio): scope all ax selectors through screen root nodes
Use desc:ScreenName > desc:element path queries so every selector is
rooted at the screen level. focusedInput stays unscoped since it lives
in the app root, outside any screen.
* fix(folio): guard newAccountBalanceIsZero against navigation false positives
Scoped selectors return [] when not on HomeScreen so accounts vanish and
reappear as apparently-new on each visit. Skip the check when prev was empty.
* chore(folio): link @sanderling/spec to local pkg/spec for IDE type checking
* feat(spec): add desc, class, clickable, enabled, checked, focused, selected to AccessibilityElement
Runtime fields set by the verifier were missing from the TypeScript type,
causing linting errors on el.desc and related accesses in specs.
* chore(folio): switch to bun, add tsconfig.json for IDE type checking
- Remove package-lock.json, add bun.lock
- Add tsconfig.json so VSCode resolves @sanderling/spec types
- Fix parseAccount/parseLedgerRow to accept string | undefined
93 lines
3.0 KiB
Go
93 lines
3.0 KiB
Go
package testrun
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"net"
|
|
"os"
|
|
"os/exec"
|
|
"strconv"
|
|
|
|
"github.com/priyanshujain/sanderling/internal/android"
|
|
"github.com/priyanshujain/sanderling/internal/driver"
|
|
"github.com/priyanshujain/sanderling/internal/driver/chrome"
|
|
driverSidecar "github.com/priyanshujain/sanderling/internal/driver/sidecar"
|
|
"github.com/priyanshujain/sanderling/internal/ios"
|
|
"github.com/priyanshujain/sanderling/internal/sidecar"
|
|
)
|
|
|
|
// buildDriver creates the appropriate DeviceDriver for the platform and returns
|
|
// a cleanup function. For web, ChromeDriver is used directly; for android/ios
|
|
// the JVM sidecar is extracted, spawned, and dialed.
|
|
func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver.DeviceDriver, func(), error) {
|
|
if options.Platform == "web" {
|
|
d := chrome.New()
|
|
return d, func() { _ = d.Terminate(context.Background()) }, nil
|
|
}
|
|
|
|
sidecarDirectory := os.TempDir() + "/sanderling-sidecar"
|
|
jarPath, err := sidecar.Extract(sidecarDirectory)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("extract sidecar: %w", err)
|
|
}
|
|
fmt.Fprintf(stdout, "sidecar JAR: %s (size=%d)\n", jarPath, sidecar.EmbeddedSize())
|
|
|
|
sidecarPort, err := pickFreePort()
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
sidecarArgs := []string{"-jar", jarPath,
|
|
"--port", strconv.Itoa(sidecarPort),
|
|
"--platform", options.Platform,
|
|
}
|
|
if options.Platform == "ios" {
|
|
if udid := ios.BootedUDID(ctx); udid != "" {
|
|
sidecarArgs = append(sidecarArgs, "--udid", udid)
|
|
}
|
|
}
|
|
sidecarCommand := exec.CommandContext(ctx, "java", sidecarArgs...)
|
|
sidecarCommand.Stdout = stdout
|
|
sidecarCommand.Stderr = stdout
|
|
sidecarCommand.Env = android.EnvWithAndroidPlatformTools(os.Environ())
|
|
if err := sidecarCommand.Start(); err != nil {
|
|
return nil, nil, fmt.Errorf("spawn sidecar: %w", err)
|
|
}
|
|
fmt.Fprintf(stdout, "sidecar pid=%d listening on 127.0.0.1:%d\n", sidecarCommand.Process.Pid, sidecarPort)
|
|
|
|
driverClient, err := driverSidecar.Dial(fmt.Sprintf("127.0.0.1:%d", sidecarPort))
|
|
if err != nil {
|
|
_ = sidecarCommand.Process.Kill()
|
|
return nil, nil, fmt.Errorf("dial sidecar: %w", err)
|
|
}
|
|
// WaitForHealth confirms the gRPC sidecar is up. For iOS, the WDA warmup
|
|
// (absorbing the XCUITest startup race) runs inside IosDriverBackend.init
|
|
// in the sidecar - no additional sleep needed here.
|
|
healthCtx, healthCancel := context.WithTimeout(ctx, sidecarStartupTimeout)
|
|
if err := driverClient.WaitForHealth(healthCtx, 250e6); err != nil {
|
|
healthCancel()
|
|
_ = sidecarCommand.Process.Kill()
|
|
_ = driverClient.Close()
|
|
return nil, nil, fmt.Errorf("sidecar health check: %w", err)
|
|
}
|
|
healthCancel()
|
|
fmt.Fprintln(stdout, "sidecar is healthy")
|
|
|
|
cleanup := func() {
|
|
_ = driverClient.Close()
|
|
if sidecarCommand.Process != nil {
|
|
_ = sidecarCommand.Process.Kill()
|
|
}
|
|
}
|
|
return driverClient, cleanup, nil
|
|
}
|
|
|
|
func pickFreePort() (int, error) {
|
|
listener, err := net.Listen("tcp", "127.0.0.1:0")
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
defer listener.Close()
|
|
return listener.Addr().(*net.TCPAddr).Port, nil
|
|
}
|