From b707085143b20e5a8d801d89b131d12445a00021 Mon Sep 17 00:00:00 2001 From: Maximilian Kaske <56969857+mxkaske@users.noreply.github.com> Date: Thu, 25 Jul 2024 22:24:18 +0200 Subject: [PATCH] fix: text body (#960) * fix: text body * ci: apply automated fixes * fix: more * ci: apply automated fixes * fix: document cookie expires date * fix: missing body --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../web/src/components/forms/monitor/form.tsx | 19 +++++++++++++---- .../forms/monitor/section-assertions.tsx | 2 +- .../ping-response-analysis/utils.ts | 1 + apps/web/src/hooks/use-cookie-state.ts | 21 +++++++++++++------ packages/api/src/router/monitor.ts | 10 ++++++++- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/apps/web/src/components/forms/monitor/form.tsx b/apps/web/src/components/forms/monitor/form.tsx index f3a81cabf..0649cf343 100644 --- a/apps/web/src/components/forms/monitor/form.tsx +++ b/apps/web/src/components/forms/monitor/form.tsx @@ -91,7 +91,10 @@ export function MonitorForm({ statusAssertions: _assertions.filter((a) => a.type === "status") as any, // TS considers a.type === "header" // biome-ignore lint/suspicious/noExplicitAny: headerAssertions: _assertions.filter((a) => a.type === "header") as any, // TS considers a.type === "status" - + textBodyAssertions: _assertions.filter( + (a) => a.type === "textBody", + // biome-ignore lint/suspicious/noExplicitAny: + ) as any, // TS considers a.type === "textBody" degradedAfter: defaultValues?.degradedAfter, timeout: defaultValues?.timeout || 45000, }, @@ -165,8 +168,15 @@ export function MonitorForm({ const pingEndpoint = async (region?: MonitorFlyRegion) => { try { - const { url, body, method, headers, statusAssertions, headerAssertions } = - form.getValues(); + const { + url, + body, + method, + headers, + statusAssertions, + headerAssertions, + textBodyAssertions, + } = form.getValues(); if (body && body !== "") { const validJSON = validateJSON(body); @@ -194,6 +204,7 @@ export function MonitorForm({ JSON.stringify([ ...(statusAssertions || []), ...(headerAssertions || []), + ...(textBodyAssertions || []), ]), ); @@ -206,7 +217,7 @@ export function MonitorForm({ if (as.length > 0) { for (const a of as) { const { success, message } = a.assert({ - body: "", // data.body ?? "", + body: data.body ?? "", header: data.headers ?? {}, status: data.status, }); diff --git a/apps/web/src/components/forms/monitor/section-assertions.tsx b/apps/web/src/components/forms/monitor/section-assertions.tsx index 30dca5c01..b1655e2d7 100644 --- a/apps/web/src/components/forms/monitor/section-assertions.tsx +++ b/apps/web/src/components/forms/monitor/section-assertions.tsx @@ -249,7 +249,7 @@ export function SectionAssertions({ form }: Props) {
(