mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 08:03:22 +00:00
Late roster data no longer overwrites notes typed for the current selection. The notes baseline is keyed by vendor, so a save never patches a previous company. Changing the primary service clears leftover notes, and a save with a missing baseline reads the current roster first. Also drops ticket keys from shipped comments. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildCompanyNotesUpdate } from "@/domain/vendors/utils/build-company-notes-patch";
|
|
|
|
const baseline = { companyId: 12, rowVersion: "AAAAAAAAB9E=", notes: "Call before arrival" };
|
|
|
|
describe("buildCompanyNotesUpdate", () => {
|
|
it("builds a notes-only additive patch when the notes changed", () => {
|
|
expect(buildCompanyNotesUpdate(baseline, " Gate code 4411 ")).toEqual({
|
|
companyId: 12,
|
|
patch: {
|
|
rowVersion: "AAAAAAAAB9E=",
|
|
addTechnicians: [],
|
|
companyFields: { notes: "Gate code 4411" },
|
|
},
|
|
});
|
|
});
|
|
|
|
it("skips the write when the notes are unchanged apart from whitespace", () => {
|
|
expect(buildCompanyNotesUpdate(baseline, "Call before arrival ")).toBeNull();
|
|
});
|
|
|
|
it("skips the write without a loaded company baseline", () => {
|
|
expect(buildCompanyNotesUpdate(null, "New notes")).toBeNull();
|
|
expect(buildCompanyNotesUpdate({ ...baseline, companyId: null }, "New notes")).toBeNull();
|
|
expect(buildCompanyNotesUpdate({ ...baseline, rowVersion: "" }, "New notes")).toBeNull();
|
|
});
|
|
|
|
it("does not send an emptied field, which the additive patch treats as unchanged", () => {
|
|
expect(buildCompanyNotesUpdate(baseline, " ")).toBeNull();
|
|
});
|
|
});
|