From c643066a4b03b68be99baae8d9ddf6615b08da57 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Fri, 10 Jan 2025 11:33:21 +0000 Subject: [PATCH] Use single driver for Edge Legacy tests --- tests/e2e/runners/edge/edge18.bs.runner.js | 13 ++++++------- tests/e2e/spec/gutenberg_ro.e2e.spec.js | 7 ++++--- tests/e2e/spec/legacy-ray_charles.e2e.spec.js | 7 ++++--- tests/e2e/spec/tonedear.e2e.spec.js | 7 ++++--- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/e2e/runners/edge/edge18.bs.runner.js b/tests/e2e/runners/edge/edge18.bs.runner.js index baf83282f..39bc06912 100644 --- a/tests/e2e/runners/edge/edge18.bs.runner.js +++ b/tests/e2e/runners/edge/edge18.bs.runner.js @@ -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); diff --git a/tests/e2e/spec/gutenberg_ro.e2e.spec.js b/tests/e2e/spec/gutenberg_ro.e2e.spec.js index 038a4e23d..024d44b67 100644 --- a/tests/e2e/spec/gutenberg_ro.e2e.spec.js +++ b/tests/e2e/spec/gutenberg_ro.e2e.spec.js @@ -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} 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'); @@ -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') { @@ -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(); } }); diff --git a/tests/e2e/spec/legacy-ray_charles.e2e.spec.js b/tests/e2e/spec/legacy-ray_charles.e2e.spec.js index 783ba34a1..974ba81bc 100644 --- a/tests/e2e/spec/legacy-ray_charles.e2e.spec.js +++ b/tests/e2e/spec/legacy-ray_charles.e2e.spec.js @@ -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} 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'); @@ -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') { @@ -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(); } }); diff --git a/tests/e2e/spec/tonedear.e2e.spec.js b/tests/e2e/spec/tonedear.e2e.spec.js index 06dd0c3da..1033b99f1 100644 --- a/tests/e2e/spec/tonedear.e2e.spec.js +++ b/tests/e2e/spec/tonedear.e2e.spec.js @@ -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} 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'); @@ -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; } @@ -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(); } });