diff --git a/cmd/internal-tools/bundle-check/main.go b/cmd/internal-tools/bundle-check/main.go index 5566ea8..17c0c81 100644 --- a/cmd/internal-tools/bundle-check/main.go +++ b/cmd/internal-tools/bundle-check/main.go @@ -17,11 +17,7 @@ func main() { specApiPath := filepath.Join(repoRoot, "pkg/spec-api/src/index.ts") result, err := bundler.Bundle(bundler.Options{ - EntryFile: "examples/specs/merchant-ledger.ts", - Defines: map[string]string{ - "UATU_TEST_PHONE": "+910000000000", - "UATU_TEST_OTP": "000000", - }, + EntryFile: "examples/sample-app/spec.ts", Aliases: map[string]string{ "@uatu/spec": specApiPath, }, diff --git a/examples/sample-app/spec.ts b/examples/sample-app/spec.ts new file mode 100644 index 0000000..4db2432 --- /dev/null +++ b/examples/sample-app/spec.ts @@ -0,0 +1,45 @@ +import { + extract, + always, + actions, + weighted, + Tap, + taps, + swipes, +} from "@uatu/spec"; + +// ── Snapshot extractors (fed by SampleApplication.kt) ────────── +// See ./android/src/main/kotlin/dev/uatu/sample/SampleApplication.kt +const appState = extract( + (state) => (state.snapshots.app_state as string) ?? "", +); +const clickCount = extract( + (state) => (state.snapshots.click_count as number) ?? 0, +); + +// ── UI elements ──────────────────────────────────────────────── +const clickButton = extract((state) => state.ax.find("text:Click me")); + +// ── Properties ───────────────────────────────────────────────── +export const properties = { + appIsRunning: always(() => appState.current === "running"), + clickCountNonNegative: always(() => clickCount.current >= 0), + clickCountNeverDecreases: always(() => { + const previous = clickCount.previous; + return previous === undefined || clickCount.current >= previous; + }), +}; + +// ── Actions ──────────────────────────────────────────────────── +const tapClickMe = actions(() => { + return clickButton.current ? [Tap({ on: clickButton.current })] : []; +}); + +export const actionsRoot = weighted( + [100, tapClickMe], + [10, taps], + [2, swipes], +); + +(globalThis as { actions?: unknown; properties?: unknown }).actions = actionsRoot; +(globalThis as { properties?: unknown }).properties = properties; diff --git a/internal/trace/writer_test.go b/internal/trace/writer_test.go index 709dd4e..fad1ccb 100644 --- a/internal/trace/writer_test.go +++ b/internal/trace/writer_test.go @@ -20,7 +20,7 @@ func TestWriteMeta_RoundTrip(t *testing.T) { meta := Meta{ Seed: 42, - SpecPath: "examples/specs/merchant-ledger.ts", + SpecPath: "examples/sample-app/spec.ts", BundleSHA256: "deadbeef", Platform: "android", BundleID: "in.okcredit.merchant",