mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 01:33:53 -05:00
b75d183cfc
[server-pro] add tests for upgrade process GitOrigin-RevId: eaa1486688cb2fa544adaaee16da04fd757a1b65
22 lines
792 B
TypeScript
22 lines
792 B
TypeScript
/**
|
|
* Helper function for throttling clicks on the recompile button to avoid hitting server side rate limits.
|
|
* The naive approach is waiting a fixed a mount of time (3s) just before clicking the button.
|
|
* This helper takes into account that other UI interactions take time. We can deduce that latency from the fixed delay (3s minus other latency). This can bring down the effective waiting time to 0s.
|
|
*/
|
|
export function throttledRecompile() {
|
|
let lastCompile = 0
|
|
function queueReset() {
|
|
cy.then(() => {
|
|
lastCompile = Date.now()
|
|
})
|
|
}
|
|
|
|
queueReset()
|
|
return () =>
|
|
cy.then(() => {
|
|
const msSinceLastCompile = Date.now() - lastCompile
|
|
cy.wait(Math.max(0, 1_000 - msSinceLastCompile))
|
|
cy.findByText('Recompile').click()
|
|
queueReset()
|
|
})
|
|
}
|