Skip to content

Commit

Permalink
Add selenium test for Echo popup (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed Sep 24, 2021
1 parent 91490dd commit 3b3ca8d
Show file tree
Hide file tree
Showing 11 changed files with 2,911 additions and 30 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- npm-test
- composer-test
# - qunit
# - selenium
- selenium
# - api-testing

runs-on: ubuntu-latest
Expand Down Expand Up @@ -145,7 +145,8 @@ jobs:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- run: yarn
# Use npm as Quibble is not compatible with yarn.
- run: npm install
- name: Main Test
run: |
cd /home/runner
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
tests/selenium/log

# npm dependencies
/node_modules/
# We use yarn instead of npm
package-lock.json

# composer dependencies
/vendor/
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
"lint": "npm run lint:prettier --silent && npm run lint:i18n --silent",
"lint:prettier": "prettier . --check",
"lint:i18n": "banana-checker --requireLowerCase=0 i18n/",
"fix": "prettier . --write"
"fix": "prettier . --write",
"selenium-daily": "npm run selenium-test",
"selenium-test": "wdio tests/selenium/wdio.conf.js"
},
"dependencies": {
"@femiwiki/ooui-femiwiki-theme": "https://github.com/femiwiki/OOUIFemiwikiTheme.git#main",
"xeicon": "^2.3.3"
},
"devDependencies": {
"@prettier/plugin-xml": "^1.0.2",
"@wdio/cli": "7.4.6",
"@wdio/dot-reporter": "7.4.2",
"@wdio/junit-reporter": "7.4.2",
"@wdio/local-runner": "7.4.6",
"@wdio/mocha-framework": "7.4.6",
"@wdio/sync": "7.4.6",
"@types/jquery": "^3.5.6",
"@types/node-fetch": "^2.5.12",
"grunt-banana-checker": "^0.9.0",
"prettier": "^2.4.1",
"typescript": "4.4.3"
"typescript": "4.4.3",
"wdio-mediawiki": "1.1.1"
}
}
4 changes: 4 additions & 0 deletions tests/selenium/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": ["wikimedia/selenium"]
}
12 changes: 12 additions & 0 deletions tests/selenium/pageobjects/echo.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';
const Page = require('wdio-mediawiki/Page');

class EchoPage extends Page {
get notifications() {
return $('#pt-notifications-all');
}
get popup() {
return $('.oo-ui-labelElement-label');
}
}
module.exports = new EchoPage();
9 changes: 9 additions & 0 deletions tests/selenium/pageobjects/femiwiki.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';
const Page = require('wdio-mediawiki/Page');

class FemiwikiPage extends Page {
get gnbMenu() {
return $('#fw-menu-toggle');
}
}
module.exports = new FemiwikiPage();
36 changes: 36 additions & 0 deletions tests/selenium/specs/echo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const Api = require('wdio-mediawiki/Api');
const Femiwiki = require('../pageobjects/femiwiki.page');
const EchoPage = require('../pageobjects/echo.page');
const Util = require('wdio-mediawiki/Util');
const assert = require('assert');
const UserLoginPage = require('wdio-mediawiki/LoginPage');
const UserPreferences = require('../userpreferences');
const BlankPage = require('wdio-mediawiki/BlankPage');
describe('flyout for notifications appears when clicked @daily', function () {
let bot;

before(async () => {
bot = await Api.bot();
});

it('checks for OOUI icon replacement @daily', function () {
// Prepares accounts
const username = Util.getTestString('User-');
const password = Util.getTestString();
browser.call(async () => {
await Api.createAccount(bot, username, password);
});

UserLoginPage.login(username, password);
UserPreferences.enableFemiwiki();
// Refresh after changing the preference
BlankPage.open();
Femiwiki.gnbMenu.click();
EchoPage.notifications.waitForDisplayed();
EchoPage.notifications.click();
EchoPage.popup.waitForDisplayed();
assert(EchoPage.popup.isExisting());
});
});
25 changes: 25 additions & 0 deletions tests/selenium/userpreferences.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const BlankPage = require('wdio-mediawiki/BlankPage');
const Util = require('wdio-mediawiki/Util');

class UserPreferences {
setPreferences(preferences) {
BlankPage.open();
Util.waitForModuleState('mediawiki.base');

return browser.execute(function (prefs) {
return mw.loader.using('mediawiki.api').then(function () {
return new mw.Api().saveOptions(prefs);
});
}, preferences);
}

enableFemiwiki() {
this.setPreferences({
skin: 'femiwiki',
});
}
}

module.exports = new UserPreferences();
12 changes: 12 additions & 0 deletions tests/selenium/wdio.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const { config } = require('wdio-mediawiki/wdio-defaults.conf.js');

exports.config = {
...config,
// Override, or add to, the setting from wdio-mediawiki.
// Learn more at https://webdriver.io/docs/configurationfile/
//
// Example:
// logLevel: 'info',
};
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"exclude": ["vendor", "resources/ooui", "resources/skins.femiwiki.share*"],
"exclude": [
"vendor",
"resources/ooui",
"resources/skins.femiwiki.share*",
"tests"
],
"compilerOptions": {
"resolveJsonModule": true,
"esModuleInterop": true,
Expand Down

0 comments on commit 3b3ca8d

Please sign in to comment.