mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
* proto(driver): drop launcher_activity from LaunchRequest * refactor(driver): rename Driver to DeviceDriver, drop launcherActivity from Launch * refactor(driver): rename package maestro to sidecar * feat(driver): add ChromeDriver backed by chromedp * feat(hierarchy): replace XML parser with TreeNode JSON parser * refactor(driver): update mock and runner to DeviceDriver, drop launcherActivity * feat(runner): add platform routing for web vs sidecar * test(verifier): update hierarchy fixtures from XML to TreeNode JSON * feat(sidecar): extract readLogcat/readProcMetrics; add MaestroDriverBackend - Extract readLogcat() and readProcMetrics() as internal package-level helpers parameterised by serial - Add MaestroDriverBackend wiring maestro-client AndroidDriver - Drop launcherActivity from DriverBackend interface and StubDriverBackend - Add maestro-utils and micrometer-core as explicit compile deps * refactor(sidecar): inject DriverBackend into DriverService; drop launcherActivity - Remove serial and default backend from DriverService constructor - Make backend a required parameter - Drop launcherActivity from launch RPC handler - Create MaestroDriverBackend in Main.kt when platform is android * test(sidecar): update tests for dropped launcherActivity and required backend * chore(sidecar): remove unnecessary micrometer-core direct dependency
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package verifier
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/priyanshujain/sanderling/internal/hierarchy"
|
|
)
|
|
|
|
// TestStateAxFindWorks verifies that a Parse+PushSnapshot+extract round trip
|
|
// actually lets the spec resolve selectors through state.ax.find.
|
|
// Reads /tmp/live-dump.json (Maestro TreeNode JSON format); skipped if absent.
|
|
func TestStateAxFindWorks(t *testing.T) {
|
|
jsonText, err := os.ReadFile("/tmp/live-dump.json")
|
|
if err != nil {
|
|
t.Skip("live-dump.json not present")
|
|
}
|
|
tree, err := hierarchy.Parse(string(jsonText))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if tree.Find("id:select_language") == nil {
|
|
t.Fatal("Go-side parser should find id:select_language")
|
|
}
|
|
|
|
verifier := newVerifier(t)
|
|
mustLoad(t, verifier, `
|
|
globalThis.probe = __sanderling__.extract(state => {
|
|
const element = state.ax.find("id:select_language");
|
|
return element ? "matched:" + element.text : "miss";
|
|
});
|
|
globalThis.count = __sanderling__.extract(state => state.ax.findAll("id:select_language").length);
|
|
`)
|
|
|
|
if err := verifier.PushSnapshot(SnapshotInput{Snapshots: Snapshots{}, Tree: tree}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
probe := verifier.runtime.GlobalObject().Get("probe").ToObject(verifier.runtime).Get("current").String()
|
|
if probe == "miss" {
|
|
t.Fatalf("state.ax.find returned undefined; got %q", probe)
|
|
}
|
|
t.Logf("probe returned %q", probe)
|
|
|
|
count := verifier.runtime.GlobalObject().Get("count").ToObject(verifier.runtime).Get("current").ToInteger()
|
|
if count != 1 {
|
|
t.Fatalf("findAll count = %d, want 1", count)
|
|
}
|
|
}
|