2024-05-30 03:12:56 -04:00
|
|
|
import { reconfigure } from './hostAdminClient'
|
2024-08-02 08:10:06 -04:00
|
|
|
import { resetActivateUserRateLimit, resetCreatedUsersCache } from './login'
|
2024-05-30 03:12:56 -04:00
|
|
|
|
2024-06-25 07:03:05 -04:00
|
|
|
export const STARTUP_TIMEOUT =
|
|
|
|
parseInt(Cypress.env('STARTUP_TIMEOUT'), 10) || 120_000
|
|
|
|
|
2024-07-10 10:00:41 -04: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 05:10:03 -04:00
|
|
|
let previousConfigFrontend: string
|
2024-05-30 03:12:56 -04:00
|
|
|
|
2024-05-30 03:13:40 -04:00
|
|
|
export function startWith({
|
|
|
|
pro = false,
|
|
|
|
version = 'latest',
|
|
|
|
vars = {},
|
|
|
|
varsFn = () => ({}),
|
2024-06-11 07:01:21 -04:00
|
|
|
withDataDir = false,
|
2024-07-10 10:00:41 -04:00
|
|
|
resetData = false,
|
2024-05-30 03:13:40 -04:00
|
|
|
}) {
|
2024-05-30 03:12:56 -04:00
|
|
|
before(async function () {
|
2024-05-30 03:13:40 -04:00
|
|
|
Object.assign(vars, varsFn())
|
2024-07-01 11:02:37 -04:00
|
|
|
const cfg = JSON.stringify({
|
|
|
|
pro,
|
|
|
|
version,
|
|
|
|
vars,
|
|
|
|
withDataDir,
|
2024-08-06 05:10:03 -04:00
|
|
|
resetData,
|
2024-07-01 11:02:37 -04:00
|
|
|
})
|
2024-07-10 10:00:41 -04:00
|
|
|
if (resetData) {
|
|
|
|
resetCreatedUsersCache()
|
2024-08-02 08:10:06 -04:00
|
|
|
resetActivateUserRateLimit()
|
2024-07-10 10:00:41 -04:00
|
|
|
// no return here, always reconfigure when resetting data
|
2024-08-06 05:10:03 -04:00
|
|
|
} else if (previousConfigFrontend === cfg) {
|
2024-07-10 10:00:41 -04:00
|
|
|
return
|
|
|
|
}
|
2024-05-30 03:12:56 -04:00
|
|
|
|
2024-06-25 07:03:05 -04:00
|
|
|
this.timeout(STARTUP_TIMEOUT)
|
2024-08-06 05:10:03 -04:00
|
|
|
const { previousConfigServer } = await reconfigure({
|
|
|
|
pro,
|
|
|
|
version,
|
|
|
|
vars,
|
|
|
|
withDataDir,
|
|
|
|
resetData,
|
|
|
|
})
|
|
|
|
if (previousConfigServer !== cfg) {
|
|
|
|
await Cypress.session.clearAllSavedSessions()
|
|
|
|
}
|
|
|
|
previousConfigFrontend = cfg
|
2024-05-30 03:12:56 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export { reconfigure }
|