Commit graph

143 commits

Author SHA1 Message Date
Thiemo Kreuz
3b03ea9bdc Add browser test for preview functionality to MediaWiki core
The basic functionality of being able to preview an edit is currently
not covered by a test, as far as I can see.

The assertion for a wpTextbox2 that should *not* be there is a result of
the issue documented at T209012, where the EditPage::isConflict flag was
accidentially set. This assertion makes sure accidential conflicts can't
happen again, no matter which extension might cause it.

Bug: T210758
Change-Id: Iae723430b3a88079ad3499429e65c29817eca67e
2018-12-07 16:27:45 +01:00
Ed Sanders
3e4e0a5774 build: Use eslint-config-wikimedia v0.9.0 and make pass
Change-Id: I7b5d228a3de4b3006751a427dec907a5bebf2f51
2018-11-23 14:20:24 +00:00
jenkins-bot
d6016fa1f9 Merge "eslintrc: Disallow calling String/Array/Object methods introduced in ES6 or later" 2018-11-07 15:55:16 +00:00
Bartosz Dziewoński
6ad73362f3 eslintrc: Disallow calling String/Array/Object methods introduced in ES6 or later
This aims to disallow using the methods listed below, which are
supported by Chromium 69 but not supported by Internet Explorer 11.
Most of them were introduced in ECMAScript 6, but some are more recent
or experimental.

We keep breaking IE 11 support by using them. Recent examples include:
* mediawiki/core:
  Ic85063dfbbcf26a99d343845c9fb801f1888d750
* mediawiki/extensions/MultimediaViewer:
  I0954c42a37668b0eb46c3e864a2e13152a6dc68a
* mediawiki/extensions/UploadWizard:
  I70d37a8f0abcc96b5e39fa71a93cda6f3421c87c
* VisualEditor/VisualEditor:
  Ic1971549da37091c41a847229d18e95aff5c9952

This will unfortunately almost certainly cause false positives, but
hopefully not too many of them. Common false positives can be
disallowed more precisely using 'no-restricted-syntax' rather than
'no-restricted-properties'.

Disallowed methods:
    String.prototype:
        codePointAt
        endsWith
        includes
        normalize
        padEnd                    (ES 2017)
        padStart                  (ES 2017)
        repeat
        startsWith
        trimEnd                   (experimental/proposed)
        trimLeft                  (experimental/proposed)
        trimRight                 (experimental/proposed)
        trimStart                 (experimental/proposed)
    Array.prototype:
        copyWithin
        entries
        fill
        find
        findIndex
        flat                      (experimental/proposed)
        flatMap                   (experimental/proposed)
        includes                  (ES 2016)
        keys
        values
    String:
        fromCodePoint
        raw
    Array:
        from
        of
    Object:
        assign
        entries                   (ES 2017)
        getOwnPropertyDescriptors (ES 2017)
        getOwnPropertySymbols
        is
        values                    (ES 2017)

I compiled the list based on running the following code in each
browser's console, since there doesn't seem to be an authoritative
list anywhere on the Internet:

    console.log( Object.getOwnPropertyNames( String.prototype ) )
    console.log( Object.getOwnPropertyNames( Array.prototype ) )
    console.log( Object.getOwnPropertyNames( Object.prototype ) )
    console.log( Object.getOwnPropertyNames( String ) )
    console.log( Object.getOwnPropertyNames( Array ) )
    console.log( Object.getOwnPropertyNames( Object ) )

Change-Id: Ic44c79834f99c52863fbc544ad657787f70fb9bb
2018-11-07 07:32:40 -08:00
jenkins-bot
1658759d42 Merge "Selenium: record video of every test" 2018-10-16 22:23:36 +00:00
Željko Filipin
0513250c88 Selenium: record video of every test
In addition to two existing modes (headless and visible), this patch
introcues another mode, headless recording.

If DISPLAY environment variable is not set, Chrome will run in it's
built-in headless mode.
If it is set, and the value starts with colon (`:`), Chrome will
run in headless mode using Xvfb and record video of every test using FFmpeg.
If the value does not start with colon, Chrome will be visible.

Bug: T179188
Change-Id: Ic1723c5f2d57a28201caf6ba7056cb73fb74a957
2018-10-16 22:07:22 +00:00
WMDE-Fisch
9425d3e46e wdio-mediawiki: Add 'fragment' parameter to Page
In some cases it's useful adding a fragment to the url, e.g. when
accessing the beta features preference page. This patch adds support
for that on the Page object.

Change-Id: I4b6aa5e7e89e60f05e217fc557bf6786441855e6
2018-10-04 11:38:58 +02:00
Pablo Grass
382582f7b9 wdio-mediawiki: relative internal lookups
"Internal lookups need to be internal, using ./.
This currently works because it executes as part of mediawiki-core, but
may fail when used from the published package, because there will not
be another "wdio-mediawiki" inside this directory." krinkle
Follow-up to a fixme in Ifc49bc5c06eef71da8aff1b1837c32debc2c45dd

Change-Id: I86f321a42eaf4cf706b4e899e4cd460654840284
2018-09-26 12:36:45 +02:00
Pablo Grass
e908d347ef selenium: invoke jobs to enforce eventual consistency
Many tests use the API during their setup phase, which does not
participate in clearing the job queue, but constantly adds new items.
Consequently the job count keeps mounting. In order to be able to assert
the state of the application once all jobs are processed we need a way
to invoke them.
This is a minimalistic alternative to Idd4924e16925cbf0cb9e42645670c3fd76b72353

Bug: T199446
Change-Id: Ifc49bc5c06eef71da8aff1b1837c32debc2c45dd
2018-09-20 11:13:38 +02: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
Pablo Grass
32c36f0e73 selenium: undo page
Add basic undo page object and test showing a previous edit can be
undone.

Bug: T201901
Change-Id: Idc1b3889abc6e655032bc1576f1b9d591abd6c8d
2018-08-14 16:27:31 +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
Daimona Eaytoy
6a17d6b3a1 Temporarily skip broken Selenium test
This test was already flaky and was fixed in
I1fd0c49263e975c6b24e2e1f9a072486a6565dda. However, this caused failures
on several repos. Temporarily disable it until we'll get it to work
properly.

Bug: T199644
Change-Id: I88be83e01eb1789f28f09fc4a0be7ea17f402858
2018-07-15 15:42:05 +02:00
Pablo Grass
42f844e04a selenium: create edit for RecentChanges through GUI
Use page object to create the page we will be asserting on
Special:RecentChanges. Apparently (post send) jobs are not executed on
API calls (that were formerly used for test setup) and consequently
presence of the edit on Special:RecentChanges could not be guaranteed.

Bug: T199446
Change-Id: I1fd0c49263e975c6b24e2e1f9a072486a6565dda
2018-07-13 17:21:25 +02:00
Stephane Bisson
aea721b883 Let 'shows page creation' test be skipped
Troubleshooting can happen in parallel without blocking
unrelated work from being merged.

Bug: T198137
Change-Id: Ie84a868a580968ff99ff6879050080c6495fa72a
2018-07-12 18:52:57 -07:00
Bartosz Dziewoński
bde7249241 selenium: Remove '☃' character (U+2603 snowman emoji) from random usernames
The AntiSpoof extension disallows this character in usernames, causing
tests to fail on some setups. Its error message claims it is an
"unassigned character" (which is false), but it seems it's
intentionally disallowed and the error message should instead say
"non-script character" or something.

Bug: T198384
Change-Id: Ia8e7b425b6a3cf3742c00178f28c97a19f46bab0
2018-06-29 16:58:36 +02:00
Timo Tijhof
cee33128c8 wdio-mediawiki: Tag v0.2.0
Change-Id: Ia975b2d35220a6ad8ca90e6198ca2ba74c256ea3
2018-06-25 21:57:32 +01:00
Jakob Warkotsch
56b2412d6a Browser tests: use Util.getTestString in specialwatchlist.js
Follow-up on I5c5e9b22af5406f347636b22e68657b2674db6c9 and
I0747c2d361e951f8b3765a3dca548e55edb72216

Change-Id: I35ad793e6d9fe4c3bf58df9b4fcf6471c0a81f70
2018-06-25 12:14:25 +02:00
jenkins-bot
3aa8c6a332 Merge "Browser tests: extract commonly used getTestString function" 2018-06-25 09:51:52 +00:00
jenkins-bot
22ff706ce0 Merge "Add browser test for basic watchlist functionality" 2018-06-25 09:49:02 +00:00
jenkins-bot
1c944a2700 Merge "Selenium: run Wikibase repo tests" 2018-06-20 11:45:55 +00: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
Željko Filipin
6ebb3a5573 Selenium: run Wikibase repo tests
Similar to custom location of VisualEditor tests, Wikibase has tests in repo and client folders.

Bug: T180228
Change-Id: I3debe8bed9a760aea374529dbe007aa5a72421aa
2018-06-19 17:04:09 +02:00
Jakob Warkotsch
b25d303007 Add browser test for basic watchlist functionality
Will be used to test more advanced title/link formatters downstream.

Bug: T191601
Change-Id: I0747c2d361e951f8b3765a3dca548e55edb72216
2018-06-19 16:24:48 +02:00
Pablo Grass
97b6792142 selenium: RecentChanges page object
Return DOM element(s) to specs instead of creating another level of
inflection and to be more in line with other implementations.
Follow-up for I916516d5055c3ce9be071a75e5c3af2b3547d4ba

Bug: T191600
Change-Id: I03b0cd4af7adca23dd34173710b995629f833a1a
2018-06-19 15:31:07 +02:00
Pablo Grass
948990f05d selenium: add RecentChanges test to page spec
Add Special:RecentChanges page object with method to retrieve
displayed titles, test page last edited is shown there.
Will be used to test more advanced title/link formatters downstream.

Bug: T191600
Change-Id: I916516d5055c3ce9be071a75e5c3af2b3547d4ba
2018-06-13 16:23:20 +02:00
WMDE-Fisch
3ad98462e7 Use more diverse unicode chars in basic browser tests
See comment in I3423011c467b0a6426cfa0dad522435618f24bd0
and https://mathiasbynens.be/notes/javascript-unicode#poo-test

Decided on using something more positive than a pile of poo though.

Change-Id: Ic34d0d78044cede71fd1cd8742214c117ed2e99f
2018-06-13 14:59:46 +02:00
addshore
8602e489e1 selenium, page spec, make "should be editable" actually edit
This was using the same content for the edit before this
patch, so no edit was actually made, (just a null edit).

Change-Id: I945090647226e82f22b5b10a414a2a0bf9f2bc19
2018-06-13 11:56:29 +00:00
addshore
09536c527d selenium: page spec, make it easier to see where strings come from
Having randomly generated strings is great, but sometimes
it can help to allow a human to easily see where the string
is actually being generated in code, so add an optional suffix
to the string being generated.

Change-Id: Ibfe45f74b4880a70a76c01223a787dabcd43607e
2018-06-13 11:56:23 +00:00
addshore
ea4e00d590 Use wd/hub not /wd/hub in selenium.sh
I have run into this before and we fixed it in the README
but not in this script (I wasn't using this script at the time)

This was changed in the README in change:
I85a9e7dbd9a66418c85585969adb5ac1548f5ef6

Bug: T182421
Change-Id: I6ab92c6a61a57dc313b05321d0789dcbeb776c94
2018-06-13 11:56:15 +00:00
addshore
ae5f5b84c2 Don't use killall in selenium.sh
git bash for windows apparently doesn't have killall
by default, so instead get the PID of the chrome driver
we start and kill that specifically.

Change-Id: I8a9a773a7d3dc23807dc3ec12f5b3ef03661c9e3
2018-06-13 11:55:59 +00: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
e52b056322 selenium: Create local ./log directory if needed
Without this, the tests sometimes fail like this:

> Error: ENOENT: no such file or directory, open './log/should-be-creatable.png'
>   at screenshot() - saveScreenshot.js:52:17
>   at saveScreenshot("./log/should-be-creatable.png")

This seems to race with the junit plugin, which uses mkdirp to
create it if missing, but the screenshot handling is separate
from that. WebdriverIO's own screenshot handling also does this
so it makes sense for ours to do that, too.

I considered trying to re-use WebdriverIO's save mechanism,
directly but it's not publicly exposed and only used for the
crash scenario, so for now we'll have to keep our own.

Also:
* Add to gitignore.

* Update default to use __dirname instead of './' because the
  latter will somtimes be mediawiki/ and sometimes be selenium/
  depending on whether you run all tests or some tests.

* Remove trailing slash from default logPath, and instead add the
  slash in filePath.
  Reason:
  - The LOG_DIR used by Jenkins doesn't end in a slash either
    (currently not failing because we no longer use that job,
    and let quibble run the tests instead, which doesn't set
    the LOG_DIR).
  - The WDIO docs and example also use screenshotPath without
    trailing slash.
  - Without this, setting LOG_DIR=/tmp/something results in
    filenames like /tmp/somethingexample.png.

Bug: T193088
Change-Id: I6550f9315bae89f96a791f7ae8cc2fbec5ee8dd5
2018-05-09 14:30:55 +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
jenkins-bot
02415cb826 Merge "selenium: Run wdio directly without grunt" 2018-05-03 07:29:40 +00:00
Timo Tijhof
495a96b51f selenium: Apply relPath() to the exclude option for CirrusSearch
It seems relPath() is used for all other paths here. When I was
running a single test from the /tests/selenium, I noticed wdio
was logging to the console that it excluded ./extensions/CirrusSearch,
which doesn't make sense from that directory. The other paths
are fine.

Change-Id: Ic89ae0a91cdb6590b7190ea44969e653e9e2d6ea
2018-05-02 16:50:50 +00:00
Timo Tijhof
9f85d84ec3 selenium: Increase mochaOpts.timeout from 20s to 60s
I was unable to get the tests passing locally in MediaWiki-Vagrant.
The main slowdown appears to be from MWBot logging-in for each
command anew. Which works fine, but just seems to be quite slow.

Change-Id: I3c0abc79cac48c26d952b0bbe73574aa48b2d70e
2018-05-02 14:50:19 +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
Timo Tijhof
ecd1f1bc90 selenium: Clean up wdio.conf.js
* Remove redundant user/pass for Jenkins, which is unused now
  that Jenkins jobs set it through ENV instead.
  See also T188520 and Ibb388741fee9 (integration/config).

* Use simple default operator (||) instead of elaborate
  undefined check.

* Document that the inline user/password defaults relate to
  MediaWiki vagrant.

* Set 'logPath' for Jenkins based on LOG_PATH env (from mw-set-env.sh),
  instead of assuming where it will be relative to mediawiki-core.

* Put new lines between blocks and functions.

* Document --no-sandbox hack from 4ff5652501.

Change-Id: I4c7856d260ded8c94e991a27863b80c9eea2e33e
2018-04-26 15:53:46 +00: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
4cbd36db87 selenium: Remove Jenkins configuration file
Both Mocha and Cucumber tests should run. Since WebdriverIO supports only
running one test framework, the only way to do it is to have a generic
configuration file and two framework-specific files (Mocha, Cucumber). Having
Jenkins configuration file complicates things, and there is no need for
it.

Bug: T179190
Change-Id: I710066f7b5479dcad27aa57cd61007c1c2d88931
2018-04-13 20:54:43 +00: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
Antoine Musso
4ff5652501 Selenium: pass -no-sandbox to Chrome under Docker
When running webdriver.io in a Jessie Docker container, the sandboxing
fails:

  Failed to move to new namespace: PID namespaces supported, Network
  namespace supported, but failed: errno = Operation not permitted

Detect whether we are in a Docker container by checking /.dockerenv and
if present append --no-sandbox to Chrome options.

Change-Id: Ie5c276d12553e4473c01b3407e0f7622e0a678e0
2018-04-12 14:26:13 +02:00
jenkins-bot
9b00306abe Merge "WebdriverIO should be able to run Chrome headlessly" 2018-04-10 16:39:17 +00:00
Željko Filipin
36c0e76874 Selenium: use default value for waitforTimeout
The default is 10000 (10 seconds). It was increased by mistake. 20000 is the value needed for mochaOpts timeout. There is no reason to have the double value for waitforTimeout.

Bug: T179190
Change-Id: I14f72367a36815d155cedc57757481f6294fdc51
2018-04-06 13:08:20 +02:00
Željko Filipin
f195a217b4 Selenium: update WebdriverIO configuration
No changes are made to the configuration file. It has just been
regenerated with the latest WebdriverIO version. Minor whitespace
cleanup has been made to the file after it has been generated so it
conforms to our ESLint configuration.

This is the first step in updating configuration so videos of failed
tests are recorded.

Bug: T179188
Change-Id: Id0db3743ae7d828357b1527770bb7dcd2e02f99b
2018-03-30 17:29:47 +02:00
Željko Filipin
e60074cecf WebdriverIO should be able to run Chrome headlessly
Chrome 59 introduced an headless mode, in this mode it does not need any
DISPLAY (Xorg, Xvfb...). That achieved by passing to chrome:

 --headless

Use headless when DISPLAY is not available. One can switch to headless
by simply unsetting the environment variable: unset(DISPLAY).

Bug: T167507
Signed-off-by: Antoine Musso <hashar@free.fr>
Change-Id: Id5424eafb20112fd74d472b8cef02cb15cafff89
2018-03-29 15:18:00 +00:00
jenkins-bot
33fa8c095c Merge "Selenium: Replace nodemw with mwbot" 2018-03-21 15:17:06 +00:00
jenkins-bot
7a7accf2f3 Merge "Selenium: Do not run CirrusSearch smoke tests in Jenkins" 2018-03-21 14:42:37 +00:00