fix(client): согласование по ссылке падало с ReferenceError src is not defined
confirmDeliveryChoice читал переменную src, которой нет в параметрах: клиент получал ошибку и выбор не сохранялся, а канал (p_src) в заказ не писался. Добавлена передача src в RPC + тест на канал.
This commit is contained in:
parent
4cc91b6dc8
commit
f2a9249bba
|
|
@ -1,7 +1,7 @@
|
||||||
const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1";
|
const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1";
|
||||||
|
|
||||||
if (!isLocalhost) {
|
if (!isLocalhost) {
|
||||||
const STATIC_CACHE = "construction-delivery-static-v131";
|
const STATIC_CACHE = "construction-delivery-static-v132";
|
||||||
const RUNTIME_CACHE = "construction-delivery-runtime-v119";
|
const RUNTIME_CACHE = "construction-delivery-runtime-v119";
|
||||||
const APP_SHELL_URLS = ["/", "/client", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"];
|
const APP_SHELL_URLS = ["/", "/client", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)) {
|
if (isLocalClientInvitationToken(token)) {
|
||||||
const baseInvitation = getCachedInvitation(token) ?? buildFallbackInvitation(token);
|
const baseInvitation = getCachedInvitation(token) ?? buildFallbackInvitation(token);
|
||||||
const invitation = cacheInvitation({
|
const invitation = cacheInvitation({
|
||||||
|
|
|
||||||
|
|
@ -169,10 +169,33 @@ describe("deliveryInvitationApi", () => {
|
||||||
p_token: "token-1",
|
p_token: "token-1",
|
||||||
p_delivery_date: "2026-04-01",
|
p_delivery_date: "2026-04-01",
|
||||||
p_delivery_time: "Первая половина дня",
|
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();
|
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 () => {
|
it("updates the local client invitation when confirmation falls back to cache", async () => {
|
||||||
invoke.mockRejectedValueOnce(new Error("worker boot error"));
|
invoke.mockRejectedValueOnce(new Error("worker boot error"));
|
||||||
await fetchDeliveryInvitation("client-flow-1001");
|
await fetchDeliveryInvitation("client-flow-1001");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue