Dictionary handling improvements

- Fix installation of dictionaries on Windows
- Use version in XPI download URL (zotero/zotero-build@c3308c7a4)
- Improve display of download errors
This commit is contained in:
Dan Stillman 2021-06-26 17:03:52 -04:00
parent 425daa3622
commit 261bb7ee91
4 changed files with 49 additions and 23 deletions

View file

@ -78,6 +78,7 @@ describe("Dictionaries", function () {
}
sandbox.stub(Zotero.File, 'download').callsFake(async (url, downloadPath) => {
Zotero.debug("Fake downloading " + url);
if (url.includes('en-UK')) {
return OS.File.copy(enUKXPIOld, downloadPath);
}
@ -89,9 +90,9 @@ describe("Dictionaries", function () {
}
throw new Error("Unexpected URL " + url);
});
await Zotero.Dictionaries.install('@fake-en-UK-dictionary');
await Zotero.Dictionaries.install('@fake-fr-FR-dictionary');
await Zotero.Dictionaries.install('@fake-xx-UN-dictionary');
await Zotero.Dictionaries.install('@fake-en-UK-dictionary', "5");
await Zotero.Dictionaries.install('@fake-fr-FR-dictionary', "1");
await Zotero.Dictionaries.install('@fake-xx-UN-dictionary', "5");
sandbox.restore();
// Create metadata response for available dictionaries
@ -112,10 +113,11 @@ describe("Dictionaries", function () {
]);
sandbox.stub(Zotero.File, 'download').callsFake(async (url, downloadPath) => {
if (url.includes('en-UK')) {
Zotero.debug("Fake downloading " + url);
if (url.includes('en-UK') && url.includes("-1.xpi")) {
return OS.File.copy(enUKXPINew, downloadPath);
}
if (url.includes('fr-FR')) {
if (url.includes('fr-FR') && url.includes("-2.xpi")) {
return OS.File.copy(frFRv2XPI, downloadPath);
}
throw new Error("Unexpected URL " + url);