[web] avoid setting up users more than once in tests (#23558)

* [web] avoid setting up users more than once in tests

* [web] tests: simplify user exists check in User.setExtraAttributes

GitOrigin-RevId: 4c526df7c933a38ab93d7760efbd0a9490d5582a
This commit is contained in:
Jakob Ackermann
2025-02-13 09:05:27 +00:00
committed by Copybot
parent dc0b214bb5
commit d1410f4636
@@ -240,7 +240,7 @@ class User {
}
setExtraAttributes(user) {
if ((user != null ? user._id : undefined) == null) {
if (!user?._id) {
throw new Error('User does not exist')
}
this.id = user._id.toString()
@@ -412,6 +412,7 @@ class User {
}
ensureUserExists(callback) {
if (this._id) return callback() // already exists
const filter = { email: this.email }
const options = { upsert: true, new: true, setDefaultsOnInsert: true }