@feedmepos/mf-order-setting 0.0.95 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DisplaySystemView-rCw3DE0u.js → DisplaySystemView-BH8SkCOF.js} +4 -4
- package/dist/FoodCourtInvitationsView-3cA0Z-5m.js +383 -0
- package/dist/FoodCourtOrderSettingsView-DysrLZJD.js +294 -0
- package/dist/FoodCourtOrdersView-CbZqHIXO.js +544 -0
- package/dist/FoodCourtStallsView-CTZzPUQ6.js +635 -0
- package/dist/FoodCourtStatusView-C71y7ghx.js +113 -0
- package/dist/{KioskDevicesView-B4dgvMq_.js → KioskDevicesView-BJpbuSzp.js} +1 -1
- package/dist/{KioskDevicesView.vue_vue_type_script_setup_true_lang-B-Oi8ZLq.js → KioskDevicesView.vue_vue_type_script_setup_true_lang-CQFpwn28.js} +7 -6
- package/dist/{KioskSettingView-DXx6wQQQ.js → KioskSettingView-CJxhMf7N.js} +3 -3
- package/dist/{KioskView-BmSHCl13.js → KioskView-BZsdRID1.js} +6 -6
- package/dist/{OrderSettingsView-9NOSAxLf.js → OrderSettingsView-gnyXaJjf.js} +10631 -10601
- package/dist/{app-y20uA-tu.js → app-CeEFBB-w.js} +4484 -3672
- package/dist/app.js +1 -1
- package/dist/dayjs.min-zBHHlxAP.js +285 -0
- package/dist/{featureFlag-GHmH1G2d.js → featureFlag-BTY_R78k.js} +1 -1
- package/dist/food-court-member-piX3gesl.js +212 -0
- package/dist/frontend/mf-order/src/api/food-court/index.d.ts +269 -0
- package/dist/frontend/mf-order/src/api/food-court/invitation.d.ts +55 -0
- package/dist/frontend/mf-order/src/app.d.ts +676 -0
- package/dist/frontend/mf-order/src/main.d.ts +676 -0
- package/dist/frontend/mf-order/src/stores/business/index.d.ts +3 -3
- package/dist/frontend/mf-order/src/stores/order-setting/index.d.ts +6 -0
- package/dist/frontend/mf-order/src/utils/constants/route.d.ts +4 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtInvitationsView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtOrdersView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtStallsView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/FoodCourtStatusView.vue.d.ts +2 -0
- package/dist/frontend/mf-order/src/views/food-court/food-court-member.d.ts +150 -0
- package/dist/frontend/mf-order/src/views/food-court/food-court-order.d.ts +66 -0
- package/dist/frontend/mf-order/src/views/food-court/invitations/JoinFoodCourtCard.vue.d.ts +13 -0
- package/dist/frontend/mf-order/src/views/food-court/invitations/MembershipRowActions.vue.d.ts +11 -0
- package/dist/frontend/mf-order/src/views/food-court/orders/FoodCourtOrderSheet.vue.d.ts +16 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/EditStallSheet.vue.d.ts +15 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/GenerateJoinCodeSheet.vue.d.ts +21 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/StallAssignmentFields.vue.d.ts +16 -0
- package/dist/frontend/mf-order/src/views/food-court/stalls/StallRowActions.vue.d.ts +11 -0
- package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{index-CmdP_QXF.js → index-601eG3_R.js} +1 -1
- package/dist/index-BeBZTUcq.js +122 -0
- package/dist/index-BtudnkMi.js +1065 -0
- package/dist/{index-BlG6mIU4.js → index-CGiWgTn1.js} +38 -37
- package/dist/{index-wMygvJpP.js → index-D5nv3ncu.js} +2 -2
- package/dist/index-DLDihONy.js +25142 -0
- package/dist/order.dto-JM_fmWnQ.js +14842 -0
- package/dist/package/entity/food-court/food-court.do.d.ts +1 -1
- package/dist/package/entity/food-court/food-court.dto.d.ts +7 -7
- package/dist/package/entity/food-court/order-v2.dto.d.ts +4 -4
- package/dist/package/entity/order-platform/order-platform.dto.d.ts +190 -92
- package/dist/package/entity/order-setting/order-setting.do.d.ts +10 -0
- package/dist/package/entity/order-setting/order-setting.dto.d.ts +20 -0
- package/dist/package/entity/order-setting/queue/queue.do.d.ts +22 -0
- package/dist/package/entity/order-setting/queue/queue.dto.d.ts +7 -0
- package/dist/package/entity/queue/queue.do.d.ts +1 -0
- package/dist/package/entity/queue/queue.dto.d.ts +8 -8
- package/dist/package/entity/restaurant/restaurant.dto.d.ts +20 -0
- package/dist/search-BAPEUu1R.js +15 -0
- package/dist/useFoodCourtContext-2p5sJMcB.js +16 -0
- package/package.json +3 -3
- package/src/api/food-court/index.ts +357 -0
- package/src/api/food-court/invitation.ts +81 -0
- package/src/locales/en-US.json +171 -2
- package/src/locales/ja-JP.json +171 -2
- package/src/locales/th-TH.json +171 -2
- package/src/locales/zh-CN.json +171 -2
- package/src/router/routes.ts +44 -0
- package/src/utils/constants/route.ts +8 -0
- package/src/views/food-court/FoodCourtInvitationsView.vue +187 -0
- package/src/views/food-court/FoodCourtOrdersView.vue +263 -0
- package/src/views/food-court/FoodCourtStallsView.vue +369 -0
- package/src/views/food-court/FoodCourtStatusView.vue +111 -0
- package/src/views/food-court/food-court-member.spec.ts +339 -0
- package/src/views/food-court/food-court-member.ts +397 -0
- package/src/views/food-court/food-court-order.spec.ts +137 -0
- package/src/views/food-court/food-court-order.ts +206 -0
- package/src/views/food-court/invitations/JoinFoodCourtCard.vue +201 -0
- package/src/views/food-court/invitations/MembershipRowActions.vue +19 -0
- package/src/views/food-court/orders/FoodCourtOrderSheet.vue +226 -0
- package/src/views/food-court/stalls/EditStallSheet.vue +91 -0
- package/src/views/food-court/stalls/GenerateJoinCodeSheet.vue +281 -0
- package/src/views/food-court/stalls/StallAssignmentFields.vue +36 -0
- package/src/views/food-court/stalls/StallRowActions.vue +31 -0
- package/src/views/order-settings/OrderSettingsView.vue +2 -4
- package/src/views/order-settings/dine-in/DineInSetting.vue +1 -4
- package/src/views/order-settings/queue/QueueSetting.vue +27 -0
- package/src/views/order-settings/reservation/ReservationSetting.vue +8 -0
- package/dist/FoodCourtOrderSettingsView-DUQXCKzB.js +0 -323
- package/dist/index-CUI1lL9F.js +0 -1347
- package/dist/order.dto-CyHtvyly.js +0 -38829
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import type {
|
|
3
|
+
FoodCourtJoinCode,
|
|
4
|
+
FoodCourtJoinCodeListItem,
|
|
5
|
+
FoodCourtMember,
|
|
6
|
+
FoodCourtMemberStatus
|
|
7
|
+
} from '@/api/food-court'
|
|
8
|
+
import type { FoodCourtMembership } from '@/api/food-court/invitation'
|
|
9
|
+
import {
|
|
10
|
+
JOIN_CODE_COUNT,
|
|
11
|
+
JOIN_CODE_ERROR_KEY,
|
|
12
|
+
STALL_ACTIONS,
|
|
13
|
+
clampJoinCodeCount,
|
|
14
|
+
formatCourtAddress,
|
|
15
|
+
formatJoinCode,
|
|
16
|
+
isWellFormedJoinCode,
|
|
17
|
+
joinCodeErrorKey,
|
|
18
|
+
joinCodeListStatus,
|
|
19
|
+
joinCodeStall,
|
|
20
|
+
joinCodesCopyText,
|
|
21
|
+
normalizeJoinCode,
|
|
22
|
+
requesterName,
|
|
23
|
+
stallListStatus,
|
|
24
|
+
stallName,
|
|
25
|
+
stallToSave,
|
|
26
|
+
toMembershipViews,
|
|
27
|
+
toStallRows
|
|
28
|
+
} from './food-court-member'
|
|
29
|
+
|
|
30
|
+
const RESTAURANT = '6ac53ebea396902557346d01'
|
|
31
|
+
|
|
32
|
+
function member(overrides: Partial<FoodCourtMember> = {}): FoodCourtMember {
|
|
33
|
+
return {
|
|
34
|
+
_id: 'm1',
|
|
35
|
+
restaurantId: RESTAURANT,
|
|
36
|
+
status: 'ACTIVE',
|
|
37
|
+
stall: null,
|
|
38
|
+
invitedBy: 'owner',
|
|
39
|
+
invitedAt: '2026-10-20T00:00:00Z',
|
|
40
|
+
inviteExpiresAt: null,
|
|
41
|
+
joinedAt: null,
|
|
42
|
+
removedAt: null,
|
|
43
|
+
visible: true,
|
|
44
|
+
remark: null,
|
|
45
|
+
history: [],
|
|
46
|
+
...overrides
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function joinCode(overrides: Partial<FoodCourtJoinCode> = {}): FoodCourtJoinCode {
|
|
51
|
+
return {
|
|
52
|
+
_id: 'jc1',
|
|
53
|
+
status: 'OPEN',
|
|
54
|
+
stall: null,
|
|
55
|
+
createdAt: '2026-10-28T00:00:00Z',
|
|
56
|
+
expiresAt: '2026-11-04T00:00:00Z',
|
|
57
|
+
restaurantId: null,
|
|
58
|
+
requestedAt: null,
|
|
59
|
+
decidedAt: null,
|
|
60
|
+
memberId: null,
|
|
61
|
+
...overrides
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe('Stalls list', () => {
|
|
66
|
+
it('shows ACTIVE as Active or Inactive by visible, a legacy INVITED row as Invited, and hides ended rows', () => {
|
|
67
|
+
expect(stallListStatus({ status: 'ACTIVE', visible: true })).toBe('ACTIVE')
|
|
68
|
+
expect(stallListStatus({ status: 'ACTIVE', visible: false })).toBe('INACTIVE')
|
|
69
|
+
expect(stallListStatus({ status: 'INVITED', visible: true })).toBe('INVITED')
|
|
70
|
+
expect(stallListStatus({ status: 'DECLINED', visible: true })).toBe('DECLINED')
|
|
71
|
+
expect(stallListStatus({ status: 'REVOKED', visible: true })).toBeNull()
|
|
72
|
+
expect(stallListStatus({ status: 'REMOVED', visible: true })).toBeNull()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('lists a PENDING code as Pending approval and an OPEN one as Code issued, and hides the rest', () => {
|
|
76
|
+
expect(joinCodeListStatus('PENDING')).toBe('PENDING_APPROVAL')
|
|
77
|
+
expect(joinCodeListStatus('OPEN')).toBe('CODE_ISSUED')
|
|
78
|
+
expect(joinCodeListStatus('APPROVED')).toBeNull()
|
|
79
|
+
expect(joinCodeListStatus('DECLINED')).toBeNull()
|
|
80
|
+
expect(joinCodeListStatus('CANCELLED')).toBeNull()
|
|
81
|
+
expect(joinCodeListStatus('EXPIRED')).toBeNull()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('keeps court order, drops REVOKED and REMOVED rows, and reads the stall and outlet name', () => {
|
|
85
|
+
const rows = toStallRows([
|
|
86
|
+
{
|
|
87
|
+
member: member({ _id: 'a', stall: { unitNo: 'A1', displayName: 'Court name' } }),
|
|
88
|
+
restaurant: { _id: RESTAURANT, name: 'Outlet', businessName: 'Biz' }
|
|
89
|
+
},
|
|
90
|
+
{ member: member({ _id: 'b', status: 'REVOKED' }), restaurant: null },
|
|
91
|
+
{ member: member({ _id: 'c', status: 'REMOVED' }), restaurant: null },
|
|
92
|
+
{ member: member({ _id: 'd', status: 'INVITED', restaurantId: 'r2' }), restaurant: null }
|
|
93
|
+
])
|
|
94
|
+
expect(rows).toEqual([
|
|
95
|
+
{
|
|
96
|
+
kind: 'member',
|
|
97
|
+
key: 'member:a',
|
|
98
|
+
memberId: 'a',
|
|
99
|
+
restaurantId: RESTAURANT,
|
|
100
|
+
restaurantName: 'Outlet',
|
|
101
|
+
status: 'ACTIVE',
|
|
102
|
+
listStatus: 'ACTIVE',
|
|
103
|
+
unitNo: 'A1',
|
|
104
|
+
displayName: 'Court name'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
kind: 'member',
|
|
108
|
+
key: 'member:d',
|
|
109
|
+
memberId: 'd',
|
|
110
|
+
restaurantId: 'r2',
|
|
111
|
+
restaurantName: null,
|
|
112
|
+
status: 'INVITED',
|
|
113
|
+
listStatus: 'INVITED',
|
|
114
|
+
unitNo: null,
|
|
115
|
+
displayName: null
|
|
116
|
+
}
|
|
117
|
+
])
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('lists join requests first, then issued codes, then members, and hides used-up codes', () => {
|
|
121
|
+
const codes: FoodCourtJoinCodeListItem[] = [
|
|
122
|
+
{
|
|
123
|
+
joinCode: joinCode({ _id: 'open-new', stall: { unitNo: 'G-12', displayName: null } }),
|
|
124
|
+
restaurant: null
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
joinCode: joinCode({
|
|
128
|
+
_id: 'pending',
|
|
129
|
+
status: 'PENDING',
|
|
130
|
+
restaurantId: 'r9',
|
|
131
|
+
requestedAt: '2026-10-28T01:00:00Z',
|
|
132
|
+
stall: { unitNo: null, displayName: 'Kopi' }
|
|
133
|
+
}),
|
|
134
|
+
restaurant: { _id: 'r9', name: 'Kopi Corner SS2', businessName: 'Kopi Sdn Bhd' }
|
|
135
|
+
},
|
|
136
|
+
{ joinCode: joinCode({ _id: 'open-old' }), restaurant: null },
|
|
137
|
+
{
|
|
138
|
+
joinCode: joinCode({ _id: 'approved', status: 'APPROVED', restaurantId: 'r8' }),
|
|
139
|
+
restaurant: null
|
|
140
|
+
},
|
|
141
|
+
{ joinCode: joinCode({ _id: 'declined', status: 'DECLINED' }), restaurant: null },
|
|
142
|
+
{ joinCode: joinCode({ _id: 'cancelled', status: 'CANCELLED' }), restaurant: null },
|
|
143
|
+
{ joinCode: joinCode({ _id: 'expired', status: 'EXPIRED' }), restaurant: null }
|
|
144
|
+
]
|
|
145
|
+
const rows = toStallRows([{ member: member({ _id: 'a' }), restaurant: null }], codes)
|
|
146
|
+
expect(rows.map((row) => [row.key, row.listStatus])).toEqual([
|
|
147
|
+
['joinCode:pending', 'PENDING_APPROVAL'],
|
|
148
|
+
['joinCode:open-new', 'CODE_ISSUED'],
|
|
149
|
+
['joinCode:open-old', 'CODE_ISSUED'],
|
|
150
|
+
['member:a', 'ACTIVE']
|
|
151
|
+
])
|
|
152
|
+
expect(rows[0]).toEqual({
|
|
153
|
+
kind: 'joinCode',
|
|
154
|
+
key: 'joinCode:pending',
|
|
155
|
+
joinCodeId: 'pending',
|
|
156
|
+
status: 'PENDING',
|
|
157
|
+
listStatus: 'PENDING_APPROVAL',
|
|
158
|
+
restaurantId: 'r9',
|
|
159
|
+
restaurantName: 'Kopi Corner SS2',
|
|
160
|
+
businessName: 'Kopi Sdn Bhd',
|
|
161
|
+
unitNo: null,
|
|
162
|
+
displayName: 'Kopi',
|
|
163
|
+
expiresAt: '2026-11-04T00:00:00Z'
|
|
164
|
+
})
|
|
165
|
+
expect(rows[1]).toMatchObject({ restaurantId: null, restaurantName: null, unitNo: 'G-12' })
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('names a stall by court name, else outlet, else id; an unused code has none', () => {
|
|
169
|
+
expect(stallName({ displayName: 'Kopi', restaurantName: 'Outlet', restaurantId: 'r1' })).toBe(
|
|
170
|
+
'Kopi'
|
|
171
|
+
)
|
|
172
|
+
expect(stallName({ displayName: null, restaurantName: 'Outlet', restaurantId: 'r1' })).toBe(
|
|
173
|
+
'Outlet'
|
|
174
|
+
)
|
|
175
|
+
expect(stallName({ displayName: null, restaurantName: null, restaurantId: 'r1' })).toBe('r1')
|
|
176
|
+
expect(stallName({ displayName: null, restaurantName: null, restaurantId: null })).toBe('')
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('names who asked to join with its business, once', () => {
|
|
180
|
+
const row = { restaurantName: 'Kopi SS2', businessName: 'Kopi Sdn Bhd', restaurantId: 'r9' }
|
|
181
|
+
expect(requesterName(row)).toBe('Kopi SS2 (Kopi Sdn Bhd)')
|
|
182
|
+
expect(requesterName({ ...row, businessName: 'Kopi SS2' })).toBe('Kopi SS2')
|
|
183
|
+
expect(requesterName({ ...row, restaurantName: null, businessName: null })).toBe('r9')
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('offers no invite again: a declined row has no action, a legacy invitation only edit or cancel', () => {
|
|
187
|
+
expect(STALL_ACTIONS.DECLINED).toEqual([])
|
|
188
|
+
expect(STALL_ACTIONS.INVITED).toEqual(['edit', 'cancelInvite'])
|
|
189
|
+
expect(STALL_ACTIONS.PENDING_APPROVAL).toEqual(['approve', 'decline'])
|
|
190
|
+
expect(STALL_ACTIONS.CODE_ISSUED).toEqual(['cancelCode'])
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('sends both stall fields, blank or the outlet name as null', () => {
|
|
194
|
+
expect(stallToSave(' A1 ', ' Outlet ', 'Outlet')).toEqual({ unitNo: 'A1', displayName: null })
|
|
195
|
+
expect(stallToSave('', 'Noodles', 'Outlet')).toEqual({ unitNo: null, displayName: 'Noodles' })
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('gives a new code a stall only when a field is filled', () => {
|
|
199
|
+
expect(joinCodeStall(' ', '')).toBeNull()
|
|
200
|
+
expect(joinCodeStall(' G-12 ', '')).toEqual({ unitNo: 'G-12', displayName: null })
|
|
201
|
+
expect(joinCodeStall(null, ' Kopi ')).toEqual({ unitNo: null, displayName: 'Kopi' })
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
describe('join codes', () => {
|
|
206
|
+
it('normalizes typed or pasted input the way the backend does', () => {
|
|
207
|
+
expect(normalizeJoinCode(' abcde-fghjk ')).toBe('ABCDEFGHJK')
|
|
208
|
+
expect(normalizeJoinCode('ABC DE\tFG-HJK\n')).toBe('ABCDEFGHJK')
|
|
209
|
+
expect(normalizeJoinCode(null)).toBe('')
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('accepts only 10 characters of the code alphabet', () => {
|
|
213
|
+
expect(isWellFormedJoinCode('abcde-fghjk')).toBe(true)
|
|
214
|
+
expect(isWellFormedJoinCode('23456 789AB')).toBe(true)
|
|
215
|
+
expect(isWellFormedJoinCode('ABCDE-FGHJ')).toBe(false)
|
|
216
|
+
expect(isWellFormedJoinCode('ABCDE-FGHJKM')).toBe(false)
|
|
217
|
+
// 0, 1, I, L and O are never in a code.
|
|
218
|
+
expect(isWellFormedJoinCode('ABCDE-FGHJ0')).toBe(false)
|
|
219
|
+
expect(isWellFormedJoinCode('ABCDE-FGHJI')).toBe(false)
|
|
220
|
+
expect(isWellFormedJoinCode('ABCDE-FGHJL')).toBe(false)
|
|
221
|
+
expect(isWellFormedJoinCode('ABCDE-FGHJO')).toBe(false)
|
|
222
|
+
expect(isWellFormedJoinCode('')).toBe(false)
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
it('shows a code as ABCDE-FGHJK', () => {
|
|
226
|
+
expect(formatJoinCode('ABCDE-FGHJK')).toBe('ABCDE-FGHJK')
|
|
227
|
+
expect(formatJoinCode('abcdefghjk')).toBe('ABCDE-FGHJK')
|
|
228
|
+
expect(formatJoinCode('abc')).toBe('ABC')
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('generates a whole number of codes from 1 to 50, 1 when blank', () => {
|
|
232
|
+
expect(JOIN_CODE_COUNT).toEqual({ min: 1, max: 50 })
|
|
233
|
+
expect(clampJoinCodeCount(null)).toBe(1)
|
|
234
|
+
expect(clampJoinCodeCount(undefined)).toBe(1)
|
|
235
|
+
expect(clampJoinCodeCount(Number.NaN)).toBe(1)
|
|
236
|
+
expect(clampJoinCodeCount(1)).toBe(1)
|
|
237
|
+
expect(clampJoinCodeCount(3)).toBe(3)
|
|
238
|
+
expect(clampJoinCodeCount(50)).toBe(50)
|
|
239
|
+
expect(clampJoinCodeCount(0)).toBe(1)
|
|
240
|
+
expect(clampJoinCodeCount(-4)).toBe(1)
|
|
241
|
+
expect(clampJoinCodeCount(51)).toBe(50)
|
|
242
|
+
expect(clampJoinCodeCount(Number.POSITIVE_INFINITY)).toBe(50)
|
|
243
|
+
expect(clampJoinCodeCount(2.9)).toBe(2)
|
|
244
|
+
expect(clampJoinCodeCount(0.5)).toBe(1)
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
it('copies every code as shown, one per line, in the order made', () => {
|
|
248
|
+
expect(joinCodesCopyText(['ABCDE-FGHJK', 'kmnpqrstuv', '23456 789AB'])).toBe(
|
|
249
|
+
'ABCDE-FGHJK\nKMNPQ-RSTUV\n23456-789AB'
|
|
250
|
+
)
|
|
251
|
+
expect(joinCodesCopyText(['ABCDE-FGHJK'])).toBe('ABCDE-FGHJK')
|
|
252
|
+
expect(joinCodesCopyText(['', null, 'abcdefghjk', undefined])).toBe('ABCDE-FGHJK')
|
|
253
|
+
expect(joinCodesCopyText([])).toBe('')
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('maps each stall-side error code to its own message, else the backend message', () => {
|
|
257
|
+
const error = (code?: unknown) => Object.assign(new Error('backend says'), { code })
|
|
258
|
+
expect(joinCodeErrorKey(error('JOIN_CODE_INVALID'))).toBe('order.foodCourt.joinErrors.invalid')
|
|
259
|
+
expect(joinCodeErrorKey(error('JOIN_CODE_EXPIRED'))).toBe('order.foodCourt.joinErrors.expired')
|
|
260
|
+
expect(joinCodeErrorKey(error('JOIN_CODE_USED'))).toBe('order.foodCourt.joinErrors.used')
|
|
261
|
+
expect(joinCodeErrorKey(error('TOO_MANY_ATTEMPTS'))).toBe(
|
|
262
|
+
'order.foodCourt.joinErrors.tooManyAttempts'
|
|
263
|
+
)
|
|
264
|
+
expect(joinCodeErrorKey(error('MEMBER_EXISTS'))).toBe('order.foodCourt.joinErrors.memberExists')
|
|
265
|
+
expect(joinCodeErrorKey(error('JOIN_REQUEST_EXISTS'))).toBe(
|
|
266
|
+
'order.foodCourt.joinErrors.requestExists'
|
|
267
|
+
)
|
|
268
|
+
expect(joinCodeErrorKey(error('RESTAURANT_NOT_MANAGEABLE'))).toBe(
|
|
269
|
+
'order.foodCourt.joinErrors.notManageable'
|
|
270
|
+
)
|
|
271
|
+
expect(Object.keys(JOIN_CODE_ERROR_KEY)).toHaveLength(7)
|
|
272
|
+
expect(joinCodeErrorKey(error('INVALID_REQUEST'))).toBeNull()
|
|
273
|
+
expect(joinCodeErrorKey(error('toString'))).toBeNull()
|
|
274
|
+
expect(joinCodeErrorKey(error())).toBeNull()
|
|
275
|
+
expect(joinCodeErrorKey(new Error('network'))).toBeNull()
|
|
276
|
+
expect(joinCodeErrorKey('JOIN_CODE_INVALID')).toBeNull()
|
|
277
|
+
expect(joinCodeErrorKey(null)).toBeNull()
|
|
278
|
+
})
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
describe('Food Courts list, stall side', () => {
|
|
282
|
+
it('joins line1, city and state, skipping blanks and never doubling a comma', () => {
|
|
283
|
+
expect(formatCourtAddress({ line1: 'Lot 1', city: 'PJ', state: 'Selangor' })).toBe(
|
|
284
|
+
'Lot 1, PJ, Selangor'
|
|
285
|
+
)
|
|
286
|
+
expect(formatCourtAddress({ line1: 'Lot 1, Jalan 2,', city: ' ', state: 'Selangor' })).toBe(
|
|
287
|
+
'Lot 1, Jalan 2, Selangor'
|
|
288
|
+
)
|
|
289
|
+
expect(formatCourtAddress({ line1: null, city: 'PJ' })).toBe('PJ')
|
|
290
|
+
expect(formatCourtAddress({ line1: ' ' })).toBeNull()
|
|
291
|
+
expect(formatCourtAddress(null)).toBeNull()
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
it('maps each row status and sorts the most recently joined (else invited) first', () => {
|
|
295
|
+
const membership = (
|
|
296
|
+
foodCourtId: string,
|
|
297
|
+
status: FoodCourtMemberStatus,
|
|
298
|
+
invitedAt: string | null,
|
|
299
|
+
joinedAt: string | null = null
|
|
300
|
+
): FoodCourtMembership => ({
|
|
301
|
+
foodCourtId,
|
|
302
|
+
profile: { name: `Court ${foodCourtId}`, address: { line1: 'Lot 1', city: 'PJ' } },
|
|
303
|
+
member: member({
|
|
304
|
+
_id: `m-${foodCourtId}`,
|
|
305
|
+
status,
|
|
306
|
+
invitedAt,
|
|
307
|
+
joinedAt,
|
|
308
|
+
stall: { unitNo: '7', displayName: null }
|
|
309
|
+
})
|
|
310
|
+
})
|
|
311
|
+
const views = toMembershipViews([
|
|
312
|
+
membership('old', 'REMOVED', '2026-10-01T00:00:00Z'),
|
|
313
|
+
membership('none', 'REVOKED', null),
|
|
314
|
+
membership('code', 'ACTIVE', null, '2026-10-27T00:00:00Z'),
|
|
315
|
+
membership('legacy', 'INVITED', '2026-10-25T00:00:00Z'),
|
|
316
|
+
membership('mid', 'ACTIVE', '2026-10-08T00:00:00Z', '2026-10-10T00:00:00Z'),
|
|
317
|
+
membership('dec', 'DECLINED', '2026-10-05T00:00:00Z')
|
|
318
|
+
])
|
|
319
|
+
expect(views.map((v) => [v.foodCourtId, v.status])).toEqual([
|
|
320
|
+
['code', 'JOINED'],
|
|
321
|
+
['legacy', 'INVITED'],
|
|
322
|
+
['mid', 'JOINED'],
|
|
323
|
+
['dec', 'DECLINED'],
|
|
324
|
+
['old', 'LEFT'],
|
|
325
|
+
['none', 'CANCELLED']
|
|
326
|
+
])
|
|
327
|
+
expect(views[0]).toEqual({
|
|
328
|
+
foodCourtId: 'code',
|
|
329
|
+
memberId: 'm-code',
|
|
330
|
+
courtName: 'Court code',
|
|
331
|
+
courtAddress: 'Lot 1, PJ',
|
|
332
|
+
status: 'JOINED',
|
|
333
|
+
unitNo: '7',
|
|
334
|
+
displayName: null,
|
|
335
|
+
joinedAt: '2026-10-27T00:00:00Z',
|
|
336
|
+
since: '2026-10-27T00:00:00Z'
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
})
|