From 8fa05f1746ef4fcbdc7fa01420c660defdaf4134 Mon Sep 17 00:00:00 2001 From: Hermes Date: Mon, 28 Sep 2026 12:25:06 +0200 Subject: [PATCH] =?UTF-8?q?test(client):=20=D1=87=D0=B8=D1=81=D1=82=D1=8B?= =?UTF-8?q?=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20invitationReference?= =?UTF-8?q?=20+=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B3=D0=BB=D0=B0=D1=81=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=B2=20jsdom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getInvitationReferenceLabel/getDeliveryNumberDigits вынесены в отдельный тест-файл (без импорта supabaseClient) — проверяются номер доставки и «Доставка …» - supabaseClient: lock берём как «no-lock», если navigator.locks.request нет (jsdom) — иначе весь тест-файл падал на импорте и тесты страницы не запускались --- .../client/invitationReference.test.js | 30 +++++++++++++++++++ src/supabaseClient.jsx | 8 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/components/client/invitationReference.test.js diff --git a/src/components/client/invitationReference.test.js b/src/components/client/invitationReference.test.js new file mode 100644 index 0000000..8d86670 --- /dev/null +++ b/src/components/client/invitationReference.test.js @@ -0,0 +1,30 @@ +import { describe, expect, it } from "vitest"; +import { + getDeliveryNumberDigits, + getInvitationReferenceLabel, +} from "./invitationReference"; + +describe("invitationReference", () => { + it("показывает номер заказа как «Доставка …», без экранирования из 1С", () => { + expect(getInvitationReferenceLabel({ orderItems: [{ name: "ТП\\-010796" }] })).toBe( + "Доставка ТП-010796", + ); + expect(getInvitationReferenceLabel({ orderNumber: "CD-240032" })).toBe("Доставка CD-240032"); + expect(getInvitationReferenceLabel({})).toBe("Доставка —"); + }); + + it("несколько счетов — через запятую", () => { + expect( + getInvitationReferenceLabel({ + orderItems: [{ name: "СФ Т\\ЕА-28687" }, { name: "СФ Т\\ЕА-28700" }], + }), + ).toBe("Доставки: СФ ТЕА-28687, СФ ТЕА-28700"); + }); + + it("номер доставки — только цифры, «ТП\\-010796» → «010796»", () => { + expect(getDeliveryNumberDigits({ orderItems: [{ name: "ТП\\-010796" }] })).toBe("010796"); + expect(getDeliveryNumberDigits({ orderNumbers: ["ТП\\-010557", "ТП\\-010599"] })).toBe("010557"); + expect(getDeliveryNumberDigits({ orderNumber: "9788324113|28.09.2026" })).toBe("978832411328092026"); + expect(getDeliveryNumberDigits({})).toBe(""); + }); +}); diff --git a/src/supabaseClient.jsx b/src/supabaseClient.jsx index 05f1200..b90f0d4 100644 --- a/src/supabaseClient.jsx +++ b/src/supabaseClient.jsx @@ -114,7 +114,13 @@ export const supabase = hasSupabaseConfig storage: secureStorage, autoRefreshToken: true, detectSessionInUrl: false, - lock: navigator.locks ? undefined : "no-lock", + // navigator.locks есть не везде (jsdom/старые окружения): тогда фиксированный lock + lock: + typeof navigator !== "undefined" && + navigator.locks && + typeof navigator.locks.request === "function" + ? undefined + : "no-lock", }, global: { headers: { "x-application-name": "supersam" },