Skip to content

Commit

Permalink
Use single driver for Edge Legacy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Jan 10, 2025
1 parent d9db9d3 commit c643066
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
13 changes: 6 additions & 7 deletions tests/e2e/runners/edge/edge18.bs.runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ async function loadEdgeLegacyDriver () {
return driver;
};

const driver_edge_tonedear = await loadEdgeLegacyDriver();
await tonedear.runTests(driver_edge_tonedear);
// For this runner, we must use a single driver for all tests to avoid the other drivers
// timing out while earlier tests complete
const singleDriver = await loadEdgeLegacyDriver();

const driver_edge_legacy = await loadEdgeLegacyDriver();
await legacyRayCharles.runTests(driver_edge_legacy);

const driver_edge_gutenberg = await loadEdgeLegacyDriver();
await gutenbergRo.runTests(driver_edge_gutenberg);
await legacyRayCharles.runTests(singleDriver, null, true);
await gutenbergRo.runTests(singleDriver, null, true);
await tonedear.runTests(singleDriver);
7 changes: 4 additions & 3 deletions tests/e2e/spec/gutenberg_ro.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ const gutenbergRoBaseFile = BROWSERSTACK ? '/tests/zims/gutenberg-ro/gutenberg_r
* Run the tests
* @param {WebDriver} driver Selenium WebDriver object
* @param {Array} modes Array of modes to run the tests in
* @param {boolean} keepDriver Whether to keep the driver open after the tests have run
* @returns {Promise<void>} A Promise for the completion of the tests
*/
function runTests (driver, modes) {
function runTests (driver, modes, keepDriver) {
let browserName, browserVersion;
driver.getCapabilities().then(function (caps) {
browserName = caps.get('browserName');
Expand Down Expand Up @@ -180,7 +181,7 @@ function runTests (driver, modes) {
} else {
// Skip remaining SW mode tests if the browser does not support the SW API
console.log('\x1b[33m%s\x1b[0m', ' Skipping SW mode tests because browser does not support API');
await driver.quit();
if (!keepDriver) await driver.quit();
}
// Disable source verification in SW mode as the dialogue box gave incosistent test results in automated tests
if (mode === 'serviceworker') {
Expand Down Expand Up @@ -397,7 +398,7 @@ function runTests (driver, modes) {
assert.ok(downloadFileStatus);

// exit if every test and mode is completed
if (mode === modes[modes.length - 1]) {
if (mode === modes[modes.length - 1] && !keepDriver) {
await driver.quit();
}
});
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/spec/legacy-ray_charles.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ console.log('\nLoading archive:\n' + rayCharlesAllParts + '\n');
* Run the tests
* @param {WebDriver} driver Selenium WebDriver object
* @param {array} modes Array of modes to run the tests in
* @param {boolean} keepDriver Whether to keep the driver open after the tests have run
* @returns {Promise<void>} A Promise for the completion of the tests
*/
function runTests (driver, modes) {
function runTests (driver, modes, keepDriver) {
let browserName, browserVersion;
driver.getCapabilities().then(function (caps) {
browserName = caps.get('browserName');
Expand Down Expand Up @@ -192,7 +193,7 @@ function runTests (driver, modes) {
} else {
// Skip remaining SW mode tests if the browser does not support the SW API
console.log('\x1b[33m%s\x1b[0m', ' Skipping SW mode tests because browser does not support API');
await driver.quit();
if (!keepDriver) await driver.quit();
}
// Disable source verification in SW mode as the dialogue box gave incosistent test results in automated tests
if (mode === 'serviceworker') {
Expand Down Expand Up @@ -345,7 +346,7 @@ function runTests (driver, modes) {
const title = await driver.findElement(By.id('titleHeading')).getText();
assert.equal('Ray Charles', title);
// If we have reached the last mode, quit the driver
if (mode === modes[modes.length - 1]) {
if (mode === modes[modes.length - 1] && !keepDriver) {
await driver.quit();
}
});
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/spec/tonedear.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const tonedearBaseFile = BROWSERSTACK ? '/tests/zims/tonedear/tonedear.com_en_20
* Run the tests
* @param {WebDriver} driver Selenium WebDriver object
* @param {Array} modes Array of modes to run the tests in
* @param {boolean} keepDriver Whether to keep the driver open after the tests have run
* @returns {Promise<void>} A Promise for the completion of the tests
*/
function runTests (driver, modes) {
function runTests (driver, modes, keepDriver) {
let browserName, browserVersion;
driver.getCapabilities().then(function (caps) {
browserName = caps.get('browserName');
Expand Down Expand Up @@ -70,7 +71,7 @@ function runTests (driver, modes) {

if (mode === 'serviceworker' && !serviceWorkerAPI) {
console.log('\x1b[33m%s\x1b[0m', ' Skipping SW mode tests because browser does not support API');
await driver.quit();
if (!keepDriver) await driver.quit();
return;
}

Expand Down Expand Up @@ -206,7 +207,7 @@ function runTests (driver, modes) {
}

// exit if every test and mode is completed
if (mode === modes[modes.length - 1]) {
if (mode === modes[modes.length - 1] && !keepDriver) {
await driver.quit();
}
});
Expand Down

0 comments on commit c643066

Please sign in to comment.