@jskit-ai/users-web 0.1.72 → 0.1.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,6 +51,22 @@ test("createCrudFormModel preserves explicit boolean defaults for nullable field
51
51
  });
52
52
  });
53
53
 
54
+ test("createCrudFormModel initializes nullable lookup fields as null", () => {
55
+ const model = createCrudFormModel([
56
+ {
57
+ key: "serviceId",
58
+ type: "string",
59
+ nullable: true,
60
+ component: "lookup",
61
+ relation: { kind: "lookup", namespace: "services" }
62
+ }
63
+ ]);
64
+
65
+ assert.deepEqual(model, {
66
+ serviceId: null
67
+ });
68
+ });
69
+
54
70
  test("buildCrudFormPayload normalizes booleans and numbers while skipping empty numeric values", () => {
55
71
  const payload = buildCrudFormPayload(
56
72
  [
@@ -114,6 +130,13 @@ test("buildCrudFormPayload serializes cleared nullable typed fields as null", ()
114
130
  [
115
131
  { key: "reviewed", type: "boolean", nullable: true },
116
132
  { key: "serviceId", type: "integer", nullable: true },
133
+ {
134
+ key: "selectedServiceId",
135
+ type: "string",
136
+ nullable: true,
137
+ component: "lookup",
138
+ relation: { kind: "lookup", namespace: "services" }
139
+ },
117
140
  { key: "fromDate", type: "string", format: "date", nullable: true },
118
141
  { key: "scheduledAt", type: "string", format: "date-time", nullable: true },
119
142
  { key: "fromTime", type: "string", format: "time", nullable: true }
@@ -121,6 +144,7 @@ test("buildCrudFormPayload serializes cleared nullable typed fields as null", ()
121
144
  {
122
145
  reviewed: null,
123
146
  serviceId: null,
147
+ selectedServiceId: "",
124
148
  fromDate: "",
125
149
  scheduledAt: "",
126
150
  fromTime: ""
@@ -130,6 +154,7 @@ test("buildCrudFormPayload serializes cleared nullable typed fields as null", ()
130
154
  assert.deepEqual(payload, {
131
155
  reviewed: null,
132
156
  serviceId: null,
157
+ selectedServiceId: null,
133
158
  fromDate: null,
134
159
  scheduledAt: null,
135
160
  fromTime: null
@@ -247,6 +272,31 @@ test("applyCrudPayloadToForm preserves nullable boolean payload values", () => {
247
272
  });
248
273
  });
249
274
 
275
+ test("applyCrudPayloadToForm preserves null lookup payload values", () => {
276
+ const fields = [
277
+ {
278
+ key: "serviceId",
279
+ type: "string",
280
+ nullable: true,
281
+ component: "lookup",
282
+ relation: { kind: "lookup", namespace: "services" }
283
+ }
284
+ ];
285
+ const form = reactive({
286
+ serviceId: "existing"
287
+ });
288
+
289
+ applyCrudPayloadToForm(fields, form, {
290
+ serviceId: null
291
+ });
292
+ assert.equal(form.serviceId, null);
293
+
294
+ applyCrudPayloadToForm(fields, form, {
295
+ serviceId: 42
296
+ });
297
+ assert.equal(form.serviceId, "42");
298
+ });
299
+
250
300
  test("resolveCrudRouteBoundFieldValues maps route params for route-bound form fields", () => {
251
301
  const values = resolveCrudRouteBoundFieldValues(
252
302
  [