From b419a456fe439ef7e08bf89744d98638ec3eaf20 Mon Sep 17 00:00:00 2001 From: vladtechno Date: Thu, 18 Jun 2026 23:05:12 +1000 Subject: [PATCH] =?UTF-8?q?fix(pwa):=20onboarding=20deep=5Flinks=20?= =?UTF-8?q?=E2=80=94=20make=20tg/max=20optional=20(MAX=20not=20configured?= =?UTF-8?q?=20in=20prod)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend omits channels without a configured username; strict zod schema threw on missing 'max', surfacing as 'Не удалось отправить код' instead of routing to the onboarding screen. Make both optional + regression test. Co-Authored-By: claude-flow --- driver-pwa/frontend/src/api/driver.test.ts | 3 +++ driver-pwa/frontend/src/api/driver.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/driver-pwa/frontend/src/api/driver.test.ts b/driver-pwa/frontend/src/api/driver.test.ts index 9f38c89..fd1e274 100644 --- a/driver-pwa/frontend/src/api/driver.test.ts +++ b/driver-pwa/frontend/src/api/driver.test.ts @@ -14,6 +14,9 @@ describe("driver api schemas", () => { expect(AuthRequestSchema.parse({ status: "code_sent", channel: "tg" }).status).toBe("code_sent"); const o = AuthRequestSchema.parse({ status: "onboarding", deep_links: { tg: "t", max: "m" } }); expect(o.status === "onboarding" && o.deep_links.tg).toBe("t"); + // prod: MAX bot not configured → backend omits `max`, must still parse (regression guard) + const tgOnly = AuthRequestSchema.parse({ status: "onboarding", deep_links: { tg: "t" } }); + expect(tgOnly.status === "onboarding" && tgOnly.deep_links.tg).toBe("t"); }); it("parses payments history", () => { const v = PaymentsSchema.parse({ payments: [{ order_id: "o1", bucket: "b", amount: 100, diff --git a/driver-pwa/frontend/src/api/driver.ts b/driver-pwa/frontend/src/api/driver.ts index 19af05a..fda7c37 100644 --- a/driver-pwa/frontend/src/api/driver.ts +++ b/driver-pwa/frontend/src/api/driver.ts @@ -3,7 +3,7 @@ import { api } from "./client"; export const AuthRequestSchema = z.union([ z.object({ status: z.literal("code_sent"), channel: z.string() }), - z.object({ status: z.literal("onboarding"), deep_links: z.object({ tg: z.string(), max: z.string() }) }), + z.object({ status: z.literal("onboarding"), deep_links: z.object({ tg: z.string().optional(), max: z.string().optional() }) }), ]); export type AuthRequest = z.infer;