Test debug output logging again

Now that we run tests in Zotero with application menus.
This commit is contained in:
Abe Jellinek 2023-05-24 20:59:29 +03:00
parent 087a9859b4
commit 794b27c1ad
2 changed files with 45 additions and 62 deletions

45
test/tests/debugTest.js Normal file
View file

@ -0,0 +1,45 @@
describe("Debug Output Logging", function () {
var server;
var win;
var doc;
before(async function () {
server = sinon.fakeServer.create();
server.autoRespond = true;
Zotero.HTTP.mock = sinon.FakeXMLHttpRequest;
win = await loadZoteroPane();
doc = win.document;
});
after(function () {
Zotero.HTTP.mock = null;
win.close();
});
it("should log output and submit to server", async function () {
doc.getElementById('debug-output-enable-disable').doCommand();
await createDataObject('item');
doc.getElementById('debug-output-submit').doCommand();
server.respond(function (req) {
if (req.method == "POST") {
req.respond(
200,
{},
'<?xml version="1.0" encoding="UTF-8"?>\n'
+ '<xml><reported reportID="1234567890"/></xml>'
);
}
});
// Make sure Debug ID is shown in dialog
var promise = waitForDialog(function (dialog) {
assert.match(dialog.document.documentElement.textContent, /D1234567890/);
});
doc.getElementById('debug-output-submit').click();
await promise;
win.close();
});
});

View file

@ -1,66 +1,4 @@
describe("Advanced Preferences", function () {
// TODO: Debug output logging is now in the application menus, and we test in Firefox...
// Maybe add the debug output menu to Firefox for the purposes of testing?
describe.skip("General", function () {
var server;
before(function () {
server = sinon.fakeServer.create();
server.autoRespond = true;
Zotero.HTTP.mock = sinon.FakeXMLHttpRequest;
});
after(function () {
Zotero.HTTP.mock = null;
})
describe("Debug Output", function () {
it("should log output and submit to server", function* () {
var win = yield loadWindow("chrome://zotero/content/preferences/preferences.xhtml", {
pane: 'zotero-prefpane-advanced',
tabIndex: 0
});
// Wait for tab to load
var doc = win.document;
var prefwindow = doc.documentElement;
var defer = Zotero.Promise.defer();
var pane = doc.getElementById('zotero-prefpane-advanced');
if (!pane.loaded) {
pane.addEventListener('paneload', function () {
defer.resolve();
})
yield defer.promise;
}
var enableButton = doc.getElementById('debug-output-enable');
enableButton.click();
yield createDataObject('item');
enableButton.click();
server.respond(function (req) {
if (req.method == "POST") {
req.respond(
200,
{},
'<?xml version="1.0" encoding="UTF-8"?>\n'
+ '<xml><reported reportID="1234567890"/></xml>'
);
}
});
// Make sure Debug ID is shown in dialog
var promise = waitForDialog(function (dialog) {
assert.match(dialog.document.documentElement.textContent, /D1234567890/);
});
doc.getElementById('debug-output-submit').click();
yield promise;
win.close();
});
});
});
describe("Files & Folders", function () {
describe("Linked Attachment Base Directory", function () {
var setBaseDirectory = Zotero.Promise.coroutine(function* (basePath) {