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