fix: track mutations by method, not body presence

POST/DELETE without a body were not recorded because
postDataJSON() returns null. Track based on HTTP method instead.
This commit is contained in:
bymyself
2026-03-28 23:20:46 -07:00
parent 71e9e7c057
commit bc52d164e2

View File

@@ -109,11 +109,17 @@ export class AssetHelper {
const url = new URL(route.request().url())
const method = route.request().method()
const path = url.pathname
const body = ['POST', 'PUT', 'DELETE'].includes(method)
? route.request().postDataJSON()
: null
const isMutation = ['POST', 'PUT', 'DELETE'].includes(method)
let body: Record<string, unknown> | null = null
if (isMutation) {
try {
body = route.request().postDataJSON()
} catch {
body = null
}
}
if (body !== null) {
if (isMutation) {
this.mutations.push({
endpoint: path,
method,