From 0624b99cb7a6ae92baf226c8137a12fee70ed8c7 Mon Sep 17 00:00:00 2001 From: Mossroy Date: Mon, 19 Jun 2017 22:38:17 +0200 Subject: [PATCH 1/2] Properly use onreadystatechange on XHR for reading ZIM for UI tests. --- www/js/app.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 41643157..2531f75d 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -575,11 +575,13 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles var request = new XMLHttpRequest(); request.open("GET", url, true); request.responseType = "blob"; - request.onload = function (e) { - if (request.response) { - // Hack to make this look similar to a file - request.response.name = url; - setLocalArchiveFromFileList([request.response]); + request.onreadystatechange = function () { + if (request.readyState === XMLHttpRequest.DONE) { + if ((request.status >= 200 && request.status < 300) || request.status === 0) { + // Hack to make this look similar to a file + request.response.name = url; + setLocalArchiveFromFileList([request.response]); + } } }; request.send(null); From 172c8a678581efba6657bb033cc56a13b6605130 Mon Sep 17 00:00:00 2001 From: Mossroy Date: Wed, 21 Jun 2017 15:57:06 +0200 Subject: [PATCH 2/2] Read the ZIM file from localhost for UI tests Instead of reading it from github.io --- browser-tests/nightwatch_runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser-tests/nightwatch_runner.js b/browser-tests/nightwatch_runner.js index ead9590b..b10c37f8 100644 --- a/browser-tests/nightwatch_runner.js +++ b/browser-tests/nightwatch_runner.js @@ -14,7 +14,7 @@ module.exports = { .url('http://localhost:8080/') .waitForElementVisible('body', 1000) .execute(function() { - window.setRemoteArchive('https://kiwix.github.io/kiwix-html5/tests/wikipedia_en_ray_charles_2015-06.zim'); + window.setRemoteArchive('http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zim'); }) .waitForElementVisible('#formArticleSearch', 20000) .waitForElementVisible('#searchArticles', 20000)