Commit graph

211 commits

Author SHA1 Message Date
Kosta Harlan
0257160852 [selenium] Make tests skin agnostic
The current tests in core rely on selectors provided by Vector, but with some
small modifications the tests can work equally well with and without Vector.

Bug: T248484
Change-Id: I5bc0c80b796252b1a920f6549ef4a462a9b13b87
2020-03-25 16:21:18 +01:00
AronDemian
47cc31de95 tests: Enable 'npm run selenium' on Windows
Run the script explictly via sh, the default is cmd.exe on Windows.
Also ported from bash to sh per Jforrester's request.

Change-Id: I96b66c6ae01a1761619955be2e8a3dbc64edff18
2020-03-15 21:46:50 +00:00
Timo Tijhof
6143f757ea selenium: Replace wdio-chromedriver with ./selenium.sh script
This package was serving two purposes:

* Install chromedriver automatically.
* Start chromedriver automatically when using the
  'npm run selenium' entry point (e.g. for local development).

For the CI entry points (selenium-test, selenium-daily) the
chromedriver is skipped. For those, we expect the CI runner to
have started a chromedriver server already, which allows the
server to continue running between different the test suites
of different extensions etc.

By letting WDIO start the chromedriver for local development,
we had the benefit of 'npm run selenium' directly being an alias
to the 'wdio' command. This made it easy to pass additional
arguments like --spec or --mochaOpts for running specific tests
only and overall makes things easier to reason about from a
developer perspective with fewer (required) layers of
indirection you see and need to understand when debugging.

But, this has also caused problems. Specifically, it means
developers have to use the same version of Chrome locally
as we specify in package.json which isn't very flexible. While
we could try to keep this up-to-date roughly, that too isn't
an option because the secure environments we recommend for local
use (Quibble and Fresh-node) both use a Debian distro with
typically older versions of Chromium than your local auto-updating
Google Chrome.

For now, let's go back to moving the responsibility of installing
chromedriver together with the responsibility to install Chrome
itself.

== Changes ==

For CI, nothing changes (it already installs both).

For developers using Quibble, Vagrant or Fresh nothing changes
(already installs both).

For developers who make their own secure environment, they will
need to make sure chromedriver is installed, just as we required
between 2017 and Aug 2019 before my commit 1955a8aa56.

== How ==

wdio-chromedriver cannot start a foreign install because the
protocol can change between versions, so unfortunately together
with not using chromedriver from npm, we also can't use
the wdio-chromedriver autostart mechanism. Instead, I'm bringing
back Antoine's shell script that did this prior to ebda397c54.
But, with a few tweaks so that it forwards shell arguments,
this way developers continue to enjoy the benefit of 1955a8aa56,
which is that 'npm run selenium -- --spec foo.js' works.

Bug: T234610
Change-Id: I03ca94315d0611d2b6abccc12cf9076d41b2c00e
2020-01-17 17:03:54 +00:00
Timo Tijhof
ec8a6c4b56 wdio-mediawiki: Release 1.0.0
Bug: T236927
Change-Id: Ifef16775e282a31a2ec750e6a98ac1f9615d277a
2019-11-05 14:47:48 -05:00
Ed Sanders
3c2cea4559 build: Update linters and fix errors
Change-Id: Ieb1eff174f5168bf6c9e9aaeb58ec1a1bcd33538
2019-10-23 11:22:41 +01:00
jenkins-bot
3c69201ec3 Merge "eslint: Use correct global values, and use jquery rules in selenium tests" 2019-10-08 21:45:33 +00:00
Reedy
8631daae64 Disable flaky Selenium test
Bug: T226144
Change-Id: Ib49898617ba419f709b249ae9a05d9cb7b8e4e9d
2019-10-08 20:50:37 +00:00
Ed Sanders
5f3b268c3f eslint: Use correct global values, and use jquery rules in selenium tests
Change-Id: Ie9fe9fc872db2e4dd0266395f112cc18d3deb807
2019-10-08 13:12:17 +01:00
Timo Tijhof
22d149c3f7 selenium: Fix more inefficient MWBot use and simplify wdio-mediawiki Api
This does the same for the other specs, as previously done to the
page.js spec in 058d5b7cd8.

* rollkback: From 6 api logins to 4 api logins.
  Before (2x3): admin for edit, admin for createaccount, vandal for edit.
  After (2x2): admin for edit + createaccount, vandal for edit.

* recentchanges spec: No difference, but updated pattern for consistency
  so that if it is extended in the future, it will be natural to re-use
  the bot object instead of creating a new one.

* watchlist spec: From 3 api logins to 1 api login.
  Before: admin for createaccount, admin for edit, admin for edit.
  After: admin (re-used)

* user spec: From 2 to 1 api login.

Also:

* Remove the now-unused Api.edit() and Api.delete() anti-pattern
  methods, as these are nothing but one-line shortcuts to the
  already one-line invocation of bot.edit() and bot.delete(),
  except that they bypassed the current bot object, causing
  inefficient repeat logins in way that was non-obvious.
  Migration is simple and won't be required until other repos
  upgrade to the next wdio-mediawiki version (not yet released).

* Make 'bot' a mandatory parameter for the createAccount, block,
  and unblock convenience wrapper methods.

* Move the vandalizePage() method from HistoryPage to rollback spec,
  as it had no connection with that page object or the action=history
  interface, and document why it can't (yet) re-use its bot object.

Bug: T234002
Change-Id: Id6e995916566f7dd7b618892295198b897fbee2e
2019-10-04 18:16:28 +01:00
Timo Tijhof
ebda397c54 selenium: Improve README docs
Simplify the README to only mention the bare minimum about
how to use WDIO itself. The rest is deferred to the various wiki
pages, which are more up to date.

Also removes selenium.sh file, which is no longer used as of 1955a8aa56,
I forgot to re-remove it during one of the rebases.
It is now supported to pass arguments to 'npm run selenium' as well.
Previously, arguments were only supported for 'npm run selenium-test',
which required manual starting of a chromedriver.

Bug: T214708
Change-Id: I5951af9146ac5fdce8d6506d703620049d6efe74
2019-10-03 17:17:28 +00:00
Ed Sanders
00b2315132 Build: Update eslint-config-wikimedia and fix errors
Change-Id: I9459dcee08ea7f5b54c41a2cfde965b011099f57
2019-10-03 08:33:21 -07:00
Timo Tijhof
46586a243c selenium: Replace ES5 one-var assignments with const/let per line
The one-var rule only applies to 'var' where it matters that we
don't let the engine implicitly hoist variables leading to
confusing code that may be unsafe to refactor in a straight-forward
manner.

This doesn't apply to ES6 const and let. While I updated the
rule in 1955a8aa5 to allow ES6, I did not enforce it. Fixed now.
When assigning a value, each assignment should be its own
statement (disallow awkward comma separated assignments).
When not assigning a value, and the lines are next to each other,
they should be in one statement. This makes sense for this small
directory and might make sense to propose for the wikimedia preset
at some point.

Note that the rule I added was not required to make the build
pass. The changes I made are allowed by default by the wikimedia
preset for es6+. The rule I added disallows the previous way.

Change-Id: I26cda095a8a4589084e36273038877f2dd1fc50b
2019-10-01 02:18:19 +00:00
Kosta Harlan
640b0b4943 Selenium: Hide VE welcome and beta dialogs
Remove uses of setLocalStorage (incompatible with chromedriver >= 75)
and also requires slightly fewer requests since BlankPage.open()
doesn't need to be invoked.

Bug: T234002
Change-Id: I4cfb4fe17a3c99bfcb7ff39ac6db60f5c5e8a687
2019-09-30 21:57:23 +02:00
jenkins-bot
b120fa4841 Merge "selenium: Fix inefficient use of MWBot in specs/page.js" 2019-09-30 18:57:01 +00:00
jenkins-bot
40c9d733e6 Merge "selenium: Use async-await for wdio-mediawiki/Api internals" 2019-09-30 18:56:52 +00:00
jenkins-bot
70987ee4c0 Merge "selenium: Remove "RunJobs" wait from specialrecentchanges test" 2019-09-30 18:34:21 +00:00
Timo Tijhof
058d5b7cd8 selenium: Fix inefficient use of MWBot in specs/page.js
This test previously took 4 minutes to run locally and ended up
running the MWBot.login process 9 times.

After this, the specs/page tests only log-in once.

Bug: T234002
Change-Id: I374620a01f49d4da559070d0982bdbe4c1269e2e
2019-09-30 14:47:00 +01:00
Timo Tijhof
3845dba69e selenium: Use async-await for wdio-mediawiki/Api internals
Bug: T234002
Change-Id: Ie4ad5248f832dd57f35710e0e9a91250e061b0bb
2019-09-30 14:47:00 +01:00
Timo Tijhof
4bd69c7536 selenium: Remove "RunJobs" wait from specialrecentchanges test
This test was consistently reaching the RunJobs timeout of
10 tries and then giving up. This happens in CI, where it wasted
about ~ 5 seconds, and locally where it takes about 30s for mw.

Like so:
> RunJobs through requests to the main page (run 1).
> RunJobs detected 12 more queued job(s).
> RunJobs through requests to the main page (run 2).
> RunJobs detected 12 more queued job(s).

Etc, until it reaches run 10 and gives up. This also suggests
the whole thing isn't wokring, but that's a separate matter.

First and foremost, RecentChange objects are saved from a PRESEND
deferred update, which means it does not require a job queue wait
in order to appear on Special:RecentChanges.

This was added in e908d347ef (T199446) "to keep the number of
unrun jobs low". The idea being that this test makes an edit via
the API, which means it creates jobs without running them. On
the other hand, there's also lots of test steps that view pages
but don't create jobs, which would make this optimisation premature.
If and when we do encounter a test failing due to a job backlog,
I'm confident we can find a better solution at that time.

Bug: T234002
Bug: T225730
Bug: T199446
Change-Id: I9ef8c5b65d4b636572569912f04f48ed40aa0564
2019-09-29 02:32:24 +00:00
Timo Tijhof
776321bf1a selenium: Remove deprecated legacy methods
These are from 2018, prior to introducing wdio-mediawiki in
commit 16a4d9da7b. Some extensions referenced these pageobjects
files through escalating "../../" references.

None of these are seen in Codesearch anymore, as well as no
references to these deprecated methods by other means.

Change-Id: Idbc373f13f9767cecd6404922b5c9773d796dda5
2019-09-29 02:31:51 +00:00
Timo Tijhof
1955a8aa56 selenium: Upgrade from webdriver v4 to v5
* Options no longer needed or no longer exist in wdio v5:
  - coloredLogs: Now always on. The underlying 'chalk' library can still
    be influenced via the FORCE_COLOR environment variable.
  - screenshotPath: Removed. Was already disabled in our config.
  - deprecationWarnings: Meh.
  - 'sync: true' – On by default when `@wdio/sync` is installed.
    The wdio v5 config generator doesn't recommend setting manually.

* The selenium.sh script was removed. It existed to start and stop
  chromedriver for local use by developers. This is now done by
  the wdio-chromedriver-service. In WMF CI, Quibble starts its own
  chromedriver (as optimisation, reused across gated repos),
  which is why the 'selenium-test' entry points remains and skips
  this.

* The wdio-mediawiki package now requires wdio v5 and Node 10.
  This doesn't affect extension repos because versions are pinned.
  Upgrade may happen at the earliest convenience.

* Several WDIO methods changed names or signature. Full list at:
  <https://github.com/webdriverio/webdriverio/blob/v5.13.2/CHANGELOG.md#v500-2018-12-20>
  Highlights:
  - browser.element() is now browser.findElement() with "$()" as alias.
  - browser.localStorage replaced by browser.setLocalStorage.
  - browser.deleteCookie() requires `name` param. To delete all at once,
    there is a new method browser.deleteAllCookies().
  - Commands that return data no longer wrapped in `{ value: … }`.
    Values are now returned directly.
  - Custom config keys are now under browser.config instead of browser.options.
    Renamed our username/password keys to be mw-prefixed, to avoid clashes
    and reduce confusion with similar config keys.
  - browser.click(selector) and browser.getText(selector) no longer exist.
    Use $(selector).click() or .getText() instead.

* Fix "no such alert" warning from specs/page.js by removing the apparently
  redundant code.

Bug: T234002
Bug: T213268
Change-Id: I908997569ca8457997af30cb29e98ac41fae3b64
2019-09-29 02:59:44 +01:00
Timo Tijhof
50cd683080 selenium: Restore sauce user/key configuration for wdio
I removed these in e78484109a because they seemed redundant
given that the library used by wdio-sauce-service already reads
these when present. However, our current version of this package
clobbers this unconditionally with config.user/config.key, thus
not letting it reach that default.

Also add sauceConnect:true which means developers can run
localhost tests against sauce labs if they so choose.

Change-Id: I8d31a23374b2b9b6cd6f1405c7a2f1001da08f1a
2019-09-29 01:39:21 +01:00
Timo Tijhof
e78484109a selenium: Only load 'sauce' service when needed
Also, remove the redundant unprefixed `user` and `key` options.
These would be cleaner to set through `sauceConnectOpts`
as `sauceConnectOpts { username: …, accesskey: … }`, but even
that isn't needed because wdio-sauce-service already reads these
same environment variables directly. No further config needed.

Also remove the duplication of default variables we don't have
any particular preference for yet so that enjoy improvements to
these when upgrading.

Change-Id: I0d4802f83509b0b49f775560b508d9929ae9979e
2019-09-20 18:52:20 +01:00
Lucas Werkmeister
55ec3e6ab1 wdio-mediawiki: release 0.5.0
Change-Id: Ib6bfcb18aed1ea24753ea8e2e15796c9fff84cf0
2019-09-18 16:07:28 +00:00
jenkins-bot
e2c20de40d Merge "wdio-mediawiki: fix @since versions" 2019-09-17 19:06:31 +00:00
Lucas Werkmeister
9d5c69dd77 wdio-mediawiki: update signatures in README.md
Add parameter types everywhere, and mark the parameters of blockUser and
unblockUser as optional.

Change-Id: I4713fed9f073801333796d974fff9d2d7059d1f0
2019-09-17 18:03:38 +02:00
Lucas Werkmeister
ce904f4bd5 wdio-mediawiki: extract bot() function
This functionality was previously copy+pasted for most other methods,
and is also useful externally, to make API requests that are not covered
by other methods in Api.js.

createAccount() needs a different type of token, so for now we leave it
alone. (Perhaps the token type could become a parameter of bot() later?)

Change-Id: Ica24213a1f0d651bfc3fbffe24b63251a4841658
2019-09-16 18:51:25 +02:00
Lucas Werkmeister
63ea34e7fe wdio-mediawiki: fix @since versions
The initial version of this package (added in change I547a7899e7, commit
16a4d9da7b) was 0.1.0, not 1.0.0.

Change-Id: I39511be15ea8ec27692f8547f375349bb6384a6b
2019-09-16 18:39:50 +02:00
James D. Forrester
aa7133ce86 wdio: Switch to dots reporter for brevity
Change-Id: Ica6cc3e4fc445f39ba911db14c58a486f32f7f89
2019-08-23 20:51:00 +00:00
Adam Wight
fae72d0bb5 Remove old comment and unused setting
Change-Id: I813c90197ba0fc76d493a47f83107ba4bb8dff2a
2019-08-05 16:29:51 +02:00
Antoine Musso
2daa2a7de1 selenium: stop running extensions/skins specs
So that we can use different framework and let developers easily upgrade
webdriver.io, selenium tests for extensions and skins must now be run
directly at the root of the extension or skin:

  cd extensions/Foobar
  npm install
  npm run-script selenium-test

All repositories had the entry point introduced and Quibble 0.0.34
supports that new scheme. Thus Wikimedia CI runs extensions / skins
tests twice: once via mediawiki/core and once via the 'selenium-test'
script.

Remove the glob specs for extensions / skins from wdio.conf.

Bug: T199116
Change-Id: If19db4e45b56989e2c15240a9ed0e8a55a940fb9
2019-07-25 21:43:08 -07:00
jenkins-bot
0854352fa7 Merge "Do not hardcode square brackets in "rollback link"" 2019-07-21 19:41:24 +00:00
jdlrobson
aaea6a0fc0 Do not hardcode square brackets in "rollback link"
Additional change:
* standardize on "optional" lowercase in qqq messages

Bug: T219948
Change-Id: I7d79c0ca534bff7165975943d5fa22dfe0a616db
2019-07-18 14:30:23 -07:00
Pablo Grass
d0b77d72da wdio-mediawiki: Release 0.4.0
a1e51bf943 unpublished 3 RunJobs methods
They do not appear to be used according to wmf codesearch
and, given their limited usefulness, are unlikely to be used elsewhere.

Change-Id: Iaefe6f71320c2c3ab86468bf827b6e8d2e80095d
2019-07-18 17:23:50 +02:00
jenkins-bot
dfec83932f Merge "Selenium: replace UserLoginPage with BlankPage where possible" 2019-07-08 17:00:13 +00:00
Željko Filipin
97c13ffeb8 Selenium: replace UserLoginPage with BlankPage where possible
When using local storage, any page has to be open. UserLoginPage is usually used.
BlankPage should be slightly faster to load. It also makes it more clear than
any page would do the job.

Change-Id: I50b23993065ad6b093a6cc951d00b0bf7a3d5e68
2019-07-08 13:44:32 +00:00
Ed Sanders
689d07b81d build: Update eslint-config-wikimedia to 0.13.0
Change-Id: I7df5840bc97f8bbcd8cfc875c2b48b3061ef2c9e
2019-07-05 13:32:26 -07:00
Kosta Harlan
2fb62de70a selenium: Skip flaky rollback test
Bug: T219440
Change-Id: I2199b7e7d4f7ba98a80ddfc568cf9957eba36182
2019-06-27 17:21:08 +00:00
Kosta Harlan
f0162afbc9 Disable flaky Selenium test
Change-Id: Ia3f2403e452f4476238b349c9d6a6f8135267456
Follows-Up: Iaf7e095b3bb34072eea6bcac76ba29358b14cc09
Bug: T226144
2019-06-19 21:43:47 -04:00
Timo Tijhof
c3e379d603 selenium: Skip another flaky Rollback test
Bug: T220479
Change-Id: Ie523e719f5c7df959ef63930edaff1a80e09ff04
2019-06-13 18:22:11 +01:00
Adam Wight
89a00d2838 selenium: Skip flaky Rollback test
Sometimes the element doesn't appear.  This is breaking during gate-and-submit,
so skipping until it can be fixed properly.

Bug: T219440
Change-Id: I7286eb5499e34146acf5da3180b665436569a18c
2019-06-10 15:18:12 +00:00
James D. Forrester
effb830977 selenium: Re-add all tests and wdio-mocha-framework, now v0.6.4
This reverts commit c3878c08b5.

Now that we're running on node10, this will fail until we fix
things.

Bug: T213268
Bug: T222406
Change-Id: I5935fc5d5bc23978e50275d3c99ac870b3b82f49
2019-06-03 12:56:07 -07:00
James D. Forrester
c3878c08b5 selenium: Temporarily drop all tests and wdio-mocha-framework
This is so that we can migrate to node 10 in CI. It should only land
for an hour or so, and is to be reverted as soon as we get CI up to
node 10 and working, lest our suites of selenium tests become
subject to bitrot.

Bug: T222406
Change-Id: I9473e0213c070a0e963913fd81062c6bbf9ec2f2
2019-06-03 14:33:42 +00:00
Adam Wight
878f2fd9c4 Exclude FileImporter browser tests
These test must be run from the extension's repo, because they use a custom
script to modify LocalSettings.php.

Bug: T190829
Change-Id: I920c7faa3ce91f1560f383575aa6a6adfcadd9c7
2019-05-20 14:03:16 +02:00
jdlrobson
b781ccb2c2 selenium: Asynchronous methods should be returned to browser.call()
Api.edit is asynchronous and is wrapped in a browser.call but
should be returned.

Follows-up 341320457c.

Bug: T220479
Change-Id: Id0e3549e93a967165bdc1bb758ddef8d59ccc300
2019-05-09 12:15:12 +00:00
jenkins-bot
35afb25421 Merge "Temporarily skip rollback test" 2019-05-07 21:50:52 +00:00
jdlrobson
ddf7a50057 Temporarily skip rollback test
This test is proving flakey (seen in Minerva and MobileFrontend)
Let's skip this until we've worked out the problem.

Bug: T220479
Change-Id: I3629d4109d8e0c5c4da0c7fb0b82cf59290c0db9
2019-05-07 13:47:58 -07:00
jenkins-bot
04fd74f44f Merge "selenium: Disable Minerva wdio tests" 2019-05-07 19:55:49 +00:00
Timo Tijhof
0b032e0509 selenium: Disable Minerva wdio tests
To match the Minerva repo per I3a48ecb768a, currently
requires duplication of logic here because Quibble ignores
per-repo settings (tracked as T199116).

Bug: T222517
Change-Id: I857458c4fd9185dea03566183f40216252c533cd
2019-05-07 01:49:15 +01:00
tzhelyazkova
3990e0bbc7 Improve rollback tests setup by extracting repeating logic to HistoryPage object
This also removes the helper method waitForScriptsToBeReady() and uses the more
general waitForModuleState() method directly.

Bug: T220479
Change-Id: I6be81ad68720449ef03b6a60b4b329040f236c72
2019-04-30 18:17:00 +02:00