Commit Graph

60 Commits

Author SHA1 Message Date
Kazuaki Matsuo b83bd04265 chore(base-driver): remove mobileRotation as no references (#19379)
* chore(base-driver): remove mobileRotation as no references

* docs: remove unused endpoint

* test: fix test
2023-11-06 23:12:11 -08:00
Mykola Mokhnach 5926919177 feat(base-driver): Add server support of TLS and SPDY protocols (#19105) 2023-09-08 08:02:56 +02:00
Mykola Mokhnach 2f69e6db2a chore(base-driver): Improve bad parameters error message (#19002) 2023-08-19 08:27:31 +02:00
Christopher Hiller 2b351705d4 fix(base-driver): pass thru all type args to ExternalDriver
- `core` module is now TS
- `constants` module is now TS
- export missing `W3C_ELEMENT_KEY`
- `JWProxy.command` returns `Promise<unknown>`.  deal with it
- updated some type tests
2023-07-03 13:10:51 -07:00
Christopher Hiller 01061b2919 fix(types,base-driver): remove deviceName from base constraints
This cap was conflicting with constraints defined in subclasses.  Currently, it isn't possible to cleanly "override" constraints.  Given `deviceName` is not used anywhere within base-driver's source, this seems like a decent workaround for now.
2023-07-03 13:10:51 -07:00
Christopher Hiller deb631b456 fix(basedriver): convert main driver implementation to typescript
This seems to fix the bug in #18379.  There must be some sort of bug in TypeScript w/r/t `@implements` or maybe even it was not treating `@typedef` as a proper alias.  Perhaps it's user error--omitting optional type args in alias-style typedefs may end up making a new type entirely.  idk, but this was easier to deal with.

Closes #18379.
2023-03-27 17:07:51 -07:00
Christopher Hiller 238c489f3a chore(base-driver): add a failing type test 2023-03-27 17:07:51 -07:00
Christopher Hiller be86627595 fix(base-driver): use new mixin strategy
also fix a broken type in fake-driver
2023-03-02 15:47:24 -08:00
Jonathan Lipps 7055a0b281 feat(base-driver): deprecate non-standard routes
and add deprecation warnings in the log when these routes are accessed
2023-01-12 10:11:08 -08:00
Jonathan Lipps d8588e107c docs: add ExternalDriver docstrings (#17985) 2023-01-10 14:36:48 -08:00
Jonathan Lipps 23224cf002 fix(appium): inability to find automationName inside appium:options (#17966)
* fix(appium): inability to find automationName inside appium:options

we fixed this before but only fixed it in basedriver's createSession, which is not
actually called by Appium's createSession (though maybe it should be)

* test(base-driver): remove appium:options test
2022-12-28 10:54:39 -08:00
Kazuaki Matsuo 316ecca8b1 feat(base): add get computed role and label in W3C v2 (#17928)
* feat(base): add get computed role and label in W3C v2

* add command names

* chore: add type

* chore: use `?` instead of `| null`

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>

* Revert "chore: use `?` instead of `| null`"

This reverts commit 62af5e80ac.

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>
2022-12-15 20:46:44 -08:00
Christopher Hiller f715bb4fd8 chore(base-driver,base-plugin,execute-driver-plugin,fake-driver,fake-plugin,images-plugin): update some types for typedoc 2022-11-22 14:32:10 -08:00
Mykola Mokhnach 91901153a1 fix(base-driver): Properly validate capabilities inside appium:options map (#17781) 2022-11-20 08:52:29 +01:00
Christopher Hiller 51d6d69ff1 fix(basedriver): ensure "opts" is defined at time of construction 2022-10-14 14:01:07 -07:00
Christopher Hiller b20d0b82a2 chore(appium,base-driver,driver-test-support,types): overhaul types for constraints and caps
The big idea here is:

1. `desiredCapConstraints` should always contain the constraints _for that driver_; it no longer contains the "base" constraints. This is the only thing that really required any logic changes (though they are somewhat spread out).  The "merged" constraints object is available via `_desiredCapConstraints`.
2. `Capabilities` and W3C-style `W3CCapabilities` are now _derived from_ constraints.  This absolves us (and extension authors) from needing to create an interface describing their capabilities.
3. Changes to caps and constraints now reflect in `DriverOpts` (`this.opts`) in drivers
4. `caps` and `originalCaps` declarations have moved from `Core` to `Driver`
5. TypeScript compiles the JS output from `@appium/types` (which is just a static "constraints" object)

Resolves #17518
2022-10-06 15:30:22 -07:00
Christopher Hiller c37f4500c2 test(base-driver): use @appium/driver-test-support 2022-08-23 13:42:47 -07:00
Christopher Hiller 70d88cb86f feat(appium,base-driver,base-plugin,test-support,types): move test fixtures into test-support
- `@appium/test-support` now exports the e2e setup for plugins, and e2e/unit suites for drivers from base-driver.  it also generates declarations.
- `appium` exports this as `appium/test`.
- The `capability.spec.js` unit test for basedriver now avoids spying on the "global" logger, due to test flake.  It now spies directly on the function which calls the global logger. (@mykola_mokhnach)
- removed homebrew ansi-stripping code from `test-support` and replaced with `@colors/colors`
- type fixes and refactors for `@appium/test-support`
- type fixes for `appium`
- simplify `lib/index.js` of `@appium/base-driver`
2022-07-18 15:58:21 -07:00
Christopher Hiller 133db5355f chore: reformat everything
this reformats all `.js`, `.ts`, and `.d.ts` files.
2022-05-09 19:09:50 -07:00
Christopher Hiller 2d76923e72 fix(base-driver): do not throw if updateSettings aren't provided
BREAKING CHANGES

Some plugin tests were calling code which called the `update()` method of `DeviceSettings`, but there's apparently no code that actually sets the `onUpdateSettings` listener anywhere (maybe drivers can opt-in to this behavior?), which was causing exceptions to get thrown.

The E2E tests expected this code to reject, but the plugin tests expected it to _not_ reject, so I'm not sure what's right.

- adds unit tests for `DeviceSettings`

_Note: after further investigation, I think this was throwing simply due to `base-plugin` using an old version of `appium-fake-driver` which used an old `appium-base-driver`.  @jlipps says this change is OK._
2022-04-14 14:30:00 -07:00
Mykola Mokhnach 78a46375ae feat(base-driver): Add a route for new window creation (#16748)
* feat(base-driver): Add a route for new window creation

* Update param name

* Update types
2022-04-12 14:51:16 -07:00
Mykola Mokhnach ff3b290c77 chore(base-driver): Update ws dependency (#16739) 2022-04-09 22:56:01 +02:00
Mykola Mokhnach a9651d3c59 fix(base-driver): Update/simplify the logic for logger prefix (#16683) 2022-04-01 22:34:57 +02:00
Mykola Mokhnach d8a9b4da36 feat(base-driver): Add more shadow root-related W3C routes (#16700) 2022-03-31 17:46:44 +02:00
Christopher Hiller 164bedb2f1 feat(base-driver): generate declaration files
This was not as easy as the other two.  The main issue involves the `BaseDriver` class and is threefold:

1. `BaseDriver` and a valid external subclass thereof (a `Driver`) are not the same, because the former is essentially _abstract_. There is no notion of an abstract class in JS nor in TS for JS.
2. Splitting `BaseDriver` into several modules and "mixing in" some modules is just not well-understood by TS.
3. `AppiumDriver` inherits _most_ of `BaseDriver`, but overrides some functions with differing signatures. This is unsupported by TS.

To work around these problems, I had to:

1. Move the `Driver` interface into `@appium/types`, since other packages may depend on it.  We do not want circular dependencies, which is likely to occur otherwise.  Further, there is no way to tell TS for JS that a class _implements_ an interface or type.
2. Refactor the mixins (in `basedriver/commands/`) into "mixin classes", as understood by typescript. These are dynamic classes returned by functions which accept a class parameter, and _extend_ that class. The result is marginally better, but the implementation is ... well, see for yourself.  It is not possible to use declaration merging to just "trick" TS into thinking that `BaseDriver` has all of these extra methods; classes cannot be merged, and even if you could, you can't use declaration merging to "add" methods afaict.
3. `BaseDriver` is now an empty class which inherits from all mixins applied to `DriverCore`.  Due to syntactic restrictions, it must be a `class` statement in order to use the `@implements` tag, which causes TS to check that the result fully implements `Driver`.  `AppiumDriver` _also_ inherits from `DriverCore`, since it does not override `BaseDriver` "properly".  `BaseDriverCore` itself is pretty small, containing only those functions which `AppiumDriver` defines as differing.

Otherwise:

- `BaseDriver` does not inherit from `Protocol`, which is just an empty class. `Protocol` was removed.
- All of the error classes are exported from `protocol/errors`, because TS cannot see them otherwise.
- Exported missing `GET_STATUS_COMMAND` from `protocol/index`
- Re-exported `normalizeBasePath` from `server` instead of `protocol`, since that's where it's defined
- Removed `index.d.ts`
- Mixins use `@implements` as well. Note that `@implements` does not support `import('..')` syntax.

chore(base-driver): attempted to make types for mixins less awful

fixed a couple issues in the types in `driver.js`

core(base-driver): add capabilities types

- also move the bluebird config into the index
- fix references to `DriverOpts`
- add `assignServer()` to `BaseDriverCore`, used by `AppiumDriver`

chore(base-driver): fix more types

add missing reference to `@appium/types` in `tsconfig.json`

fix(base-driver): ensure getLogEvents is async

fix(base-driver): add some more type checks and fix logCustomEvent to be async

chore(base-driver): reformat
2022-03-25 14:54:45 -07:00
Christopher Hiller 35d9dc7ebc chore(base-driver): ungulpify
This PR removes Gulp from `@appium/base-driver` and reorganizes the test files.

The build needs to be a little different since other modules depend on its `build/test/basedriver` module.  IMO this should probably get moved elsewhere, but this does not break compatibility.
2022-03-22 18:12:02 -07:00
Kazuaki Matsuo 3ee93ba5bd fix: revert 15809 (#16621)
* fix: revert 15809

* change comment
2022-03-21 10:10:35 -07:00
Christopher Hiller 5be33381fd test(base-driver): rewrite some assertions in capability-specs
simplified some stuff that was giving me problems.

instead of doing a try..await..catch and calling `fail()` if the catch block wasn't called, just use `sinon-chai`'s `.should.eventually.be.rejectedWith(ErrorClass, /message/)`

depending on the order in which this test file is run versus others, it's possible that some will fail because of global logging weirdness.  but normally this doesn't happen... keep an eye on it!
2022-03-09 14:50:45 -08:00
Christopher Hiller 2781805c05 chore: ban direct usage of sinon (#16485)
* chore: ban direct usage of sinon

Calling `sinon.stub()`, `sinon.mock()` etc., directly is error-prone. Care must be taken to explicitly restore any stub created.

Using a sandbox (via `sinon.createSandbox()`), you don't need to remember to restore everything you fiddled with.

To that end, I've converted all direct `sinon` calls into sandbox calls and **BANNED** direct usage of `sinon` via ESLint.

# Conflicts:
#	.eslintrc

* test(base-driver): replace restricted sinon.spy() usage in server-specs.js

* test(support): formatting
2022-03-09 14:50:45 -08:00
Mykola Mokhnach 493c48d190 feat: Add a missing route for element shadow root (#16538) 2022-03-09 18:51:41 +01:00
Mykola Mokhnach 83493941ee refactor: Make loggers connected to the particular driver instances (#16478) 2022-02-23 07:49:42 +01:00
Christopher Hiller 79772d7a4f test(base-driver): replace direct calls to sinon with a sandbox
This is safer, because test failures can happen due to lack of isolation and order in which tests are executed
2022-02-17 11:52:52 -08:00
Mykola Mokhnach ed50a38657 refactor: Allow any of createSession arguments to be W3C capabilities object (#16408) 2022-02-07 15:27:55 +01:00
Mykola Mokhnach d69fc6002c refactor(base-driver): Make configureApp helper more flexible (#16168) 2021-12-15 09:51:00 +01:00
Mykola Mokhnach 07887b7c18 refactor(base-driver): Always assume the returned responses are in W3C format (#16175) 2021-11-29 22:55:48 +01:00
Jonathan Lipps 0e7b19aabe chore!(base-driver): remove support for execute driver script since it will be a plugin moving forward 2021-11-23 09:54:19 -08:00
Christopher Hiller 85cd55bc2c fix(base-driver): create cjs wrapper 2021-11-18 12:08:50 -08:00
Jonathan Lipps 5b9a4c2ffa chore(appium): some cosmetic improvements to session and proxy naming etc 2021-11-12 22:15:06 -05:00
Jonathan Lipps 9e6c0a13ef feat(fake-driver): add a new 'PROXY' context that does 'proxying' for use in testing 2021-11-12 22:15:06 -05:00
Kazuaki Matsuo 829eb6623d chore(base-driver): Add params to setWindowRect handler (#15974) 2021-10-17 08:07:04 +09:00
Christopher Hiller a172196d43 chore(base-driver): revert name change of TEST_HOST to DEFAULT_TEST_HOST
This would have been a breaking change if other packages depend on it, since I think it's a public API
2021-09-28 07:54:20 -07:00
Christopher Hiller cf86871d4f fix(base-driver): allow https in helper URL generation
- use constants/helpers for `jsonwp-proxy` url tests
2021-09-28 07:54:20 -07:00
Christopher Hiller 01d7c1bd7e fix(base-driver): better URL handling in driver-e2e tests
- fix a potential port-reuse issue in `getTestPort()` helper
- dedupe `127.0.0.1` constant
- export curried `createAppiumURL(address, port, session, pathname)` helper for less error-prone URL generation
- export some HTTP method names as constants
2021-09-28 07:54:20 -07:00
Christopher Hiller a3b021a0e8 chore: replace occurrences of 'localhost' with '127.0.01'; use random ports; closes #15399
- `base-driver` gets a new `helpers` module with a `getTestPort` function; this is now used throughout the tests
- `fake-driver` can't use random ports because it depends on `appium-base-driver`'s test suite, and that is _not_ the current appium-2.0-compatible `@appium/base-driver`
2021-09-28 07:54:20 -07:00
Jonathan Lipps 3e5aec945b feat(base-driver): allow drivers, and plugins to declare that certain routes must never be proxied 2021-09-16 10:13:57 -07:00
Jonathan Lipps 050d099e87 feat!(appium): support driver-specific args via --driver-args
Co-authored-by: Ayan Khan <ayan@headspin.io>
2021-09-10 10:35:56 -07:00
Kazuaki Matsuo 6b8ac24b25 chore(base-driver): remove non-W3C route which are already in W3C (#15809)
* chore: remove some mjsonwp route

* update hash
2021-09-10 14:46:54 +09:00
Kazuaki Matsuo 71e50c5619 feat(base-driver): add /se route for log (#15788)
* feat(base-driver): add /se route for log

* fix(base-driver): fix test
2021-08-30 15:11:06 +09:00
Jonathan Lipps 4f1bf3d3b8 feat(base-driver): support appium:options capability to hold all appium caps 2021-08-19 13:38:28 -07:00
Christopher Hiller ee00285b38 chore: global chai
This PR makes `chai` and `should()` _globals_ when using Mocha:

- `chai` is configured with `chai-as-promised`
- A `.mocharc.js` requires `./test/setup.js` _from the monorepo root_.
- Updated the ESLint config to recognize the globals.
- Updated Wallaby config

All instances of `import chai...` and the like have been removed from all test files.
2021-08-13 10:40:52 -07:00