@activecollab/components 2.0.576 → 2.0.578

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.
Files changed (156) hide show
  1. package/dist/cjs/presentation/myWork/MyWorkTasks.js +83 -30
  2. package/dist/cjs/presentation/myWork/MyWorkTasks.js.map +1 -1
  3. package/dist/cjs/presentation/myWork/agendaGrid.js +1095 -0
  4. package/dist/cjs/presentation/myWork/agendaGrid.js.map +1 -0
  5. package/dist/cjs/presentation/reports/allReports.js +6 -0
  6. package/dist/cjs/presentation/reports/allReports.js.map +1 -1
  7. package/dist/cjs/presentation/reports/controls.js +6 -3
  8. package/dist/cjs/presentation/reports/controls.js.map +1 -1
  9. package/dist/cjs/presentation/reports/expenses.js +946 -0
  10. package/dist/cjs/presentation/reports/expenses.js.map +1 -0
  11. package/dist/cjs/presentation/shared/settings.js +6 -2
  12. package/dist/cjs/presentation/shared/settings.js.map +1 -1
  13. package/dist/cjs/presentation/shared/tokens.js +8 -1
  14. package/dist/cjs/presentation/shared/tokens.js.map +1 -1
  15. package/dist/cjs/presentation/timeboxes/AdjustmentList.js +31 -0
  16. package/dist/cjs/presentation/timeboxes/AdjustmentList.js.map +1 -0
  17. package/dist/cjs/presentation/timeboxes/AgendaDayView.js +1722 -0
  18. package/dist/cjs/presentation/timeboxes/AgendaDayView.js.map +1 -0
  19. package/dist/cjs/presentation/timeboxes/CapacityBar.js +54 -0
  20. package/dist/cjs/presentation/timeboxes/CapacityBar.js.map +1 -0
  21. package/dist/cjs/presentation/timeboxes/SimulationCard.js +47 -0
  22. package/dist/cjs/presentation/timeboxes/SimulationCard.js.map +1 -0
  23. package/dist/cjs/presentation/timeboxes/SimulationPanel.js +319 -0
  24. package/dist/cjs/presentation/timeboxes/SimulationPanel.js.map +1 -0
  25. package/dist/cjs/presentation/timeboxes/TimeRecordsSection.js +206 -0
  26. package/dist/cjs/presentation/timeboxes/TimeRecordsSection.js.map +1 -0
  27. package/dist/cjs/presentation/timeboxes/WorkloadView.js +887 -0
  28. package/dist/cjs/presentation/timeboxes/WorkloadView.js.map +1 -0
  29. package/dist/cjs/presentation/timeboxes/__tests__/timeboxes.test.js +699 -0
  30. package/dist/cjs/presentation/timeboxes/__tests__/timeboxes.test.js.map +1 -0
  31. package/dist/cjs/presentation/timeboxes/changes.js +293 -0
  32. package/dist/cjs/presentation/timeboxes/changes.js.map +1 -0
  33. package/dist/cjs/presentation/timeboxes/mockData.js +320 -0
  34. package/dist/cjs/presentation/timeboxes/mockData.js.map +1 -0
  35. package/dist/cjs/presentation/timeboxes/model.js +186 -0
  36. package/dist/cjs/presentation/timeboxes/model.js.map +1 -0
  37. package/dist/cjs/presentation/timeboxes/pillLook.js +72 -0
  38. package/dist/cjs/presentation/timeboxes/pillLook.js.map +1 -0
  39. package/dist/cjs/presentation/timeboxes/plan.js +181 -0
  40. package/dist/cjs/presentation/timeboxes/plan.js.map +1 -0
  41. package/dist/cjs/presentation/timeboxes/reducer.js +763 -0
  42. package/dist/cjs/presentation/timeboxes/reducer.js.map +1 -0
  43. package/dist/cjs/presentation/timeboxes/scheduler.js +147 -0
  44. package/dist/cjs/presentation/timeboxes/scheduler.js.map +1 -0
  45. package/dist/cjs/presentation/timeboxes/store.js +65 -0
  46. package/dist/cjs/presentation/timeboxes/store.js.map +1 -0
  47. package/dist/cjs/presentation/timeboxes/timeBlocks.js +1931 -0
  48. package/dist/cjs/presentation/timeboxes/timeBlocks.js.map +1 -0
  49. package/dist/cjs/presentation/timeboxes/timeboxSettings.js +369 -0
  50. package/dist/cjs/presentation/timeboxes/timeboxSettings.js.map +1 -0
  51. package/dist/cjs/presentation/timeboxes/tracked.js +189 -0
  52. package/dist/cjs/presentation/timeboxes/tracked.js.map +1 -0
  53. package/dist/esm/presentation/myWork/MyWorkTasks.d.ts +81 -1
  54. package/dist/esm/presentation/myWork/MyWorkTasks.d.ts.map +1 -1
  55. package/dist/esm/presentation/myWork/MyWorkTasks.js +76 -23
  56. package/dist/esm/presentation/myWork/MyWorkTasks.js.map +1 -1
  57. package/dist/esm/presentation/myWork/agendaGrid.d.ts +341 -0
  58. package/dist/esm/presentation/myWork/agendaGrid.d.ts.map +1 -0
  59. package/dist/esm/presentation/myWork/agendaGrid.js +1001 -0
  60. package/dist/esm/presentation/myWork/agendaGrid.js.map +1 -0
  61. package/dist/esm/presentation/reports/allReports.d.ts.map +1 -1
  62. package/dist/esm/presentation/reports/allReports.js +6 -0
  63. package/dist/esm/presentation/reports/allReports.js.map +1 -1
  64. package/dist/esm/presentation/reports/controls.d.ts +3 -1
  65. package/dist/esm/presentation/reports/controls.d.ts.map +1 -1
  66. package/dist/esm/presentation/reports/controls.js +6 -3
  67. package/dist/esm/presentation/reports/controls.js.map +1 -1
  68. package/dist/esm/presentation/reports/expenses.d.ts +62 -0
  69. package/dist/esm/presentation/reports/expenses.d.ts.map +1 -0
  70. package/dist/esm/presentation/reports/expenses.js +849 -0
  71. package/dist/esm/presentation/reports/expenses.js.map +1 -0
  72. package/dist/esm/presentation/shared/settings.d.ts +2 -0
  73. package/dist/esm/presentation/shared/settings.d.ts.map +1 -1
  74. package/dist/esm/presentation/shared/settings.js +5 -1
  75. package/dist/esm/presentation/shared/settings.js.map +1 -1
  76. package/dist/esm/presentation/shared/tokens.d.ts +6 -0
  77. package/dist/esm/presentation/shared/tokens.d.ts.map +1 -1
  78. package/dist/esm/presentation/shared/tokens.js +7 -0
  79. package/dist/esm/presentation/shared/tokens.js.map +1 -1
  80. package/dist/esm/presentation/timeboxes/AdjustmentList.d.ts +11 -0
  81. package/dist/esm/presentation/timeboxes/AdjustmentList.d.ts.map +1 -0
  82. package/dist/esm/presentation/timeboxes/AdjustmentList.js +22 -0
  83. package/dist/esm/presentation/timeboxes/AdjustmentList.js.map +1 -0
  84. package/dist/esm/presentation/timeboxes/AgendaDayView.d.ts +15 -0
  85. package/dist/esm/presentation/timeboxes/AgendaDayView.d.ts.map +1 -0
  86. package/dist/esm/presentation/timeboxes/AgendaDayView.js +1524 -0
  87. package/dist/esm/presentation/timeboxes/AgendaDayView.js.map +1 -0
  88. package/dist/esm/presentation/timeboxes/CapacityBar.d.ts +15 -0
  89. package/dist/esm/presentation/timeboxes/CapacityBar.d.ts.map +1 -0
  90. package/dist/esm/presentation/timeboxes/CapacityBar.js +48 -0
  91. package/dist/esm/presentation/timeboxes/CapacityBar.js.map +1 -0
  92. package/dist/esm/presentation/timeboxes/SimulationCard.d.ts +13 -0
  93. package/dist/esm/presentation/timeboxes/SimulationCard.d.ts.map +1 -0
  94. package/dist/esm/presentation/timeboxes/SimulationCard.js +41 -0
  95. package/dist/esm/presentation/timeboxes/SimulationCard.js.map +1 -0
  96. package/dist/esm/presentation/timeboxes/SimulationPanel.d.ts +18 -0
  97. package/dist/esm/presentation/timeboxes/SimulationPanel.d.ts.map +1 -0
  98. package/dist/esm/presentation/timeboxes/SimulationPanel.js +267 -0
  99. package/dist/esm/presentation/timeboxes/SimulationPanel.js.map +1 -0
  100. package/dist/esm/presentation/timeboxes/TimeRecordsSection.d.ts +14 -0
  101. package/dist/esm/presentation/timeboxes/TimeRecordsSection.d.ts.map +1 -0
  102. package/dist/esm/presentation/timeboxes/TimeRecordsSection.js +159 -0
  103. package/dist/esm/presentation/timeboxes/TimeRecordsSection.js.map +1 -0
  104. package/dist/esm/presentation/timeboxes/WorkloadView.d.ts +9 -0
  105. package/dist/esm/presentation/timeboxes/WorkloadView.d.ts.map +1 -0
  106. package/dist/esm/presentation/timeboxes/WorkloadView.js +761 -0
  107. package/dist/esm/presentation/timeboxes/WorkloadView.js.map +1 -0
  108. package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.d.ts +2 -0
  109. package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.d.ts.map +1 -0
  110. package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.js +640 -0
  111. package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.js.map +1 -0
  112. package/dist/esm/presentation/timeboxes/changes.d.ts +72 -0
  113. package/dist/esm/presentation/timeboxes/changes.d.ts.map +1 -0
  114. package/dist/esm/presentation/timeboxes/changes.js +224 -0
  115. package/dist/esm/presentation/timeboxes/changes.js.map +1 -0
  116. package/dist/esm/presentation/timeboxes/mockData.d.ts +16 -0
  117. package/dist/esm/presentation/timeboxes/mockData.d.ts.map +1 -0
  118. package/dist/esm/presentation/timeboxes/mockData.js +297 -0
  119. package/dist/esm/presentation/timeboxes/mockData.js.map +1 -0
  120. package/dist/esm/presentation/timeboxes/model.d.ts +136 -0
  121. package/dist/esm/presentation/timeboxes/model.d.ts.map +1 -0
  122. package/dist/esm/presentation/timeboxes/model.js +129 -0
  123. package/dist/esm/presentation/timeboxes/model.js.map +1 -0
  124. package/dist/esm/presentation/timeboxes/pillLook.d.ts +40 -0
  125. package/dist/esm/presentation/timeboxes/pillLook.d.ts.map +1 -0
  126. package/dist/esm/presentation/timeboxes/pillLook.js +65 -0
  127. package/dist/esm/presentation/timeboxes/pillLook.js.map +1 -0
  128. package/dist/esm/presentation/timeboxes/plan.d.ts +62 -0
  129. package/dist/esm/presentation/timeboxes/plan.d.ts.map +1 -0
  130. package/dist/esm/presentation/timeboxes/plan.js +116 -0
  131. package/dist/esm/presentation/timeboxes/plan.js.map +1 -0
  132. package/dist/esm/presentation/timeboxes/reducer.d.ts +203 -0
  133. package/dist/esm/presentation/timeboxes/reducer.d.ts.map +1 -0
  134. package/dist/esm/presentation/timeboxes/reducer.js +616 -0
  135. package/dist/esm/presentation/timeboxes/reducer.js.map +1 -0
  136. package/dist/esm/presentation/timeboxes/scheduler.d.ts +63 -0
  137. package/dist/esm/presentation/timeboxes/scheduler.d.ts.map +1 -0
  138. package/dist/esm/presentation/timeboxes/scheduler.js +120 -0
  139. package/dist/esm/presentation/timeboxes/scheduler.js.map +1 -0
  140. package/dist/esm/presentation/timeboxes/store.d.ts +23 -0
  141. package/dist/esm/presentation/timeboxes/store.d.ts.map +1 -0
  142. package/dist/esm/presentation/timeboxes/store.js +46 -0
  143. package/dist/esm/presentation/timeboxes/store.js.map +1 -0
  144. package/dist/esm/presentation/timeboxes/timeBlocks.d.ts +10 -0
  145. package/dist/esm/presentation/timeboxes/timeBlocks.d.ts.map +1 -0
  146. package/dist/esm/presentation/timeboxes/timeBlocks.js +1767 -0
  147. package/dist/esm/presentation/timeboxes/timeBlocks.js.map +1 -0
  148. package/dist/esm/presentation/timeboxes/timeboxSettings.d.ts +71 -0
  149. package/dist/esm/presentation/timeboxes/timeboxSettings.d.ts.map +1 -0
  150. package/dist/esm/presentation/timeboxes/timeboxSettings.js +302 -0
  151. package/dist/esm/presentation/timeboxes/timeboxSettings.js.map +1 -0
  152. package/dist/esm/presentation/timeboxes/tracked.d.ts +51 -0
  153. package/dist/esm/presentation/timeboxes/tracked.d.ts.map +1 -0
  154. package/dist/esm/presentation/timeboxes/tracked.js +136 -0
  155. package/dist/esm/presentation/timeboxes/tracked.js.map +1 -0
  156. package/package.json +1 -1
@@ -0,0 +1,699 @@
1
+ "use strict";
2
+
3
+ var _changes = require("../changes");
4
+ var _mockData = require("../mockData");
5
+ var _model = require("../model");
6
+ var _plan = require("../plan");
7
+ var _reducer = require("../reducer");
8
+ var _scheduler = require("../scheduler");
9
+ var _tracked = require("../tracked");
10
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
20
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
+ var context = {
22
+ users: _mockData.USERS
23
+ };
24
+ var marko = _mockData.USERS[0];
25
+ var WED = "2026-11-04";
26
+ var MON = "2026-11-02";
27
+ var TUE = "2026-11-03";
28
+ var THU = "2026-11-05";
29
+ var A = 101;
30
+ var B = 102;
31
+ var C = 103;
32
+ var D = 104;
33
+ var E = 105;
34
+ var F = 106;
35
+ var at = function at(clock) {
36
+ return (0, _model.clockToMinutes)(clock);
37
+ };
38
+ var apply = function apply(state) {
39
+ for (var _len = arguments.length, actions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
40
+ actions[_key - 1] = arguments[_key];
41
+ }
42
+ return actions.reduce(function (next, action) {
43
+ var result = (0, _reducer.reduce)(next, context, action);
44
+ if (result.error) throw new Error(result.error);
45
+ return result.state;
46
+ }, state);
47
+ };
48
+ var dayTotal = function dayTotal(state, taskId, date) {
49
+ return (0, _model.allocationOn)(state, (0, _plan.taskById)(state, taskId), marko, date);
50
+ };
51
+ describe("scheduler: the brief's Wednesday", function () {
52
+ var plan = (0, _plan.planDay)((0, _mockData.initialState)(), context, _mockData.ME, WED);
53
+ it("fills the free gaps in order, with overtime after the window", function () {
54
+ var rows = plan.suggestions.map(function (suggestion) {
55
+ return [suggestion.taskId, (0, _model.minutesToClock)(suggestion.start), (0, _model.minutesToClock)(suggestion.end), "".concat(suggestion.fragment, "/").concat(suggestion.fragments), suggestion.overtime];
56
+ });
57
+ expect(rows).toEqual([[C, "09:00", "09:30", "1/3", false], [C, "10:30", "11:00", "2/3", false], [C, "12:30", "13:30", "3/3", false], [D, "13:30", "14:00", "1/2", false], [D, "15:00", "16:00", "2/2", false], [E, "16:00", "17:00", "1/2", false], [E, "17:00", "18:00", "2/2", true]]);
58
+ });
59
+ it("keeps A and B pinned and Sprint planning as the event", function () {
60
+ expect(plan.timeboxes.map(function (timebox) {
61
+ return [timebox.task.id, (0, _model.minutesToClock)(timebox.range.start), (0, _model.minutesToClock)(timebox.range.end)];
62
+ })).toEqual([[A, "09:30", "10:30"], [B, "11:00", "12:30"]]);
63
+ expect(plan.events.map(function (event) {
64
+ return event.name;
65
+ })).toEqual(["Sprint planning"]);
66
+ });
67
+ it("is overbooked by 1h and leaves F to the All Day row", function () {
68
+ expect(plan.overbooked).toBe(60);
69
+ expect(plan.unscheduled).toEqual([]);
70
+ expect(plan.withoutEstimate.map(function (task) {
71
+ return task.id;
72
+ })).toEqual([F]);
73
+ expect(plan.allocated).toBe(480);
74
+ expect(plan.capacity).toBe(480);
75
+ });
76
+ });
77
+ describe("scheduler: min gap", function () {
78
+ it("leaves gaps shorter than the min gap empty", function () {
79
+ var result = (0, _scheduler.schedule)({
80
+ windowStart: at("09:00"),
81
+ windowEnd: at("17:00"),
82
+ busy: [{
83
+ start: at("09:10"),
84
+ end: at("10:00")
85
+ }],
86
+ demands: [{
87
+ taskId: 1,
88
+ minutes: 30,
89
+ isImportant: false,
90
+ dueOn: WED,
91
+ position: 1
92
+ }],
93
+ minGap: 15
94
+ });
95
+ expect(result.suggestions[0].start).toBe(at("10:00"));
96
+ });
97
+ it("never cuts a task into a tail shorter than the min gap", function () {
98
+ var result = (0, _scheduler.schedule)({
99
+ windowStart: at("09:00"),
100
+ windowEnd: at("17:00"),
101
+ busy: [{
102
+ start: at("10:00"),
103
+ end: at("11:00")
104
+ }],
105
+ demands: [{
106
+ taskId: 1,
107
+ minutes: 70,
108
+ isImportant: false,
109
+ dueOn: WED,
110
+ position: 1
111
+ }],
112
+ minGap: 15
113
+ });
114
+ expect(result.suggestions.map(function (item) {
115
+ return item.end - item.start;
116
+ })).toEqual([55, 15]);
117
+ });
118
+ it("puts important work first and what does not fit before midnight in unscheduled", function () {
119
+ var result = (0, _scheduler.schedule)({
120
+ windowStart: at("22:00"),
121
+ windowEnd: at("23:00"),
122
+ busy: [],
123
+ demands: [{
124
+ taskId: 1,
125
+ minutes: 60,
126
+ isImportant: false,
127
+ dueOn: MON,
128
+ position: 1
129
+ }, {
130
+ taskId: 2,
131
+ minutes: 90,
132
+ isImportant: true,
133
+ dueOn: WED,
134
+ position: 2
135
+ }],
136
+ minGap: 15
137
+ });
138
+ /* 22:00–23:00 and 23:00–23:30 (overtime) for the important task, then
139
+ 23:30–24:00 for the other; its last 30 minutes do not fit. */
140
+ expect(result.suggestions.map(function (item) {
141
+ return [item.taskId, item.overtime];
142
+ })).toEqual([[2, false], [2, true], [1, true]]);
143
+ expect(result.unscheduled).toEqual([{
144
+ taskId: 1,
145
+ minutes: 30
146
+ }]);
147
+ });
148
+ });
149
+ describe("edit day value", function () {
150
+ /* D: Mon–Thu, 6h; Mon/Tue/Wed 1h30 untimed; Thu 10:00–11:00 + 30m. */
151
+ var editD = function editD(state, date, minutes) {
152
+ return apply(state, {
153
+ type: "editDayValue",
154
+ taskId: D,
155
+ date,
156
+ minutes
157
+ });
158
+ };
159
+ var ranges = function ranges(state, taskId, date) {
160
+ return (0, _model.timeboxesOn)(state, taskId, date).map(function (part) {
161
+ var _part$startsOnTime;
162
+ return [part.startsOnTime, (0, _model.minutesToClock)(at((_part$startsOnTime = part.startsOnTime) !== null && _part$startsOnTime !== void 0 ? _part$startsOnTime : "00:00") + part.durationMinutes)];
163
+ });
164
+ };
165
+ var untimed = function untimed(state, taskId, date) {
166
+ var _untimedPartOn$durati, _untimedPartOn;
167
+ return (_untimedPartOn$durati = (_untimedPartOn = (0, _model.untimedPartOn)(state, taskId, date)) === null || _untimedPartOn === void 0 ? void 0 : _untimedPartOn.durationMinutes) !== null && _untimedPartOn$durati !== void 0 ? _untimedPartOn$durati : 0;
168
+ };
169
+ it("Tue → 2h spreads the rest and keeps Thursday's timebox", function () {
170
+ var next = editD((0, _mockData.initialState)(), TUE, 120);
171
+ expect(dayTotal(next, D, MON)).toBe(90);
172
+ expect(dayTotal(next, D, TUE)).toBe(120);
173
+ expect(dayTotal(next, D, WED)).toBe(75);
174
+ expect(untimed(next, D, WED)).toBe(75);
175
+ expect(dayTotal(next, D, THU)).toBe(75);
176
+ expect(ranges(next, D, THU)).toEqual([["10:00", "11:00"]]);
177
+ expect(untimed(next, D, THU)).toBe(15);
178
+ });
179
+ it("Tue → 3h30 takes Thursday's untimed part, then shortens its timebox", function () {
180
+ var next = editD((0, _mockData.initialState)(), TUE, 210);
181
+ expect(dayTotal(next, D, WED)).toBe(30);
182
+ expect(dayTotal(next, D, THU)).toBe(30);
183
+ expect(ranges(next, D, THU)).toEqual([["10:00", "10:30"]]);
184
+ expect(untimed(next, D, THU)).toBe(0);
185
+ });
186
+ it("Tue → 4h30 (the max) deletes Thursday's timebox", function () {
187
+ var next = editD((0, _mockData.initialState)(), TUE, 270);
188
+ expect(dayTotal(next, D, WED)).toBe(0);
189
+ expect(dayTotal(next, D, THU)).toBe(0);
190
+ expect((0, _model.timeboxesOn)(next, D, THU)).toHaveLength(0);
191
+ });
192
+ it("validates up to the estimate left and locks the last workday", function () {
193
+ var state = (0, _mockData.initialState)();
194
+ expect((0, _reducer.dayValueRange)(state, context, D, TUE)).toEqual({
195
+ min: 0,
196
+ max: 270,
197
+ locked: false
198
+ });
199
+ expect((0, _reducer.dayValueError)(state, context, D, TUE, 300)).toBe("At most 4h30: the estimate has no more left");
200
+ expect((0, _reducer.dayValueRange)(state, context, D, THU).locked).toBe(true);
201
+ var pinnedTuesday = apply(state, {
202
+ type: "pin",
203
+ taskId: D,
204
+ date: TUE,
205
+ start: at("09:00"),
206
+ minutes: 60
207
+ });
208
+ expect((0, _reducer.dayValueError)(pinnedTuesday, context, D, TUE, 30)).toBeNull();
209
+ });
210
+ it("deletes the latest timebox and shortens the one before (the brief's example)", function () {
211
+ var twoHours = apply(editD((0, _mockData.initialState)(), WED, 120), {
212
+ type: "pin",
213
+ taskId: D,
214
+ date: WED,
215
+ start: at("09:00"),
216
+ minutes: 90
217
+ }, {
218
+ type: "pin",
219
+ taskId: D,
220
+ date: WED,
221
+ start: at("14:00"),
222
+ minutes: 30
223
+ });
224
+ expect(untimed(twoHours, D, WED)).toBe(0);
225
+ var next = editD(twoHours, WED, 60);
226
+ expect(ranges(next, D, WED)).toEqual([["09:00", "10:00"]]);
227
+ expect(untimed(next, D, WED)).toBe(0);
228
+ expect(dayTotal(next, D, THU)).toBe(120);
229
+ });
230
+ it("deletes a timebox that would end up under the min gap", function () {
231
+ var pinned = apply((0, _mockData.initialState)(), {
232
+ type: "pin",
233
+ taskId: D,
234
+ date: WED,
235
+ start: at("09:00"),
236
+ minutes: 60
237
+ }, {
238
+ type: "pin",
239
+ taskId: D,
240
+ date: WED,
241
+ start: at("14:00"),
242
+ minutes: 30
243
+ });
244
+ var next = editD(pinned, WED, 70);
245
+ expect(ranges(next, D, WED)).toEqual([["09:00", "10:00"]]);
246
+ expect(untimed(next, D, WED)).toBe(10);
247
+ });
248
+ it("grows a day past its allocation and shortens a later timebox", function () {
249
+ var pinned = apply((0, _mockData.initialState)(), {
250
+ type: "pin",
251
+ taskId: D,
252
+ date: WED,
253
+ start: at("15:00"),
254
+ minutes: 60
255
+ });
256
+ var partId = (0, _model.timeboxesOn)(pinned, D, WED)[0].id;
257
+ expect((0, _reducer.previewDayValue)(pinned, context, D, WED, 150)).toEqual([{
258
+ taskId: D,
259
+ date: THU,
260
+ kind: "resized",
261
+ partId: "p6",
262
+ from: {
263
+ start: at("10:00"),
264
+ end: at("11:00")
265
+ },
266
+ to: {
267
+ start: at("10:00"),
268
+ end: at("10:30")
269
+ }
270
+ }]);
271
+ var grown = apply(pinned, {
272
+ type: "resizeTimebox",
273
+ partId,
274
+ start: at("15:00"),
275
+ end: at("17:30"),
276
+ allowIncrease: true
277
+ });
278
+ expect(dayTotal(grown, D, WED)).toBe(150);
279
+ expect(dayTotal(grown, D, THU)).toBe(30);
280
+ expect(ranges(grown, D, THU)).toEqual([["10:00", "10:30"]]);
281
+ });
282
+ });
283
+ describe("operations", function () {
284
+ it("pins a suggestion of an unsplit task without changing the day", function () {
285
+ var _untimedPartOn2;
286
+ var next = apply((0, _mockData.initialState)(), {
287
+ type: "pin",
288
+ taskId: C,
289
+ date: WED,
290
+ start: at("09:00"),
291
+ minutes: 30
292
+ });
293
+ expect((0, _model.isSplit)(next, C)).toBe(true);
294
+ expect(dayTotal(next, C, WED)).toBe(120);
295
+ expect((_untimedPartOn2 = (0, _model.untimedPartOn)(next, C, WED)) === null || _untimedPartOn2 === void 0 ? void 0 : _untimedPartOn2.durationMinutes).toBe(90);
296
+ });
297
+ it("splits E evenly before pinning it", function () {
298
+ var next = apply((0, _mockData.initialState)(), {
299
+ type: "pin",
300
+ taskId: E,
301
+ date: WED,
302
+ start: at("16:00"),
303
+ minutes: 60
304
+ });
305
+ expect(["2026-11-03", WED, THU, "2026-11-06"].map(function (day) {
306
+ return dayTotal(next, E, day);
307
+ })).toEqual([120, 120, 120, 120]);
308
+ });
309
+ it("drops F as a 1h timebox and sets an hour a day as its estimate", function () {
310
+ var state = (0, _mockData.initialState)();
311
+ expect((0, _reducer.planDrop)(state, context, F, WED, at("16:02"))).toEqual({
312
+ start: at("16:00"),
313
+ minutes: 60
314
+ });
315
+ var next = apply(state, {
316
+ type: "dropTask",
317
+ taskId: F,
318
+ date: WED,
319
+ start: at("16:02")
320
+ });
321
+ expect((0, _plan.taskById)(next, F).estimate).toBe(60);
322
+ expect((0, _model.timeboxesOn)(next, F, WED)).toHaveLength(1);
323
+ });
324
+ it("cuts a drop at the next pinned timebox and refuses fully pinned rows", function () {
325
+ expect((0, _reducer.planDrop)((0, _mockData.initialState)(), context, C, WED, at("10:30"))).toEqual({
326
+ start: at("10:30"),
327
+ minutes: 30
328
+ });
329
+ expect((0, _reducer.planDrop)((0, _mockData.initialState)(), context, A, WED, at("16:00"))).toEqual({
330
+ error: "All of today's allocation is scheduled"
331
+ });
332
+ });
333
+ it("moves a timebox but stops at its pinned neighbour", function () {
334
+ var next = apply((0, _mockData.initialState)(), {
335
+ type: "moveTimebox",
336
+ partId: "p1",
337
+ start: at("10:45")
338
+ });
339
+ /* A (1h) can go no later than B's 11:00 start. */
340
+ expect((0, _model.timeboxesOn)(next, A, WED)[0].startsOnTime).toBe("10:00");
341
+ });
342
+ it("stops a one-day task's resize at its allocation", function () {
343
+ var plan = (0, _reducer.planResize)((0, _mockData.initialState)(), context, "p1", at("09:30"), at("11:00"));
344
+ expect(plan).toMatchObject({
345
+ kind: "blocked",
346
+ end: at("10:30"),
347
+ reason: "Today's allocation is 1h"
348
+ });
349
+ });
350
+ it("asks before growing a day past its allocation, then takes it from later days", function () {
351
+ var state = (0, _mockData.initialState)();
352
+ var plan = (0, _reducer.planResize)(state, context, "p6", at("10:00"), at("12:00"));
353
+ expect(plan).toMatchObject({
354
+ kind: "blocked"
355
+ });
356
+ /* Thursday is D's last day; on Wednesday pin 1h then grow it to 2h. */
357
+ var pinned = apply(state, {
358
+ type: "pin",
359
+ taskId: D,
360
+ date: WED,
361
+ start: at("15:00"),
362
+ minutes: 60
363
+ });
364
+ var partId = (0, _model.timeboxesOn)(pinned, D, WED)[0].id;
365
+ expect((0, _reducer.planResize)(pinned, context, partId, at("15:00"), at("17:00"))).toMatchObject({
366
+ kind: "increase",
367
+ from: 90,
368
+ to: 120
369
+ });
370
+ var grown = apply(pinned, {
371
+ type: "resizeTimebox",
372
+ partId,
373
+ start: at("15:00"),
374
+ end: at("17:00"),
375
+ allowIncrease: true
376
+ });
377
+ expect(dayTotal(grown, D, WED)).toBe(120);
378
+ expect(dayTotal(grown, D, THU)).toBe(60);
379
+ });
380
+ it("unpins back into the day's untimed part", function () {
381
+ var next = apply((0, _mockData.initialState)(), {
382
+ type: "unpin",
383
+ partId: "p6"
384
+ });
385
+ expect((0, _model.pinnedOn)(next, D, THU)).toBe(0);
386
+ expect(dayTotal(next, D, THU)).toBe(90);
387
+ });
388
+ it("unsplits with the number of pinned timeboxes in the confirm", function () {
389
+ var state = (0, _mockData.initialState)();
390
+ expect((0, _reducer.unsplitConfirmText)(state, (0, _plan.taskById)(state, D))).toBe("Unsplit Workload export and remove 1 pinned timebox?");
391
+ var next = apply(state, {
392
+ type: "unsplit",
393
+ taskId: D
394
+ });
395
+ expect((0, _model.isSplit)(next, D)).toBe(false);
396
+ expect(dayTotal(next, D, MON)).toBe(90);
397
+ });
398
+ });
399
+ describe("merging", function () {
400
+ /* D on Wednesday: 1h30 untimed; A and B are pinned before 13:00. */
401
+ var pinD = function pinD(state, clock, minutes) {
402
+ return apply(state, {
403
+ type: "pin",
404
+ taskId: D,
405
+ date: WED,
406
+ start: at(clock),
407
+ minutes
408
+ });
409
+ };
410
+ var wedBoxes = function wedBoxes(state) {
411
+ return (0, _model.timeboxesOn)(state, D, WED).map(function (part) {
412
+ var _part$startsOnTime2;
413
+ return [part.startsOnTime, (0, _model.minutesToClock)(at((_part$startsOnTime2 = part.startsOnTime) !== null && _part$startsOnTime2 !== void 0 ? _part$startsOnTime2 : "00:00") + part.durationMinutes)];
414
+ });
415
+ };
416
+ var wedUntimed = function wedUntimed(state) {
417
+ var _untimedPartOn$durati2, _untimedPartOn3;
418
+ return (_untimedPartOn$durati2 = (_untimedPartOn3 = (0, _model.untimedPartOn)(state, D, WED)) === null || _untimedPartOn3 === void 0 ? void 0 : _untimedPartOn3.durationMinutes) !== null && _untimedPartOn$durati2 !== void 0 ? _untimedPartOn$durati2 : 0;
419
+ };
420
+ var firstId = function firstId(state) {
421
+ return (0, _model.timeboxesOn)(state, D, WED)[0].id;
422
+ };
423
+ var AB = [["09:30", "10:30"], ["11:00", "12:30"]];
424
+ var abOf = function abOf(state) {
425
+ return [...(0, _model.timeboxesOn)(state, A, WED), ...(0, _model.timeboxesOn)(state, B, WED)].map(function (part) {
426
+ var _part$startsOnTime3;
427
+ return [part.startsOnTime, (0, _model.minutesToClock)(at((_part$startsOnTime3 = part.startsOnTime) !== null && _part$startsOnTime3 !== void 0 ? _part$startsOnTime3 : "00:00") + part.durationMinutes)];
428
+ });
429
+ };
430
+ var twoPieces = function twoPieces() {
431
+ return pinD(pinD((0, _mockData.initialState)(), "13:00", 30), "14:00", 30);
432
+ };
433
+ it("resizing to touch joins the two into one, the day's total unchanged", function () {
434
+ var state = twoPieces();
435
+ var next = apply(state, {
436
+ type: "resizeTimebox",
437
+ partId: firstId(state),
438
+ start: at("13:00"),
439
+ end: at("14:00")
440
+ });
441
+ expect(wedBoxes(next)).toEqual([["13:00", "14:30"]]);
442
+ expect(wedUntimed(next)).toBe(0);
443
+ expect(dayTotal(next, D, WED)).toBe(90);
444
+ expect(abOf(next)).toEqual(AB);
445
+ });
446
+ it("resizing through the other gives the same union", function () {
447
+ var state = twoPieces();
448
+ var next = apply(state, {
449
+ type: "resizeTimebox",
450
+ partId: firstId(state),
451
+ start: at("13:00"),
452
+ end: at("14:15")
453
+ });
454
+ expect(wedBoxes(next)).toEqual([["13:00", "14:30"]]);
455
+ expect(wedUntimed(next)).toBe(0);
456
+ });
457
+ it("moving to touch joins them; moving over gives the overlap back to untimed", function () {
458
+ var state = pinD(pinD((0, _mockData.initialState)(), "13:00", 30), "15:00", 30);
459
+ var later = (0, _model.timeboxesOn)(state, D, WED)[1].id;
460
+ var touching = apply(state, {
461
+ type: "moveTimebox",
462
+ partId: later,
463
+ start: at("13:30")
464
+ });
465
+ expect(wedBoxes(touching)).toEqual([["13:00", "14:00"]]);
466
+ expect(wedUntimed(touching)).toBe(30);
467
+ var overlapping = apply(state, {
468
+ type: "moveTimebox",
469
+ partId: later,
470
+ start: at("13:15")
471
+ });
472
+ expect(wedBoxes(overlapping)).toEqual([["13:00", "13:45"]]);
473
+ expect(wedUntimed(overlapping)).toBe(45);
474
+ expect(dayTotal(overlapping, D, WED)).toBe(90);
475
+ });
476
+ it("pinning next to a timebox joins it", function () {
477
+ var first = pinD((0, _mockData.initialState)(), "13:00", 30);
478
+ var id = firstId(first);
479
+ var next = pinD(first, "13:30", 30);
480
+ expect(wedBoxes(next)).toEqual([["13:00", "14:00"]]);
481
+ expect(firstId(next)).toBe(id);
482
+ });
483
+ it("asks to increase when bridging the gap needs more than the untimed part", function () {
484
+ var state = pinD(pinD((0, _mockData.initialState)(), "13:00", 60), "14:30", 30);
485
+ expect(wedUntimed(state)).toBe(0);
486
+ expect((0, _reducer.planResize)(state, context, firstId(state), at("13:00"), at("14:30"))).toMatchObject({
487
+ kind: "increase",
488
+ start: at("13:00"),
489
+ end: at("15:00"),
490
+ from: 90,
491
+ to: 120
492
+ });
493
+ });
494
+ it("never merges or overlaps another task's timebox", function () {
495
+ var state = pinD((0, _mockData.initialState)(), "13:00", 30);
496
+ expect((0, _reducer.planMove)(state, firstId(state), at("11:15"))).toBe(at("12:30"));
497
+ });
498
+ it("logs a move onto a timebox as moved and merged", function () {
499
+ var state = pinD(pinD((0, _mockData.initialState)(), "13:00", 30), "15:00", 30);
500
+ var next = apply(state, {
501
+ type: "moveTimebox",
502
+ partId: firstId(state),
503
+ start: at("14:30")
504
+ });
505
+ expect((0, _changes.changeLines)((0, _changes.describeChange)(state, next, context), next)).toEqual(["Workload export · moved Wed, Nov 4 13:00–13:30 and merged with 15:00–15:30 → 14:30–15:30"]);
506
+ });
507
+ it("logs the join as one merged line", function () {
508
+ var state = twoPieces();
509
+ var next = apply(state, {
510
+ type: "resizeTimebox",
511
+ partId: firstId(state),
512
+ start: at("13:00"),
513
+ end: at("14:00")
514
+ });
515
+ expect((0, _changes.changeLines)((0, _changes.describeChange)(state, next, context), next)).toEqual(["Workload export · merged Wed, Nov 4 13:00–13:30 + 14:00–14:30 → 13:00–14:30"]);
516
+ });
517
+ });
518
+ describe("change log", function () {
519
+ it("lists the day totals and the timebox a resize past the allocation moved", function () {
520
+ var before = apply((0, _mockData.initialState)(), {
521
+ type: "pin",
522
+ taskId: D,
523
+ date: WED,
524
+ start: at("15:00"),
525
+ minutes: 60
526
+ });
527
+ var partId = (0, _model.timeboxesOn)(before, D, WED)[0].id;
528
+ var after = apply(before, {
529
+ type: "resizeTimebox",
530
+ partId,
531
+ start: at("15:00"),
532
+ end: at("17:00"),
533
+ allowIncrease: true
534
+ });
535
+ var change = (0, _changes.describeChange)(before, after, context);
536
+ expect((0, _changes.changeLines)(change, after)).toEqual(["Workload export · resized Wed, Nov 4 15:00–16:00 → 15:00–17:00", "Workload export · Wed, Nov 4: 1h30 → 2h", "Workload export · Thu, Nov 5: 1h30 → 1h"]);
537
+ });
538
+ it("lists a timebox a split edit removes as deleted, an unpin as unpinned", function () {
539
+ var state = (0, _mockData.initialState)();
540
+ var edited = apply(state, {
541
+ type: "editDayValue",
542
+ taskId: D,
543
+ date: TUE,
544
+ minutes: 270
545
+ });
546
+ expect((0, _changes.changeLines)((0, _changes.describeChange)(state, edited, context), edited)).toEqual(expect.arrayContaining(["Workload export · deleted Thu, Nov 5 10:00–11:00"]));
547
+ var unpinned = apply(state, {
548
+ type: "unpin",
549
+ partId: "p6"
550
+ });
551
+ expect((0, _changes.changeLines)((0, _changes.describeChange)(state, unpinned, context), unpinned)).toEqual(["Workload export · unpinned Thu, Nov 5 10:00–11:00"]);
552
+ });
553
+ it("notes the split a first pin makes", function () {
554
+ var after = apply((0, _mockData.initialState)(), {
555
+ type: "pin",
556
+ taskId: C,
557
+ date: WED,
558
+ start: at("09:00"),
559
+ minutes: 30
560
+ });
561
+ var change = (0, _changes.describeChange)((0, _mockData.initialState)(), after, context);
562
+ expect(change.splits).toEqual([{
563
+ taskId: C,
564
+ split: true
565
+ }]);
566
+ expect(change.days).toEqual([]);
567
+ });
568
+ });
569
+ describe("tracked time", function () {
570
+ /* D alone on Wednesday (Marko's other tasks and the events taken out),
571
+ its day as the given parts, the given events and the given minutes
572
+ tracked on it. */
573
+ var onlyD = function onlyD(parts, events, tracked) {
574
+ var state = (0, _mockData.initialState)();
575
+ return _objectSpread(_objectSpread({}, state), {}, {
576
+ tasks: state.tasks.filter(function (task) {
577
+ return task.id === D || task.assigneeId !== _mockData.ME;
578
+ }),
579
+ parts: [...state.parts.filter(function (part) {
580
+ return !(part.taskId === D && part.date === WED);
581
+ }), ...parts.map(function (part, index) {
582
+ return {
583
+ id: "d".concat(index),
584
+ taskId: D,
585
+ date: WED,
586
+ startsOnTime: part.start,
587
+ durationMinutes: part.minutes
588
+ };
589
+ })],
590
+ events: events.map(function (_ref, index) {
591
+ var _ref2 = _slicedToArray(_ref, 2),
592
+ start = _ref2[0],
593
+ end = _ref2[1];
594
+ return {
595
+ id: 900 + index,
596
+ name: "Busy",
597
+ calendarName: "Work",
598
+ color: "#63A7DE",
599
+ date: WED,
600
+ startsOnTime: start,
601
+ endsOnTime: end,
602
+ isParticipant: true,
603
+ meetingUrl: null
604
+ };
605
+ }),
606
+ timeRecords: tracked > 0 ? [{
607
+ id: "tr",
608
+ taskId: D,
609
+ userId: _mockData.ME,
610
+ recordDate: WED,
611
+ minutes: tracked
612
+ }] : []
613
+ });
614
+ };
615
+
616
+ /* 09:00–10:30 pinned, 13:00–13:30 suggested (an event fills the time
617
+ between), 14:00–14:30 pinned. */
618
+ var example = function example(tracked) {
619
+ return onlyD([{
620
+ start: "09:00",
621
+ minutes: 90
622
+ }, {
623
+ start: "14:00",
624
+ minutes: 30
625
+ }, {
626
+ start: null,
627
+ minutes: 30
628
+ }], [["10:30", "13:00"]], tracked);
629
+ };
630
+ it("moves nothing in the plan and logs the record", function () {
631
+ var before = (0, _mockData.initialState)();
632
+ var after = apply(before, {
633
+ type: "addTimeRecord",
634
+ taskId: C,
635
+ recordDate: WED,
636
+ minutes: 45
637
+ });
638
+ [MON, TUE, WED, THU].forEach(function (date) {
639
+ expect((0, _plan.planDay)(after, context, _mockData.ME, date)).toEqual((0, _plan.planDay)(before, context, _mockData.ME, date));
640
+ });
641
+ expect(after.parts).toEqual(before.parts);
642
+ expect((0, _changes.changeLines)((0, _changes.describeChange)(before, after, context), after)).toEqual(["Onboarding emails · tracked Wed 45m"]);
643
+ expect((0, _reducer.reduce)(before, context, {
644
+ type: "addTimeRecord",
645
+ taskId: C,
646
+ recordDate: WED,
647
+ minutes: 0
648
+ }).error).toBeDefined();
649
+ });
650
+
651
+ /** The Tracked column's blocks of the day, as [task, start, end, late,
652
+ past its blocks]. */
653
+ var piecesOf = function piecesOf(state) {
654
+ return (0, _tracked.trackedBlocks)(state, context, WED).blocks.map(function (block) {
655
+ return [block.taskId, block.start, block.end, block.lateMinutes, block.afterMinutes];
656
+ });
657
+ };
658
+ it("lays tracked time over the blocks, back-to-back pieces as one", function () {
659
+ expect(piecesOf(example(105))).toEqual([[D, at("09:00"), at("10:30"), 0, 0], [D, at("13:00"), at("13:15"), 0, 0]]);
660
+ /* The 30m past its blocks runs on from 14:30: one block with 14:00. */
661
+ expect(piecesOf(example(180))).toEqual([[D, at("09:00"), at("10:30"), 0, 0], [D, at("13:00"), at("13:30"), 0, 0], [D, at("14:00"), at("15:00"), 0, 30]]);
662
+ });
663
+ it("lays the mock's Wednesday out as planned", function () {
664
+ expect(piecesOf((0, _mockData.initialState)())).toEqual([[C, at("09:00"), at("09:30"), 0, 0], [A, at("09:30"), at("10:30"), 0, 0], [C, at("10:30"), at("10:45"), 0, 0]]);
665
+ });
666
+ it("pushes what comes after tracked time on, never over it", function () {
667
+ /* A tracks 1h30 on its 09:30 hour: its 30m extra takes 10:30–11:00,
668
+ so C's 15m planned at 10:30 starts at 11:00. */
669
+ var state = apply((0, _mockData.initialState)(), {
670
+ type: "addTimeRecord",
671
+ taskId: A,
672
+ recordDate: WED,
673
+ minutes: 30
674
+ });
675
+ expect(piecesOf(state)).toEqual([[C, at("09:00"), at("09:30"), 0, 0], [A, at("09:30"), at("11:00"), 0, 30], [C, at("11:00"), at("11:15"), 30, 0]]);
676
+ });
677
+ it("places a completed task's time and keeps untimed time apart", function () {
678
+ var completed = apply((0, _mockData.initialState)(), {
679
+ type: "setCompleted",
680
+ taskId: A,
681
+ completed: true
682
+ });
683
+ expect((0, _tracked.trackedBlocks)(completed, context, WED).blocks.find(function (block) {
684
+ return block.taskId === A;
685
+ })).toMatchObject({
686
+ start: at("09:30"),
687
+ end: at("10:30")
688
+ });
689
+ expect((0, _tracked.trackedBlocks)(onlyD([], [], 45), context, WED)).toEqual({
690
+ blocks: [],
691
+ untimed: [{
692
+ taskId: D,
693
+ minutes: 45,
694
+ planned: 0
695
+ }]
696
+ });
697
+ });
698
+ });
699
+ //# sourceMappingURL=timeboxes.test.js.map