@happychef/algorithm 1.2.10 → 1.2.12

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 (46) hide show
  1. package/.github/workflows/ci-cd.yml +133 -2
  2. package/BRANCH_PROTECTION_SETUP.md +167 -0
  3. package/CHANGELOG.md +8 -8
  4. package/RESERVERINGEN_GIDS.md +986 -986
  5. package/assignTables.js +424 -398
  6. package/changes/2025/December/PR2___change.md +14 -14
  7. package/changes/2025/December/PR3_add__change.md +20 -20
  8. package/changes/2025/December/PR4___.md +16 -0
  9. package/changes/2025/December/PR5___.md +16 -0
  10. package/changes/2025/December/PR6__del_.md +18 -0
  11. package/changes/2025/December/PR7_add__change.md +22 -0
  12. package/changes/2026/January/PR8_add__change.md +39 -0
  13. package/changes/2026/January/PR9_add__change.md +20 -0
  14. package/filters/maxArrivalsFilter.js +114 -114
  15. package/filters/maxGroupsFilter.js +221 -221
  16. package/filters/timeFilter.js +89 -89
  17. package/getAvailableTimeblocks.js +158 -158
  18. package/grouping.js +162 -162
  19. package/index.js +42 -42
  20. package/isDateAvailable.js +80 -80
  21. package/isDateAvailableWithTableCheck.js +171 -171
  22. package/isTimeAvailable.js +25 -25
  23. package/package.json +27 -27
  24. package/processing/dailyGuestCounts.js +73 -73
  25. package/processing/mealTypeCount.js +133 -133
  26. package/processing/timeblocksAvailable.js +167 -167
  27. package/reservation_data/counter.js +64 -64
  28. package/restaurant_data/exceptions.js +149 -149
  29. package/restaurant_data/openinghours.js +123 -123
  30. package/simulateTableAssignment.js +709 -699
  31. package/tableHelpers.js +178 -178
  32. package/tables/time/parseTime.js +19 -19
  33. package/tables/time/shifts.js +7 -7
  34. package/tables/utils/calculateDistance.js +13 -13
  35. package/tables/utils/isTableFreeForAllSlots.js +14 -14
  36. package/tables/utils/isTemporaryTableValid.js +39 -39
  37. package/test/test_counter.js +194 -194
  38. package/test/test_dailyCount.js +81 -81
  39. package/test/test_datesAvailable.js +106 -106
  40. package/test/test_exceptions.js +172 -172
  41. package/test/test_isDateAvailable.js +330 -330
  42. package/test/test_mealTypeCount.js +54 -54
  43. package/test/test_timesAvailable.js +88 -88
  44. package/test-meal-stop-fix.js +147 -147
  45. package/test-meal-stop-simple.js +93 -93
  46. package/test.js +336 -336
@@ -1,54 +1,54 @@
1
- // mealReservationTests.js
2
-
3
- const { getGuestCountsForMeal } = require('../processing/mealTypeCount');
4
-
5
- // Sample data including shifts
6
- const data = {
7
- "_id": "demo",
8
- "openinghours-breakfast": {
9
- "schemeSettings": {
10
- "Monday": {
11
- "enabled": true,
12
- "startTime": "07:00",
13
- "endTime": "09:30",
14
- "maxCapacityEnabled": true,
15
- "maxCapacity": "12",
16
- "shiftsEnabled": true,
17
- "shifts": [
18
- {
19
- "name": "Shift 1",
20
- "time": "08:00"
21
- },
22
- {
23
- "name": "Shift 2",
24
- "time": "09:00"
25
- }
26
- ]
27
- }
28
- },
29
- "storedNumber": {
30
- "$numberInt": "0"
31
- }
32
- },
33
- // Other meal data...
34
- };
35
-
36
- // Sample reservations
37
- const reservations = [
38
- { guests: "5", time: "08:00", date: "2024-12-02" },
39
- { guests: "3", time: "09:00", date: "2024-12-02" },
40
- { guests: "2", time: "07:00", date: "2024-12-02" },
41
- { guests: "4", time: "07:30", date: "2024-12-02" },
42
- { guests: "6", time: "08:00", date: "2024-12-02" }, // Reservation on a different date
43
- ];
44
-
45
- console.log('--- Meal Reservation Guest Counts Tests ---');
46
-
47
- // Test 1: Breakfast on January 12th (Monday) with shifts
48
- const dateStr = '2024-12-02';
49
- const mealType = 'breakfast';
50
-
51
- const guestCounts = getGuestCountsForMeal(data, dateStr, mealType, reservations);
52
-
53
- console.log('Test 1 - Guest Counts for Breakfast on January 12th with Shifts:');
54
- console.log(guestCounts);
1
+ // mealReservationTests.js
2
+
3
+ const { getGuestCountsForMeal } = require('../processing/mealTypeCount');
4
+
5
+ // Sample data including shifts
6
+ const data = {
7
+ "_id": "demo",
8
+ "openinghours-breakfast": {
9
+ "schemeSettings": {
10
+ "Monday": {
11
+ "enabled": true,
12
+ "startTime": "07:00",
13
+ "endTime": "09:30",
14
+ "maxCapacityEnabled": true,
15
+ "maxCapacity": "12",
16
+ "shiftsEnabled": true,
17
+ "shifts": [
18
+ {
19
+ "name": "Shift 1",
20
+ "time": "08:00"
21
+ },
22
+ {
23
+ "name": "Shift 2",
24
+ "time": "09:00"
25
+ }
26
+ ]
27
+ }
28
+ },
29
+ "storedNumber": {
30
+ "$numberInt": "0"
31
+ }
32
+ },
33
+ // Other meal data...
34
+ };
35
+
36
+ // Sample reservations
37
+ const reservations = [
38
+ { guests: "5", time: "08:00", date: "2024-12-02" },
39
+ { guests: "3", time: "09:00", date: "2024-12-02" },
40
+ { guests: "2", time: "07:00", date: "2024-12-02" },
41
+ { guests: "4", time: "07:30", date: "2024-12-02" },
42
+ { guests: "6", time: "08:00", date: "2024-12-02" }, // Reservation on a different date
43
+ ];
44
+
45
+ console.log('--- Meal Reservation Guest Counts Tests ---');
46
+
47
+ // Test 1: Breakfast on January 12th (Monday) with shifts
48
+ const dateStr = '2024-12-02';
49
+ const mealType = 'breakfast';
50
+
51
+ const guestCounts = getGuestCountsForMeal(data, dateStr, mealType, reservations);
52
+
53
+ console.log('Test 1 - Guest Counts for Breakfast on January 12th with Shifts:');
54
+ console.log(guestCounts);
@@ -1,88 +1,88 @@
1
- // timeblocksAvailableTests.js
2
-
3
- const { timeblocksAvailable } = require('../processing/timeblocksAvailable');
4
-
5
- // Sample data (same as previous examples)
6
- const data = {
7
- "_id": "demo",
8
- "general-settings": {
9
- "zitplaatsen": "5",
10
- "duurReservatie": "120", // Reservation duration of 120 minutes
11
- "intervalReservatie": "30" // Time increment of 30 minutes
12
- },
13
- "openinghours-breakfast": {
14
- "schemeSettings": {
15
- "Monday": {
16
- "enabled": false,
17
- "startTime": "07:00",
18
- "endTime": "11:00",
19
- "maxCapacityEnabled": false,
20
- "maxCapacity": "0",
21
- "shiftsEnabled": false,
22
- "shifts": []
23
- }
24
- },
25
- "storedNumber": {
26
- "$numberInt": "0"
27
- }
28
- },
29
- "openinghours-lunch": {
30
- "schemeSettings": {
31
- "Monday": {
32
- "enabled": false,
33
- "startTime": "13:00",
34
- "endTime": "16:00",
35
- "maxCapacityEnabled": true,
36
- "maxCapacity": "20",
37
- "shiftsEnabled": false,
38
- "shifts": []
39
- }
40
- },
41
- "storedNumber": {
42
- "$numberInt": "0"
43
- }
44
- },
45
- "openinghours-dinner": {
46
- "schemeSettings": {
47
- "Monday": {
48
- "enabled": true,
49
- "startTime": "16:00",
50
- "endTime": "23:00",
51
- "maxCapacityEnabled": true,
52
- "maxCapacity": "5",
53
- "shiftsEnabled": true,
54
- "shifts": [
55
- {
56
- "name": "Shift 1",
57
- "time": "18:00"
58
- },
59
- {
60
- "name": "Shift 2",
61
- "time": "20:00"
62
- }
63
- ]
64
- }
65
- },
66
- "storedNumber": {
67
- "$numberInt": "0"
68
- }
69
- },
70
- "exceptions": []
71
- };
72
-
73
- // Sample reservations
74
- const reservations = [
75
- // Dinner reservations
76
- { guests: "5", time: "18:00", date: "2024-12-02" }, // Shift 1 is fully booked
77
- { guests: "2", time: "20:00", date: "2024-12-02" }, // Shift 2 has available seats
78
- ];
79
-
80
- console.log('--- Time Blocks Availability Tests ---');
81
-
82
- const guests = 3;
83
- const dateStr = '2024-12-02';
84
-
85
- const availableTimeblocks = timeblocksAvailable(data, dateStr, reservations, guests);
86
-
87
- console.log(`Available time blocks for ${guests} guests on ${dateStr}:`);
88
- console.log(availableTimeblocks);
1
+ // timeblocksAvailableTests.js
2
+
3
+ const { timeblocksAvailable } = require('../processing/timeblocksAvailable');
4
+
5
+ // Sample data (same as previous examples)
6
+ const data = {
7
+ "_id": "demo",
8
+ "general-settings": {
9
+ "zitplaatsen": "5",
10
+ "duurReservatie": "120", // Reservation duration of 120 minutes
11
+ "intervalReservatie": "30" // Time increment of 30 minutes
12
+ },
13
+ "openinghours-breakfast": {
14
+ "schemeSettings": {
15
+ "Monday": {
16
+ "enabled": false,
17
+ "startTime": "07:00",
18
+ "endTime": "11:00",
19
+ "maxCapacityEnabled": false,
20
+ "maxCapacity": "0",
21
+ "shiftsEnabled": false,
22
+ "shifts": []
23
+ }
24
+ },
25
+ "storedNumber": {
26
+ "$numberInt": "0"
27
+ }
28
+ },
29
+ "openinghours-lunch": {
30
+ "schemeSettings": {
31
+ "Monday": {
32
+ "enabled": false,
33
+ "startTime": "13:00",
34
+ "endTime": "16:00",
35
+ "maxCapacityEnabled": true,
36
+ "maxCapacity": "20",
37
+ "shiftsEnabled": false,
38
+ "shifts": []
39
+ }
40
+ },
41
+ "storedNumber": {
42
+ "$numberInt": "0"
43
+ }
44
+ },
45
+ "openinghours-dinner": {
46
+ "schemeSettings": {
47
+ "Monday": {
48
+ "enabled": true,
49
+ "startTime": "16:00",
50
+ "endTime": "23:00",
51
+ "maxCapacityEnabled": true,
52
+ "maxCapacity": "5",
53
+ "shiftsEnabled": true,
54
+ "shifts": [
55
+ {
56
+ "name": "Shift 1",
57
+ "time": "18:00"
58
+ },
59
+ {
60
+ "name": "Shift 2",
61
+ "time": "20:00"
62
+ }
63
+ ]
64
+ }
65
+ },
66
+ "storedNumber": {
67
+ "$numberInt": "0"
68
+ }
69
+ },
70
+ "exceptions": []
71
+ };
72
+
73
+ // Sample reservations
74
+ const reservations = [
75
+ // Dinner reservations
76
+ { guests: "5", time: "18:00", date: "2024-12-02" }, // Shift 1 is fully booked
77
+ { guests: "2", time: "20:00", date: "2024-12-02" }, // Shift 2 has available seats
78
+ ];
79
+
80
+ console.log('--- Time Blocks Availability Tests ---');
81
+
82
+ const guests = 3;
83
+ const dateStr = '2024-12-02';
84
+
85
+ const availableTimeblocks = timeblocksAvailable(data, dateStr, reservations, guests);
86
+
87
+ console.log(`Available time blocks for ${guests} guests on ${dateStr}:`);
88
+ console.log(availableTimeblocks);
@@ -1,147 +1,147 @@
1
- // Test to verify meal stop filters work with Brussels timezone
2
-
3
- const { getAvailableTimeblocks } = require('./getAvailableTimeblocks');
4
- const { getMealTypeByTime } = require('./tableHelpers');
5
-
6
- // Mock restaurant data
7
- const testData = {
8
- 'general-settings': {
9
- zitplaatsen: 20,
10
- uurOpVoorhand: 0,
11
- dagenInToekomst: 365,
12
- minGasten: 1,
13
- maxGasten: 10,
14
- intervalReservatie: 30,
15
- duurReservatie: 120,
16
- ontbijtStop: "10:00", // Breakfast stops at 10:00
17
- lunchStop: "12:00", // Lunch stops at 12:00
18
- dinerStop: "20:00" // Dinner stops at 20:00
19
- },
20
- 'openinghours-breakfast': {
21
- monday: { enabled: true, startTime: '08:00', endTime: '11:00' },
22
- tuesday: { enabled: true, startTime: '08:00', endTime: '11:00' },
23
- wednesday: { enabled: true, startTime: '08:00', endTime: '11:00' },
24
- thursday: { enabled: true, startTime: '08:00', endTime: '11:00' },
25
- friday: { enabled: true, startTime: '08:00', endTime: '11:00' },
26
- saturday: { enabled: true, startTime: '08:00', endTime: '11:00' },
27
- sunday: { enabled: true, startTime: '08:00', endTime: '11:00' }
28
- },
29
- 'openinghours-lunch': {
30
- monday: { enabled: true, startTime: '11:00', endTime: '15:00' },
31
- tuesday: { enabled: true, startTime: '11:00', endTime: '15:00' },
32
- wednesday: { enabled: true, startTime: '11:00', endTime: '15:00' },
33
- thursday: { enabled: true, startTime: '11:00', endTime: '15:00' },
34
- friday: { enabled: true, startTime: '11:00', endTime: '15:00' },
35
- saturday: { enabled: true, startTime: '11:00', endTime: '15:00' },
36
- sunday: { enabled: true, startTime: '11:00', endTime: '15:00' }
37
- },
38
- 'openinghours-dinner': {
39
- monday: { enabled: true, startTime: '17:00', endTime: '22:00' },
40
- tuesday: { enabled: true, startTime: '17:00', endTime: '22:00' },
41
- wednesday: { enabled: true, startTime: '17:00', endTime: '22:00' },
42
- thursday: { enabled: true, startTime: '17:00', endTime: '22:00' },
43
- friday: { enabled: true, startTime: '17:00', endTime: '22:00' },
44
- saturday: { enabled: true, startTime: '17:00', endTime: '22:00' },
45
- sunday: { enabled: true, startTime: '17:00', endTime: '22:00' }
46
- },
47
- 'max-arrivals-breakfast': {},
48
- 'max-arrivals-lunch': {},
49
- 'max-arrivals-dinner': {},
50
- tables: [
51
- { name: 'Table 1', minCapacity: 1, maxCapacity: 4 },
52
- { name: 'Table 2', minCapacity: 1, maxCapacity: 4 },
53
- { name: 'Table 3', minCapacity: 1, maxCapacity: 4 },
54
- { name: 'Table 4', minCapacity: 1, maxCapacity: 4 },
55
- { name: 'Table 5', minCapacity: 1, maxCapacity: 4 }
56
- ]
57
- };
58
-
59
- // Get today's date in YYYY-MM-DD format (Brussels timezone)
60
- const nowInBrussels = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Brussels' }));
61
- const year = nowInBrussels.getFullYear();
62
- const month = String(nowInBrussels.getMonth() + 1).padStart(2, '0');
63
- const day = String(nowInBrussels.getDate()).padStart(2, '0');
64
- const todayStr = `${year}-${month}-${day}`;
65
-
66
- const currentHour = nowInBrussels.getHours();
67
- const currentMinute = nowInBrussels.getMinutes();
68
- const currentTimeStr = `${String(currentHour).padStart(2, '0')}:${String(currentMinute).padStart(2, '0')}`;
69
-
70
- console.log('=== MEAL STOP FILTER TEST ===\n');
71
- console.log(`Current date (Brussels): ${todayStr}`);
72
- console.log(`Current time (Brussels): ${currentTimeStr}`);
73
- console.log(`\nMeal stop times:`);
74
- console.log(` - Breakfast stops at: 10:00`);
75
- console.log(` - Lunch stops at: 12:00`);
76
- console.log(` - Dinner stops at: 20:00\n`);
77
-
78
- // Test with today's date
79
- const reservations = [];
80
- const guests = 2;
81
- const blockedSlots = [];
82
- const giftcard = null;
83
- const isAdmin = false;
84
-
85
- const availableTimeblocks = getAvailableTimeblocks(
86
- testData,
87
- todayStr,
88
- reservations,
89
- guests,
90
- blockedSlots,
91
- giftcard,
92
- isAdmin
93
- );
94
-
95
- // Categorize by meal type
96
- const breakfast = [];
97
- const lunch = [];
98
- const dinner = [];
99
-
100
- for (const time in availableTimeblocks) {
101
- const mealType = getMealTypeByTime(time);
102
- if (mealType === 'breakfast') breakfast.push(time);
103
- else if (mealType === 'lunch') lunch.push(time);
104
- else if (mealType === 'dinner') dinner.push(time);
105
- }
106
-
107
- console.log('Available timeblocks:');
108
- console.log(` - Breakfast slots (${breakfast.length}): ${breakfast.join(', ') || 'NONE'}`);
109
- console.log(` - Lunch slots (${lunch.length}): ${lunch.join(', ') || 'NONE'}`);
110
- console.log(` - Dinner slots (${dinner.length}): ${dinner.join(', ') || 'NONE'}`);
111
-
112
- console.log('\n--- Expected Behavior ---');
113
- console.log('If current time < 10:00: Breakfast slots should be available');
114
- console.log('If current time >= 10:00: Breakfast slots should be BLOCKED');
115
- console.log('If current time < 12:00: Lunch slots should be available');
116
- console.log('If current time >= 12:00: Lunch slots should be BLOCKED');
117
- console.log('If current time < 20:00: Dinner slots should be available');
118
- console.log('If current time >= 20:00: Dinner slots should be BLOCKED');
119
-
120
- console.log('\n--- Actual Behavior ---');
121
- const currentMinutes = currentHour * 60 + currentMinute;
122
-
123
- if (currentMinutes < 10 * 60) {
124
- console.log(`Current time (${currentTimeStr}) is BEFORE 10:00`);
125
- console.log(`✓ Expected: Breakfast available = ${breakfast.length > 0 ? 'YES ✓' : 'NO ✗'}`);
126
- } else {
127
- console.log(`Current time (${currentTimeStr}) is AT OR AFTER 10:00`);
128
- console.log(`✓ Expected: Breakfast blocked = ${breakfast.length === 0 ? 'YES ✓' : 'NO ✗'}`);
129
- }
130
-
131
- if (currentMinutes < 12 * 60) {
132
- console.log(`Current time (${currentTimeStr}) is BEFORE 12:00`);
133
- console.log(`✓ Expected: Lunch available = ${lunch.length > 0 ? 'YES ✓' : 'NO ✗'}`);
134
- } else {
135
- console.log(`Current time (${currentTimeStr}) is AT OR AFTER 12:00`);
136
- console.log(`✓ Expected: Lunch blocked = ${lunch.length === 0 ? 'YES ✓' : 'NO ✗'}`);
137
- }
138
-
139
- if (currentMinutes < 20 * 60) {
140
- console.log(`Current time (${currentTimeStr}) is BEFORE 20:00`);
141
- console.log(`✓ Expected: Dinner available = ${dinner.length > 0 ? 'YES ✓' : 'NO ✗'}`);
142
- } else {
143
- console.log(`Current time (${currentTimeStr}) is AT OR AFTER 20:00`);
144
- console.log(`✓ Expected: Dinner blocked = ${dinner.length === 0 ? 'YES ✓' : 'NO ✗'}`);
145
- }
146
-
147
- console.log('\n=== TEST COMPLETE ===');
1
+ // Test to verify meal stop filters work with Brussels timezone
2
+
3
+ const { getAvailableTimeblocks } = require('./getAvailableTimeblocks');
4
+ const { getMealTypeByTime } = require('./tableHelpers');
5
+
6
+ // Mock restaurant data
7
+ const testData = {
8
+ 'general-settings': {
9
+ zitplaatsen: 20,
10
+ uurOpVoorhand: 0,
11
+ dagenInToekomst: 365,
12
+ minGasten: 1,
13
+ maxGasten: 10,
14
+ intervalReservatie: 30,
15
+ duurReservatie: 120,
16
+ ontbijtStop: "10:00", // Breakfast stops at 10:00
17
+ lunchStop: "12:00", // Lunch stops at 12:00
18
+ dinerStop: "20:00" // Dinner stops at 20:00
19
+ },
20
+ 'openinghours-breakfast': {
21
+ monday: { enabled: true, startTime: '08:00', endTime: '11:00' },
22
+ tuesday: { enabled: true, startTime: '08:00', endTime: '11:00' },
23
+ wednesday: { enabled: true, startTime: '08:00', endTime: '11:00' },
24
+ thursday: { enabled: true, startTime: '08:00', endTime: '11:00' },
25
+ friday: { enabled: true, startTime: '08:00', endTime: '11:00' },
26
+ saturday: { enabled: true, startTime: '08:00', endTime: '11:00' },
27
+ sunday: { enabled: true, startTime: '08:00', endTime: '11:00' }
28
+ },
29
+ 'openinghours-lunch': {
30
+ monday: { enabled: true, startTime: '11:00', endTime: '15:00' },
31
+ tuesday: { enabled: true, startTime: '11:00', endTime: '15:00' },
32
+ wednesday: { enabled: true, startTime: '11:00', endTime: '15:00' },
33
+ thursday: { enabled: true, startTime: '11:00', endTime: '15:00' },
34
+ friday: { enabled: true, startTime: '11:00', endTime: '15:00' },
35
+ saturday: { enabled: true, startTime: '11:00', endTime: '15:00' },
36
+ sunday: { enabled: true, startTime: '11:00', endTime: '15:00' }
37
+ },
38
+ 'openinghours-dinner': {
39
+ monday: { enabled: true, startTime: '17:00', endTime: '22:00' },
40
+ tuesday: { enabled: true, startTime: '17:00', endTime: '22:00' },
41
+ wednesday: { enabled: true, startTime: '17:00', endTime: '22:00' },
42
+ thursday: { enabled: true, startTime: '17:00', endTime: '22:00' },
43
+ friday: { enabled: true, startTime: '17:00', endTime: '22:00' },
44
+ saturday: { enabled: true, startTime: '17:00', endTime: '22:00' },
45
+ sunday: { enabled: true, startTime: '17:00', endTime: '22:00' }
46
+ },
47
+ 'max-arrivals-breakfast': {},
48
+ 'max-arrivals-lunch': {},
49
+ 'max-arrivals-dinner': {},
50
+ tables: [
51
+ { name: 'Table 1', minCapacity: 1, maxCapacity: 4 },
52
+ { name: 'Table 2', minCapacity: 1, maxCapacity: 4 },
53
+ { name: 'Table 3', minCapacity: 1, maxCapacity: 4 },
54
+ { name: 'Table 4', minCapacity: 1, maxCapacity: 4 },
55
+ { name: 'Table 5', minCapacity: 1, maxCapacity: 4 }
56
+ ]
57
+ };
58
+
59
+ // Get today's date in YYYY-MM-DD format (Brussels timezone)
60
+ const nowInBrussels = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Brussels' }));
61
+ const year = nowInBrussels.getFullYear();
62
+ const month = String(nowInBrussels.getMonth() + 1).padStart(2, '0');
63
+ const day = String(nowInBrussels.getDate()).padStart(2, '0');
64
+ const todayStr = `${year}-${month}-${day}`;
65
+
66
+ const currentHour = nowInBrussels.getHours();
67
+ const currentMinute = nowInBrussels.getMinutes();
68
+ const currentTimeStr = `${String(currentHour).padStart(2, '0')}:${String(currentMinute).padStart(2, '0')}`;
69
+
70
+ console.log('=== MEAL STOP FILTER TEST ===\n');
71
+ console.log(`Current date (Brussels): ${todayStr}`);
72
+ console.log(`Current time (Brussels): ${currentTimeStr}`);
73
+ console.log(`\nMeal stop times:`);
74
+ console.log(` - Breakfast stops at: 10:00`);
75
+ console.log(` - Lunch stops at: 12:00`);
76
+ console.log(` - Dinner stops at: 20:00\n`);
77
+
78
+ // Test with today's date
79
+ const reservations = [];
80
+ const guests = 2;
81
+ const blockedSlots = [];
82
+ const giftcard = null;
83
+ const isAdmin = false;
84
+
85
+ const availableTimeblocks = getAvailableTimeblocks(
86
+ testData,
87
+ todayStr,
88
+ reservations,
89
+ guests,
90
+ blockedSlots,
91
+ giftcard,
92
+ isAdmin
93
+ );
94
+
95
+ // Categorize by meal type
96
+ const breakfast = [];
97
+ const lunch = [];
98
+ const dinner = [];
99
+
100
+ for (const time in availableTimeblocks) {
101
+ const mealType = getMealTypeByTime(time);
102
+ if (mealType === 'breakfast') breakfast.push(time);
103
+ else if (mealType === 'lunch') lunch.push(time);
104
+ else if (mealType === 'dinner') dinner.push(time);
105
+ }
106
+
107
+ console.log('Available timeblocks:');
108
+ console.log(` - Breakfast slots (${breakfast.length}): ${breakfast.join(', ') || 'NONE'}`);
109
+ console.log(` - Lunch slots (${lunch.length}): ${lunch.join(', ') || 'NONE'}`);
110
+ console.log(` - Dinner slots (${dinner.length}): ${dinner.join(', ') || 'NONE'}`);
111
+
112
+ console.log('\n--- Expected Behavior ---');
113
+ console.log('If current time < 10:00: Breakfast slots should be available');
114
+ console.log('If current time >= 10:00: Breakfast slots should be BLOCKED');
115
+ console.log('If current time < 12:00: Lunch slots should be available');
116
+ console.log('If current time >= 12:00: Lunch slots should be BLOCKED');
117
+ console.log('If current time < 20:00: Dinner slots should be available');
118
+ console.log('If current time >= 20:00: Dinner slots should be BLOCKED');
119
+
120
+ console.log('\n--- Actual Behavior ---');
121
+ const currentMinutes = currentHour * 60 + currentMinute;
122
+
123
+ if (currentMinutes < 10 * 60) {
124
+ console.log(`Current time (${currentTimeStr}) is BEFORE 10:00`);
125
+ console.log(`✓ Expected: Breakfast available = ${breakfast.length > 0 ? 'YES ✓' : 'NO ✗'}`);
126
+ } else {
127
+ console.log(`Current time (${currentTimeStr}) is AT OR AFTER 10:00`);
128
+ console.log(`✓ Expected: Breakfast blocked = ${breakfast.length === 0 ? 'YES ✓' : 'NO ✗'}`);
129
+ }
130
+
131
+ if (currentMinutes < 12 * 60) {
132
+ console.log(`Current time (${currentTimeStr}) is BEFORE 12:00`);
133
+ console.log(`✓ Expected: Lunch available = ${lunch.length > 0 ? 'YES ✓' : 'NO ✗'}`);
134
+ } else {
135
+ console.log(`Current time (${currentTimeStr}) is AT OR AFTER 12:00`);
136
+ console.log(`✓ Expected: Lunch blocked = ${lunch.length === 0 ? 'YES ✓' : 'NO ✗'}`);
137
+ }
138
+
139
+ if (currentMinutes < 20 * 60) {
140
+ console.log(`Current time (${currentTimeStr}) is BEFORE 20:00`);
141
+ console.log(`✓ Expected: Dinner available = ${dinner.length > 0 ? 'YES ✓' : 'NO ✗'}`);
142
+ } else {
143
+ console.log(`Current time (${currentTimeStr}) is AT OR AFTER 20:00`);
144
+ console.log(`✓ Expected: Dinner blocked = ${dinner.length === 0 ? 'YES ✓' : 'NO ✗'}`);
145
+ }
146
+
147
+ console.log('\n=== TEST COMPLETE ===');