Commit graph

95 commits

Author SHA1 Message Date
Ed Sanders
d4a2191957 build: Update eslint-config-wikimedia
Change-Id: I5a8768e1a7e3960d2c822c5f842c0ffa29e2f08b
2018-09-11 23:25:26 +01:00
James D. Forrester
a6242eff16 Bump qunit from 2.6.0 to 2.6.2
Change-Id: Id7f47eee423c2fc1289f468c6622b952814d8912
2018-09-10 13:37:48 -07:00
James D. Forrester
b0df641d31 build: Update grunt-karma from 2.0.0 to 3.0.0
Bug: T194280
Change-Id: Iba043c036c06bebd961896f390063ca9a0129eb2
2018-09-10 09:46:17 -07:00
jenkins-bot
0cbccb51b4 Merge "build: Bump most devDependencies to latest" 2018-09-07 21:54:47 +00:00
James D. Forrester
3f767b2468 build: Bump most devDependencies to latest
grunt-stylelint         0.10.0  →  0.10.1
 karma                    2.0.2  →   3.0.0
 karma-firefox-launcher   1.0.1  →   1.1.0
 karma-qunit              2.0.1  →   2.1.0
 postcss-less             1.1.5  →   2.0.0

This reduces our `npm audit` alerts down to just those from grunt-karma.

Bug: T194280
Change-Id: I7d321dd715db9d214e65ed7197e917cb7c6b14f3
2018-09-06 17:01:45 +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
Željko Filipin
0a56fd356d Selenium: selenium-daily NPM script
selenium-daily just calls selenium-test. It's needed for daily Jenkins job targeting
beta cluster. The script might seem redundant, but it provides flexibility. In case
a repository does not want to run all tests daily, that's easily fixed by updating
the the script.

Bug: T188742
Change-Id: Idf86f94cc31abda4bfcdc1ac4eba29206d9c91f9
2018-08-29 13:00:16 +00:00
Ed Sanders
606f2783c1 build: Update eslint-config-wikimedia to 0.7.2
Change-Id: Ibdf9cc013e1265ef461169ec2227652eaf917900
2018-08-14 19:24:51 +01:00
James D. Forrester
6450fc980b build: Upgrade eslint to 5.x
Add two exceptions for max-len and no-prototype-builtins.

Change-Id: I5d3f7a3e282a237fb5de9f0eb29b579a08c32652
2018-07-05 16:58:14 -07:00
Željko Filipin
9029425a8a Update grunt and grunt-contrib-watch to resolve vulnerabilities
`npm audit` found 27 vulnerabilities (11 low, 12 moderate, 4 high).
`npm audit fix` fixed most of them.
There are 8 vulnerabilities remaining (2 low, 6 moderate).

Bug: T194280
Change-Id: I05d80bc38d16be8249a27d94dad8e13c65139545
2018-06-15 13:46:46 +02:00
addshore
0f472c4bc1 npm selenium command, use bash
On Windows this seems to complain unless bash is specified

Change-Id: I4515c851ffea143d4c1c6d111ffdd64b62f9f304
2018-06-11 07:31:02 +00:00
Ed Sanders
5e18d925e7 build: Introduce eslint-plugin-qunit and enforce
Change-Id: Iefe06cc865c458000ca5350c2d9205f5b768bac8
2018-06-05 21:58:25 +01:00
Željko Filipin
dba1de4627 build: update to grunt-contrib-watch@1.0.1 to resolve a vulnerability
Recommended by `npm audit`.

Moves us from

21 vulnerabilities ... 12 Low | 5 Moderate | 4 High

to

20 vulnerabilities ... 11 Low | 5 Moderate | 4 High

Bug: T194280
Change-Id: I9d6d2fed4ca3d4c43d9b5085873210493081f7e0
2018-05-11 16:30:32 +02:00
Željko Filipin
5dce51470d build: Update Karma to v2.0.2
The current version has a couple of dependencies with high severity
vulnerabilities.

Bug: T194280
Change-Id: I3f9f36a6a5c2ba1716b91d14e59bc60f9e0ff513
2018-05-10 15:58:32 +00:00
jenkins-bot
45258656ab Merge "build: Update Karma's qunit from 2.5.0 to 2.6.0" 2018-05-10 14:36:33 +00:00
Timo Tijhof
3166ab5f00 build: Update Karma's qunit from 2.5.0 to 2.6.0
Follows-up 065b21b4bd which updated the copy of QUnit used
on Special:JavaScriptTest.

Change-Id: I24b17c9c266f58d48caa9c3392496c469b3ddba0
2018-05-10 14:12:17 +01:00
Željko Filipin
d888d84e60 Fix a critical NPM package vulnerability
NPM v6 audits packages during installation. This is the only critical vulnerability.

Bug: T194280
Change-Id: I5fe35067919ad67b9781701136e290eda17c3afa
2018-05-10 14:13:45 +02: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
Timo Tijhof
810afd33e0 selenium: Run wdio directly without grunt
Doesn't seem to add anything, except complexity.

This has the benefit of matching more closely the way the README
recommends running individual tests.

Also add a check for 'chromedriver' before running it.
Normally the -e and pipefail would suffice, but because
it runs in the background, the error can be buried,
hard to find, or even not cause exit code to be set
properly. Thus, do a simple 'hash' check that will
print a useful command and exit cleanly.

Before:
> $ something &
> [1] 57922
> -bash: something: command not found
> [1]+  Exit 127                something
> $ echo $?
> 0

After:
> $ hash something
> -bash: hash: something: not found
> (exit: 1) $ echo $?
> 1

Change-Id: Id95f18927b5443defe679a77a82c5cbdd127c716
2018-04-30 21:54:15 +00:00
jenkins-bot
b824f88a95 Merge "selenium: Abstract test command behind 'npm run'" 2018-04-23 16:53:11 +00:00
Timo Tijhof
83425bd0a8 build: Switch QUnit package from deprecated 'qunitjs' to 'qunit'
This should fix the deprecation warning from npm in CI logs.

Change-Id: I5d02dd8d6a86123d7935db51b8d0b5d88218869f
2018-04-23 16:32:50 +01:00
Timo Tijhof
c0600fd29c selenium: Abstract test command behind 'npm run'
This makes it possible to use in Quibble. Right now, Quibble
cannot use 'npm run selenium' yet because it sets up its own
chromedriver, which would conflict with selenium.sh.

But, in preparation for Id95f18927b5, we can at least abstract
the test command so that it can easily be changed without having
to update Quibble and without having to worry about it being the
same in all MediaWiki branches.

Bug: T179190
Change-Id: I622ec3bf36746502cae891cc6bec23982b21f876
2018-04-23 15:56:54 +01:00
Željko Filipin
d972780d8b Selenium: move logic for running tests from package.json to selenium.sh
Just running `npm run selenium` in CI does not work. If WebdriverIO fails, the
job still passes since the last command to run is  `killall chromedriver`.
Reusing the script from CI that starts and stops Chromedriver should fix the
problem.

Bug: T179190
Change-Id: If29227263d23a3e4f26e2329dfa13c49f976cf8e
2018-04-13 14:21:29 +00:00
James D. Forrester
69b1210838 build: Bump postcss-less up to 1.1.5 from 1.1.3
Problem over, we think.

Bug: T190269
Change-Id: I0a94c99fb75613b03f15954512744dec63fd779e
2018-04-04 17:43:15 -07:00
James D. Forrester
9adae152b2 build: Bump devDependencies to latest
grunt-stylelint             0.9.0  →  0.10.0
 stylelint                   8.2.0  →   9.2.0
 stylelint-config-wikimedia  0.4.2  →   0.4.3

Change-Id: I612cf96d99e2af67b3f7ef3284657f66f3e18d2e
2018-04-04 17:40:46 -07:00
Željko Filipin
c2792982c5 Selenium: install bluebird, mwbot dependency
Bluebird is implicitly installed on my machine, probably because I have a recent npm version. It needs to be explicitly installed in MediaWiki-Vagrant, probably because of an older npm version.

Bug: T190914
Change-Id: I9c704502fb5e20abf9b21d483723eb55b6fb3875
2018-03-28 13:15:57 +02:00
jenkins-bot
33fa8c095c Merge "Selenium: Replace nodemw with mwbot" 2018-03-21 15:17:06 +00:00
jenkins-bot
edf7224639 Merge "Selenium: Upgrade WebdriverIO to 4.12.0" 2018-03-21 14:37:30 +00:00
Željko Filipin
9c5fa5567b Selenium: Replace nodemw with mwbot
Bug: T181284
Change-Id: I012a5cc6a7f30a8652cbad87293eb119fa2e405f
Depends-On: Ic69be92c2b0b7a08a9b8cc417a40ebb38f249ea3
2018-03-21 13:34:37 +01:00
Željko Filipin
771c5a7814 Selenium: Upgrade WebdriverIO to 4.12.0
Bug: T180144
Change-Id: I8d34e2240fe76798c99315a54ea5bab63b2409e9
Depends-On: Ic69be92c2b0b7a08a9b8cc417a40ebb38f249ea3
2018-03-21 12:20:42 +00:00
Željko Filipin
15624aaeb9 Lock postcss-less to v1.1.3 because v 1.1.4 breaks CI
mediawiki-core-npm-node-6-docker Jenkins job is failing with
`Warning: Task "stylelint:src" failed.`

Bug: T190269
Change-Id: Ic69be92c2b0b7a08a9b8cc417a40ebb38f249ea3
2018-03-21 13:15:01 +01:00
Timo Tijhof
b043cec2d7 build: Add 'npm run qunit' command
The running of 'grunt qunit' is unconvenient due to it only working
if the user has grunt-cli installed globally, which should not be
needed because it is already installed in the local directory.

It could be worked around by instructing users to use
`./node_modules/.bin/grunt qunit`, but it would be much simpler
to instruct them to use `npm run qunit` instead.

Unlike 'composer', 'npm' does not come by default with a command
like 'composer exec' that one could pass a command directly
without needing to register it. This is fixed in more recent
versions through 'npx -c', but that's a bit too new to require
in the manual, so adding it as a run-script instead.

Change-Id: I2812b13dbed50612b1626a617ba65f92e212f01a
2017-11-22 10:48:27 -08:00
Ed Sanders
0c84c04a9b build: Upgrade grunt-stylelint
Change-Id: I4c47f1d290802705d061167fe369c130405512e0
2017-10-30 21:49:12 +00:00
James D. Forrester
67a3e5ea7f build: Bump karma devDependencies to latest
karma                   1.5.0  →   1.7.1
 karma-chrome-launcher   2.0.0  →   2.2.0
 karma-mocha-reporter    2.2.3  →   2.2.5
 nodemw                 0.10.1  →  0.11.0
 qunitjs                 2.4.0  →   2.4.1

Change-Id: I1e06189a12fbbc1d62781a4636f192c5b7078c1a
2017-10-30 21:46:42 +00:00
jenkins-bot
be2621ebe6 Merge "build: Bump eslint devDependencies to latest" 2017-10-30 21:43:51 +00:00
Ed Sanders
1064426327 build: Update stylelint
Change-Id: I5a0ccb26a54109e641fd121c6427a71e82e05c74
2017-10-27 13:31:41 +01:00
James D. Forrester
ce869f0bb4 build: Bump eslint devDependencies to latest
eslint                 3.12.2  →   4.9.0
 grunt-eslint           20.0.0  →  20.1.0

Change-Id: I7eb9964fb5d163c5bbcef850f62383cbceb59287
2017-10-26 14:16:23 -07:00
James D. Forrester
6096be63d5 Follow-up 2454f51b27: Upgrade qunit from 1.x to 2.x too
karma-qunit             1.0.0  →   1.2.1
 qunitjs                1.23.1  →   2.4.0

Bug: T170515
Change-Id: Ibc0909ed5fbde715814b0ddb1a1d1c9668d10a85
2017-10-11 16:29:02 +00:00
James D. Forrester
b96e76aeca build: Bump eslint-config-wikimedia from 0.4.0 to 0.5.0
Change-Id: I06010cd6367c1884b5536e7929d3345feba7f305
2017-08-21 17:12:17 -07:00
jenkins-bot
18bf8815c1 Merge "build: Upgrade grunt-eslint from 19.0.0 to 20.0.0" 2017-07-18 18:10:48 +00:00
Ed Sanders
2c03d167fa build: Upgrade grunt-eslint from 19.0.0 to 20.0.0
Most indent and escaping fixes.

Change-Id: I210e2fc3c0ce3148327ef81f824e1ce9f1e269b6
2017-07-18 16:57:03 +01:00
Ed Sanders
098a93b2ed build: Update grunt-stylelint
Change-Id: I05e48d3eb749d192ccd4b837e4b8dc6307d761af
2017-07-18 14:16:24 +01: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
86b867f794 Make running Selenium tests using Sauce Labs easy
If SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are not
defined, tests are run with `npm run selenium`, as usual.

https://www.mediawiki.org/wiki/Selenium/Node.js/Inside_MediaWiki-Vagrant
https://www.mediawiki.org/wiki/Selenium/Node.js/Target_MediaWiki-Vagrant

If the environment variables are defined, to run tests using Sauce Labs
and targeting Beta Cluster, run this:

```
export SAUCE_USERNAME=***
export SAUCE_ACCESS_KEY=***
export MW_SERVER=https://en.wikipedia.beta.wmflabs.org
./node_modules/.bin/wdio tests/selenium/wdio.conf.js
```

https://www.mediawiki.org/wiki/Selenium/Node.js/Target_beta_cluster_using_Sauce_Labs

Bug: T139740
Change-Id: I622d9c55ae595ab772e733388d209623e3a9f81e
2017-05-25 15:57:04 +00:00
Ed Sanders
ee3d5a014f build: Update eslint to 0.4.0 and make pass
Change-Id: Ib230392f332268ac801cf668f399fcefb1cb1cc5
2017-05-04 22:38:03 +00:00
Timo Tijhof
4a8045400a build: Sync qunitjs version for karma with version of Special page
Special:JavaScriptTest loads qunitjs from /resources/lib/qunitjs
which was upgraded in 99aad9397e to 1.23.1.

However, when running QUnit tests from the command-line, QUnit is
loaded by karma-qunit using the npm qunitjs dependency, which was
still at v1.22.0.

Change-Id: Ie24b2b061735fa03a8ed1527d09f65c103506c67
2017-04-18 16:31:42 -07:00
Paladox
7dfe22b45e build: Update karma to 1.5.0, karma-firefox-launcher to 1.0.1
karma:
 Changelog at https://github.com/karma-runner/karma/releases
 https://github.com/karma-runner/karma/compare/v1.1.0...v1.5.0

karma-firefox-launcher:
 Changelog at https://github.com/karma-runner/karma-firefox-launcher/blob/master/CHANGELOG.md#101-2017-03-04
 https://github.com/karma-runner/karma-firefox-launcher/compare/v1.0.0...v1.0.1


Karma v1.1.1 added use of `<script crossorigin="anonymous">` for
the urls it initially loads. While most requests will be done by
MW itself directly (and served locally via the proxy at /w/) the
initial request cannot come from the proxy and is loaded from wgServer
directly. Therefore we need to set crossOriginAttribute=false to override
the new default that v1.1.1 introduced.

Change-Id: I9f5067b949c0a77e46f47c2a110a7b5df5953fda
2017-04-15 03:14:55 +00:00
James D. Forrester
0190d6cbb6 build: Bump grunt-banana-checker from 0.5.0 to 0.6.0
Change-Id: I64d4267d20716b893237f7f13729343593c8d382
2017-03-28 15:08:05 -04:00
Antoine Musso
c35a2c0567 build: karma now reports with mocha formatter
The progress reporter is quite nice to avoid spammy output to the
terminal, but it is not very human friendly when trying to find out what
is breaking.

Mocha has a very nice reporting organized as modules and list items for
each of the tests:

ext.cx.tools.template
  ✖ Equivalent template exists
  ✔ Adapting a template not existing in target language
  ✖ Adapting template having invalid title
  ✖ Template name and params adaptation using templatedata
  ✖ Template params adaptation using templateData - English to French
  ✖ Template params adaptation using templateData - English to Spanish

Add karma-mocha-reporter node module and make it the reporter.

Change-Id: Ic7d848b45e8e5ad3839d8a2bd822b63838319ad7
2017-03-20 19:12:18 +00:00