passing newItem tests

This commit is contained in:
Bogdan Abaev 2024-01-12 10:07:19 -05:00 committed by Dan Stillman
parent 3073137d39
commit 8e4fd75f1d
2 changed files with 12 additions and 12 deletions
chrome/content/zotero
test/tests

View file

@ -1328,9 +1328,11 @@ var ZoteroPane = new function()
if (manual) {
// Update most-recently-used list for New Item menu
this.addItemTypeToNewItemTypeMRU(Zotero.ItemTypes.getName(typeID));
// Focus the title field
document.getElementById('zotero-editpane-item-box').focusFirstField();
// Focus the title field if the itemPane is expanded
let itemPane = document.getElementById("zotero-item-pane");
if (!itemPane.getAttribute("collapsed")) {
document.getElementById('zotero-item-pane-header').querySelector("editable-text").focus();
}
}
return Zotero.Items.getAsync(itemID);

View file

@ -18,21 +18,19 @@ describe("ZoteroPane", function() {
describe("#newItem", function () {
it("should create an item and focus the title field", function* () {
yield zp.newItem(Zotero.ItemTypes.getID('book'), {}, null, true);
var itemBox = doc.getElementById('zotero-editpane-item-box');
var textboxes = itemBox.querySelectorAll('input, textarea');
assert.lengthOf(textboxes, 1);
assert.equal(textboxes[0].getAttribute('fieldname'), 'title');
textboxes[0].blur();
let title = doc.getElementById('zotero-item-pane-header').querySelector("editable-text");
assert.equal(doc.activeElement.getAttribute("aria-label"), title.getAttribute("aria-label"));
title.blur();
yield Zotero.Promise.delay(1);
})
it("should save an entered value when New Item is used", function* () {
var value = "Test";
var item = yield zp.newItem(Zotero.ItemTypes.getID('book'), {}, null, true);
var itemBox = doc.getElementById('zotero-editpane-item-box');
var textbox = itemBox.querySelector('textarea');
textbox.value = value;
yield itemBox.blurOpenField();
let header = doc.getElementById('zotero-item-pane-header');
let title = header.querySelector("editable-text");
title.value = value;
yield header.save();
item = yield Zotero.Items.getAsync(item.id);
assert.equal(item.getField('title'), value);
})