2024-05-30 07:12:56 +00:00
|
|
|
import { reconfigure } from './hostAdminClient'
|
2024-08-02 12:10:06 +00:00
|
|
|
import { resetActivateUserRateLimit, resetCreatedUsersCache } from './login'
|
2024-05-30 07:12:56 +00:00
|
|
|
|
2024-06-25 11:03:05 +00:00
|
|
|
export const STARTUP_TIMEOUT =
|
|
|
|
parseInt(Cypress.env('STARTUP_TIMEOUT'), 10) || 120_000
|
|
|
|
|
2024-07-10 14:00:41 +00:00
|
|
|
export function isExcludedBySharding(
|
|
|
|
shard:
|
|
|
|
| 'CE_DEFAULT'
|
|
|
|
| 'CE_CUSTOM_1'
|
|
|
|
| 'CE_CUSTOM_2'
|
|
|
|
| 'PRO_DEFAULT_1'
|
|
|
|
| 'PRO_DEFAULT_2'
|
|
|
|
| 'PRO_CUSTOM_1'
|
|
|
|
| 'PRO_CUSTOM_2'
|
|
|
|
| 'PRO_CUSTOM_3'
|
|
|
|
) {
|
|
|
|
const SHARD = Cypress.env('SHARD')
|
|
|
|
return SHARD && shard !== SHARD
|
|
|
|
}
|
|
|
|
|
2024-08-06 09:10:03 +00:00
|
|
|
let previousConfigFrontend: string
|
2024-05-30 07:12:56 +00:00
|
|
|
|
2024-05-30 07:13:40 +00:00
|
|
|
export function startWith({
|
|
|
|
pro = false,
|
|
|
|
version = 'latest',
|
|
|
|
vars = {},
|
|
|
|
varsFn = () => ({}),
|
2024-06-11 11:01:21 +00:00
|
|
|
withDataDir = false,
|
2024-07-10 14:00:41 +00:00
|
|
|
resetData = false,
|
2024-05-30 07:13:40 +00:00
|
|
|
}) {
|
2024-05-30 07:12:56 +00:00
|
|
|
before(async function () {
|
2024-05-30 07:13:40 +00:00
|
|
|
Object.assign(vars, varsFn())
|
2024-07-01 15:02:37 +00:00
|
|
|
const cfg = JSON.stringify({
|
|
|
|
pro,
|
|
|
|
version,
|
|
|
|
vars,
|
|
|
|
withDataDir,
|
2024-08-06 09:10:03 +00:00
|
|
|
resetData,
|
2024-07-01 15:02:37 +00:00
|
|
|
})
|
2024-07-10 14:00:41 +00:00
|
|
|
if (resetData) {
|
|
|
|
resetCreatedUsersCache()
|
2024-08-02 12:10:06 +00:00
|
|
|
resetActivateUserRateLimit()
|
2024-07-10 14:00:41 +00:00
|
|
|
// no return here, always reconfigure when resetting data
|
2024-08-06 09:10:03 +00:00
|
|
|
} else if (previousConfigFrontend === cfg) {
|
2024-07-10 14:00:41 +00:00
|
|
|
return
|
|
|
|
}
|
2024-05-30 07:12:56 +00:00
|
|
|
|
2024-06-25 11:03:05 +00:00
|
|
|
this.timeout(STARTUP_TIMEOUT)
|
2024-08-06 09:10:03 +00:00
|
|
|
const { previousConfigServer } = await reconfigure({
|
|
|
|
pro,
|
|
|
|
version,
|
|
|
|
vars,
|
|
|
|
withDataDir,
|
|
|
|
resetData,
|
|
|
|
})
|
|
|
|
if (previousConfigServer !== cfg) {
|
|
|
|
await Cypress.session.clearAllSavedSessions()
|
|
|
|
}
|
|
|
|
previousConfigFrontend = cfg
|
2024-05-30 07:12:56 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export { reconfigure }
|