fix(pwa): onboarding deep_links — make tg/max optional (MAX not configured in prod)

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 <ruv@ruv.net>
This commit is contained in:
2026-06-18 23:05:12 +10:00
co-authored by claude-flow
parent 08ebc09814
commit b419a456fe
2 changed files with 4 additions and 1 deletions
@@ -14,6 +14,9 @@ describe("driver api schemas", () => {
expect(AuthRequestSchema.parse({ status: "code_sent", channel: "tg" }).status).toBe("code_sent"); expect(AuthRequestSchema.parse({ status: "code_sent", channel: "tg" }).status).toBe("code_sent");
const o = AuthRequestSchema.parse({ status: "onboarding", deep_links: { tg: "t", max: "m" } }); const o = AuthRequestSchema.parse({ status: "onboarding", deep_links: { tg: "t", max: "m" } });
expect(o.status === "onboarding" && o.deep_links.tg).toBe("t"); 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", () => { it("parses payments history", () => {
const v = PaymentsSchema.parse({ payments: [{ order_id: "o1", bucket: "b", amount: 100, const v = PaymentsSchema.parse({ payments: [{ order_id: "o1", bucket: "b", amount: 100,
+1 -1
View File
@@ -3,7 +3,7 @@ import { api } from "./client";
export const AuthRequestSchema = z.union([ export const AuthRequestSchema = z.union([
z.object({ status: z.literal("code_sent"), channel: z.string() }), 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<typeof AuthRequestSchema>; export type AuthRequest = z.infer<typeof AuthRequestSchema>;