Merge pull request #19778 from overleaf/jpa-e2e-reuse-sessions

[server-pro] tests: implement session re-usage

GitOrigin-RevId: 81f2feb39e413c858eb287784e378cf43423d0a4
This commit is contained in:
Jakob Ackermann
2024-08-07 08:04:28 +00:00
committed by Copybot
parent 399e834e36
commit 37f486ca9a
8 changed files with 58 additions and 35 deletions
+5 -5
View File
@@ -15,7 +15,7 @@ export async function reconfigure({
vars = {},
withDataDir = false,
resetData = false,
}) {
}): Promise<{ previousConfigServer: string }> {
return await fetchJSON(`${hostAdminUrl}/reconfigure`, {
method: 'POST',
body: JSON.stringify({
@@ -28,15 +28,15 @@ export async function reconfigure({
})
}
async function fetchJSON(
async function fetchJSON<T = { stdout: string; stderr: string }>(
input: RequestInfo,
init?: RequestInit
): Promise<{ stdout: string; stderr: string }> {
): Promise<T> {
if (init?.body) {
init.headers = { 'Content-Type': 'application/json' }
}
const res = await fetch(input, init)
const { error, stdout, stderr } = await res.json()
const { error, stdout, stderr, ...rest } = await res.json()
if (error) {
console.error(input, init, 'failed:', error)
if (stdout) console.log(stdout)
@@ -45,7 +45,7 @@ async function fetchJSON(
Object.assign(err, error)
throw err
}
return { stdout, stderr }
return { stdout, stderr, ...rest }
}
export async function runScript({