mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 11:01:56 +02:00
Make test admin users engineers
GitOrigin-RevId: 627b5b05eefdfa675937764b7c798e99ab6ef37e
This commit is contained in:
@@ -32,6 +32,7 @@ async function createUser(email) {
|
||||
$set: {
|
||||
// Set admin flag.
|
||||
isAdmin: email.startsWith('admin+'),
|
||||
adminRoles: email.startsWith('admin+') ? ['engineering'] : [],
|
||||
// Disable spell-checking for performance and flakiness reasons.
|
||||
'ace.spellCheckLanguage': '',
|
||||
// Override features.
|
||||
|
||||
@@ -16,6 +16,7 @@ describe('AdminPrivilegeAvailable', function () {
|
||||
adminUser = new User()
|
||||
await adminUser.ensureUserExists()
|
||||
await adminUser.ensureAdmin()
|
||||
await adminUser.ensureAdminRole('engineering')
|
||||
await adminUser.login()
|
||||
})
|
||||
|
||||
|
||||
@@ -212,6 +212,7 @@ describe('Authorization', function () {
|
||||
this.other2 = new User()
|
||||
this.anon = new User()
|
||||
this.site_admin = new User({ email: 'admin@example.com' })
|
||||
settings.adminRolesEnabled = false
|
||||
await Promise.all([
|
||||
this.owner.login(),
|
||||
this.other1.login(),
|
||||
|
||||
@@ -579,6 +579,10 @@ class User {
|
||||
this.mongoUpdate({ $set: { isAdmin: true } }, callback)
|
||||
}
|
||||
|
||||
ensureAdminRole(role, callback) {
|
||||
this.mongoUpdate({ $addToSet: { adminRoles: 'engineering' } }, callback)
|
||||
}
|
||||
|
||||
ensureStaffAccess(flag, callback) {
|
||||
const update = { $set: {} }
|
||||
update.$set[`staffAccess.${flag}`] = true
|
||||
|
||||
Reference in New Issue
Block a user