From 1ebf46eaa5c1c9ba70f33da913d632fd3d902540 Mon Sep 17 00:00:00 2001 From: RG Date: Thu, 19 Oct 2023 22:42:28 +0530 Subject: [PATCH] [FIX] zim not loading in tests --- tests/e2e/spec/gutenberg_ro.e2e.spec.js | 4 ++++ tests/e2e/spec/legacy-ray_charles.e2e.spec.js | 3 +++ www/js/app.js | 1 + 3 files changed, 8 insertions(+) diff --git a/tests/e2e/spec/gutenberg_ro.e2e.spec.js b/tests/e2e/spec/gutenberg_ro.e2e.spec.js index 4232085d1..9c76368a1 100644 --- a/tests/e2e/spec/gutenberg_ro.e2e.spec.js +++ b/tests/e2e/spec/gutenberg_ro.e2e.spec.js @@ -192,6 +192,10 @@ function runTests (driver, modes) { const archiveFiles = await driver.findElement(By.id('archiveFiles')); if (!isFileLoaded) await archiveFiles.sendKeys(gutenbergRoBaseFile); filesLength = await driver.executeScript('return document.getElementById("archiveFiles").files.length'); + + // In new browsers Files are loaded using the FileSystem API, so we have to set the local archives using JavaScript + // which were selected using the file input + await driver.executeScript('window.setLocalArchiveFromFileSelect();'); // Check that we loaded 1 file assert.equal(1, filesLength); } else { diff --git a/tests/e2e/spec/legacy-ray_charles.e2e.spec.js b/tests/e2e/spec/legacy-ray_charles.e2e.spec.js index 162497289..7691ddcc3 100644 --- a/tests/e2e/spec/legacy-ray_charles.e2e.spec.js +++ b/tests/e2e/spec/legacy-ray_charles.e2e.spec.js @@ -207,6 +207,9 @@ function runTests (driver, modes) { filesLength = await driver.executeScript('return document.getElementById("archiveFiles").files.length'); return filesLength === 15; }, 5000); + // In new browsers Files are loaded using the FileSystem API, so we have to set the local archives using JavaScript + // which were selected using the file input + await driver.executeScript('window.setLocalArchiveFromFileSelect();'); // Check that we loaded 15 files assert.equal(15, filesLength); } else { diff --git a/www/js/app.js b/www/js/app.js index a8d5eef06..b19ad4295 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1438,6 +1438,7 @@ function archiveReadyCallback (archive) { function setLocalArchiveFromFileSelect () { setLocalArchiveFromFileList(document.getElementById('archiveFiles').files); } +window.setLocalArchiveFromFileSelect = setLocalArchiveFromFileSelect; /** * Reads a remote archive with given URL, and returns the response in a Promise.