mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
* refactor: rename examples/sample-app to examples/folio Directory-level rename and path references in Go tests, bundle-check, top-level README, and getting-started docs. Package declarations, Gradle config, iOS bundle IDs, and class names follow in later commits. * refactor(folio): rename Kotlin package dev.uatu.sample to app.folio Moves source dirs and sqldelight schema from dev/uatu/sample to app/folio, updates package declarations and imports, and switches Android namespace/applicationId, iOS binaryOption bundleId, and sqldelight database packageName to the new identifier. * refactor(folio): rename SampleApplication to FolioApplication Android manifest now points at .FolioApplication with label 'Folio' instead of 'Uatu Sample'. * refactor(folio): set iOS bundle id and display name to Folio bundleIdPrefix + PRODUCT_BUNDLE_IDENTIFIER -> app.folio. CFBundleName + CFBundleDisplayName -> 'Folio'. * refactor(folio): update demo email to [email protected] * refactor(folio): point justfile at app.folio bundle id Updates xcrun simctl launch target, uatu test --bundle-id, and the build/uninstall comments to reference folio instead of sample. * test: update fixture package ids to app.folio Sidecar activity-resolver test and verifier spec-integration XML fixtures referenced the old dev.uatu.sample Android package. Updates them to match the folio app's real package id so the tests stay representative of what the CLI sees on-device. * test(verifier): rename SampleApp identifiers to Folio Renames TestSampleAppSpec* functions, bundleSampleAppSpec helper, and sampleAppHierarchyXML const (now loginHierarchyXML for consistency with the other per-screen fixtures). Updates trailing sample-app mentions in comments and assertion messages. * refactor(folio): rename Gradle/npm/wasm project identifiers to folio settings.gradle.kts rootProject.name, package.json + package-lock.json name, and the WasmJS index.html <title> all still read 'uatu-sample' / 'Uatu Sample'. Realigns them with the Folio brand. * docs(folio): rewrite README title + getting-started bundle id examples/folio/README.md is now titled 'Folio' with the Kotlin source paths corrected to app/folio. Getting-started example uses --bundle-id app.folio. Harness launch message is now generic ('app under test') since uatu-sample-harness is not specific to folio. * chore(folio): drop trailing 'sample' reference in gradle.properties * refactor(folio): rename LoginPage composable to LoginScreen Align with KMP/Android industry convention (NowInAndroid, Cash App, JetBrains samples use Screen, not Page). * refactor(folio): rename HomePage composable to HomeScreen * refactor(folio): rename AddAccountPage composable to AddAccountScreen * refactor(folio): rename LedgerPage composable to LedgerScreen * refactor(folio): rename AddTransactionPage composable to AddTransactionScreen * refactor(folio): split Models.kt into app.folio.data package Account, Transaction (with TxnType), and Session move into their own files under app.folio.data, matching NowInAndroid-style per-type organization. * refactor(folio): move data layer into app.folio.data package Repository, LedgerStore (expect + interface), SqlLedgerStore, WebLedgerStore, DriverFactory (expect + actuals), AndroidLedgerContext, and Snapshot move into app.folio.data. Update all consumer imports. * refactor(folio): move Navigation into app.folio.navigation package Split the former Navigation.kt into Route.kt (sealed interface) and Navigator.kt (singleton). Update consumer imports across screens, App.kt, and FolioApplication. * refactor(folio): move Platform and Format into app.folio.platform Both files carry expect declarations (Platform object, formatDate); grouping them into a dedicated platform package makes the KMP seam obvious and mirrors the structure used by JetBrains samples. * refactor(folio): move login into feature/auth package Create app.folio.feature.auth with LoginScreen + LoginUiState. Inline the former Auth.kt (DEMO_EMAIL, DEMO_PASSWORD, checkCredentials) into LoginScreen since it is the sole caller. * refactor(folio): move HomeScreen into feature/home package * refactor(folio): move account creation into feature/account package AddAccountScreen gets its own AddAccountUiState colocated with the screen, replacing the shared UiState.addAccountError. * refactor(folio): move ledger screens into feature/ledger package LedgerScreen and AddTransactionScreen move into app.folio.feature.ledger with AddTransactionUiState (txnError, txnFormType) colocated. The former catch-all UiState.kt is removed now that each screen owns its state alongside its UI. * refactor(folio): split Theme.kt; move theme and icons to subpackages Theme split into Theme.kt (tokens, layout dims, LedgerTheme) and Type.kt (typography) under app.folio.ui.theme. Icons moves to app.folio.ui.icon. Update every consumer's imports to match. * refactor(folio): split ui components into per-file under ui/component Former Widgets.kt and Components.kt become 10 focused files: AppButton, Card, EmptyState, ErrorText, FieldLabel, Header, IconButton (w/ BackButton), Screen, Segmented, TextInput. Matches NowInAndroid style of one composable per file in a designsystem/component package. * chore(folio): consolidate uatu testing files under uatu/ folder Move spec.ts, package.json, package-lock.json into examples/folio/uatu so all uatu-specific testing artifacts live in one place. runs/ and node_modules/ follow the same convention (both remain gitignored). Update justfile, README, and the two Go consumers (bundle-check tool + verifier/trace tests) that referenced the old path. * refactor(trace): drop folio path in writer test Round-trip only needs a non-empty string; neutralize to keep the library free of folio references. * refactor(sidecar): neutralize ResolveActivity test fixtures Swap app.folio for com.example.app in the fixture strings so the sidecar tests don't reference the example app by name. * refactor(bundle-check): take spec path as argument Previously the tool hardcoded examples/folio/uatu/spec.ts. Accept a positional spec path instead so the tool works for any example and leaves no folio reference in the library surface. * test(verifier): add neutral integration spec and hierarchy fixtures Adds testdata/integration_spec.ts with two routes ("list", "form"), an InputText on text_field, a Tap on primary/secondary_action, a safety property (itemCountNonNegative), and a liveness property (submitEventually). Adds hierarchies_test.go with matching XML fixtures. Constants intentionally go in a _test.go at package root rather than testdata/hierarchies.go because go skips .go files under testdata/. * refactor(verifier): replace folio integration tests with neutral ones Renames bundleFolioSpec -> bundleIntegrationSpec and the three Test* entry points to TestIntegrationSpec*. Uses the synthetic spec and hierarchies added in the previous commit so the library's test suite no longer references examples/folio at all. Folio-specific coverage remains covered by examples/folio/justfile's 'just test' which exercises the real spec on device/emulator. * chore: remove cmd/uatu-sample-harness Not referenced by Makefile, docs, CI, or any script. Duplicates the adb reverse helpers already in cmd/uatu/test_run.go, and its name implies ownership by the sample app which violates the library/ example decoupling. If a bare-protocol debugging tool is later needed it belongs inside cmd/uatu/. * docs(folio): drop Layout section and KMP layout paragraph; fix AVD override syntax The directory-tree Layout section rots faster than the code and duplicates what ls shows for free. The expect/actual paragraph in Stack was the same kind of filler. The README also claimed 'just AVD=Pixel_7 test' but the justfile reads AVD as an env var via env_var_or_default, so the correct invocation is 'AVD=Pixel_7 just test'.
204 lines
5.7 KiB
Go
204 lines
5.7 KiB
Go
package verifier
|
|
|
|
import (
|
|
"encoding/json"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/priyanshujain/uatu/internal/bundler"
|
|
"github.com/priyanshujain/uatu/internal/hierarchy"
|
|
"github.com/priyanshujain/uatu/internal/ltl"
|
|
)
|
|
|
|
// bundleIntegrationSpec bundles testdata/integration_spec.ts via the real
|
|
// @uatu/spec API so the integration test exercises the same path the CLI
|
|
// uses, with no reference to any specific example app.
|
|
func bundleIntegrationSpec(t *testing.T) string {
|
|
t.Helper()
|
|
specPath, err := filepath.Abs("testdata/integration_spec.ts")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
apiPath, err := filepath.Abs("../../pkg/spec-api/src/index.ts")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defaultsPath, err := filepath.Abs("../../pkg/spec-api/src/defaults/properties.ts")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
bundle, err := bundler.Bundle(bundler.Options{
|
|
EntryFile: specPath,
|
|
Aliases: map[string]string{
|
|
"@uatu/spec": apiPath,
|
|
"@uatu/spec/defaults/properties": defaultsPath,
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return string(bundle.JavaScript)
|
|
}
|
|
|
|
func listSnapshots() Snapshots {
|
|
return Snapshots{
|
|
"route": json.RawMessage(`"list"`),
|
|
"item_count": json.RawMessage(`0`),
|
|
"has_submitted": json.RawMessage(`false`),
|
|
}
|
|
}
|
|
|
|
func formSnapshots() Snapshots {
|
|
return Snapshots{
|
|
"route": json.RawMessage(`"form"`),
|
|
"item_count": json.RawMessage(`0`),
|
|
"has_submitted": json.RawMessage(`false`),
|
|
}
|
|
}
|
|
|
|
// TestIntegrationSpecFiresInputActions verifies the bundled neutral spec
|
|
// emits an InputText action on the text field and a Tap action on the
|
|
// primary button when both are present in the hierarchy.
|
|
func TestIntegrationSpecFiresInputActions(t *testing.T) {
|
|
v := newVerifier(t)
|
|
if err := v.Load(bundleIntegrationSpec(t)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
tree, err := hierarchy.Parse(formHierarchyXML)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := v.PushSnapshot(SnapshotInput{Snapshots: formSnapshots(), Tree: tree}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
typeFieldHits := 0
|
|
tapPrimaryHits := 0
|
|
for range 400 {
|
|
action, err := v.NextAction()
|
|
if err != nil {
|
|
continue
|
|
}
|
|
switch {
|
|
case action.Kind == ActionKindInputText && action.On == "desc:text_field":
|
|
typeFieldHits++
|
|
case action.Kind == ActionKindTap && action.On == "desc:primary_action":
|
|
tapPrimaryHits++
|
|
}
|
|
}
|
|
if typeFieldHits == 0 {
|
|
t.Fatal("typeIntoField never typed into desc:text_field on form hierarchy")
|
|
}
|
|
if tapPrimaryHits == 0 {
|
|
t.Fatal("tapPrimary never tapped desc:primary_action on form hierarchy")
|
|
}
|
|
}
|
|
|
|
// TestIntegrationSpecPropertiesEvaluate checks the properties declared in
|
|
// the neutral spec evaluate sensibly across a small snapshot sequence. The
|
|
// spec mixes safety and liveness properties; Pending verdicts are expected
|
|
// for liveness properties that haven't had time to resolve yet.
|
|
func TestIntegrationSpecPropertiesEvaluate(t *testing.T) {
|
|
v := newVerifier(t)
|
|
if err := v.Load(bundleIntegrationSpec(t)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
tree, err := hierarchy.Parse(listHierarchyXML)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := v.PushSnapshot(SnapshotInput{Snapshots: listSnapshots(), Tree: tree}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
verdicts := v.EvaluateProperties()
|
|
if verdicts["itemCountNonNegative"] != ltl.VerdictHolds {
|
|
t.Errorf("itemCountNonNegative: got %v, want holds", verdicts["itemCountNonNegative"])
|
|
}
|
|
if verdicts["routeIsKnown"] != ltl.VerdictHolds {
|
|
t.Errorf("routeIsKnown: got %v, want holds", verdicts["routeIsKnown"])
|
|
}
|
|
if verdicts["noUncaughtExceptions"] != ltl.VerdictHolds {
|
|
t.Errorf("noUncaughtExceptions: got %v, want holds", verdicts["noUncaughtExceptions"])
|
|
}
|
|
// Liveness: submitEventually hasn't resolved yet.
|
|
if verdicts["submitEventually"] != ltl.VerdictPending {
|
|
t.Errorf("submitEventually: got %v, want pending", verdicts["submitEventually"])
|
|
}
|
|
}
|
|
|
|
// TestIntegrationSpecActionsFireOnEachRoute pushes a hierarchy + snapshot
|
|
// pair representative of each route and verifies the expected action
|
|
// generators fire against that state.
|
|
func TestIntegrationSpecActionsFireOnEachRoute(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
xml string
|
|
snapshots Snapshots
|
|
expectKind ActionKind
|
|
expectOns []string
|
|
}{
|
|
{
|
|
name: "list",
|
|
xml: listHierarchyXML,
|
|
snapshots: listSnapshots(),
|
|
expectKind: ActionKindTap,
|
|
expectOns: []string{"desc:primary_action", "desc:secondary_action"},
|
|
},
|
|
{
|
|
name: "form",
|
|
xml: formHierarchyXML,
|
|
snapshots: formSnapshots(),
|
|
expectKind: ActionKindTap,
|
|
expectOns: []string{"desc:primary_action", "desc:secondary_action"},
|
|
},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
v := newVerifier(t)
|
|
if err := v.Load(bundleIntegrationSpec(t)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
tree, err := hierarchy.Parse(tc.xml)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := v.PushSnapshot(SnapshotInput{Snapshots: tc.snapshots, Tree: tree}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
sawOn := map[string]bool{}
|
|
sawInputText := map[string]bool{}
|
|
for range 800 {
|
|
action, err := v.NextAction()
|
|
if err != nil {
|
|
continue
|
|
}
|
|
if action.Kind == tc.expectKind {
|
|
sawOn[action.On] = true
|
|
}
|
|
if action.Kind == ActionKindInputText {
|
|
sawInputText[action.On] = true
|
|
}
|
|
}
|
|
for _, on := range tc.expectOns {
|
|
if !sawOn[on] {
|
|
t.Errorf("%s: no %s action on %q; saw %v", tc.name, tc.expectKind, on, keysOf(sawOn))
|
|
}
|
|
}
|
|
if tc.name == "form" && !sawInputText["desc:text_field"] {
|
|
t.Errorf("form: typeIntoField never fired; saw %v", keysOf(sawInputText))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func keysOf(m map[string]bool) []string {
|
|
out := make([]string, 0, len(m))
|
|
for k := range m {
|
|
out = append(out, k)
|
|
}
|
|
return out
|
|
}
|