mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-08 23:00:53 -04:00
Restructure tests and add Gutenberg tests on BrowserStack (#1079)
This commit is contained in:
parent
3a56e9a7c9
commit
b78c85c4d1
59
.github/workflows/CI.yml
vendored
59
.github/workflows/CI.yml
vendored
@ -93,23 +93,56 @@ jobs:
|
||||
local-testing: start
|
||||
local-identifier: random
|
||||
|
||||
- name: Run BrowserStack tests
|
||||
- name: Run App locally in background
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: |
|
||||
npx http-server --silent -p 8099 &
|
||||
echo -e "\n\e[0;32mTesting on Edge Legacy 18 / Win10..."
|
||||
npx mocha tests/edge18.bs.runner.js
|
||||
echo -e "\n\e[0;32mTesting on Firefox Legacy 56 / Win10..."
|
||||
npx mocha tests/firefox56.bs.runner.js
|
||||
echo -e "\n\e[0;32mTesting on Firefox 61 / Win10..."
|
||||
npx mocha tests/firefox61.bs.runner.js
|
||||
echo -e "\n\e[0;32mTesting on Chrome 58 / Mojave..."
|
||||
npx mocha tests/chrome58.bs.runner.js
|
||||
echo -e "\n\e[0;32mTesting on Safari 14 / Big Sur..."
|
||||
npx mocha tests/safari14.bs.runner.js
|
||||
run: npx http-server --silent -p 8099 &
|
||||
|
||||
- name: Run BrowserStack tests on Firefox Legacy 56 / Win10
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: npx mocha tests/e2e/runners/firefox/firefox56.bs.runner.js
|
||||
|
||||
- name: Run BrowserStack tests on Firefox 70 / Win10 [Gutenberg]
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: npx mocha tests/e2e/runners/firefox/firefox70.bs.runner.js
|
||||
|
||||
- name: Run BrowserStack tests on Chrome 58 / Mojave
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: npx mocha tests/e2e/runners/chrome/chrome58.bs.runner.js
|
||||
|
||||
- name: Run BrowserStack tests on Chrome 60 / Mojave
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: npx mocha tests/e2e/runners/chrome/chrome60.bs.runner.js
|
||||
|
||||
- name: Run BrowserStack tests on Safari 14 / Big Sur
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: npx mocha tests/e2e/runners/safari/safari14.bs.runner.js
|
||||
|
||||
# [DEV] Test on Edge18 are bit flaky, so we are retrying 2 times
|
||||
- name: Run BrowserStack tests on Edge Legacy 18 / Win10
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
env:
|
||||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
||||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
||||
run: npx mocha tests/e2e/runners/edge/edge18.bs.runner.js --retries 2
|
||||
|
||||
|
||||
- name: Stop BrowserStackLocal
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
|
20
package.json
20
package.json
@ -10,18 +10,18 @@
|
||||
"prebuild-src": "del-cli dist",
|
||||
"build-src": "rollup --config --file dist/www/js/bundle.js",
|
||||
"del-dist": "del-cli dist",
|
||||
"test": "testcafe all ./tests/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-browsers": "testcafe firefox:headless,chrome:headless,edge:headless ./tests/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-firefox": "testcafe firefox:headless ./tests/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-chrome": "testcafe chrome:headless ./tests/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-edge": "testcafe edge:headless ./tests/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-mac": "testcafe safari ./tests/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test": "testcafe all ./tests/unit/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-browsers": "testcafe firefox:headless,chrome:headless,edge:headless ./tests/unit/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-firefox": "testcafe firefox:headless ./tests/unit/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-chrome": "testcafe chrome:headless ./tests/unit/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-edge": "testcafe edge:headless ./tests/unit/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"test-unit-mac": "testcafe safari ./tests/unit/initTestCafe.js --app \"http-server --silent -p 8080 .\"",
|
||||
"web-server": "http-server -p 8080 .",
|
||||
"test-e2e": "npm run test-e2e-firefox && npm run test-e2e-chrome && npm run test-e2e-edge && npm run test-e2e-iemode",
|
||||
"test-e2e-firefox": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/firefox.e2e.runner.js'",
|
||||
"test-e2e-chrome": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/chromium.e2e.runner.js'",
|
||||
"test-e2e-edge": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/microsoftEdge.e2e.runner.js'",
|
||||
"test-e2e-iemode": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/ieMode.e2e.runner.js'"
|
||||
"test-e2e-firefox": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/e2e/runners/firefox/firefox.e2e.runner.js'",
|
||||
"test-e2e-chrome": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/e2e/runners/chrome/chromium.e2e.runner.js'",
|
||||
"test-e2e-edge": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/e2e/runners/edge/microsoftEdge.e2e.runner.js'",
|
||||
"test-e2e-iemode": "npx start-server-and-test 'http-server --silent' 8080 'npx mocha ./tests/e2e/runners/edge/ieMode.e2e.runner.js'"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
import path from 'path';
|
||||
|
||||
const rayCharlesBaseFile = path.resolve('./tests/wikipedia_en_ray_charles_2015-06.zimaa');
|
||||
const gutenbergRoBaseFile = path.resolve('./tests/gutenberg_ro_all_2023-08.zim');
|
||||
const rayCharlesBaseFile = path.resolve('./tests/zims/legacy-ray-charles/wikipedia_en_ray_charles_2015-06.zimaa');
|
||||
const gutenbergRoBaseFile = path.resolve('./tests/zims/gutenberg-ro/gutenberg_ro_all_2023-08.zim');
|
||||
const downloadDir = path.resolve('./tests/');
|
||||
|
||||
export default {
|
@ -1,5 +1,5 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
@ -29,9 +29,8 @@ async function loadChromeDriver () {
|
||||
return driver;
|
||||
};
|
||||
|
||||
const driver_chrome = await loadChromeDriver();
|
||||
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
// await driver_chrome.manage().window().maximize(); // Not supported in this version / Selenium
|
||||
|
||||
legacyRayCharles.runTests(driver_chrome);
|
||||
// make sure to use await running tests or we are charged unnecessarily on Browserstack
|
||||
await legacyRayCharles.runTests(await loadChromeDriver());
|
41
tests/e2e/runners/chrome/chrome60.bs.runner.js
Normal file
41
tests/e2e/runners/chrome/chrome60.bs.runner.js
Normal file
@ -0,0 +1,41 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import { Options } from 'selenium-webdriver/chrome.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
import paths from '../../paths.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Input capabilities
|
||||
const capabilities = {
|
||||
'bstack:options': {
|
||||
os: 'OS X',
|
||||
osVersion: 'Mojave',
|
||||
browserVersion: '60.0',
|
||||
projectName: 'BStack Project Name: Kiwix JS e2e tests',
|
||||
buildName: 'BStack Build Name: Chrome 58 on Mojave',
|
||||
local: true,
|
||||
localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
|
||||
userName: process.env.BROWSERSTACK_USERNAME,
|
||||
accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
|
||||
seleniumVersion: '3.141.59'
|
||||
},
|
||||
browserName: 'Chrome'
|
||||
};
|
||||
|
||||
async function loadChromeDriver () {
|
||||
const options = new Options()
|
||||
options.setUserPreferences({ 'download.default_directory': paths.downloadDir });
|
||||
|
||||
const driver = await new Builder()
|
||||
// .forBrowser('edge')
|
||||
.usingServer('https://hub-cloud.browserstack.com/wd/hub')
|
||||
.withCapabilities(capabilities)
|
||||
.build();
|
||||
return driver;
|
||||
};
|
||||
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
// await driver_chrome.manage().window().maximize(); // Not supported in this version / Selenium
|
||||
|
||||
// make sure to use await running tests or we are charged unnecessarily on Browserstack
|
||||
await gutenbergRo.runTests(await loadChromeDriver());
|
@ -1,8 +1,8 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import { Options } from 'selenium-webdriver/chrome.js';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from './gutenberg_ro.e2e.spec.js';
|
||||
import paths from './paths.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
import paths from '../../paths.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
@ -29,12 +30,13 @@ async function loadEdgeLegacyDriver () {
|
||||
.usingServer('https://hub-cloud.browserstack.com/wd/hub')
|
||||
.withCapabilities(capabilities)
|
||||
.build();
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
await driver.manage().window().maximize();
|
||||
return driver;
|
||||
};
|
||||
|
||||
const driver_edge_legacy = await loadEdgeLegacyDriver();
|
||||
await legacyRayCharles.runTests(driver_edge_legacy);
|
||||
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
await driver_edge_legacy.manage().window().maximize();
|
||||
|
||||
legacyRayCharles.runTests(driver_edge_legacy);
|
||||
const driver_edge_gutenberg = await loadEdgeLegacyDriver();
|
||||
await gutenbergRo.runTests(driver_edge_gutenberg);
|
@ -1,7 +1,7 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import { Options } from 'selenium-webdriver/ie.js';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from './gutenberg_ro.e2e.spec.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import { Options } from 'selenium-webdriver/edge.js';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from './gutenberg_ro.e2e.spec.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
async function loadMSEdgeDriver () {
|
@ -1,8 +1,8 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import firefox from 'selenium-webdriver/firefox.js';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from './gutenberg_ro.e2e.spec.js';
|
||||
import paths from './paths.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
import paths from '../../paths.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// Input capabilities
|
||||
@ -8,7 +7,7 @@ const capabilities = {
|
||||
'bstack:options': {
|
||||
os: 'Windows',
|
||||
osVersion: '10',
|
||||
browserVersion: '61.0',
|
||||
browserVersion: '70.0',
|
||||
projectName: 'BStack Project Name: Kiwix JS e2e tests',
|
||||
buildName: 'BStack Build Name: Firefox 61',
|
||||
local: true,
|
||||
@ -26,14 +25,13 @@ async function loadFirefoxDriver () {
|
||||
.usingServer('https://hub-cloud.browserstack.com/wd/hub')
|
||||
.withCapabilities(capabilities)
|
||||
.build();
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
await driver.manage().window().maximize();
|
||||
return driver;
|
||||
};
|
||||
|
||||
const driver_fx = await loadFirefoxDriver();
|
||||
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
await driver_fx.manage().window().maximize();
|
||||
const driver_gutenberg_fx = await loadFirefoxDriver();
|
||||
|
||||
// Run test in SW mode only
|
||||
console.log('Running tests in Service Worker mode only for this browser version');
|
||||
legacyRayCharles.runTests(driver_fx, ['serviceworker']);
|
||||
await gutenbergRo.runTests(driver_gutenberg_fx);
|
@ -1,5 +1,6 @@
|
||||
import { Builder } from 'selenium-webdriver';
|
||||
import legacyRayCharles from './legacy-ray_charles.e2e.spec.js';
|
||||
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
|
||||
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
@ -26,13 +27,16 @@ async function loadSafariDriver () {
|
||||
.usingServer('https://hub-cloud.browserstack.com/wd/hub')
|
||||
.withCapabilities(capabilities)
|
||||
.build();
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
await driver.manage().window().maximize();
|
||||
return driver;
|
||||
};
|
||||
|
||||
const driver_safari = await loadSafariDriver();
|
||||
const driver_legacy_safari = await loadSafariDriver();
|
||||
|
||||
// Maximize the window so that full browser state is visible in the screenshots
|
||||
await driver_safari.manage().window().maximize();
|
||||
// Browserstack Safari does not support Service Workers
|
||||
console.log('Running tests in jQuery mode only for this browser version')
|
||||
legacyRayCharles.runTests(driver_safari, ['jquery']);
|
||||
await legacyRayCharles.runTests(driver_legacy_safari, ['jquery']);
|
||||
|
||||
const driver_gutenberg_safari = await loadSafariDriver();
|
||||
await gutenbergRo.runTests(driver_gutenberg_safari, ['jquery']);
|
@ -23,13 +23,19 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import { By, Key, until, WebDriver } from 'selenium-webdriver';
|
||||
import assert from 'assert';
|
||||
import paths from './paths.js';
|
||||
import paths from '../paths.js';
|
||||
import fs from 'fs';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
/* global describe, it */
|
||||
|
||||
const port = process.env.BROWSERSTACK_LOCAL_IDENTIFIER ? '8099' : '8080';
|
||||
// Get the BrowserStack environment variable
|
||||
const BROWSERSTACK = !!process.env.BROWSERSTACK_LOCAL_IDENTIFIER;
|
||||
// DEV: For local testing, use line below instead
|
||||
// const BROWSERSTACK = true;
|
||||
|
||||
const port = BROWSERSTACK ? '8099' : '8080';
|
||||
const gutenbergRoBaseFile = BROWSERSTACK ? '/tests/zims/gutenberg-ro/gutenberg_ro_all_2023-08.zim' : paths.gutenbergRoBaseFile
|
||||
|
||||
/**
|
||||
* Run the tests
|
||||
@ -100,7 +106,7 @@ function runTests (driver, modes) {
|
||||
this.slow(10000);
|
||||
// Run tests twice, once in serviceworker mode and once in jquery mode
|
||||
it('Load Kiwix JS and check title', async function () {
|
||||
await driver.get('http://localhost:8080/dist/www/index.html');
|
||||
await driver.get('http://localhost:' + port + '/dist/www/index.html');
|
||||
const title = await driver.getTitle();
|
||||
assert.equal('Kiwix', title);
|
||||
});
|
||||
@ -175,17 +181,24 @@ function runTests (driver, modes) {
|
||||
console.log('\x1b[33m%s\x1b[0m', ' Test skipped.');
|
||||
return;
|
||||
}
|
||||
const archiveFiles = await driver.findElement(By.id('archiveFiles'));
|
||||
await archiveFiles.sendKeys(paths.gutenbergRoBaseFile);
|
||||
// Wait until files have loaded
|
||||
var filesLength;
|
||||
await driver.wait(async function () {
|
||||
const isFileLoaded = await driver.wait(async function () {
|
||||
// check if file has been loaded
|
||||
filesLength = await driver.executeScript('return document.getElementById("archiveFiles").files.length');
|
||||
return filesLength === 1;
|
||||
}, 5000);
|
||||
// Check that we loaded 1 file
|
||||
assert.equal(1, filesLength);
|
||||
}, 2000).catch(() => false);
|
||||
if (!BROWSERSTACK) {
|
||||
const archiveFiles = await driver.findElement(By.id('archiveFiles'));
|
||||
if (!isFileLoaded) await archiveFiles.sendKeys(gutenbergRoBaseFile);
|
||||
filesLength = await driver.executeScript('return document.getElementById("archiveFiles").files.length');
|
||||
// Check that we loaded 1 file
|
||||
assert.equal(1, filesLength);
|
||||
} else {
|
||||
// We are running tests on BrowserStack, so create files as blobs and use the setRemoteArchives function to initiate the app
|
||||
await driver.executeScript('var files = arguments[0]; window.setRemoteArchives.apply(this, files);', [gutenbergRoBaseFile]);
|
||||
await driver.sleep('1300');
|
||||
}
|
||||
});
|
||||
|
||||
// In JQuery mode, the app warns the user that there is active content it cannot run, so we test for this and dismiss
|
||||
@ -210,9 +223,8 @@ function runTests (driver, modes) {
|
||||
await driver.wait(until.elementIsVisible(driver.findElement(By.id('popularity_sort')))).click();
|
||||
await driver.sleep(500);
|
||||
// get the text of first result and check if it is the same as expected
|
||||
const firstBookName = await driver.wait(async function () {
|
||||
return await driver.findElement(By.xpath('//*[@id="books_table"]/tbody/tr[1]/td[1]/div[2]/div/div/span[2]')).getText();
|
||||
})
|
||||
const firstBookName = await driver.wait(until.elementLocated(By.xpath('//*[@id="books_table"]/tbody/tr[1]/td[1]/div[2]/div/div/span[2]')), 4000).getText();
|
||||
|
||||
assert.equal(firstBookName, 'Poezii');
|
||||
});
|
||||
|
||||
@ -221,11 +233,16 @@ function runTests (driver, modes) {
|
||||
console.log('\x1b[33m%s\x1b[0m', ' Test skipped.');
|
||||
return;
|
||||
}
|
||||
// We switch to default Content and back to Iframe because the If we are retrying the test
|
||||
// It will make sure reset the iframe
|
||||
await driver.switchTo().defaultContent();
|
||||
await driver.switchTo().frame('articleContent');
|
||||
let firstBookName = '';
|
||||
await driver.wait(until.elementIsVisible(driver.findElement(By.id('alpha_sort')))).click();
|
||||
await driver.sleep(1500);
|
||||
const firstBookName = await driver.wait(async function () {
|
||||
return await driver.findElement(By.xpath('//*[@id="books_table"]/tbody/tr[1]/td[1]/div[2]/div/div/span[2]')).getText();
|
||||
}, 3000);
|
||||
await driver.sleep(4000);
|
||||
|
||||
const bookList = await driver.wait(until.elementsLocated(By.className('table-title')), 1500)
|
||||
firstBookName = await bookList[0].getText();
|
||||
// get the text of first result and check if it is the same as expected
|
||||
assert.equal(firstBookName, 'Creierul, O Enigma Descifrata');
|
||||
});
|
||||
@ -294,6 +311,7 @@ function runTests (driver, modes) {
|
||||
await btnBack.click();
|
||||
await btnBack.click();
|
||||
await btnBack.click();
|
||||
if (browserName === 'internet explorer') await btnBack.click();
|
||||
// Title lies in iframe so we need to switch to it
|
||||
await driver.switchTo().frame('articleContent');
|
||||
// in some browsers the title is loaded slowly so we need to wait for it
|
||||
@ -349,8 +367,8 @@ function runTests (driver, modes) {
|
||||
// await downloadButton.click();
|
||||
const downloadFileStatus = await driver.wait(async function () {
|
||||
// We can only check if the file exist in firefox and chrome (IE and Edge not supported)
|
||||
if (!['firefox', 'chrome'].includes(browserName)) {
|
||||
// will skip if any other browser and pass test
|
||||
if (!['firefox', 'chrome'].includes(browserName) || BROWSERSTACK) {
|
||||
// will skip if any other browser or Running in browserstack and pass test
|
||||
return true;
|
||||
}
|
||||
const downloadFileStatus = fs.readdirSync(paths.downloadDir).includes(downloadFileName);
|
@ -23,7 +23,7 @@
|
||||
import { By, Key, WebDriver, until } from 'selenium-webdriver';
|
||||
// import firefox from 'selenium-webdriver/firefox.js';
|
||||
import assert from 'assert';
|
||||
import paths from './paths.js';
|
||||
import paths from '../paths.js';
|
||||
|
||||
/* eslint-disable camelcase, one-var, prefer-const */
|
||||
/* global describe, it */
|
||||
@ -34,13 +34,13 @@ const BROWSERSTACK = !!process.env.BROWSERSTACK_LOCAL_IDENTIFIER;
|
||||
// const BROWSERSTACK = true;
|
||||
|
||||
// Select the correct port according to the environment
|
||||
const port = process.env.BROWSERSTACK_LOCAL_IDENTIFIER ? '8099' : '8080';
|
||||
const port = BROWSERSTACK ? '8099' : '8080';
|
||||
|
||||
// Set the archives to load
|
||||
let rayCharlesBaseFile = paths.rayCharlesBaseFile;
|
||||
// For BrowserStack, we have to construct the file blops with XHR instead
|
||||
if (BROWSERSTACK) {
|
||||
rayCharlesBaseFile = '/tests/wikipedia_en_ray_charles_2015-06.zimaa';
|
||||
rayCharlesBaseFile = '/tests/zims/legacy-ray-charles/wikipedia_en_ray_charles_2015-06.zimaa';
|
||||
}
|
||||
let rayCharlesAllParts = '', rayCharlesFileArray = [];
|
||||
for (let i = 0; i < 15; i++) {
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<base href="../">
|
||||
<base href="../../">
|
||||
<title>Kiwix-js Unit tests</title>
|
||||
|
||||
<!--
|
||||
@ -30,8 +30,8 @@
|
||||
<script>
|
||||
QUnit.config.autostart = false;
|
||||
</script>
|
||||
<script type="text/javascript" src="./tests/init.js"></script>
|
||||
<script type="module" src="./tests/tests.js"></script>
|
||||
<script type="text/javascript" src="./tests/unit/js/init.js"></script>
|
||||
<script type="module" src="./tests/unit/spec/tests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<b>NOTE:</b> Firefox and Chrome do not allow access to some local filesystem files used in testing. So, if you're opening this through a file:// URL, you should instead go through a web server : either through a local one (http://localhost/...) or through a remote one (but you need SSL : https://webserver/...).<br/>
|
@ -3,7 +3,7 @@
|
||||
import { Selector } from 'testcafe'; // first import testcafe selectors
|
||||
|
||||
fixture`Start QUnit tests`// declare the fixture
|
||||
.page`http://localhost:8080/tests/`; // specify the start page
|
||||
.page`http://localhost:8080/tests/unit/`; // specify the start page
|
||||
|
||||
// then create a test and place your code within it
|
||||
test('Check for success', async t => {
|
@ -26,9 +26,11 @@
|
||||
/* global webpHero */
|
||||
|
||||
// Define global params needed for tests to run on existing app code
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var params = {};
|
||||
|
||||
// Test if WebP is natively supported, and if not, load a webpMachine instance. This is used in uiUtils.js.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var webpMachine = false;
|
||||
|
||||
// We use a self-invoking function here to avoid defining unnecessary global functions and variables
|
||||
@ -46,7 +48,7 @@ var webpMachine = false;
|
||||
webpScript.onload = function () {
|
||||
webpMachine = new webpHero.WebpMachine({ useCanvasElements: true });
|
||||
}
|
||||
webpScript.src = '../www/js/webpHeroBundle_0.0.2.js';
|
||||
webpScript.src = '../../www/js/lib/webpHeroBundle_0.0.2.js';
|
||||
document.head.appendChild(webpScript);
|
||||
}
|
||||
});
|
@ -24,13 +24,13 @@
|
||||
|
||||
// import '../www/js/lib/promisePolyfill.js';
|
||||
// import '../www/js/lib/arrayFromPolyfill.js';
|
||||
import './init.js';
|
||||
import '../js/init.js';
|
||||
// import '../www/js/app.js';
|
||||
import zimArchive from '../www/js/lib/zimArchive.js';
|
||||
import zimDirEntry from '../www/js/lib/zimDirEntry.js';
|
||||
import util from '../www/js/lib/util.js';
|
||||
import uiUtil from '../www/js/lib/uiUtil.js';
|
||||
import utf8 from '../www/js/lib/utf8.js';
|
||||
import zimArchive from '../../../www/js/lib/zimArchive.js';
|
||||
import zimDirEntry from '../../../www/js/lib/zimDirEntry.js';
|
||||
import util from '../../../www/js/lib/util.js';
|
||||
import uiUtil from '../../../www/js/lib/uiUtil.js';
|
||||
import utf8 from '../../../www/js/lib/utf8.js';
|
||||
|
||||
var localZimArchive;
|
||||
|
||||
@ -77,7 +77,7 @@ var zimArchiveFiles = [];
|
||||
|
||||
var splitBlobs = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'].map(function (c) {
|
||||
var filename = 'wikipedia_en_ray_charles_2015-06.zima' + c;
|
||||
return makeBlobRequest('tests/' + filename, filename);
|
||||
return makeBlobRequest('tests/zims/legacy-ray-charles/' + filename, filename);
|
||||
});
|
||||
Promise.all(splitBlobs)
|
||||
.then(function (values) {
|
Loading…
x
Reference in New Issue
Block a user