Commit graph

21 commits

Author SHA1 Message Date
DannyS712
676d8a6488 Selenium: provide CreateAccountPage in wdio-mediawiki
So that it can be used by extensions too. Use case:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GrowthExperiments/+/702893

Change-Id: Ie1c71484526718b91c43ae881b0230ac4f1cef61
2021-07-08 03:50:24 +00:00
Željko Filipin
24e2f591f2 selenium: Delete tests disabled for more than 1 year
Rollback with confirmation
- should offer rollback options for admin users (Kosta Harlan, 2 years ago, 2fb62de)
- should offer a way to cancel rollbacks (Adam Roses Wight, 2 years ago, 89a00d2)
- should perform rollbacks after confirming intention (Jon Robson, 2 years ago, ddf7a50)
- should verify rollbacks via GET requests are confirmed on a follow-up page (Timo Tijhof, 2 years ago, c3e379d)

Rollback without confirmation
- should perform rollback via POST request without asking the user to confirm (Sam Reed, 2 years ago, 8631daa)
- should perform rollback via GET request without asking the user to confirm (Kosta Harlan, 2 years ago, f0162af)

User
- should be able to change preferences (Kunal Mehta, 3 years ago, 4b0cde2)

Bug: T280652
Change-Id: Ieaccf37ad016f2e811aeb98d2bd2f061c9b13fbf
2021-04-23 13:25:59 +02:00
Ed Sanders
8b720e9bd6 eslint: Update to eslint-config-wikimedia 0.16.0
* valid-jsdoc replaced with jsdoc plugin
* New /selenium config

Change-Id: I471eebac0312cb25c539c3f6a3ecfc7cfd4ed8d6
2020-06-02 21:32:56 +01:00
Ed Sanders
d94f90e088 eslint: Code style fixes for upcoming config change
Change-Id: Ief44c0bb26c5a1c1773cab5dba51d5e856612bf7
2020-05-14 22:19:55 +01:00
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
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
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
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
Ž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
Željko Filipin
e552e95f71 Selenium: Daily Jenkins job targeting beta cluster should run only tests that pass
Selenium tests run fine when targeting MediaWiki installation in
MediaWiki-Vagrant and in Jenkins, but fail when targeting beta cluster.
Until tests are refactored to run without failure for beta cluster, let's disable
failing tests.

Bug: T185011
Change-Id: I12da893e7d624d4ebe478bccf0706aa07c965796
2018-09-04 12:47:07 +02:00
Kunal Mehta
4b0cde2a09 Disable "...able to change preferences" browser test
It's incredibly flaky.

Bug: T199446
Change-Id: I5372a285dab4f5f032ae340d9fd30b9c7c8bf72a
2018-07-31 12:28:31 -07:00
Jakob Warkotsch
d96ca0d6a9 Browser tests: extract commonly used getTestString function
Extracting this function into a Util module reduces redundancy for
existing and future tests in core and extensions.

Change-Id: I5c5e9b22af5406f347636b22e68657b2674db6c9
2018-06-20 13:06:45 +02:00
Ed Sanders
4ffbfabf16 Selenium tests: Use assert.strictEqual instead of assert.equal
assert.equal is deprecated

Change-Id: I2f83d596db2ad475de5e005baa849782261d433e
2018-06-06 11:53:29 +01:00
Timo Tijhof
16a4d9da7b selenium: Initial version of wdio-mediawiki package
This is new package will be reusable by other repositories for
their browser tests, without having to reference the internal
selenium/pageobjects/ directory from MediaWiki core.

In addition to not requiring direct imports, it will also avoid
problems in the future by allowing the package to be versioned
and iterated upon without forcing an atomic global upgrade
(or broken master builds), everytime we change something.

See wdio-mediawiki/README for details.

Within MediaWiki core itself, the package is used using the
'file' specifier in its package.json, so that we always test
and develop using its working copy, which makes drafting and
testing changes easier.

Also misc changes to make wdio.conf easier to understand.

Bug: T193088
Change-Id: I547a7899e7a97693a93567dd763784e637433d55
2018-05-09 14:43:30 +00:00
Timo Tijhof
2729bf4653 selenium: Minor clean-up in preparation for packaging
This is functionally a no-op, purely refactoring (mostly style).

* Consistently require packages at the top of a file.
  (e.g. MWBot in edit.page.js).

* Remove unused .call(this) from mwbot interaction closures,
  which didn't use 'this'.

* Use Node.js regular Promise chaining with then(), instead of
  complex bluebird.coroutine generator function yields, which
  are intended to emulate async-await, but the syntax is quite
  error-prone for inexperienced developers and hard to debug.
  Once we require Node 7+ for the selenium tests, we can use
  async-await here natively, but until then, might as well use
  regular then() syntax, which we already use elsewhere in the
  tests, and is also what MWBot documentation uses.

* Also applied some minor whitespace changes for consistency
  among these files and other MediaWiki JS. E.g. no empty line
  before the first statement of a function. Add a new line between
  different methods, and between the end of a class and the
  export statement.

* Remove 'use strict' from test files. The patterns that would expose
  the bad non-strict behaviour are mostly already forbidden by ESLint,
  and the run-time optimisation to disable non-strict can't be noticed
  in tests (more useful in prod where e.g. the same process would run
  a function 1 million times). Main reason here is to keep things
  simple for new-comers and reduce boilerplate, given that these tests
  will mainly be worked on by browser-JS developers, not Node.js devs,
  and we don't currently use strict mode in our front-end code, either.

* Remove unused bluebird dependency.

Bug: T193088
Change-Id: I59f9211299e8e884c28c7733bcee3b7b28542610
2018-05-08 14:42:59 +00:00
Jdlrobson
33ba3cfebb Revert "selenium: add new message banner test to user spec"
This reverts commit 6ca3e221d1.
This is breaking CI for the Minerva skin and Echo as Echo changes how
this interaction works. When the browser test tries to locate the
div.usermessage it has moved so fails.

This test needs to be rewritten to take this into account.

On a side note, given usermessage is generated by all skins (and not
in core) there is a big argument to be made that this shouldn't be in
core but in the individual skins. MinervaNeue the mobile skin notably
does not use this class so this test would always fail on a mediawiki
instance which only uses the Minerva skin.

Bug: T185928
Change-Id: I43b6cf328aaf4a4fded0bb9746716c4cc9d8f364
2018-01-29 20:41:21 +00:00
addshore
6ca3e221d1 selenium: add new message banner test to user spec
Change-Id: I92dc612d215d1d3eb8dff02c2ff4d57da0105d69
2018-01-24 14:06:01 -08:00
Željko Filipin
fedebb1834 Disable VisualEditor welcome dialog when running Selenium tests
Bug: T164721
Change-Id: I7b5f73c6fbaaa221ac1b689344f9015fb903220f
2017-07-07 11:54:46 +02:00
Željko Filipin
853cba1deb Create users and pages for Selenium tests using action API
This will make tests slightly more robust.

Bug: T164721
Bug: T167502
Change-Id: I9b2fea77b28af4f7f521490a0105e7d04730bc87
2017-07-07 04:59:14 +00:00
Željko Filipin
7aee98758a Selenium tests in Node.js using WebdriverIO
Introduce the WebdriverIO browser testing framework driven by Node.js.
The overall intents are:
* have MediaWiki core to provide a platform to run tests that is shared
  between core and the extensions.
* phase out ruby driven browser tests eventually.

Code is namespaced in sub directory /tests/selenium
The 'pages' sub directory provides helper representing a MediaWiki page
such as Special:Login and human friendly helpers to interact with the
elements.

Add Grunt task webdriver:test.

Provide a npm script to easily spawn/dispose chromedriver and run above
grunt task.

wdio.conf.js provides all the configuration. It defaults to point to a
MediaWiki-Vagrant installation on http://127.0.0.1:8080. Can be
overriden with environment settings as needed.

glob patterns (specs) are made absolute paths from MediaWiki root path
that let us run the tests either from the root path (eg the npm
wrapper or from the tests/selenium directory when invoking wdio
directly. wdio assumes they are relative to the current working
directory, hence the normalization.

wdio.conf.jenkins.js extends the configuration and is used solely for
Jenkins.  The switch is done from the Gruntfile.js whenever JENKINS_HOME
is set.  Specially we want junit reports to be generated.

Provide a more specific eslint configuration.

References:

* MALU https://phabricator.wikimedia.org/source/malu/
* T151442 Research WebdriverIO
* T151443 Research Nightwatch.js

Bug: T139740
Signed-off-by: Antoine Musso <hashar@free.fr>
Change-Id: Ibe7a004a120e82af637ab3e31b725de743134c99
2017-03-14 12:20:32 +01:00