mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
[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:
@@ -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 }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user