ti2-tourplan 1.0.126 → 1.0.127
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/.claude/settings.local.json +10 -0
- package/index.test.js +78 -0
- package/itinerary-add-service.js +9 -1
- package/package.json +1 -1
package/index.test.js
CHANGED
|
@@ -132,6 +132,84 @@ describe('search tests', () => {
|
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
|
+
describe('addServiceToItinerary', () => {
|
|
136
|
+
it('limits new booking names after escaping XML characters', async () => {
|
|
137
|
+
mockCallTourplan.mockImplementationOnce(async () => ({
|
|
138
|
+
AddServiceReply: {
|
|
139
|
+
BookingId: '12345',
|
|
140
|
+
Ref: 'TESTREF',
|
|
141
|
+
Services: {
|
|
142
|
+
Service: {
|
|
143
|
+
LinePrice: '10.00',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
ServiceLineId: '10',
|
|
147
|
+
},
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
const quoteName = 'Ä'.repeat(30);
|
|
151
|
+
await app.addServiceToItinerary({
|
|
152
|
+
axios,
|
|
153
|
+
token,
|
|
154
|
+
payload: {
|
|
155
|
+
quoteName,
|
|
156
|
+
optionId: 'ABC123',
|
|
157
|
+
startDate: '2026-07-03',
|
|
158
|
+
reference: 'TESTREF',
|
|
159
|
+
paxConfigs: [{ roomType: 'Double', adults: 2 }],
|
|
160
|
+
notes: '',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
expect(mockCallTourplan).toHaveBeenCalledTimes(1);
|
|
165
|
+
const newBookingName = mockCallTourplan.mock.calls[0][0]
|
|
166
|
+
.model.AddServiceRequest.NewBookingInfo.Name;
|
|
167
|
+
|
|
168
|
+
expect(newBookingName.length).toBe(59);
|
|
169
|
+
expect(newBookingName).toBe(`${'Ae'.repeat(29)}A`);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('limits new booking names supplied by directHeaderPayload after escaping XML characters', async () => {
|
|
173
|
+
mockCallTourplan.mockImplementationOnce(async () => ({
|
|
174
|
+
AddServiceReply: {
|
|
175
|
+
BookingId: '12345',
|
|
176
|
+
Ref: 'TESTREF',
|
|
177
|
+
Services: {
|
|
178
|
+
Service: {
|
|
179
|
+
LinePrice: '10.00',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
ServiceLineId: '10',
|
|
183
|
+
},
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
await app.addServiceToItinerary({
|
|
187
|
+
axios,
|
|
188
|
+
token,
|
|
189
|
+
payload: {
|
|
190
|
+
quoteName: 'Short quote name',
|
|
191
|
+
optionId: 'ABC123',
|
|
192
|
+
startDate: '2026-07-03',
|
|
193
|
+
reference: 'TESTREF',
|
|
194
|
+
paxConfigs: [{ roomType: 'Double', adults: 2 }],
|
|
195
|
+
notes: '',
|
|
196
|
+
directHeaderPayload: {
|
|
197
|
+
Name: 'Ä'.repeat(30),
|
|
198
|
+
HeaderField: 'kept',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(mockCallTourplan).toHaveBeenCalledTimes(1);
|
|
204
|
+
const newBookingInfo = mockCallTourplan.mock.calls[0][0]
|
|
205
|
+
.model.AddServiceRequest.NewBookingInfo;
|
|
206
|
+
|
|
207
|
+
expect(newBookingInfo.Name.length).toBe(59);
|
|
208
|
+
expect(newBookingInfo.Name).toBe(`${'Ae'.repeat(29)}A`);
|
|
209
|
+
expect(newBookingInfo.HeaderField).toBe('kept');
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
135
213
|
describe('cancelBooking', () => {
|
|
136
214
|
it('cancels a booking by id', async () => {
|
|
137
215
|
mockCallTourplan.mockImplementationOnce(async () => ({
|
package/itinerary-add-service.js
CHANGED
|
@@ -8,8 +8,12 @@ const {
|
|
|
8
8
|
} = require('./utils');
|
|
9
9
|
|
|
10
10
|
const DEFAULT_TOURPLAN_SERVICE_STATUS = 'IR';
|
|
11
|
+
const MAX_BOOKING_NAME_LENGTH = 59;
|
|
11
12
|
const SERVICE_CANNOT_BE_ADDED_ERROR_MESSAGE = 'Service cannot be added to quote for the requested date/stay. (e.g. no rates, block out period, on request, minimum stay etc.)';
|
|
12
13
|
|
|
14
|
+
const getBookingName = quoteName => escapeInvalidXmlChars(quoteName)
|
|
15
|
+
.substring(0, MAX_BOOKING_NAME_LENGTH);
|
|
16
|
+
|
|
13
17
|
const addServiceToItinerary = async ({
|
|
14
18
|
axios,
|
|
15
19
|
token: {
|
|
@@ -61,6 +65,10 @@ const addServiceToItinerary = async ({
|
|
|
61
65
|
return acc;
|
|
62
66
|
}, {});
|
|
63
67
|
|
|
68
|
+
const directHeaderPayloadHasName = directHeaderPayload &&
|
|
69
|
+
Object.prototype.hasOwnProperty.call(directHeaderPayload, 'Name');
|
|
70
|
+
const bookingNameSource = directHeaderPayloadHasName ? directHeaderPayload.Name : quoteName;
|
|
71
|
+
|
|
64
72
|
const rateIdFromAvailCheckObj = R.path(['rateId'], availCheckObj);
|
|
65
73
|
if (availCheckObj &&
|
|
66
74
|
(rateIdFromAvailCheckObj === CUSTOM_RATE_ID_NAME
|
|
@@ -141,9 +149,9 @@ const addServiceToItinerary = async ({
|
|
|
141
149
|
ExistingBookingInfo: { BookingId: quoteId },
|
|
142
150
|
} : {
|
|
143
151
|
NewBookingInfo: {
|
|
144
|
-
Name: escapeInvalidXmlChars(quoteName),
|
|
145
152
|
QB: QB || 'Q',
|
|
146
153
|
...(directHeaderPayload || {}),
|
|
154
|
+
Name: getBookingName(bookingNameSource),
|
|
147
155
|
},
|
|
148
156
|
}),
|
|
149
157
|
...(puTime ? { puTime } : {}),
|