mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Merge pull request #27579 from overleaf/jpa-saas-e2e-split
[saas-e2e] prepare for running in Jenkins GitOrigin-RevId: 4d87d8a548849c193c5263a3b4f01202876f43a3
This commit is contained in:
@@ -9,7 +9,6 @@ import ProjectDeleter from '../app/src/Features/Project/ProjectDeleter.js'
|
||||
import SplitTestManager from '../app/src/Features/SplitTests/SplitTestManager.js'
|
||||
import UserDeleter from '../app/src/Features/User/UserDeleter.js'
|
||||
import UserRegistrationHandler from '../app/src/Features/User/UserRegistrationHandler.js'
|
||||
import { scriptRunner } from './lib/ScriptRunner.mjs'
|
||||
|
||||
const MONOREPO = Path.dirname(
|
||||
Path.dirname(Path.dirname(Path.dirname(fileURLToPath(import.meta.url))))
|
||||
@@ -24,7 +23,7 @@ async function createUser(email) {
|
||||
email,
|
||||
password: process.env.CYPRESS_DEFAULT_PASSWORD,
|
||||
})
|
||||
const features = email.startsWith('free@')
|
||||
const features = email.startsWith('free+')
|
||||
? Settings.defaultFeatures
|
||||
: Settings.features.professional
|
||||
await db.users.updateOne(
|
||||
@@ -32,7 +31,7 @@ async function createUser(email) {
|
||||
{
|
||||
$set: {
|
||||
// Set admin flag.
|
||||
isAdmin: email.startsWith('admin@'),
|
||||
isAdmin: email.startsWith('admin+'),
|
||||
// Disable spell-checking for performance and flakiness reasons.
|
||||
'ace.spellCheckLanguage': '',
|
||||
// Override features.
|
||||
@@ -76,6 +75,11 @@ async function deleteUser(email) {
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async function provisionUser(email) {
|
||||
if (!email.includes('+')) {
|
||||
throw new Error(
|
||||
`email=${email} should include the test suite name, e.g. user+project-sharing@example.com`
|
||||
)
|
||||
}
|
||||
await deleteUser(email)
|
||||
await createUser(email)
|
||||
}
|
||||
@@ -83,7 +87,7 @@ async function provisionUser(email) {
|
||||
async function provisionUsers() {
|
||||
const emails = Settings.recaptcha.trustedUsers
|
||||
console.log(`> Provisioning ${emails.length} E2E users.`)
|
||||
await promiseMapWithLimit(3, emails, provisionUser)
|
||||
await promiseMapWithLimit(5, emails, provisionUser)
|
||||
}
|
||||
|
||||
async function purgeNewUsers() {
|
||||
@@ -95,7 +99,7 @@ async function purgeNewUsers() {
|
||||
.toArray()
|
||||
console.log(`> Deleting ${users.length} newly created E2E users.`)
|
||||
await promiseMapWithLimit(
|
||||
3,
|
||||
5,
|
||||
users.map(user => user.email),
|
||||
deleteUser
|
||||
)
|
||||
@@ -154,12 +158,10 @@ async function main() {
|
||||
throw new Error('only available in dev-env')
|
||||
}
|
||||
|
||||
await purgeNewUsers()
|
||||
await provisionUsers()
|
||||
await provisionSplitTests()
|
||||
await Promise.all([purgeNewUsers(), provisionUsers(), provisionSplitTests()])
|
||||
}
|
||||
|
||||
await scriptRunner(main)
|
||||
await main()
|
||||
await GracefulShutdown.gracefulShutdown(
|
||||
{
|
||||
close(cb) {
|
||||
|
||||
Reference in New Issue
Block a user