mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-24 04:54:51 -04:00
Merge pull request #298 from kiwix/make-nightwatch-use-split-test-zim-file
Make Nightwatch use the split ZIM files of Ray Charles archive.
This commit is contained in:
commit
6b3076a701
@ -14,7 +14,22 @@ module.exports = {
|
||||
.url('http://localhost:8080/')
|
||||
.waitForElementVisible('body', 1000)
|
||||
.execute(function() {
|
||||
window.setRemoteArchive('http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zim');
|
||||
window.setRemoteArchives('http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimaa',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimab',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimac',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimad',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimae',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimaf',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimag',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimah',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimai',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimaj',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimak',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimal',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimam',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.ziman',
|
||||
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimao'
|
||||
);
|
||||
})
|
||||
.waitForElementVisible('#formArticleSearch', 20000)
|
||||
.waitForElementVisible('#searchArticles', 20000)
|
||||
|
Binary file not shown.
@ -26,8 +26,8 @@
|
||||
// This uses require.js to structure javascript:
|
||||
// http://requirejs.org/docs/api.html#define
|
||||
|
||||
define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFilesystemAccess'],
|
||||
function($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess) {
|
||||
define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFilesystemAccess','q'],
|
||||
function($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess, q) {
|
||||
|
||||
/**
|
||||
* Maximum number of articles to display in a search
|
||||
@ -560,9 +560,14 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used in the testing interface to inject a remote archive.
|
||||
* Reads a remote archive with given URL, and returns the response in a Promise.
|
||||
* This function is used by setRemoteArchives below, for UI tests
|
||||
*
|
||||
* @param url The URL of the archive to read
|
||||
* @returns {Promise}
|
||||
*/
|
||||
window.setRemoteArchive = function(url) {
|
||||
function readRemoteArchive(url) {
|
||||
var deferred = q.defer();
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("GET", url, true);
|
||||
request.responseType = "blob";
|
||||
@ -571,11 +576,32 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
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]);
|
||||
deferred.resolve(request.response);
|
||||
}
|
||||
else {
|
||||
deferred.reject("HTTP status " + request.status + " when reading " + url);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.onabort = function (e) {
|
||||
deferred.reject(e);
|
||||
};
|
||||
request.send(null);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used in the testing interface to inject remote archives
|
||||
*/
|
||||
window.setRemoteArchives = function() {
|
||||
var readRequests = [];
|
||||
var i;
|
||||
for (i = 0; i < arguments.length; i++) {
|
||||
readRequests[i] = readRemoteArchive(arguments[i]);
|
||||
}
|
||||
return q.all(readRequests).then(function(arrayOfArchives) {
|
||||
setLocalArchiveFromFileList(arrayOfArchives);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user