selenium: Minor clean-up in preparation for packaging
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 2 May 2018 03:48:36 +0000 (04:48 +0100)
committerKrinkle <krinklemail@gmail.com>
Tue, 8 May 2018 14:42:59 +0000 (14:42 +0000)
commit2729bf4653ca87c427f696f53624217d62096a25
treeb6098b2d908b5d57d427b35ff9bf6e02051efda5
parent911e74ea89864f3b0f5455f46d983d280df95e93
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
12 files changed:
package.json
tests/selenium/pageobjects/createaccount.page.js
tests/selenium/pageobjects/delete.page.js
tests/selenium/pageobjects/edit.page.js
tests/selenium/pageobjects/history.page.js
tests/selenium/pageobjects/page.js
tests/selenium/pageobjects/preferences.page.js
tests/selenium/pageobjects/restore.page.js
tests/selenium/pageobjects/userlogin.page.js
tests/selenium/specs/page.js
tests/selenium/specs/user.js
tests/selenium/wdio.conf.js