Commit graph

271 commits

Author SHA1 Message Date
osamaahmed17
ecd2550027 selenium: Refactor WebdriverIO tests from sync to async mode
Adding missing await statements.

Bug: T293071
Change-Id: I2818d8a72d2ad1d0173e0ee284de3ad8c67c9e18
2022-01-29 04:00:51 +11:00
WMDE-Fisch
ab4b1b2b6d [selenium] Remove leftovers from rollback tests
Leftover from Ieaccf37ad016f2e811aeb98d2bd2f061c9b13fbf

Bug: T280652
Change-Id: I87c8440d970bf0ae33160fb2031abb9e07dcc76f
2022-01-27 16:23:16 +01:00
osamaahmed17
290f77e3fc wdio-mediawiki: Release 2.0.0
Bug: T293071
Change-Id: I4d4328d3c2d0d44d4e12f35fe15a9d8f8839ff81
2022-01-11 18:13:12 +01:00
osamaahmed17
8f973d8503 selenium: Refactor WebdriverIO tests from sync to async mode
WebdriverIO has dropped support of sync mode due to breaking changes in Chromium, hence all tests have been changed to async.

Bug: T293071
Change-Id: I15347b789f11de84b764e13a3981545ed6759881
2022-01-06 07:17:48 +11:00
Antoine Musso
6850566572 selenium: run 4 tests in parallel
Wikimedia CI now serves MediaWiki over Apache (T286649) which mean we
can now do concurrent requests!

Change-Id: I5513535ac43138df1215a4896267aaa689bb2f56
2022-01-05 17:31:13 +01:00
Reedy
2a2bb1e9bd Remove or replace usages of "sane"
Bug: T254646
Change-Id: I096b2cf738a1395a14f1d47bcbed0c2c686c2581
2021-11-22 13:35:17 +00:00
jenkins-bot
ff7a116541 Merge "mediawiki.api: Move example doc from constructor to @class block" 2021-08-26 18:14:21 +00:00
Timo Tijhof
1917ed656c mediawiki.api: Move example doc from constructor to @class block
For 99% of JS classes, there is no constructor description and instead
the class/constructor are defined together followed by both `@class`
and `@constructor` in the same block. These are interpreted as the
description belonging to the class and prominently displayed in the
documentation.

For the very rare cases where a constructor has its own description,
this must follow the tag rather than preceed it. This makes sense
when thinking about it in terms of how classes are usually defined
(above the constructor, and thus the space above `@constructor`
already belongs to `@class`).

This has the unfortunate side-effect, however, that when a constructor
is documented on its own, that any text above `@constructor` is
ignored, as happened with mw.Api.

But, as so often with strict documentation warnings, it helped uncover
a mistake. The text here is quite useful and not really specific to
the constructor and more broadly useful for the module as a whole,
as such I moved it to the class block.

Also:

* Clean up the code by bringing the class and constructor definition
  back together.

* Fix warning about invalid internal reference:
  > Warning: /resources/src/mediawiki.api/index.js:3: {@link https://…}
  The `@see` tag is only valid when referring to another index entity.
  There were three other uses of `@see` with a URL in core, but only in
  `@ignore`-ed code, which this commit fixes at the same time.

  Follows-up a28b76abe9.

* Use local `var` declarion for `promises`, since "one-var" style
  is no longer current.

Change-Id: I2d4f8b99c2896d4e1af50956c9faa8b36344884e
2021-08-24 16:38:26 +00:00
James D. Forrester
66e9dab5f5 Selenium tests: Skip wikitext-specific tests if NS isn't wikitext
Change-Id: I2745532e5c9b2204fd2ee87ced004abd13dd4d4b
2021-08-24 08:53:42 -07:00
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
Kosta Harlan
4ee71ea809 Allow a retry of flaky selenium test
Flaky selenium tests are a problem (https://w.wiki/3XMD).

Ideally we'd have better shared practices around writing tests that
reduce flakiness, but there will probably always be some element of
instability due to the nature of these tests.

We should fix flaky tests where there are clear fixes to do so, but it
would also be nice to not have to re-run a 20 minute build when a 5
second test, when retried, passes.

https://webdriver.io/docs/retry indicates that you can specify a number
of times to retry a spec file, so that's what is added here.

Change-Id: I29a4943e7ddaf755b242756543d9402177a0f6e5
2021-06-22 12:01:22 +00:00
jenkins-bot
bc9bc0d07f Merge "selenium: Remove debugging information for video recording" 2021-06-17 11:48:13 +00:00
Željko Filipin
f6fa7f5fee selenium: Remove debugging information for video recording
All other debugging information (screenshots, webdriverio, mwbot) is
already  removed.

Bug: T284335
Change-Id: I27eb5053c35b4d7813315f3001c07d469fe9cbd2
2021-06-17 13:06:32 +02:00
DannyS712
4105ad3ef6 Selenium watchlist tests: don't create a new account
Use existing admin account

Change-Id: I316de111341c37a462c883fccdad9db634204fc5
2021-06-09 12:05:27 +00:00
Petr Pchelko
ff4e6f59dc Add selenium tests for page protection
Change-Id: I31349f747dc1fa22c3bfbb3fe02386686aeb2cf1
2021-06-07 11:35:02 -07:00
Željko Filipin
4ff24e5ced wdio-mediawiki: Release 1.1.1
Bug: T283613
Change-Id: If3933b4e338f1bcb572d692600f7e4354026e4b9
2021-05-26 11:38:35 +02:00
Željko Filipin
eb44ff5e01 selenium: Fix Cannot find module 'dotenv'
dotenv is used only in core. It's usage was introduced into
wdio-defaults.conf.js by mistake in 8a4fab5, while moving functionality
from wdio.conf.js.

This patch moves dotenv usage back to wdio.conf.js, where it should be.

Bug: T283613
Change-Id: I6ec96248cd0b829ef44e574b7e6dc98cf363ee3a
2021-05-25 19:05:10 +02:00
jenkins-bot
b8960a9ced Merge "wdio-mediawiki: Release 1.1.0" 2021-05-25 08:55:15 +00:00
jenkins-bot
a4911a17bf Merge "docs: Document release process for wdio-mediawiki" 2021-05-25 08:54:21 +00:00
sahil
ca162392cd selenium: Dismiss Chrome's Save password? popup
Bug: T280969
Change-Id: I1d2230dc3ce7cc0f3186b373d467c6e386722e10
2021-05-24 17:56:52 +00:00
Kosta Harlan
86a89baad1 wdio-mediawiki: Release 1.1.0
Bug: T280332
Change-Id: I1c572b306962140ee6c81e41971ab1e3b2b3b62d
2021-05-21 17:40:13 +00:00
Timo Tijhof
fe251f8ee5 docs: Document release process for wdio-mediawiki
Change-Id: I64c2123aed047b525575d4d6ca5b0e4f21936978
2021-05-21 17:39:54 +00:00
Adam Wight
bf08ba4496 Minor cleanups to wdio default config
Renames and documents the config file to make its usage clear.

Bug: T281484
Change-Id: I5cb66265077787657047bbd9106cef595b5e607d
2021-05-21 13:40:42 +02:00
jenkins-bot
fd29aa7655 Merge "selenium: Record videos using Xvfb+ffmpeg" 2021-05-21 10:36:07 +00:00
jenkins-bot
12b0d496a4 Merge "selenium: Add a basic wdio.conf.js to wdio-mediawiki" 2021-05-21 10:35:31 +00:00
Željko Filipin
00582fa7a8 selenium: Simplify spec file names
Remove `special` from `recentchanges.js` and `watchlist.js`.
The entire `spec` folder has only four files. The two mentioned and
`page.js` and `user.js`. If that was a folder with a lot of files, it
would make sense to use `special`. Now it just makes file names long.
Additionally, files in `pageobjects` folder are already using simpler
names, `recentchanges.page.js` and `watchlist.page.js`, without
`special`.

Bug: T210726
Change-Id: I156f436e2de345586a25174c630ad60259504115
2021-05-20 19:46:09 +02:00
Željko Filipin
d94b16a74d selenium: Record videos using Xvfb+ffmpeg
Unil 2020-06-15 we were using Xvfb+ffmpeg to record videos.

In eed975d we have switched to wdio-video-reporter npm package.
It has never worked very well. It does not really record videos.
It creates screenshots and creates videos from them.
It does not record modal popups. Sometimes, it doesn't create a video
for a test at all.

I think it's time to switch back to Xvfb+ffmpeg. It has worked well. The
reason we moved to wdio-video-reporter was that it worked on all
platforms. That's not really important any more, since Xvfb+ffmpeg works
in a Fresh container.

Bug: T253113
Change-Id: I221775208576b6496f682ceefd6e6334db488bd4
2021-05-20 15:46:20 +02:00
Željko Filipin
8a4fab569c selenium: Add a basic wdio.conf.js to wdio-mediawiki
So far, each repository had it's own wdio.conf.js file. That lead to a
lot of duplicated code. This patch moves core's wdio.conf.js file to
wdio-mediawiki package. The file can be used by core, extensions and
skins. Each repository can override settings, if needed.

Bug: T281484
Change-Id: Icd098a2adf8f6183aad5fb6b33196c67fd809e15
2021-05-20 13:29:23 +00:00
Željko Filipin
41373ba0d6 selenium: Update mwbot to v2
v2 includes removing `[MWBOT] Login successful` message.

Bug: T280332
Change-Id: Ibe84bce93f0dcea1ffcbda9042435565d1935090
2021-05-19 15:39:09 -07:00
Željko Filipin
4a657ec634 selenium: Fix failing selenium-daily-beta(commons)-MediaWiki Jenkins job
The jobs are running a subset of tests. (Tests containing string
`@daily` in  the name.) To find the tests we are using
`--mochaOpts.grep` WebdriverIO command line option. The filter is
executed after the tests have already started. Since some test files
have no tests with string `@daily`, they are skipped. That results in
JUnit reporter creating a couple of empty XML files. Jenkins thinks
empty files are failures and fails the build.

This commit creates a suite of files that have tests with string
`@daily` and runs only those files.

Bug: T281505
Change-Id: Id844da81feac49f2a2b6820e98ead98d7e932e9f
2021-04-30 13:42:20 +02:00
Željko Filipin
c518ccbc20 selenium: Fix JUnit reporter
JUnit reporter configuration changed since WebdriverIO v6. Before this
patch, the reporter was creating files in format
wdio-*-junit-reporter.log while Jenkins expects files in format
WDIO.xunit*.xml.

Bug: T214686
Change-Id: Iba68a48e3b3f512c5004446b21cdfde6558e8b15
2021-04-29 12:53:31 +00:00
Željko Filipin
4f62b94d4e selenium: Add timestamp to screenshot file name
When debugging, it's useful to have screenshots from multiple test runs.
At the moment, file name is created only with test suite name and test
name. When a new test (suite) is executed, screenshots from the previous
one are overwritten.

This patch adds date and time in a slightly modified ISO 8601 format.
(Colons and dots are replaced with dashes.)

Example old file name:
Special%3ARecentChanges-shows-page-creation.png

Example new file name:
Special%3ARecentChanges-shows-page-creation-2021-04-27T12-58-01-822Z.png

Bug: T280970
Change-Id: I90fbcdaf5cb22ea455fd55e718e8db3b3c1dfaea
2021-04-28 21:08:56 +00:00
Željko Filipin
50b4df3515 selenium: File name friendly version of ISO 8601 date and time
Two tasks (T214686 and T280970) need a timestamp in file name.

It's currently implemented as a simple constant, but it's duplicated
in two files, tests/selenium/wdio.conf.js and
tests/selenium/wdio-mediawiki/index.js.

To reduce duplication, this patch creates a simple function in
wdio-mediawiki.

Bug: T281372
Change-Id: Id2a9a340e7e3be253238463b9bd25483647e227c
2021-04-28 21:07:52 +00:00
jenkins-bot
5ecccfd765 Merge "selenium: Delete tests disabled for more than 1 year" 2021-04-26 21:25:37 +00:00
jenkins-bot
f244a0d634 Merge "selenium: DEBUG environment variable increases Mocha timeout" 2021-04-26 15:19:15 +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
Željko Filipin
0d3c17754c selenium: Fix browser.getText is not a function
Tests in rollback.js are disabled due to flakiness. After enabling them
a few of them fail with `browser.getText is not a function`.
It is caused by WebdriverIO API change. `browser.getText()` was replaced
with `$().getText()`. The problem was not noticed during the WebdriverIO
upgrade since the tests were disabled.

Bug: T280639
Change-Id: I4b21bbc1ad9ddbc8b04b444b21ee67b2621f54e7
2021-04-20 10:37:43 +00:00
Željko Filipin
1d851ec5bd selenium: Fix ReferenceError: test is not defined
I've removed `test` argument from afterTest hook by mistake in 2320f00.
It's needed by `filePath()`.

Linters didn't catch this and tests didn't fail, so this mistake went
unnoticed.

Bug: T280355
Change-Id: I1bc142d8282b7a7266233c69d0b27f8700c8f473
2021-04-16 20:11:05 +02:00
jenkins-bot
2bb6e3b270 Merge "selenium: Explicitly make screenshots for passing and failing tests" 2021-04-16 17:49:47 +00:00
Željko Filipin
2320f00eef selenium: Explicitly make screenshots for passing and failing tests
There is code in wdio.conf.js to only take screenshots of failed tests.

For a while now, `test.passed` is returning `undefined`, so screenshots
are taken for both passing and failing tests. The change probably
happened when we upgraded webdriverio to v5 or v6, but nobody noticed
it.

I actually like the current behavior. We take videos for both passing
and failing tests, so it makes sense to take screenshots too. Both
screenshots and videos are small files.
(The biggest screenshot is 539 KB, the biggest video is 21 KB.)

Bug: T280355
Change-Id: I8a73afcda19d6dc1cad75256835448488aff37d5
2021-04-16 17:01:53 +00:00
Željko Filipin
d0762b576f selenium: Remove Screenshot location... messages
A typical output when running Selenium tests contains a lot of
`Screenshot location...` messages. They are not useful and should be
removed.

Bug: T280343
Change-Id: I462a3764f4a26c4231ff48797c4834ba80a4079d
2021-04-16 15:45:53 +02:00
Željko Filipin
38e9981a56 selenium: DEBUG environment variable increases Mocha timeout
By default, Mocha will abort the test suite if it takes more than 60
seconds. That is usually plenty when you're just running tests, but it's
usually not enough when you're debugging. At the moment, you have to
manually increase `mochaOpts` `timeout` in `wdio.conf.js`.

This patch checks if DEBUG is set, and if so, increases `timeout` from
60 seconds to 60 minutes.

This patch simplifies debugging. Instead of having to manually edit
`wdio.conf.js`, increasing `timeout` is done by:

    DEBUG=true npm run selenium-test

Debugging is documented at
https://www.mediawiki.org/wiki/Selenium/How-to/Debug_with_browser.debug()#mochaOpts

Bug: T278827
Change-Id: Ied8e7eab34d9472b841b803ada6541dd12f85976
2021-04-15 16:10:28 +00:00
Željko Filipin
ee14595404 selenium: Delete Sauce Labs configuration
It is no longer used. See
https://phabricator.wikimedia.org/M317

Bug: T248221
Change-Id: I87c583d046d5a7547503eb5e358f9ee470b2360a
2021-03-26 18:15:14 +01:00
Kosta Harlan
3244a9e367 selenium: Disable flaky undoable page test
Bug: T276783
Change-Id: Ic3f9dbd38511ffb503ffd341f8af4a32405ad1ed
2021-03-11 11:55:07 +01:00
jenkins-bot
5a844e9b08 Merge "selenium: Tests pass if Vector skin is not installed" 2021-03-09 20:22:46 +00:00
Željko Filipin
4cf24376b7 selenium: Tests pass if Vector skin is not installed
A year ago (in 0257160) Kosta Harlan changed the tests to use class name
instead of ID to find page elements. That made the tests pass even when
Vector skin is not installed. Apparently something changed since and
core now uses ID instead of class name.

Bug: T276900
Change-Id: Iac4295627547f70e81eeab61d0c64208d7be1d1d
2021-03-09 15:02:03 +00:00
Gergő Tisza
d1bf6a036d Suppress VisualEditor welcome dialog in undo Selenium test
Bug: T276783
Change-Id: I1a67a1e8dc8c46e86aaadb0dccc9ec8d21f737c1
2021-03-09 14:51:34 +01:00
Željko Filipin
5015a623d6 selenium: Remove ChromeDriver dependency
Since WebdriverIO v5, Puppeteer is available as a Chromedriver
alternative.

Puppeteer and Chromedriver behave almost the same, but there were a few
minor failures that needed to be fixed.

Puppeteer is bundled with WebdriverIO. Chromedriver needs to be installed
(and started/stopped) separately. Getting rid of Chromedriver simplifies
our documentation, among other things.

The commit updates tests/selenium/wdio.conf.js to use Puppeteer.
It also fixes a few minor problems in tests/selenium/specs/page.js
introduced by the change.

Bug: T269566
Change-Id: I143c44304461980a2be98eb60741184fa7671343
2021-03-07 02:31:06 +00:00
James D. Forrester
5a622b6a2e build: Upgrade eslint-config-wikimedia from 0.17.0 to 0.18.1
Change-Id: I5e3687be2b197134578126e1b890ee37dbc1bc1b
2021-02-18 08:39:09 -08:00
Adam Wight
bc4d631c08 Wait until the recent changes are updated
There may be a race condition when running against a multithreaded
server, in which the Special:RecentChanges request arrives before the
deferred job has updated history.  The API call ensures that the
recentchanges table has been updated, within a 5-second grace period.

Bug: T225218
Change-Id: I0882a5624c62b94f8c6e6056ea3396d9e2904d48
2021-01-05 16:49:27 +01:00