From f2a9249bba1f2a6d7a00b9d7c328d9999796dca8 Mon Sep 17 00:00:00 2001 From: Hermes Date: Fri, 2 Oct 2026 15:18:22 +0200 Subject: [PATCH] =?UTF-8?q?fix(client):=20=D1=81=D0=BE=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B5=20=D0=BF=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=20=D1=81=20ReferenceError=20src=20is=20not=20defin?= =?UTF-8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit confirmDeliveryChoice читал переменную src, которой нет в параметрах: клиент получал ошибку и выбор не сохранялся, а канал (p_src) в заказ не писался. Добавлена передача src в RPC + тест на канал. --- public/service-worker.js | 2 +- src/services/deliveryInvitationApi.js | 2 +- src/services/deliveryInvitationApi.test.js | 23 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/public/service-worker.js b/public/service-worker.js index 38b9354..9252f3e 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,7 +1,7 @@ const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1"; if (!isLocalhost) { - const STATIC_CACHE = "construction-delivery-static-v131"; + const STATIC_CACHE = "construction-delivery-static-v132"; const RUNTIME_CACHE = "construction-delivery-runtime-v119"; const APP_SHELL_URLS = ["/", "/client", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"]; diff --git a/src/services/deliveryInvitationApi.js b/src/services/deliveryInvitationApi.js index e041924..c5d3fdc 100644 --- a/src/services/deliveryInvitationApi.js +++ b/src/services/deliveryInvitationApi.js @@ -278,7 +278,7 @@ export const fetchDeliveryInvitation = async (token) => { } }; -export const confirmDeliveryChoice = async ({ token, deliveryDate, deliveryTime, deliveryType, pickupDate, pickupTimeSlot, deliveryAddress }) => { +export const confirmDeliveryChoice = async ({ token, deliveryDate, deliveryTime, deliveryType, pickupDate, pickupTimeSlot, deliveryAddress, src }) => { if (isLocalClientInvitationToken(token)) { const baseInvitation = getCachedInvitation(token) ?? buildFallbackInvitation(token); const invitation = cacheInvitation({ diff --git a/src/services/deliveryInvitationApi.test.js b/src/services/deliveryInvitationApi.test.js index 99086ee..ea1e264 100644 --- a/src/services/deliveryInvitationApi.test.js +++ b/src/services/deliveryInvitationApi.test.js @@ -169,10 +169,33 @@ describe("deliveryInvitationApi", () => { p_token: "token-1", p_delivery_date: "2026-04-01", p_delivery_time: "Первая половина дня", + p_delivery_type: "delivery", + p_pickup_date: null, + p_pickup_time_slot: null, + p_delivery_address: null, + p_src: null, }); expect(invoke).not.toHaveBeenCalled(); }); + it("passes the channel the client came from (src) to the confirm RPC", async () => { + rpc.mockResolvedValueOnce({ data: { ok: true }, error: null }); + + await expect( + confirmDeliveryChoice({ + token: "token-1", + deliveryDate: "2026-04-01", + deliveryTime: "Первая половина дня", + src: "sms", + }), + ).resolves.toEqual({ ok: true }); + + expect(rpc).toHaveBeenCalledWith( + "confirm_delivery_choice_by_token", + expect.objectContaining({ p_src: "sms" }), + ); + }); + it("updates the local client invitation when confirmation falls back to cache", async () => { invoke.mockRejectedValueOnce(new Error("worker boot error")); await fetchDeliveryInvitation("client-flow-1001");