mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
fix: prevent response disposal race condition in E2E test
This commit is contained in:
@@ -85,7 +85,17 @@ test.describe('Open Project', () => {
|
|||||||
// AND inject our test project into the projects list
|
// AND inject our test project into the projects list
|
||||||
await page.route('**/api/settings/global', async (route) => {
|
await page.route('**/api/settings/global', async (route) => {
|
||||||
const response = await route.fetch();
|
const response = await route.fetch();
|
||||||
const json = await response.json();
|
// Immediately consume the body to prevent disposal issues
|
||||||
|
const bodyPromise = response.body();
|
||||||
|
const status = response.status();
|
||||||
|
const headers = response.headers();
|
||||||
|
const body = await bodyPromise;
|
||||||
|
let json;
|
||||||
|
try {
|
||||||
|
json = JSON.parse(body.toString());
|
||||||
|
} catch {
|
||||||
|
json = {};
|
||||||
|
}
|
||||||
if (json.settings) {
|
if (json.settings) {
|
||||||
// Remove currentProjectId to prevent restoring a project
|
// Remove currentProjectId to prevent restoring a project
|
||||||
json.settings.currentProjectId = null;
|
json.settings.currentProjectId = null;
|
||||||
@@ -106,8 +116,8 @@ test.describe('Open Project', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
status: response.status(),
|
status: status,
|
||||||
headers: response.headers(),
|
headers: headers,
|
||||||
json,
|
json,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user