Default to first translator for /connector/savePage if not provided
This commit is contained in:
parent
bb0fa73899
commit
01df8f59e5
3 changed files with 70 additions and 2 deletions
|
@ -390,6 +390,58 @@ describe("Connector Server", function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe("/connector/savePage", function() {
|
||||
// TEMP: Wait for indexing to complete, which happens after a 1-second delay, after a 201 has
|
||||
// been returned to the connector. Would be better to make sure indexing has completed.
|
||||
afterEach(function* () {
|
||||
yield Zotero.Promise.delay(1050);
|
||||
});
|
||||
|
||||
it("should return 500 if no translator available for page", function* () {
|
||||
var xmlhttp = yield Zotero.HTTP.request(
|
||||
'POST',
|
||||
connectorServerPath + "/connector/savePage",
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uri: "http://example.com",
|
||||
html: "<html><head><title>Title</title><body>Body</body></html>"
|
||||
}),
|
||||
successCodes: false
|
||||
}
|
||||
);
|
||||
assert.equal(xmlhttp.status, 500);
|
||||
});
|
||||
|
||||
it("should translate a page if translators are available", function* () {
|
||||
var html = Zotero.File.getContentsFromURL(getTestDataUrl('coins.html'));
|
||||
var promise = waitForItemEvent('add');
|
||||
var xmlhttp = yield Zotero.HTTP.request(
|
||||
'POST',
|
||||
connectorServerPath + "/connector/savePage",
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uri: "https://example.com/test",
|
||||
html
|
||||
}),
|
||||
successCodes: false
|
||||
}
|
||||
);
|
||||
|
||||
let ids = yield promise;
|
||||
var item = Zotero.Items.get(ids[0]);
|
||||
var title = "Test Page";
|
||||
assert.equal(JSON.parse(xmlhttp.responseText).items[0].title, title);
|
||||
assert.equal(item.getField('title'), title);
|
||||
assert.equal(xmlhttp.status, 201);
|
||||
});
|
||||
});
|
||||
|
||||
describe('/connector/installStyle', function() {
|
||||
var endpoint;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue