zotero/test/tests/usersTest.js
Dan Stillman 04321fc627 Restore cached user name on transaction rollback
Zotero.Users.setName() updated the in-memory cache even if the
transaction was later rolled back, so a retry (e.g., of a failed sync
download batch) would skip rewriting the users row.
2026-08-09 14:29:48 -04:00

20 lines
704 B
JavaScript

describe("Zotero.Users", function () {
describe("#setName()", function () {
it("should restore the cached name if the transaction is rolled back", async function () {
var userID = 24631244;
await Zotero.Users.setName(userID, 'A');
await executeTransactionWithForcedRollback(async function () {
await Zotero.Users.setName(userID, 'B');
assert.equal(Zotero.Users.getName(userID), 'B');
});
assert.equal(Zotero.Users.getName(userID), 'A');
// A later save should write the new name to the database
await Zotero.Users.setName(userID, 'B');
assert.equal(
await Zotero.DB.valueQueryAsync("SELECT name FROM users WHERE userID=?", userID),
'B'
);
});
});
});