Fix handling of 413 for over-quota errors
And fix handling of custom error dialog button text/callbacks in general.
This commit is contained in:
parent
098655d913
commit
1c90a77298
8 changed files with 75 additions and 27 deletions
|
@ -821,5 +821,42 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () {
|
|||
assert.isFalse(result.remoteChanges);
|
||||
assert.isTrue(result.syncRequired);
|
||||
})
|
||||
|
||||
it("should handle 413 on quota limit", function* () {
|
||||
var { engine, client, caller } = yield setup();
|
||||
var zfs = new Zotero.Sync.Storage.Mode.ZFS({
|
||||
apiClient: client
|
||||
})
|
||||
|
||||
var file = getTestDataDirectory();
|
||||
file.append('test.png');
|
||||
var item = yield Zotero.Attachments.importFromFile({ file });
|
||||
item.version = 5;
|
||||
item.synced = true;
|
||||
yield item.saveTx();
|
||||
|
||||
server.respond(function (req) {
|
||||
if (req.method == "POST"
|
||||
&& req.url == `${baseURL}users/1/items/${item.key}/file`
|
||||
&& req.requestBody.indexOf('upload=') == -1
|
||||
&& req.requestHeaders["If-None-Match"] == "*") {
|
||||
req.respond(
|
||||
413,
|
||||
{
|
||||
"Content-Type": "application/json",
|
||||
"Last-Modified-Version": 10
|
||||
},
|
||||
"File would exceed quota (299.7 + 0.5 > 300)"
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
var e = yield getPromiseError(zfs._processUploadFile({
|
||||
name: item.libraryKey
|
||||
}));
|
||||
assert.ok(e);
|
||||
assert.equal(e.errorType, 'warning');
|
||||
assert.include(e.message, 'would exceed your');
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue