@solidxai/core 0.1.22-beta.1 → 0.1.22-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/controllers/module-package.controller.d.ts +198 -0
- package/dist/controllers/module-package.controller.d.ts.map +1 -1
- package/dist/controllers/test-run.controller.d.ts +5 -0
- package/dist/controllers/test-run.controller.d.ts.map +1 -1
- package/dist/controllers/test-run.controller.js +17 -0
- package/dist/controllers/test-run.controller.js.map +1 -1
- package/dist/dtos/confirm-module-package-import.dto.d.ts +2 -0
- package/dist/dtos/confirm-module-package-import.dto.d.ts.map +1 -1
- package/dist/dtos/confirm-module-package-import.dto.js +21 -1
- package/dist/dtos/confirm-module-package-import.dto.js.map +1 -1
- package/dist/dtos/create-field-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-field-metadata.dto.js +3 -3
- package/dist/dtos/create-field-metadata.dto.js.map +1 -1
- package/dist/dtos/create-model-metadata.dto.d.ts +6 -6
- package/dist/dtos/create-model-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-model-metadata.dto.js +13 -7
- package/dist/dtos/create-model-metadata.dto.js.map +1 -1
- package/dist/dtos/test-run-request.dto.d.ts +12 -1
- package/dist/dtos/test-run-request.dto.d.ts.map +1 -1
- package/dist/dtos/test-run-request.dto.js +16 -1
- package/dist/dtos/test-run-request.dto.js.map +1 -1
- package/dist/helpers/module-package-sync.helper.d.ts +71 -0
- package/dist/helpers/module-package-sync.helper.d.ts.map +1 -0
- package/dist/helpers/module-package-sync.helper.js +318 -0
- package/dist/helpers/module-package-sync.helper.js.map +1 -0
- package/dist/helpers/module-package-sync.helper.spec.d.ts +2 -0
- package/dist/helpers/module-package-sync.helper.spec.d.ts.map +1 -0
- package/dist/helpers/module-package-sync.helper.spec.js +229 -0
- package/dist/helpers/module-package-sync.helper.spec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.d.ts +3 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js +19 -6
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +9 -0
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +138 -0
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +0 -47
- package/dist/services/module-package.service.d.ts +38 -0
- package/dist/services/module-package.service.d.ts.map +1 -1
- package/dist/services/module-package.service.js +314 -33
- package/dist/services/module-package.service.js.map +1 -1
- package/dist/services/module-package.service.spec.d.ts +2 -0
- package/dist/services/module-package.service.spec.d.ts.map +1 -0
- package/dist/services/module-package.service.spec.js +347 -0
- package/dist/services/module-package.service.spec.js.map +1 -0
- package/dist/services/view-metadata.service.d.ts.map +1 -1
- package/dist/services/view-metadata.service.js +5 -4
- package/dist/services/view-metadata.service.js.map +1 -1
- package/dist/testing/__integration__/mobile-emulator.integration.d.ts +2 -0
- package/dist/testing/__integration__/mobile-emulator.integration.d.ts.map +1 -0
- package/dist/testing/__integration__/mobile-emulator.integration.js +368 -0
- package/dist/testing/__integration__/mobile-emulator.integration.js.map +1 -0
- package/dist/testing/adapters/mobile/capabilities.d.ts +4 -0
- package/dist/testing/adapters/mobile/capabilities.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/capabilities.js +85 -0
- package/dist/testing/adapters/mobile/capabilities.js.map +1 -0
- package/dist/testing/adapters/mobile/capabilities.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/capabilities.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/capabilities.spec.js +215 -0
- package/dist/testing/adapters/mobile/capabilities.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/fake-driver.d.ts +113 -0
- package/dist/testing/adapters/mobile/fake-driver.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/fake-driver.js +122 -0
- package/dist/testing/adapters/mobile/fake-driver.js.map +1 -0
- package/dist/testing/adapters/mobile/ios-keyboard.d.ts +31 -0
- package/dist/testing/adapters/mobile/ios-keyboard.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/ios-keyboard.js +157 -0
- package/dist/testing/adapters/mobile/ios-keyboard.js.map +1 -0
- package/dist/testing/adapters/mobile/ios-keyboard.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/ios-keyboard.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/ios-keyboard.spec.js +36 -0
- package/dist/testing/adapters/mobile/ios-keyboard.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/locator.d.ts +12 -0
- package/dist/testing/adapters/mobile/locator.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/locator.js +96 -0
- package/dist/testing/adapters/mobile/locator.js.map +1 -0
- package/dist/testing/adapters/mobile/locator.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/locator.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/locator.spec.js +136 -0
- package/dist/testing/adapters/mobile/locator.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/logcat.d.ts +9 -0
- package/dist/testing/adapters/mobile/logcat.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/logcat.js +28 -0
- package/dist/testing/adapters/mobile/logcat.js.map +1 -0
- package/dist/testing/adapters/mobile/logcat.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/logcat.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/logcat.spec.js +46 -0
- package/dist/testing/adapters/mobile/logcat.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/mobile-adapter.d.ts +67 -0
- package/dist/testing/adapters/mobile/mobile-adapter.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/mobile-adapter.ios.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/mobile-adapter.ios.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/mobile-adapter.ios.spec.js +240 -0
- package/dist/testing/adapters/mobile/mobile-adapter.ios.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/mobile-adapter.js +494 -0
- package/dist/testing/adapters/mobile/mobile-adapter.js.map +1 -0
- package/dist/testing/adapters/mobile/mobile-adapter.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/mobile-adapter.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/mobile-adapter.spec.js +567 -0
- package/dist/testing/adapters/mobile/mobile-adapter.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/mobile.types.d.ts +111 -0
- package/dist/testing/adapters/mobile/mobile.types.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/mobile.types.js +3 -0
- package/dist/testing/adapters/mobile/mobile.types.js.map +1 -0
- package/dist/testing/adapters/mobile/phone-errors.d.ts +6 -0
- package/dist/testing/adapters/mobile/phone-errors.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/phone-errors.js +43 -0
- package/dist/testing/adapters/mobile/phone-errors.js.map +1 -0
- package/dist/testing/adapters/mobile/platform.d.ts +7 -0
- package/dist/testing/adapters/mobile/platform.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/platform.js +11 -0
- package/dist/testing/adapters/mobile/platform.js.map +1 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.d.ts +6 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.js +95 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.js.map +1 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.spec.js +199 -0
- package/dist/testing/adapters/mobile/resolve-mobile-target.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/run-options.d.ts +11 -0
- package/dist/testing/adapters/mobile/run-options.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/run-options.js +41 -0
- package/dist/testing/adapters/mobile/run-options.js.map +1 -0
- package/dist/testing/adapters/mobile/run-options.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/run-options.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/run-options.spec.js +100 -0
- package/dist/testing/adapters/mobile/run-options.spec.js.map +1 -0
- package/dist/testing/adapters/mobile/syslog.d.ts +9 -0
- package/dist/testing/adapters/mobile/syslog.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/syslog.js +45 -0
- package/dist/testing/adapters/mobile/syslog.js.map +1 -0
- package/dist/testing/adapters/mobile/syslog.spec.d.ts +2 -0
- package/dist/testing/adapters/mobile/syslog.spec.d.ts.map +1 -0
- package/dist/testing/adapters/mobile/syslog.spec.js +81 -0
- package/dist/testing/adapters/mobile/syslog.spec.js.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +24 -3
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.js +113 -14
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
- package/dist/testing/adapters/ui/resolve-target.d.ts +12 -0
- package/dist/testing/adapters/ui/resolve-target.d.ts.map +1 -0
- package/dist/testing/adapters/ui/resolve-target.js +95 -0
- package/dist/testing/adapters/ui/resolve-target.js.map +1 -0
- package/dist/testing/adapters/ui/ui.types.d.ts +12 -0
- package/dist/testing/adapters/ui/ui.types.d.ts.map +1 -1
- package/dist/testing/adapters/ui/ui.types.js.map +1 -1
- package/dist/testing/contracts/runtime-context.types.d.ts +14 -0
- package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -1
- package/dist/testing/contracts/runtime-context.types.js.map +1 -1
- package/dist/testing/contracts/testing-metadata.types.d.ts +28 -1
- package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -1
- package/dist/testing/contracts/testing-metadata.types.js.map +1 -1
- package/dist/testing/core/step-registry.d.ts +1 -0
- package/dist/testing/core/step-registry.d.ts.map +1 -1
- package/dist/testing/core/step-registry.js +3 -0
- package/dist/testing/core/step-registry.js.map +1 -1
- package/dist/testing/core/testing-engine.d.ts +16 -4
- package/dist/testing/core/testing-engine.d.ts.map +1 -1
- package/dist/testing/core/testing-engine.js +109 -33
- package/dist/testing/core/testing-engine.js.map +1 -1
- package/dist/testing/reporter/console-reporter.d.ts +7 -13
- package/dist/testing/reporter/console-reporter.d.ts.map +1 -1
- package/dist/testing/reporter/console-reporter.js +15 -1
- package/dist/testing/reporter/console-reporter.js.map +1 -1
- package/dist/testing/reporter/file-service-artifact-sink.d.ts +2 -0
- package/dist/testing/reporter/file-service-artifact-sink.d.ts.map +1 -1
- package/dist/testing/reporter/file-service-artifact-sink.js +2 -1
- package/dist/testing/reporter/file-service-artifact-sink.js.map +1 -1
- package/dist/testing/reporter/lifecycle-events.types.d.ts +11 -0
- package/dist/testing/reporter/lifecycle-events.types.d.ts.map +1 -1
- package/dist/testing/reporter/lifecycle-events.types.js.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts +7 -5
- package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.js +25 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.js.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.spec.d.ts +2 -0
- package/dist/testing/reporter/lifecycle-webhook-reporter.spec.d.ts.map +1 -0
- package/dist/testing/reporter/lifecycle-webhook-reporter.spec.js +72 -0
- package/dist/testing/reporter/lifecycle-webhook-reporter.spec.js.map +1 -0
- package/dist/testing/reporter/progress-reporter.d.ts +4 -13
- package/dist/testing/reporter/progress-reporter.d.ts.map +1 -1
- package/dist/testing/reporter/progress-reporter.js +5 -1
- package/dist/testing/reporter/progress-reporter.js.map +1 -1
- package/dist/testing/reporter/reporter.types.d.ts +27 -13
- package/dist/testing/reporter/reporter.types.d.ts.map +1 -1
- package/dist/testing/reporter/reporter.types.js.map +1 -1
- package/dist/testing/runner/lifecycle.d.ts +8 -0
- package/dist/testing/runner/lifecycle.d.ts.map +1 -1
- package/dist/testing/runner/lifecycle.js +80 -0
- package/dist/testing/runner/lifecycle.js.map +1 -1
- package/dist/testing/runner/lifecycle.spec.d.ts +2 -0
- package/dist/testing/runner/lifecycle.spec.d.ts.map +1 -0
- package/dist/testing/runner/lifecycle.spec.js +33 -0
- package/dist/testing/runner/lifecycle.spec.js.map +1 -0
- package/dist/testing/runner/mobile-session.d.ts +24 -0
- package/dist/testing/runner/mobile-session.d.ts.map +1 -0
- package/dist/testing/runner/mobile-session.js +96 -0
- package/dist/testing/runner/mobile-session.js.map +1 -0
- package/dist/testing/runner/mobile-session.spec.d.ts +2 -0
- package/dist/testing/runner/mobile-session.spec.d.ts.map +1 -0
- package/dist/testing/runner/mobile-session.spec.js +89 -0
- package/dist/testing/runner/mobile-session.spec.js.map +1 -0
- package/dist/testing/runner/recording-reporter.d.ts +62 -0
- package/dist/testing/runner/recording-reporter.d.ts.map +1 -0
- package/dist/testing/runner/recording-reporter.js +35 -0
- package/dist/testing/runner/recording-reporter.js.map +1 -0
- package/dist/testing/runner/run-cancellation.d.ts +7 -0
- package/dist/testing/runner/run-cancellation.d.ts.map +1 -0
- package/dist/testing/runner/run-cancellation.js +30 -0
- package/dist/testing/runner/run-cancellation.js.map +1 -0
- package/dist/testing/runner/run-from-metadata.cancel.spec.d.ts +2 -0
- package/dist/testing/runner/run-from-metadata.cancel.spec.d.ts.map +1 -0
- package/dist/testing/runner/run-from-metadata.cancel.spec.js +58 -0
- package/dist/testing/runner/run-from-metadata.cancel.spec.js.map +1 -0
- package/dist/testing/runner/run-from-metadata.d.ts +4 -0
- package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
- package/dist/testing/runner/run-from-metadata.js +152 -25
- package/dist/testing/runner/run-from-metadata.js.map +1 -1
- package/dist/testing/runner/run-from-metadata.mobile.spec.d.ts +2 -0
- package/dist/testing/runner/run-from-metadata.mobile.spec.d.ts.map +1 -0
- package/dist/testing/runner/run-from-metadata.mobile.spec.js +498 -0
- package/dist/testing/runner/run-from-metadata.mobile.spec.js.map +1 -0
- package/dist/testing/runner/run-from-metadata.spec.js +188 -0
- package/dist/testing/runner/run-from-metadata.spec.js.map +1 -1
- package/dist/testing/runner/scenario-graph.d.ts +8 -0
- package/dist/testing/runner/scenario-graph.d.ts.map +1 -0
- package/dist/testing/runner/scenario-graph.js +120 -0
- package/dist/testing/runner/scenario-graph.js.map +1 -0
- package/dist/testing/runner/scenario-graph.spec.d.ts +2 -0
- package/dist/testing/runner/scenario-graph.spec.d.ts.map +1 -0
- package/dist/testing/runner/scenario-graph.spec.js +97 -0
- package/dist/testing/runner/scenario-graph.spec.js.map +1 -0
- package/dist/testing/runtime/default-registry.d.ts +3 -0
- package/dist/testing/runtime/default-registry.d.ts.map +1 -0
- package/dist/testing/runtime/default-registry.js +21 -0
- package/dist/testing/runtime/default-registry.js.map +1 -0
- package/dist/testing/runtime/index.d.ts +22 -0
- package/dist/testing/runtime/index.d.ts.map +1 -0
- package/dist/testing/runtime/index.js +63 -0
- package/dist/testing/runtime/index.js.map +1 -0
- package/dist/testing/runtime/mobile-step-executor.spec.d.ts +2 -0
- package/dist/testing/runtime/mobile-step-executor.spec.d.ts.map +1 -0
- package/dist/testing/runtime/mobile-step-executor.spec.js +157 -0
- package/dist/testing/runtime/mobile-step-executor.spec.js.map +1 -0
- package/dist/testing/runtime/step-executor.d.ts +92 -0
- package/dist/testing/runtime/step-executor.d.ts.map +1 -0
- package/dist/testing/runtime/step-executor.js +171 -0
- package/dist/testing/runtime/step-executor.js.map +1 -0
- package/dist/testing/runtime/step-executor.spec.d.ts +2 -0
- package/dist/testing/runtime/step-executor.spec.d.ts.map +1 -0
- package/dist/testing/runtime/step-executor.spec.js +137 -0
- package/dist/testing/runtime/step-executor.spec.js.map +1 -0
- package/dist/testing/steps/mobile/actions.step.d.ts +3 -0
- package/dist/testing/steps/mobile/actions.step.d.ts.map +1 -0
- package/dist/testing/steps/mobile/actions.step.js +151 -0
- package/dist/testing/steps/mobile/actions.step.js.map +1 -0
- package/dist/testing/steps/mobile/app.step.d.ts +3 -0
- package/dist/testing/steps/mobile/app.step.d.ts.map +1 -0
- package/dist/testing/steps/mobile/app.step.js +20 -0
- package/dist/testing/steps/mobile/app.step.js.map +1 -0
- package/dist/testing/steps/mobile/assertions.step.d.ts +3 -0
- package/dist/testing/steps/mobile/assertions.step.d.ts.map +1 -0
- package/dist/testing/steps/mobile/assertions.step.js +55 -0
- package/dist/testing/steps/mobile/assertions.step.js.map +1 -0
- package/dist/testing/steps/mobile/gestures.step.d.ts +3 -0
- package/dist/testing/steps/mobile/gestures.step.d.ts.map +1 -0
- package/dist/testing/steps/mobile/gestures.step.js +85 -0
- package/dist/testing/steps/mobile/gestures.step.js.map +1 -0
- package/dist/testing/steps/mobile/index.d.ts +3 -0
- package/dist/testing/steps/mobile/index.d.ts.map +1 -0
- package/dist/testing/steps/mobile/index.js +14 -0
- package/dist/testing/steps/mobile/index.js.map +1 -0
- package/dist/testing/steps/mobile/mobile-steps.ios.spec.d.ts +2 -0
- package/dist/testing/steps/mobile/mobile-steps.ios.spec.d.ts.map +1 -0
- package/dist/testing/steps/mobile/mobile-steps.ios.spec.js +315 -0
- package/dist/testing/steps/mobile/mobile-steps.ios.spec.js.map +1 -0
- package/dist/testing/steps/mobile/mobile-steps.spec.d.ts +2 -0
- package/dist/testing/steps/mobile/mobile-steps.spec.d.ts.map +1 -0
- package/dist/testing/steps/mobile/mobile-steps.spec.js +338 -0
- package/dist/testing/steps/mobile/mobile-steps.spec.js.map +1 -0
- package/dist/testing/steps/mobile/shared.d.ts +13 -0
- package/dist/testing/steps/mobile/shared.d.ts.map +1 -0
- package/dist/testing/steps/mobile/shared.js +41 -0
- package/dist/testing/steps/mobile/shared.js.map +1 -0
- package/dist/testing/steps/mobile/swipe-line.d.ts +14 -0
- package/dist/testing/steps/mobile/swipe-line.d.ts.map +1 -0
- package/dist/testing/steps/mobile/swipe-line.js +20 -0
- package/dist/testing/steps/mobile/swipe-line.js.map +1 -0
- package/dist/testing/steps/mobile/swipe-line.spec.d.ts +2 -0
- package/dist/testing/steps/mobile/swipe-line.spec.d.ts.map +1 -0
- package/dist/testing/steps/mobile/swipe-line.spec.js +25 -0
- package/dist/testing/steps/mobile/swipe-line.spec.js.map +1 -0
- package/dist/testing/steps/ui/actions.step.d.ts.map +1 -1
- package/dist/testing/steps/ui/actions.step.js +8 -5
- package/dist/testing/steps/ui/actions.step.js.map +1 -1
- package/dist/testing/steps/ui/aria-snapshot.step.d.ts +3 -0
- package/dist/testing/steps/ui/aria-snapshot.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/aria-snapshot.step.js +70 -0
- package/dist/testing/steps/ui/aria-snapshot.step.js.map +1 -0
- package/dist/testing/steps/ui/assertions.step.d.ts.map +1 -1
- package/dist/testing/steps/ui/assertions.step.js +5 -2
- package/dist/testing/steps/ui/assertions.step.js.map +1 -1
- package/dist/testing/steps/ui/form.step.d.ts.map +1 -1
- package/dist/testing/steps/ui/form.step.js +7 -3
- package/dist/testing/steps/ui/form.step.js.map +1 -1
- package/dist/testing/steps/ui/index.d.ts.map +1 -1
- package/dist/testing/steps/ui/index.js +2 -0
- package/dist/testing/steps/ui/index.js.map +1 -1
- package/package.json +15 -5
- package/src/controllers/test-run.controller.ts +17 -1
- package/src/dtos/confirm-module-package-import.dto.ts +16 -0
- package/src/dtos/create-field-metadata.dto.ts +4 -3
- package/src/dtos/create-model-metadata.dto.ts +19 -13
- package/src/dtos/test-run-request.dto.ts +18 -0
- package/src/entities/media-migration-plan.md +20 -0
- package/src/helpers/module-package-sync.helper.spec.ts +253 -0
- package/src/helpers/module-package-sync.helper.ts +381 -0
- package/src/index.ts +3 -0
- package/src/jobs/database/test-run-queue-subscriber-database.service.ts +21 -5
- package/src/seeders/module-metadata-seeder.service.ts +154 -0
- package/src/seeders/seed-data/solid-core-metadata.json +0 -47
- package/src/services/module-package.service.spec.ts +398 -0
- package/src/services/module-package.service.ts +433 -37
- package/src/services/view-metadata.service.ts +6 -4
- package/src/testing/README.md +198 -1
- package/src/testing/__integration__/mobile-emulator.integration.ts +409 -0
- package/src/testing/adapters/mobile/capabilities.spec.ts +247 -0
- package/src/testing/adapters/mobile/capabilities.ts +108 -0
- package/src/testing/adapters/mobile/fake-driver.ts +133 -0
- package/src/testing/adapters/mobile/ios-keyboard.spec.ts +40 -0
- package/src/testing/adapters/mobile/ios-keyboard.ts +187 -0
- package/src/testing/adapters/mobile/locator.spec.ts +200 -0
- package/src/testing/adapters/mobile/locator.ts +118 -0
- package/src/testing/adapters/mobile/logcat.spec.ts +63 -0
- package/src/testing/adapters/mobile/logcat.ts +44 -0
- package/src/testing/adapters/mobile/mobile-adapter.ios.spec.ts +277 -0
- package/src/testing/adapters/mobile/mobile-adapter.spec.ts +632 -0
- package/src/testing/adapters/mobile/mobile-adapter.ts +599 -0
- package/src/testing/adapters/mobile/mobile.types.ts +177 -0
- package/src/testing/adapters/mobile/phone-errors.ts +59 -0
- package/src/testing/adapters/mobile/platform.ts +15 -0
- package/src/testing/adapters/mobile/resolve-mobile-target.spec.ts +227 -0
- package/src/testing/adapters/mobile/resolve-mobile-target.ts +104 -0
- package/src/testing/adapters/mobile/run-options.spec.ts +121 -0
- package/src/testing/adapters/mobile/run-options.ts +49 -0
- package/src/testing/adapters/mobile/syslog.spec.ts +108 -0
- package/src/testing/adapters/mobile/syslog.ts +57 -0
- package/src/testing/adapters/ui/playwright-adapter.ts +149 -22
- package/src/testing/adapters/ui/resolve-target.ts +121 -0
- package/src/testing/adapters/ui/ui.types.ts +23 -0
- package/src/testing/contracts/runtime-context.types.ts +24 -0
- package/src/testing/contracts/testing-metadata.types.ts +72 -1
- package/src/testing/core/step-registry.ts +4 -0
- package/src/testing/core/testing-engine.ts +148 -42
- package/src/testing/reporter/console-reporter.ts +22 -10
- package/src/testing/reporter/file-service-artifact-sink.ts +9 -3
- package/src/testing/reporter/lifecycle-events.types.ts +17 -0
- package/src/testing/reporter/lifecycle-webhook-reporter.spec.ts +77 -0
- package/src/testing/reporter/lifecycle-webhook-reporter.ts +31 -2
- package/src/testing/reporter/progress-reporter.ts +9 -10
- package/src/testing/reporter/reporter.types.ts +37 -9
- package/src/testing/runner/lifecycle.spec.ts +41 -0
- package/src/testing/runner/lifecycle.ts +95 -0
- package/src/testing/runner/mobile-session.spec.ts +106 -0
- package/src/testing/runner/mobile-session.ts +138 -0
- package/src/testing/runner/recording-reporter.ts +34 -0
- package/src/testing/runner/run-cancellation.ts +38 -0
- package/src/testing/runner/run-from-metadata.cancel.spec.ts +75 -0
- package/src/testing/runner/run-from-metadata.mobile.spec.ts +580 -0
- package/src/testing/runner/run-from-metadata.spec.ts +180 -2
- package/src/testing/runner/run-from-metadata.ts +215 -33
- package/src/testing/runner/scenario-graph.spec.ts +122 -0
- package/src/testing/runner/scenario-graph.ts +142 -0
- package/src/testing/runtime/default-registry.ts +19 -0
- package/src/testing/runtime/index.ts +79 -0
- package/src/testing/runtime/mobile-step-executor.spec.ts +177 -0
- package/src/testing/runtime/step-executor.spec.ts +156 -0
- package/src/testing/runtime/step-executor.ts +315 -0
- package/src/testing/steps/mobile/actions.step.ts +176 -0
- package/src/testing/steps/mobile/app.step.ts +23 -0
- package/src/testing/steps/mobile/assertions.step.ts +59 -0
- package/src/testing/steps/mobile/gestures.step.ts +102 -0
- package/src/testing/steps/mobile/index.ts +12 -0
- package/src/testing/steps/mobile/mobile-steps.ios.spec.ts +364 -0
- package/src/testing/steps/mobile/mobile-steps.spec.ts +415 -0
- package/src/testing/steps/mobile/shared.ts +48 -0
- package/src/testing/steps/mobile/swipe-line.spec.ts +27 -0
- package/src/testing/steps/mobile/swipe-line.ts +30 -0
- package/src/testing/steps/ui/actions.step.ts +11 -8
- package/src/testing/steps/ui/aria-snapshot.step.ts +101 -0
- package/src/testing/steps/ui/assertions.step.ts +7 -9
- package/src/testing/steps/ui/form.step.ts +10 -10
- package/src/testing/steps/ui/index.ts +2 -0
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
import type { HealEvent } from "../../contracts/runtime-context.types";
|
|
2
|
+
import type { HealingPolicy } from "../../contracts/testing-metadata.types";
|
|
3
|
+
import { DEFAULT_UI_TIMEOUT_MS } from "../ui/playwright-adapter";
|
|
4
|
+
import type { FailureArtifact } from "../ui/playwright-adapter";
|
|
5
|
+
import { buildCapabilities } from "./capabilities";
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
7
|
+
import { resolveLocator } from "./locator";
|
|
8
|
+
import { toConsoleEntries } from "./logcat";
|
|
9
|
+
import { appIdArg, BUNDLE_ID_RE, isIos } from "./platform";
|
|
10
|
+
import { CLEAR_DATA_NEEDS_BUILD, withPhoneHint } from "./phone-errors";
|
|
11
|
+
import { toSyslogConsoleEntries } from "./syslog";
|
|
12
|
+
import type { ResolvedLocator } from "./locator";
|
|
13
|
+
import type { FindOptions, MobileAdapterOptions, MobileDriver, MobileElement, MobileRemoteOptions, MobileClock } from "./mobile.types";
|
|
14
|
+
|
|
15
|
+
/** Keep the device log bounded, like the UI adapter's console buffer. */
|
|
16
|
+
const MAX_LOGCAT_ENTRIES = 500;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Two-thirds scale and a modest bit rate keep a run's recording small (D15). Android records at most 180 s
|
|
20
|
+
* per file, so a longer limit makes Appium record in 180 s chunks. It merges them at the end when `ffmpeg`
|
|
21
|
+
* is installed; without it, Appium returns the most recent chunk, which is the part that matters when a run
|
|
22
|
+
* fails. With a limit of 180 the recording would stop after the first chunk and miss the failure.
|
|
23
|
+
*/
|
|
24
|
+
const ANDROID_RECORDING_OPTIONS = { videoSize: "720x1600", bitRate: 2_000_000, timeLimit: "1800" };
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* iOS records through ffmpeg, which must be installed. The default codec, mjpeg, does not play in a browser, and the
|
|
28
|
+
* hardware encoder produced an empty file, so libx264 it is. The scale halves the screen, keeping even dimensions (D37).
|
|
29
|
+
*/
|
|
30
|
+
const IOS_RECORDING_OPTIONS = {
|
|
31
|
+
videoType: "libx264",
|
|
32
|
+
videoFps: 10,
|
|
33
|
+
timeLimit: "1800",
|
|
34
|
+
videoScale: "trunc(iw/4)*2:trunc(ih/4)*2",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const SIMCTL_TIMEOUT_MS = 15_000;
|
|
38
|
+
const SIMULATOR_ID_RE = /^[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
39
|
+
|
|
40
|
+
function defaultRunCommand(file: string, args: string[]): Promise<void> {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
execFile(file, args, { timeout: SIMCTL_TIMEOUT_MS }, (error) => (error ? reject(error) : resolve()));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ELEMENT_POLL_MS = 500;
|
|
47
|
+
|
|
48
|
+
const realClock: MobileClock = {
|
|
49
|
+
now: () => Date.now(),
|
|
50
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** App states from `mobile: queryAppState`, the same numbers on both platforms. 4 means running in the foreground. */
|
|
54
|
+
const APP_STATE_FOREGROUND = 4;
|
|
55
|
+
const APP_STATE_NOT_RUNNING = 1;
|
|
56
|
+
const APP_STATE_NAMES: Record<number, string> = {
|
|
57
|
+
0: "not installed",
|
|
58
|
+
1: "not running",
|
|
59
|
+
2: "background, suspended",
|
|
60
|
+
3: "background",
|
|
61
|
+
4: "foreground",
|
|
62
|
+
};
|
|
63
|
+
/** How often `launch` starts an app again after Android stopped it while it was starting. */
|
|
64
|
+
const MAX_LAUNCH_RESTARTS = 2;
|
|
65
|
+
|
|
66
|
+
async function defaultDriverFactory(options: MobileRemoteOptions): Promise<MobileDriver> {
|
|
67
|
+
// The module name is a variable so TypeScript does not try to resolve this optional peer.
|
|
68
|
+
const moduleName = "webdriverio";
|
|
69
|
+
let mod: { remote: (opts: MobileRemoteOptions) => Promise<MobileDriver> };
|
|
70
|
+
try {
|
|
71
|
+
mod = await import(moduleName);
|
|
72
|
+
} catch (error: any) {
|
|
73
|
+
if (error?.code === "MODULE_NOT_FOUND" || error?.code === "ERR_MODULE_NOT_FOUND") {
|
|
74
|
+
throw new Error(
|
|
75
|
+
'Mobile scenarios need the "webdriverio" package. Install it in the app that runs tests: npm i webdriverio@^10.0.1',
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Could not load "webdriverio": ${error?.message ?? error}`);
|
|
79
|
+
}
|
|
80
|
+
return mod.remote(options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Drives one Android or iOS device, emulator or simulator through an Appium server. Mirrors PlaywrightAdapter: one
|
|
85
|
+
* session per run, shared by every mobile scenario, started lazily and stopped when the run ends.
|
|
86
|
+
*/
|
|
87
|
+
export class MobileAdapter {
|
|
88
|
+
private readonly defaultTimeoutMs: number;
|
|
89
|
+
private readonly navigationTimeoutMs: number;
|
|
90
|
+
private readonly strictLocators: boolean;
|
|
91
|
+
private readonly recordVideo: boolean;
|
|
92
|
+
private readonly captureConsole: boolean;
|
|
93
|
+
private readonly captureScreenshot: boolean;
|
|
94
|
+
private driver?: MobileDriver;
|
|
95
|
+
private recording = false;
|
|
96
|
+
private runVideo?: FailureArtifact;
|
|
97
|
+
/** The first launch of a session grants permissions on a simulator even without a reset (D28). */
|
|
98
|
+
private launchedOnce = false;
|
|
99
|
+
private readonly logType: "logcat" | "syslog";
|
|
100
|
+
private readonly clock: MobileClock;
|
|
101
|
+
private readonly healing: HealingPolicy;
|
|
102
|
+
/** The driver belongs to the caller (an authoring session): {@link stop} lets go of it but never ends its session. */
|
|
103
|
+
private attached = false;
|
|
104
|
+
private heals: HealEvent[] = [];
|
|
105
|
+
/** The longest a single device lookup took since the last {@link takeSlowestCallMs}, for the step report. */
|
|
106
|
+
private slowestCallMs = 0;
|
|
107
|
+
|
|
108
|
+
/** Set when screen recording could not start; the run continues without a video. */
|
|
109
|
+
public recordingError?: string;
|
|
110
|
+
/** Set when a simulator could not be told to allow permissions; the app may then show a permission prompt. */
|
|
111
|
+
public grantError?: string;
|
|
112
|
+
|
|
113
|
+
constructor(private readonly opts: MobileAdapterOptions) {
|
|
114
|
+
this.defaultTimeoutMs = opts.defaultTimeoutMs ?? DEFAULT_UI_TIMEOUT_MS;
|
|
115
|
+
this.navigationTimeoutMs = opts.navigationTimeoutMs ?? this.defaultTimeoutMs;
|
|
116
|
+
this.strictLocators = opts.strictLocators ?? true;
|
|
117
|
+
this.recordVideo = opts.recordVideo ?? true;
|
|
118
|
+
this.captureConsole = opts.capture?.console ?? false;
|
|
119
|
+
this.captureScreenshot = opts.capture?.screenshot ?? false;
|
|
120
|
+
this.logType = isIos(opts) ? "syslog" : "logcat";
|
|
121
|
+
this.clock = opts.clock ?? realClock;
|
|
122
|
+
this.healing = opts.healing ?? "report";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Whether this session drives an iOS device or simulator. */
|
|
126
|
+
get ios(): boolean {
|
|
127
|
+
return isIos(this.opts);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Whether this session drives a real iPhone: iOS, and not a simulator. */
|
|
131
|
+
get phone(): boolean {
|
|
132
|
+
return isIos(this.opts) && !this.opts.simulator;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** An explicit per-step value wins, otherwise the run-wide default applies. */
|
|
136
|
+
resolveTimeout(stepTimeoutMs?: number): number {
|
|
137
|
+
return typeof stepTimeoutMs === "number" && Number.isFinite(stepTimeoutMs)
|
|
138
|
+
? stepTimeoutMs
|
|
139
|
+
: this.defaultTimeoutMs;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
resolveNavigationTimeout(stepTimeoutMs?: number): number {
|
|
143
|
+
return typeof stepTimeoutMs === "number" && Number.isFinite(stepTimeoutMs)
|
|
144
|
+
? stepTimeoutMs
|
|
145
|
+
: this.navigationTimeoutMs;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether `clearData` can work: always on Android, which clears an installed app in place; on iOS only with a build to install
|
|
150
|
+
* again (the Simulator's `.app`, or an iPhone's `.ipa`).
|
|
151
|
+
*/
|
|
152
|
+
get canReinstall(): boolean {
|
|
153
|
+
return !this.ios || !!this.opts.appPath;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
isStarted(): boolean {
|
|
157
|
+
return !!this.driver;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* An adapter around a driver the caller already opened and keeps (an authoring session), so steps run through the same
|
|
162
|
+
* code as a test run without this adapter starting, recording or ending the session. `appiumUrl`, `udid` and `appSource`
|
|
163
|
+
* are only used to open a session, so they may be placeholders here.
|
|
164
|
+
*/
|
|
165
|
+
static attach(driver: MobileDriver, opts: Omit<MobileAdapterOptions, "appiumUrl" | "udid" | "appSource"> & Partial<MobileAdapterOptions>): MobileAdapter {
|
|
166
|
+
const adapter = new MobileAdapter({
|
|
167
|
+
appiumUrl: "attached",
|
|
168
|
+
udid: "attached",
|
|
169
|
+
appSource: "installed",
|
|
170
|
+
...opts,
|
|
171
|
+
recordVideo: false,
|
|
172
|
+
});
|
|
173
|
+
adapter.driver = driver;
|
|
174
|
+
adapter.attached = true;
|
|
175
|
+
return adapter;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The screen's accessibility tree as XML. */
|
|
179
|
+
async getPageSource(): Promise<string> {
|
|
180
|
+
return this.getDriver().getPageSource();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getDriver(): MobileDriver {
|
|
184
|
+
if (!this.driver) {
|
|
185
|
+
throw new Error("Mobile session is not started");
|
|
186
|
+
}
|
|
187
|
+
return this.driver;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async start(): Promise<void> {
|
|
191
|
+
let url: URL;
|
|
192
|
+
try {
|
|
193
|
+
url = new URL(this.opts.appiumUrl);
|
|
194
|
+
} catch {
|
|
195
|
+
throw new Error(`appiumUrl is not a valid URL: "${this.opts.appiumUrl}"`);
|
|
196
|
+
}
|
|
197
|
+
const secure = url.protocol === "https:";
|
|
198
|
+
const remoteOptions: MobileRemoteOptions = {
|
|
199
|
+
protocol: secure ? "https" : "http",
|
|
200
|
+
hostname: url.hostname,
|
|
201
|
+
port: url.port ? Number(url.port) : secure ? 443 : 80,
|
|
202
|
+
path: url.pathname || "/",
|
|
203
|
+
capabilities: buildCapabilities(this.opts),
|
|
204
|
+
logLevel: "error",
|
|
205
|
+
connectionRetryCount: 0,
|
|
206
|
+
// Starting a session waits for the device, and on iOS the first one for WebDriverAgent to build (D34).
|
|
207
|
+
connectionRetryTimeout: this.ios && !this.opts.wdaPrebuilt ? 600_000 : 240_000,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const factory = this.opts.driverFactory ?? defaultDriverFactory;
|
|
211
|
+
try {
|
|
212
|
+
this.driver = await factory(remoteOptions);
|
|
213
|
+
} catch (error: any) {
|
|
214
|
+
// Only on a phone: these texts mean signing and trust there, and could mean something else on a simulator.
|
|
215
|
+
const explained = this.phone ? withPhoneHint(String(error?.message ?? error)) : undefined;
|
|
216
|
+
if (explained) throw new Error(explained);
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (this.recordVideo) {
|
|
221
|
+
try {
|
|
222
|
+
await this.driver.startRecordingScreen(this.ios ? IOS_RECORDING_OPTIONS : ANDROID_RECORDING_OPTIONS);
|
|
223
|
+
this.recording = true;
|
|
224
|
+
} catch (error: any) {
|
|
225
|
+
this.recordingError = String(error?.message ?? error).split("\n")[0];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Finds one element. Waits until at least one element matches; with strict locators (the default)
|
|
232
|
+
* a locator that matches several elements fails unless it has an `index` (D6).
|
|
233
|
+
*/
|
|
234
|
+
async find(locator: unknown, stepTimeoutMs?: number, opts?: FindOptions): Promise<MobileElement> {
|
|
235
|
+
const resolved = this.resolve(locator);
|
|
236
|
+
const timeout = this.resolveTimeout(stepTimeoutMs);
|
|
237
|
+
return this.findResolved(resolved, timeout, false, opts?.answerWithinMs);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Like {@link find}, but the element must also be displayed, checked in the same poll within the same timeout. */
|
|
241
|
+
async findDisplayed(locator: unknown, stepTimeoutMs?: number, opts?: FindOptions): Promise<MobileElement> {
|
|
242
|
+
const resolved = this.resolve(locator);
|
|
243
|
+
const timeout = this.resolveTimeout(stepTimeoutMs);
|
|
244
|
+
return this.findResolved(resolved, timeout, true, opts?.answerWithinMs);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Waits until no element matching the locator is displayed. Ignores `index`: any visible match counts. */
|
|
248
|
+
async waitHidden(locator: unknown, stepTimeoutMs?: number): Promise<void> {
|
|
249
|
+
const driver = this.getDriver();
|
|
250
|
+
const resolved = this.resolve(locator);
|
|
251
|
+
const timeout = this.resolveTimeout(stepTimeoutMs);
|
|
252
|
+
const deadline = this.clock.now() + timeout;
|
|
253
|
+
for (;;) {
|
|
254
|
+
const matches = await this.withinDeadline(deadline, timeout, `looking for ${resolved.label}`, () => driver.$$(resolved.selector));
|
|
255
|
+
let shown = false;
|
|
256
|
+
for (const element of matches) {
|
|
257
|
+
if (await this.withinDeadline(deadline, timeout, `checking ${resolved.label}`, () => element.isDisplayed())) {
|
|
258
|
+
shown = true;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (!shown) return;
|
|
263
|
+
if (this.clock.now() >= deadline) throw new Error(`${resolved.label} is still visible after ${timeout} ms`);
|
|
264
|
+
await this.clock.sleep(Math.min(ELEMENT_POLL_MS, Math.max(0, deadline - this.clock.now())));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
getHealingPolicy(): HealingPolicy {
|
|
269
|
+
return this.healing;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
recordHeal(heal: HealEvent): void {
|
|
273
|
+
this.heals.push(heal);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Heals recorded since the last {@link resetCapture}. */
|
|
277
|
+
getHeals(): HealEvent[] {
|
|
278
|
+
return [...this.heals];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Whether any element matches the locator within `timeoutMs` (0 asks once). A lookup that does not answer in time
|
|
283
|
+
* counts as "not there", so choosing a healed locator never waits on a stalled device.
|
|
284
|
+
*/
|
|
285
|
+
async isPresent(locator: unknown, timeoutMs: number): Promise<boolean> {
|
|
286
|
+
const driver = this.getDriver();
|
|
287
|
+
const resolved = this.resolve(locator);
|
|
288
|
+
const deadline = this.clock.now() + timeoutMs;
|
|
289
|
+
for (;;) {
|
|
290
|
+
try {
|
|
291
|
+
const matches = await this.withinDeadline(deadline, timeoutMs, `looking for ${resolved.label}`, () => driver.$$(resolved.selector));
|
|
292
|
+
if (matches.length > 0) return true;
|
|
293
|
+
} catch {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (this.clock.now() >= deadline) return false;
|
|
297
|
+
await this.clock.sleep(Math.min(ELEMENT_POLL_MS, Math.max(0, deadline - this.clock.now())));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** How many matching elements are displayed right now, without waiting for any to appear. */
|
|
302
|
+
async countDisplayed(locator: unknown, budgetMs = 3000): Promise<number> {
|
|
303
|
+
const driver = this.getDriver();
|
|
304
|
+
const resolved = this.resolve(locator);
|
|
305
|
+
const deadline = this.clock.now() + budgetMs;
|
|
306
|
+
const matches = await this.withinDeadline(deadline, budgetMs, `looking for ${resolved.label}`, () => driver.$$(resolved.selector));
|
|
307
|
+
let shown = 0;
|
|
308
|
+
for (const element of matches) {
|
|
309
|
+
if (await this.withinDeadline(deadline, budgetMs, `checking ${resolved.label}`, () => element.isDisplayed())) shown += 1;
|
|
310
|
+
}
|
|
311
|
+
return shown;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** The longest single device lookup since the last call, in ms, and starts counting again. */
|
|
315
|
+
takeSlowestCallMs(): number {
|
|
316
|
+
const slowest = this.slowestCallMs;
|
|
317
|
+
this.slowestCallMs = 0;
|
|
318
|
+
return slowest;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Stops the app, optionally wipes its data, then starts it and waits until it is in the foreground. On iOS a wipe is a
|
|
323
|
+
* reinstall of the build (D27): `clearApp` leaves an app's preferences behind. On a simulator, permissions are granted
|
|
324
|
+
* after the app is installed and before it starts, because the permission prompt cannot be accepted by the session (D28).
|
|
325
|
+
* On Android, permissions are granted again after a wipe, because clearing data revokes them.
|
|
326
|
+
*/
|
|
327
|
+
async launch(opts: { clearData?: boolean; timeoutMs?: number; grantPermissions?: boolean } = {}): Promise<void> {
|
|
328
|
+
// iOS clears an app's data by installing it again. Without a build there is nothing to install: refuse before touching it (D41).
|
|
329
|
+
if (opts.clearData && this.ios && !this.canReinstall) throw new Error(CLEAR_DATA_NEEDS_BUILD);
|
|
330
|
+
const driver = this.getDriver();
|
|
331
|
+
const appId = this.opts.appPackage;
|
|
332
|
+
const idArg = appIdArg(this.opts);
|
|
333
|
+
const timeout = this.resolveNavigationTimeout(opts.timeoutMs);
|
|
334
|
+
|
|
335
|
+
await driver.execute("mobile: terminateApp", idArg);
|
|
336
|
+
if (opts.clearData) {
|
|
337
|
+
if (this.ios) await this.reinstall();
|
|
338
|
+
else {
|
|
339
|
+
await driver.execute("mobile: clearApp", idArg);
|
|
340
|
+
// Clearing an Android app's data takes back its runtime permissions, so the next permission prompt would
|
|
341
|
+
// cover the screen. Grant them again, unless the scenario is testing that prompt.
|
|
342
|
+
if (opts.grantPermissions !== false) await this.grantAndroidPermissions();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (this.opts.simulator && opts.grantPermissions !== false && (opts.clearData || !this.launchedOnce)) {
|
|
346
|
+
await this.grantPermissions();
|
|
347
|
+
}
|
|
348
|
+
this.launchedOnce = true;
|
|
349
|
+
await driver.execute("mobile: activateApp", idArg);
|
|
350
|
+
|
|
351
|
+
// Android gives a starting app about ten seconds to attach and kills it otherwise, which is likely on a device that
|
|
352
|
+
// has only just booted or is short of memory. The app then reads "not running", so start it again a few times.
|
|
353
|
+
let lastState: number | undefined;
|
|
354
|
+
let polls = 0;
|
|
355
|
+
let restarts = 0;
|
|
356
|
+
try {
|
|
357
|
+
await driver.waitUntil(
|
|
358
|
+
async () => {
|
|
359
|
+
lastState = Number(await driver.execute("mobile: queryAppState", idArg));
|
|
360
|
+
polls += 1;
|
|
361
|
+
if (lastState === APP_STATE_FOREGROUND) return true;
|
|
362
|
+
if (lastState === APP_STATE_NOT_RUNNING && polls > 1 && restarts < MAX_LAUNCH_RESTARTS) {
|
|
363
|
+
restarts += 1;
|
|
364
|
+
await driver.execute("mobile: activateApp", idArg);
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
timeout,
|
|
370
|
+
timeoutMsg: `${appId} did not reach the foreground within ${timeout} ms`,
|
|
371
|
+
interval: ELEMENT_POLL_MS,
|
|
372
|
+
},
|
|
373
|
+
);
|
|
374
|
+
} catch (error: any) {
|
|
375
|
+
const detail = [
|
|
376
|
+
lastState !== undefined ? `last state: ${APP_STATE_NAMES[lastState] ?? lastState}` : "",
|
|
377
|
+
restarts ? `started again ${restarts} time${restarts === 1 ? "" : "s"}` : "",
|
|
378
|
+
].filter(Boolean).join(", ");
|
|
379
|
+
const hint =
|
|
380
|
+
lastState === APP_STATE_NOT_RUNNING
|
|
381
|
+
? " The app was started but stopped again; the device may be overloaded. See the device log."
|
|
382
|
+
: "";
|
|
383
|
+
throw new Error(`${error?.message ?? error}${detail ? ` (${detail})` : ""}.${hint}`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async terminate(): Promise<void> {
|
|
388
|
+
await this.getDriver().execute("mobile: terminateApp", appIdArg(this.opts));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** iOS reset: remove the app and install the build again, which clears everything `clearApp` leaves behind (D27). */
|
|
392
|
+
private async reinstall(): Promise<void> {
|
|
393
|
+
const driver = this.getDriver();
|
|
394
|
+
const appPath = this.opts.appPath;
|
|
395
|
+
if (!appPath) {
|
|
396
|
+
throw new Error(CLEAR_DATA_NEEDS_BUILD);
|
|
397
|
+
}
|
|
398
|
+
try {
|
|
399
|
+
await driver.execute("mobile: removeApp", { bundleId: this.opts.appPackage });
|
|
400
|
+
await driver.execute("mobile: installApp", { app: appPath });
|
|
401
|
+
} catch (error: any) {
|
|
402
|
+
throw new Error(`Could not reinstall ${this.opts.appPackage} to clear its data: ${String(error?.message ?? error).split("\n")[0]}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* `autoAcceptAlerts` denies permission prompts, so a simulator is told to allow everything before the app starts.
|
|
408
|
+
* Best-effort: a failure leaves the prompt, and the scenario fails where the prompt gets in the way.
|
|
409
|
+
*/
|
|
410
|
+
private async grantPermissions(): Promise<void> {
|
|
411
|
+
const { udid, appPackage } = this.opts;
|
|
412
|
+
if (!SIMULATOR_ID_RE.test(udid) || !BUNDLE_ID_RE.test(appPackage)) return;
|
|
413
|
+
try {
|
|
414
|
+
await (this.opts.runCommand ?? defaultRunCommand)("xcrun", ["simctl", "privacy", udid, "grant", "all", appPackage]);
|
|
415
|
+
} catch (error: any) {
|
|
416
|
+
this.grantError = String(error?.message ?? error).split("\n")[0];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** Android: grants every runtime permission the app declares. Best-effort: a failure is noted, never thrown. */
|
|
421
|
+
private async grantAndroidPermissions(): Promise<void> {
|
|
422
|
+
try {
|
|
423
|
+
await this.getDriver().execute("mobile: changePermissions", {
|
|
424
|
+
permissions: "all",
|
|
425
|
+
appPackage: this.opts.appPackage,
|
|
426
|
+
action: "grant",
|
|
427
|
+
});
|
|
428
|
+
} catch (error: any) {
|
|
429
|
+
this.grantError = String(error?.message ?? error).split("\n")[0];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Starts a clean capture window for the next scenario. Best-effort: never throws. */
|
|
434
|
+
async resetCapture(): Promise<void> {
|
|
435
|
+
this.heals = [];
|
|
436
|
+
if (!this.driver || !this.captureConsole) return;
|
|
437
|
+
try {
|
|
438
|
+
// Reading the device log drains it, so the next read only returns newer entries.
|
|
439
|
+
await this.driver.getLogs(this.logType);
|
|
440
|
+
} catch {
|
|
441
|
+
// Not every device exposes the log; a failed drain must never fail a scenario.
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** The device log, and a screenshot when asked for, for a failed scenario. Each part is best-effort. */
|
|
446
|
+
async collectFailureArtifacts(): Promise<FailureArtifact[]> {
|
|
447
|
+
if (!this.driver) return [];
|
|
448
|
+
const artifacts: FailureArtifact[] = [];
|
|
449
|
+
|
|
450
|
+
if (this.captureConsole) {
|
|
451
|
+
try {
|
|
452
|
+
const entries = await this.driver.getLogs(this.logType);
|
|
453
|
+
const mapped = this.ios
|
|
454
|
+
? toSyslogConsoleEntries(entries, { processName: this.opts.appProcessName, bundleId: this.opts.appPackage }, MAX_LOGCAT_ENTRIES)
|
|
455
|
+
: toConsoleEntries(entries, this.opts.appPackage, MAX_LOGCAT_ENTRIES);
|
|
456
|
+
if (mapped.length) {
|
|
457
|
+
artifacts.push({ name: "console.json", contentType: "application/json", data: JSON.stringify(mapped) });
|
|
458
|
+
}
|
|
459
|
+
} catch {
|
|
460
|
+
// Best-effort.
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (this.captureScreenshot) {
|
|
465
|
+
try {
|
|
466
|
+
const png = await this.driver.takeScreenshot();
|
|
467
|
+
if (png) {
|
|
468
|
+
artifacts.push({ name: "screenshot.png", contentType: "image/png", data: Buffer.from(png, "base64") });
|
|
469
|
+
}
|
|
470
|
+
} catch {
|
|
471
|
+
// Best-effort.
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return artifacts;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** Waits on the adapter's clock, so a test with a fake clock does not wait for real. */
|
|
479
|
+
pause(ms: number): Promise<void> {
|
|
480
|
+
return this.clock.sleep(ms);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/** Printable form of a locator for error messages, e.g. `{ by: "accessibilityId", value: "Save" }`. */
|
|
484
|
+
describeLocator(locator: unknown): string {
|
|
485
|
+
return this.resolve(locator).label;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** Whole-run recording, available after {@link stop} when it was asked to keep the video. */
|
|
489
|
+
getRunVideo(): FailureArtifact | undefined {
|
|
490
|
+
return this.runVideo;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Never throws: a failure to close must not mask the run's real result. */
|
|
494
|
+
async stop(opts?: { keepVideo?: boolean }): Promise<void> {
|
|
495
|
+
if (this.attached) {
|
|
496
|
+
this.driver = undefined;
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const keepVideo = opts?.keepVideo ?? false;
|
|
500
|
+
const driver = this.driver;
|
|
501
|
+
try {
|
|
502
|
+
if (driver && this.recording) {
|
|
503
|
+
try {
|
|
504
|
+
const base64 = await driver.stopRecordingScreen();
|
|
505
|
+
// Only keep the recording when the run FAILED; passing runs discard it unread.
|
|
506
|
+
if (keepVideo && base64) {
|
|
507
|
+
this.runVideo = { name: "run.mp4", contentType: "video/mp4", data: Buffer.from(base64, "base64") };
|
|
508
|
+
}
|
|
509
|
+
} catch {
|
|
510
|
+
// A recording that cannot be read is simply not attached.
|
|
511
|
+
} finally {
|
|
512
|
+
this.recording = false;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
} finally {
|
|
516
|
+
this.driver = undefined;
|
|
517
|
+
if (driver) {
|
|
518
|
+
try {
|
|
519
|
+
await driver.deleteSession();
|
|
520
|
+
} catch {
|
|
521
|
+
// Best-effort.
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
private resolve(locator: unknown): ResolvedLocator {
|
|
528
|
+
return resolveLocator(locator, { appPackage: this.opts.appPackage, platform: this.opts.platformName });
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Polls with one lookup per tick (every lookup is a round trip to the device) and returns as soon as the element is
|
|
533
|
+
* there, and displayed when asked, so a step waits only as long as the app needs. The failure messages are the ones
|
|
534
|
+
* the steps and the agent have always matched on.
|
|
535
|
+
*/
|
|
536
|
+
private async findResolved(resolved: ResolvedLocator, timeout: number, displayed: boolean, answerWithinMs?: number): Promise<MobileElement> {
|
|
537
|
+
const driver = this.getDriver();
|
|
538
|
+
const deadline = this.clock.now() + timeout;
|
|
539
|
+
// `timeout` is how long to keep looking. A caller that expects "not there" to be a normal answer (an optional step) also
|
|
540
|
+
// gives each call this long to answer, so a slow device's late "not there" is not mistaken for a device that is not answering.
|
|
541
|
+
const callDeadline = () => (answerWithinMs === undefined ? deadline : Math.max(deadline, this.clock.now() + answerWithinMs));
|
|
542
|
+
const callLimit = answerWithinMs ?? timeout;
|
|
543
|
+
for (;;) {
|
|
544
|
+
const matches = await this.withinDeadline(callDeadline(), callLimit, `looking for ${resolved.label}`, () => driver.$$(resolved.selector));
|
|
545
|
+
if (matches.length > 0) {
|
|
546
|
+
const element = this.pickMatch(resolved, matches);
|
|
547
|
+
if (!displayed) return element;
|
|
548
|
+
if (await this.withinDeadline(callDeadline(), callLimit, `checking ${resolved.label}`, () => element.isDisplayed())) return element;
|
|
549
|
+
}
|
|
550
|
+
if (this.clock.now() >= deadline) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
matches.length > 0
|
|
553
|
+
? `${resolved.label} is not displayed after ${timeout} ms`
|
|
554
|
+
: `No element matches ${resolved.label} after ${timeout} ms`,
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
await this.clock.sleep(Math.min(ELEMENT_POLL_MS, Math.max(0, deadline - this.clock.now())));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
private pickMatch(resolved: ResolvedLocator, matches: MobileElement[]): MobileElement {
|
|
562
|
+
if (resolved.index !== undefined) {
|
|
563
|
+
if (resolved.index >= matches.length) {
|
|
564
|
+
throw new Error(`Locator ${resolved.label} has no match at index ${resolved.index} (found ${matches.length})`);
|
|
565
|
+
}
|
|
566
|
+
return matches[resolved.index];
|
|
567
|
+
}
|
|
568
|
+
if (this.strictLocators && matches.length > 1) {
|
|
569
|
+
throw new Error(`Locator ${resolved.label} matched ${matches.length} elements; make it unique or add "index"`);
|
|
570
|
+
}
|
|
571
|
+
return matches[0];
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Runs one device call that has to answer before `deadline`. UiAutomator2 can leave a request unanswered for tens of
|
|
576
|
+
* seconds while the app's UI is busy. Without a limit that one call outlives the step's timeout, and the step then
|
|
577
|
+
* reports an element as missing that was there. The slowest call is kept for the step report.
|
|
578
|
+
*/
|
|
579
|
+
private async withinDeadline<T>(deadline: number, timeout: number, what: string, call: () => Promise<T>): Promise<T> {
|
|
580
|
+
const budget = Math.max(1, deadline - this.clock.now());
|
|
581
|
+
const startedAt = Date.now();
|
|
582
|
+
let timer: NodeJS.Timeout | undefined;
|
|
583
|
+
const expired = new Promise<never>((_, reject) => {
|
|
584
|
+
timer = setTimeout(
|
|
585
|
+
() => reject(new Error(`The device did not answer while ${what} within the ${timeout} ms timeout; the app's UI may be busy`)),
|
|
586
|
+
budget,
|
|
587
|
+
);
|
|
588
|
+
});
|
|
589
|
+
const pending = call();
|
|
590
|
+
// If the deadline wins, the call may still fail later; nobody is left to hear it.
|
|
591
|
+
pending.catch(() => undefined);
|
|
592
|
+
try {
|
|
593
|
+
return await Promise.race([pending, expired]);
|
|
594
|
+
} finally {
|
|
595
|
+
clearTimeout(timer);
|
|
596
|
+
this.slowestCallMs = Math.max(this.slowestCallMs, Date.now() - startedAt);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|