Накатил человеческий дизайн

This commit is contained in:
mi
2026-07-21 16:01:24 +03:00
parent 9cfc157124
commit 627371b221
35 changed files with 2415 additions and 293 deletions
@@ -3,6 +3,12 @@ import { reconcileMessages } from "../../src/reconcile";
import { sessionMemory } from "../../src/session";
import { SingleFlight } from "../../src/single-flight";
import { websocketJwtProtocol } from "../../src/realtime";
import {
clearPendingTextIntent,
createPendingTextIntent,
loadPendingTextIntent,
savePendingTextIntent,
} from "../../src/pending-intent";
import type { Message } from "../../src/types";
const message = (id: string, createdAt: string, status: Message["delivery_status"] = "accepted"): Message => ({
@@ -26,6 +32,15 @@ describe("reconcileMessages", () => {
expect(result.map((item) => item.message_id)).toEqual(["1", "2", "3"]);
expect(result[1]?.delivery_status).toBe("delivered");
});
it("сортирует realtime-сообщения по абсолютному времени при разных часовых поясах", () => {
const result = reconcileMessages(
[message("client", "2026-07-21T15:48:00+03:00")],
[message("company", "2026-07-21T12:49:00Z")],
);
expect(result.map((item) => item.message_id)).toEqual(["client", "company"]);
});
});
describe("UX session memory", () => {
@@ -38,6 +53,24 @@ describe("UX session memory", () => {
});
});
describe("pending message intent", () => {
it("сохраняет ключи повтора и очищается после завершения", () => {
const intent = createPendingTextIntent("Сообщение после входа");
savePendingTextIntent(intent);
expect(loadPendingTextIntent()).toEqual(intent);
clearPendingTextIntent();
expect(loadPendingTextIntent()).toBeNull();
});
it("игнорирует повреждённое значение", () => {
sessionStorage.setItem("han.pending-message", "{\"text\":42}");
expect(loadPendingTextIntent()).toBeNull();
clearPendingTextIntent();
});
});
describe("SingleFlight", () => {
it("объединяет параллельные refresh операции", async () => {
const flight = new SingleFlight<number>();