ti2-tourplan 1.0.127 → 1.0.128
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/index.test.js +62 -0
- package/itinerary-products-search.js +9 -2
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -10
package/index.test.js
CHANGED
|
@@ -799,6 +799,68 @@ describe('search tests', () => {
|
|
|
799
799
|
expect(retVal).toMatchSnapshot();
|
|
800
800
|
});
|
|
801
801
|
|
|
802
|
+
it('searchProductsForItinerary skips AC in full catalog when skipAccommodation is set', async () => {
|
|
803
|
+
const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => {});
|
|
804
|
+
const bdOption = {
|
|
805
|
+
Opt: 'TESTBDOPTION00001',
|
|
806
|
+
OptGeneral: {
|
|
807
|
+
SupplierId: '1001',
|
|
808
|
+
SupplierName: 'Test Supplier',
|
|
809
|
+
Description: 'Test BD Product',
|
|
810
|
+
SType: 'N',
|
|
811
|
+
AdultsAllowed: 'Y',
|
|
812
|
+
Adult_From: 16,
|
|
813
|
+
Adult_To: 999,
|
|
814
|
+
ButtonName: 'Sightseeing',
|
|
815
|
+
},
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
mockCallTourplan
|
|
819
|
+
.mockImplementationOnce(async () => ({
|
|
820
|
+
GetServicesReply: {
|
|
821
|
+
TPLServices: {
|
|
822
|
+
TPLService: [
|
|
823
|
+
{ Code: 'AC', Name: 'Accommodation' },
|
|
824
|
+
{ Code: 'BD', Name: 'Bundle' },
|
|
825
|
+
],
|
|
826
|
+
},
|
|
827
|
+
},
|
|
828
|
+
}))
|
|
829
|
+
.mockImplementationOnce(async ({ model }) => {
|
|
830
|
+
const opt = model.OptionInfoRequest.Opt;
|
|
831
|
+
if (opt === '???AC????????????') {
|
|
832
|
+
throw new Error('AC OptionInfo should have been skipped');
|
|
833
|
+
}
|
|
834
|
+
if (opt === '???BD????????????') {
|
|
835
|
+
return { OptionInfoReply: { Option: bdOption } };
|
|
836
|
+
}
|
|
837
|
+
throw new Error(`Unexpected OptionInfo Opt: ${opt}`);
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
const retVal = await app.searchProductsForItinerary({
|
|
841
|
+
axios,
|
|
842
|
+
token,
|
|
843
|
+
typeDefsAndQueries,
|
|
844
|
+
payload: {
|
|
845
|
+
searchInput: '',
|
|
846
|
+
skipAccommodation: true,
|
|
847
|
+
},
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
const optionInfoCalls = mockCallTourplan.mock.calls
|
|
851
|
+
.map(([call]) => call.model.OptionInfoRequest)
|
|
852
|
+
.filter(Boolean);
|
|
853
|
+
expect(optionInfoCalls).toHaveLength(1);
|
|
854
|
+
expect(optionInfoCalls[0].Opt).toBe('???BD????????????');
|
|
855
|
+
expect(debugSpy).toHaveBeenCalledWith(
|
|
856
|
+
'[tourplan] Accommodation (AC) service code will be skipped in full catalog product search',
|
|
857
|
+
);
|
|
858
|
+
expect(retVal.products).toHaveLength(1);
|
|
859
|
+
expect(retVal.products[0].options[0].optionId).toBe('TESTBDOPTION00001');
|
|
860
|
+
|
|
861
|
+
debugSpy.mockRestore();
|
|
862
|
+
});
|
|
863
|
+
|
|
802
864
|
describe('availability tests', () => {
|
|
803
865
|
it('searchAvailabilityForItinerary - not bookable', async () => {
|
|
804
866
|
axios.mockImplementation(getFixture);
|
|
@@ -22,6 +22,8 @@ const searchProductsForItinerary = async ({
|
|
|
22
22
|
// lastUpdatedFrom is used to get options that were updated after a certain date in Tourplan
|
|
23
23
|
// example: lastUpdatedFrom: '2024-04-22 05:17:57.427Z'
|
|
24
24
|
lastUpdatedFrom,
|
|
25
|
+
// skip Accommodation (AC) service code in full catalog search
|
|
26
|
+
skipAccommodation,
|
|
25
27
|
},
|
|
26
28
|
callTourplan,
|
|
27
29
|
}) => {
|
|
@@ -58,7 +60,7 @@ const searchProductsForItinerary = async ({
|
|
|
58
60
|
/*
|
|
59
61
|
Full catalog path:
|
|
60
62
|
1. getServiceCodes -> [AC, BD]
|
|
61
|
-
2. for each serviceCode getoptions
|
|
63
|
+
2. for each serviceCode getoptions (optionally skip AC when skipAccommodation is set)
|
|
62
64
|
3. convert them to ti2 products structure
|
|
63
65
|
4. merge all products from all serviceCodes
|
|
64
66
|
*/
|
|
@@ -77,7 +79,12 @@ const searchProductsForItinerary = async ({
|
|
|
77
79
|
});
|
|
78
80
|
let serviceCodes = R.pathOr([], ['GetServicesReply', 'TPLServices', 'TPLService'], getServicesReply);
|
|
79
81
|
if (!Array.isArray(serviceCodes)) serviceCodes = [serviceCodes];
|
|
80
|
-
|
|
82
|
+
if (skipAccommodation) {
|
|
83
|
+
console.debug('[tourplan] Accommodation (AC) service code will be skipped in full catalog product search');
|
|
84
|
+
}
|
|
85
|
+
serviceCodes = serviceCodes
|
|
86
|
+
.map(s => s.Code)
|
|
87
|
+
.filter(code => !(skipAccommodation && code === 'AC'));
|
|
81
88
|
await Promise.each(serviceCodes, async serviceCode => {
|
|
82
89
|
const getOptionsModel = {
|
|
83
90
|
OptionInfoRequest: {
|
package/package.json
CHANGED