@7365admin1/core 3.131.1 → 3.132.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@7365admin1/core",
3
3
  "license": "MIT",
4
- "version": "3.131.1",
4
+ "version": "3.132.0",
5
5
  "author": "7365admin1",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -339,3 +339,48 @@ test("live state mapping, recorded reply (pure)", () => {
339
339
  const faulty = ounitechRobotFromHomeRow({ robotSn: "E" }, { statusFlag: 1, rtFaultList: [{ errCode: "302", errMsg: "Clean water tank empty" }] }, now);
340
340
  assert.deepEqual(faulty.fault, { code: "302", message: "Clean water tank empty" });
341
341
  });
342
+
343
+ test("cleaning readings: water levels, tanks and covers, job progress only while cleaning (pure)", async () => {
344
+ const { ounitechCleaning } = await import("./.build/services/ounitech.adapter.mjs");
345
+ const now = RECORDED_UPDATE_ON + 20_000;
346
+ const row = { robotId: 424, robotSn: "F8FCA9A1B1C4C", modelCode: "Q3", robotState: { statusFlag: 99 } };
347
+ // The recorded prod reply: idle, clean 62 %, dirty 8 %, every tank/cover fitted.
348
+ assert.deepEqual(ounitechRobotFromHomeRow(row, recordedState(424), now).cleaning, {
349
+ cleanWater: { level: "medium", percent: 62 },
350
+ dirtyWater: { level: "low", percent: 8 },
351
+ parts: [
352
+ { part: "top cover", ok: true },
353
+ { part: "clean-water tank", ok: true },
354
+ { part: "dirty-water tank", ok: true },
355
+ ],
356
+ job: null,
357
+ });
358
+ const st = (props) => ({ properties: props.map(([k, v]) => s(k, v)) });
359
+ // Cleaning: this job's % and area; low clean water, full dirty water, cover open.
360
+ const c = ounitechCleaning(st([["clean-water", 12], ["dirty-water", 91], ["top-cover", "false"], ["dust-box", "true"], ["acc-percent", 40], ["acc-area", "120.46"], ["count-area", "300"]]), true);
361
+ assert.deepEqual(c, {
362
+ cleanWater: { level: "low", percent: 12 },
363
+ dirtyWater: { level: "high", percent: 91 },
364
+ parts: [{ part: "top cover", ok: false }, { part: "dust box", ok: true }],
365
+ job: { percent: 40, areaDone: 120.5, areaPlanned: 300 },
366
+ });
367
+ // Not cleaning: no job line even with acc-* readings.
368
+ assert.equal(ounitechCleaning(st([["acc-percent", 40]]), false), null);
369
+ // No % sent: the robot's own level word.
370
+ assert.deepEqual(ounitechCleaning(st([["clean-water-level", "中"], ["dirty-water-level", "高"]]), false).dirtyWater, { level: "high", percent: null });
371
+ // Nothing reported: null, never guessed.
372
+ assert.equal(ounitechCleaning({ properties: [] }, true), null);
373
+ // Job % falls back to the list's taskState.
374
+ assert.deepEqual(ounitechCleaning({ properties: [] }, true, 55.4).job, { percent: 55, areaDone: null, areaPlanned: null });
375
+ // Offline: nothing.
376
+ assert.equal(ounitechRobotFromHomeRow(row, { ...recordedState(424), statusFlag: 99 }, now).cleaning, undefined);
377
+ });
378
+
379
+ test("cleaning readings reach the fleet state (waterTanks brands only)", async () => {
380
+ const { fleetStateItem } = await import("./.build/services/robot-fleet.service.mjs");
381
+ const cleaning = { cleanWater: { level: "low", percent: 10 }, dirtyWater: null, parts: [], job: null };
382
+ assert.deepEqual(fleetStateItem("x", { online: true, cleaning }).cleaning, cleaning);
383
+ assert.equal(fleetStateItem("x", { online: true }).cleaning, null);
384
+ const r = await adapter().getRobot("LISTOFFLINE");
385
+ assert.equal(r.cleaning.cleanWater.percent, 62);
386
+ });