@duffel/components 2.7.19 → 3.0.0-canary
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/.circleci/config.yml +67 -0
- package/.eslintrc.js +34 -0
- package/.github/renovate.json +16 -0
- package/.github/workflows/autoapprove.yml +18 -0
- package/.github/workflows/release.yml +86 -0
- package/.husky/post-commit +4 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +2 -0
- package/.storybook/Storyshots.test.js +3 -0
- package/.storybook/__snapshots__/Storyshots.test.js.snap +48133 -0
- package/.storybook/main.ts +33 -0
- package/.storybook/preview.tsx +28 -0
- package/.tool-versions +1 -0
- package/README.md +129 -16
- package/__mocks__/styleMock.js +6 -0
- package/babel.config.js +20 -0
- package/commitlint.config.js +4 -0
- package/config/esbuild.base.config.js +14 -0
- package/config/esbuild.cdn.config.js +50 -0
- package/config/esbuild.dev.config.js +45 -0
- package/config/esbuild.react.config.js +42 -0
- package/jest.config.ts +14 -0
- package/package.json +123 -192
- package/react-dist/components/AnimatedLoaderEllipsis.d.ts +2 -0
- package/react-dist/components/Button.d.ts +23 -0
- package/react-dist/components/Card.d.ts +14 -0
- package/react-dist/components/Counter.d.ts +10 -0
- package/react-dist/components/DuffelAncillaries.d.ts +3 -0
- package/react-dist/components/DuffelAncillariesCustomElement.d.ts +13 -0
- package/react-dist/components/ErrorBoundary.d.ts +13 -0
- package/react-dist/components/FetchOfferErrorState.d.ts +5 -0
- package/react-dist/components/Icon.d.ts +44 -0
- package/react-dist/components/IconButton.d.ts +16 -0
- package/react-dist/components/Modal.d.ts +11 -0
- package/react-dist/components/NonIdealState.d.ts +4 -0
- package/react-dist/components/Stamp.d.ts +7 -0
- package/react-dist/components/Tabs.d.ts +16 -0
- package/react-dist/components/bags/BaggageSelectionCard.d.ts +11 -0
- package/react-dist/components/bags/BaggageSelectionController.d.ts +13 -0
- package/react-dist/components/bags/BaggageSelectionModal.d.ts +11 -0
- package/react-dist/components/bags/BaggageSelectionModalBody.d.ts +11 -0
- package/react-dist/components/bags/BaggageSelectionModalBodyPassenger.d.ts +13 -0
- package/react-dist/components/bags/BaggageSelectionModalFooter.d.ts +14 -0
- package/react-dist/components/bags/BaggageSelectionModalHeader.d.ts +9 -0
- package/react-dist/components/bags/IncludedBaggageBanner.d.ts +7 -0
- package/react-dist/components/cancel_for_any_reason/CfarSelectionCard.d.ts +10 -0
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModal.d.ts +11 -0
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalBody.d.ts +7 -0
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +4 -0
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +11 -0
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +2 -0
- package/react-dist/components/seats/Amenity.d.ts +6 -0
- package/react-dist/components/seats/DeckSelect.d.ts +15 -0
- package/react-dist/components/seats/Element.d.ts +15 -0
- package/react-dist/components/seats/EmptyElement.d.ts +2 -0
- package/react-dist/components/seats/ExitElement.d.ts +6 -0
- package/react-dist/components/seats/Legend.d.ts +12 -0
- package/react-dist/components/seats/Row.d.ts +13 -0
- package/react-dist/components/seats/RowSection.d.ts +17 -0
- package/react-dist/components/seats/SeatElement.d.ts +13 -0
- package/react-dist/components/seats/SeatInfo.d.ts +7 -0
- package/react-dist/components/seats/SeatMap.d.ts +12 -0
- package/react-dist/components/seats/SeatMapUnavailable.d.ts +2 -0
- package/react-dist/components/seats/SeatSelectionCard.d.ts +13 -0
- package/react-dist/components/seats/SeatSelectionModal.d.ts +13 -0
- package/react-dist/components/seats/SeatSelectionModalBody.d.ts +4 -0
- package/react-dist/components/seats/SeatSelectionModalFooter.d.ts +16 -0
- package/react-dist/components/seats/SeatSelectionModalHeader.d.ts +10 -0
- package/react-dist/components/seats/SeatUnavailable.d.ts +5 -0
- package/react-dist/index.d.ts +8 -0
- package/react-dist/index.js +36 -0
- package/react-dist/index.js.map +7 -0
- package/react-dist/lib/captureErrorInSentry.d.ts +1 -0
- package/react-dist/lib/compileCreateOrderPayload.d.ts +14 -0
- package/react-dist/lib/createPriceFormatters.d.ts +12 -0
- package/react-dist/lib/fetchFromDuffelAPI.d.ts +1 -0
- package/react-dist/lib/fetchFromFixtures.d.ts +4 -0
- package/react-dist/lib/formatAvailableServices.d.ts +12 -0
- package/react-dist/lib/formatDate.d.ts +2 -0
- package/react-dist/lib/formatSeatMaps.d.ts +4 -0
- package/react-dist/lib/getBaggageServiceDescription.d.ts +2 -0
- package/react-dist/lib/getCabinsForSegmentAndDeck.d.ts +2 -0
- package/react-dist/lib/getCurrencyForSeatMaps.d.ts +10 -0
- package/react-dist/lib/getCurrencyForServices.d.ts +11 -0
- package/react-dist/lib/getFirstSeatElementMatchingCriteria.d.ts +3 -0
- package/react-dist/lib/getPassengerBySegmentList.d.ts +6 -0
- package/react-dist/lib/getPassengerInitials.d.ts +1 -0
- package/react-dist/lib/getPassengerMapById.d.ts +3 -0
- package/react-dist/lib/getPassengerName.d.ts +3 -0
- package/react-dist/lib/getRowNumber.d.ts +2 -0
- package/react-dist/lib/getSegmentList.d.ts +2 -0
- package/react-dist/lib/getServicePriceMapById.d.ts +3 -0
- package/react-dist/lib/getSymbols.d.ts +2 -0
- package/react-dist/lib/getTotalAmountForServices.d.ts +6 -0
- package/react-dist/lib/getTotalQuantity.d.ts +2 -0
- package/react-dist/lib/hasService.d.ts +2 -0
- package/react-dist/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +3 -0
- package/react-dist/lib/hasWings.d.ts +2 -0
- package/react-dist/lib/isBaggageService.d.ts +2 -0
- package/react-dist/lib/isCancelForAnyReasonService.d.ts +2 -0
- package/react-dist/lib/isFixtureOfferId.d.ts +2 -0
- package/react-dist/lib/isPayloadComplete.d.ts +2 -0
- package/react-dist/lib/isSeatElement.d.ts +2 -0
- package/react-dist/lib/logging.d.ts +53 -0
- package/react-dist/lib/moneyStringFormatter.d.ts +8 -0
- package/react-dist/lib/offerIsExpired.d.ts +2 -0
- package/react-dist/lib/retrieveOffer.d.ts +2 -0
- package/react-dist/lib/retrieveOfferFromDuffelAPI.d.ts +1 -0
- package/react-dist/lib/retrieveSeatMaps.d.ts +2 -0
- package/react-dist/lib/retrieveSeatMapsFromDuffelAPI.d.ts +1 -0
- package/react-dist/lib/setBodyScrollability.d.ts +1 -0
- package/react-dist/lib/validateProps.d.ts +7 -0
- package/react-dist/lib/withPlural.d.ts +1 -0
- package/react-dist/types/Aircraft.d.ts +14 -0
- package/react-dist/types/Airline.d.ts +14 -0
- package/react-dist/types/Airport.d.ts +44 -0
- package/react-dist/types/City.d.ts +18 -0
- package/react-dist/types/CreateOrderPayload.d.ts +72 -0
- package/react-dist/types/CurrencyConversion.d.ts +10 -0
- package/react-dist/types/DuffelAncillariesProps.d.ts +70 -0
- package/react-dist/types/Offer.d.ts +711 -0
- package/react-dist/types/Order.d.ts +8 -0
- package/react-dist/types/Place.d.ts +8 -0
- package/react-dist/types/SeatMap.d.ts +190 -0
- package/react-dist/types/index.d.ts +11 -0
- package/scripts/generate-fixture.ts +195 -0
- package/scripts/upload-to-cdn.sh +39 -0
- package/scripts.tsconfig.json +11 -0
- package/src/components/AnimatedLoaderEllipsis.tsx +5 -0
- package/src/components/Button.tsx +62 -0
- package/src/components/Card.tsx +126 -0
- package/src/components/Counter.tsx +40 -0
- package/src/components/DuffelAncillaries.tsx +346 -0
- package/src/components/DuffelAncillariesCustomElement.tsx +124 -0
- package/src/components/ErrorBoundary.tsx +54 -0
- package/src/components/FetchOfferErrorState.tsx +35 -0
- package/src/components/Icon.tsx +151 -0
- package/src/components/IconButton.tsx +42 -0
- package/src/components/Modal.tsx +36 -0
- package/src/components/NonIdealState.tsx +28 -0
- package/src/components/Stamp.tsx +29 -0
- package/src/components/Tabs.tsx +36 -0
- package/src/components/bags/BaggageSelectionCard.tsx +96 -0
- package/src/components/bags/BaggageSelectionController.tsx +88 -0
- package/src/components/bags/BaggageSelectionModal.tsx +81 -0
- package/src/components/bags/BaggageSelectionModalBody.tsx +60 -0
- package/src/components/bags/BaggageSelectionModalBodyPassenger.tsx +122 -0
- package/src/components/bags/BaggageSelectionModalFooter.tsx +81 -0
- package/src/components/bags/BaggageSelectionModalHeader.tsx +76 -0
- package/src/components/bags/IncludedBaggageBanner.tsx +51 -0
- package/src/components/cancel_for_any_reason/CfarSelectionCard.tsx +90 -0
- package/src/components/cancel_for_any_reason/CfarSelectionModal.tsx +63 -0
- package/src/components/cancel_for_any_reason/CfarSelectionModalBody.tsx +56 -0
- package/src/components/cancel_for_any_reason/CfarSelectionModalBodyListItem.tsx +11 -0
- package/src/components/cancel_for_any_reason/CfarSelectionModalFooter.tsx +74 -0
- package/src/components/cancel_for_any_reason/CfarSelectionModalHeader.tsx +9 -0
- package/src/components/seats/Amenity.tsx +21 -0
- package/src/components/seats/DeckSelect.tsx +27 -0
- package/src/components/seats/Element.tsx +52 -0
- package/src/components/seats/EmptyElement.tsx +5 -0
- package/src/components/seats/ExitElement.tsx +17 -0
- package/src/components/seats/Legend.tsx +60 -0
- package/src/components/seats/Row.tsx +47 -0
- package/src/components/seats/RowSection.tsx +75 -0
- package/src/components/seats/SeatElement.tsx +120 -0
- package/src/components/seats/SeatInfo.tsx +32 -0
- package/src/components/seats/SeatMap.tsx +81 -0
- package/src/components/seats/SeatMapUnavailable.tsx +21 -0
- package/src/components/seats/SeatSelectionCard.tsx +103 -0
- package/src/components/seats/SeatSelectionModal.tsx +142 -0
- package/src/components/seats/SeatSelectionModalBody.tsx +13 -0
- package/src/components/seats/SeatSelectionModalFooter.tsx +82 -0
- package/src/components/seats/SeatSelectionModalHeader.tsx +87 -0
- package/src/components/seats/SeatUnavailable.tsx +14 -0
- package/src/examples/client-side/index.html +57 -0
- package/src/examples/full-stack/index.html +48 -0
- package/src/examples/full-stack/server.mjs +157 -0
- package/src/examples/just-typescript/README.md +37 -0
- package/src/examples/just-typescript/package.json +16 -0
- package/src/examples/just-typescript/src/index.html +23 -0
- package/src/examples/just-typescript/src/index.ts +35 -0
- package/src/examples/just-typescript/yarn.lock +154 -0
- package/src/examples/react-app/README.md +37 -0
- package/src/examples/react-app/package.json +20 -0
- package/src/examples/react-app/src/index.html +19 -0
- package/src/examples/react-app/src/index.tsx +43 -0
- package/src/examples/react-app/yarn.lock +219 -0
- package/src/fixtures/offers/off_0000AUde3KwTztSRK1cznH.json +497 -0
- package/src/fixtures/offers/off_0000AVx4lUFFKW8PsPeQeQ.json +307 -0
- package/src/fixtures/offers/off_1.json +497 -0
- package/src/fixtures/passengers/mock_passengers.ts +26 -0
- package/src/fixtures/seat-maps/off_0000AUde3KwTztSRK1cznH.json +6852 -0
- package/src/fixtures/seat-maps/off_0000AVx4lUFFKW8PsPeQeQ.json +1 -0
- package/src/fixtures/seat-maps/off_1.json +6852 -0
- package/src/index.ts +8 -0
- package/src/lib/captureErrorInSentry.ts +60 -0
- package/src/lib/compileCreateOrderPayload.ts +63 -0
- package/src/lib/createPriceFormatters.ts +73 -0
- package/src/lib/fetchFromDuffelAPI.ts +24 -0
- package/src/lib/fetchFromFixtures.ts +18 -0
- package/src/lib/formatAvailableServices.ts +91 -0
- package/src/lib/formatDate.ts +21 -0
- package/src/lib/formatSeatMaps.ts +81 -0
- package/src/lib/getBaggageServiceDescription.ts +44 -0
- package/src/lib/getCabinsForSegmentAndDeck.ts +4 -0
- package/src/lib/getCurrencyForSeatMaps.ts +22 -0
- package/src/lib/getCurrencyForServices.ts +24 -0
- package/src/lib/getFirstSeatElementMatchingCriteria.ts +22 -0
- package/src/lib/getPassengerBySegmentList.ts +10 -0
- package/src/lib/getPassengerInitials.ts +6 -0
- package/src/lib/getPassengerMapById.ts +17 -0
- package/src/lib/getPassengerName.ts +37 -0
- package/src/lib/getRowNumber.ts +16 -0
- package/src/lib/getSegmentList.ts +7 -0
- package/src/lib/getServicePriceMapById.ts +20 -0
- package/src/lib/getSymbols.ts +22 -0
- package/src/lib/getTotalAmountForServices.ts +72 -0
- package/src/lib/getTotalQuantity.ts +5 -0
- package/src/lib/hasService.ts +24 -0
- package/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.ts +35 -0
- package/src/lib/hasWings.ts +8 -0
- package/src/lib/isBaggageService.ts +8 -0
- package/src/lib/isCancelForAnyReasonService.ts +9 -0
- package/src/lib/isFixtureOfferId.ts +4 -0
- package/src/lib/isPayloadComplete.ts +11 -0
- package/src/lib/isSeatElement.ts +10 -0
- package/src/lib/logging.ts +100 -0
- package/src/lib/moneyStringFormatter.ts +34 -0
- package/src/lib/offerIsExpired.ts +5 -0
- package/src/lib/retrieveOffer.ts +49 -0
- package/src/lib/retrieveOfferFromDuffelAPI.ts +13 -0
- package/src/lib/retrieveSeatMaps.ts +50 -0
- package/src/lib/retrieveSeatMapsFromDuffelAPI.ts +13 -0
- package/src/lib/setBodyScrollability.ts +7 -0
- package/src/lib/validateProps.ts +37 -0
- package/src/lib/withPlural.ts +8 -0
- package/src/stories/BaggageSelectionModalHeader.stories.tsx +21 -0
- package/src/stories/Button.stories.tsx +60 -0
- package/src/stories/DuffelAncillaries.stories.tsx +126 -0
- package/src/stories/Icon.stories.tsx +34 -0
- package/src/stories/IconButton.stories.tsx +25 -0
- package/src/styles/colors.css +22 -0
- package/src/styles/components/Amenity.css +23 -0
- package/src/styles/components/BaggageDisplay.css +25 -0
- package/src/styles/components/Button.css +161 -0
- package/src/styles/components/Card.css +52 -0
- package/src/styles/components/CfarSelectionModal.css +34 -0
- package/src/styles/components/Counter.css +18 -0
- package/src/styles/components/IconButton.css +63 -0
- package/src/styles/components/Legend.css +58 -0
- package/src/styles/components/Loader.css +37 -0
- package/src/styles/components/LoadingState.css +81 -0
- package/src/styles/components/Modal.css +83 -0
- package/src/styles/components/PassengerSelect.css +93 -0
- package/src/styles/components/PassengersLayout.css +90 -0
- package/src/styles/components/Row.css +70 -0
- package/src/styles/components/Seat.css +57 -0
- package/src/styles/components/SeatInfo.css +61 -0
- package/src/styles/components/SeatMap.css +24 -0
- package/src/styles/components/SeatSelect.css +92 -0
- package/src/styles/components/Segment.css +17 -0
- package/src/styles/components/SelectionSegment.css +10 -0
- package/src/styles/components/Summary.css +70 -0
- package/src/styles/components/Tabs.css +49 -0
- package/src/styles/flex.css +5 -0
- package/src/styles/font-families.css +47 -0
- package/src/styles/global.css +50 -0
- package/src/styles/margin.css +3 -0
- package/src/styles/spacing.css +18 -0
- package/src/styles/transitions.css +3 -0
- package/src/styles/typography.css +13 -0
- package/src/tests/components/DuffelAncillaries.test.tsx +342 -0
- package/src/tests/lib/createPriceFormatters.test.tsx +152 -0
- package/src/tests/lib/formatAvailableServices.test.tsx +79 -0
- package/src/tests/lib/formatSeatMaps.test.tsx +49 -0
- package/src/tests/lib/getCurrencyForServices.test.tsx +44 -0
- package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +86 -0
- package/src/tests/lib/logging.test.tsx +32 -0
- package/src/tests/lib/moneyStringFormatter.test.tsx +12 -0
- package/src/tests/lib/validateProps.test.tsx +57 -0
- package/src/types/Aircraft.ts +16 -0
- package/src/types/Airline.ts +16 -0
- package/src/types/Airport.ts +54 -0
- package/src/types/City.ts +21 -0
- package/src/types/CreateOrderPayload.ts +99 -0
- package/src/types/CurrencyConversion.ts +10 -0
- package/src/types/DuffelAncillariesProps.ts +108 -0
- package/src/types/Offer.ts +851 -0
- package/src/types/Order.ts +6 -0
- package/src/types/Place.ts +6 -0
- package/src/types/SeatMap.ts +231 -0
- package/src/types/index.ts +11 -0
- package/tsconfig.json +52 -0
- package/LICENSE +0 -21
- package/dist/AdditionalBaggage.esm.js +0 -1
- package/dist/AdditionalBaggage.js +0 -1
- package/dist/AdditionalBaggage.min.css +0 -408
- package/dist/AdditionalBaggage.umd.min.js +0 -2
- package/dist/AdditionalBaggage.umd.min.js.LICENSE.txt +0 -60
- package/dist/AdditionalBaggageSelection.esm.js +0 -1
- package/dist/AdditionalBaggageSelection.js +0 -1
- package/dist/AdditionalBaggageSelection.min.css +0 -744
- package/dist/AdditionalBaggageSelection.umd.min.js +0 -2
- package/dist/AdditionalBaggageSelection.umd.min.js.LICENSE.txt +0 -93
- package/dist/CardPayment.esm.js +0 -2
- package/dist/CardPayment.esm.js.LICENSE.txt +0 -6
- package/dist/CardPayment.js +0 -2
- package/dist/CardPayment.js.LICENSE.txt +0 -6
- package/dist/CardPayment.min.css +0 -233
- package/dist/CardPayment.umd.min.js +0 -2
- package/dist/CardPayment.umd.min.js.LICENSE.txt +0 -61
- package/dist/SeatSelection.esm.js +0 -1
- package/dist/SeatSelection.js +0 -1
- package/dist/SeatSelection.min.css +0 -1127
- package/dist/SeatSelection.umd.min.js +0 -2
- package/dist/SeatSelection.umd.min.js.LICENSE.txt +0 -60
- package/dist/duffel-components.d.ts +0 -1614
- package/dist/duffel-components.esm.js +0 -2
- package/dist/duffel-components.esm.js.LICENSE.txt +0 -6
- package/dist/duffel-components.js +0 -2
- package/dist/duffel-components.js.LICENSE.txt +0 -6
- package/dist/duffel-components.min.css +0 -1280
- package/dist/duffel-components.umd.min.js +0 -2
- package/dist/duffel-components.umd.min.js.LICENSE.txt +0 -102
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
.summary__segment {
|
|
2
|
+
border-bottom: 1px solid var(--GREY-200);
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
margin-bottom: var(--SPACING-SM-3);
|
|
7
|
+
padding-bottom: var(--SPACING-SM-3);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.summary > .passenger-segment__title {
|
|
11
|
+
padding: 0;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.summary-passenger {
|
|
16
|
+
color: var(--GREY-900);
|
|
17
|
+
font-size: var(--FONT-SIZES-C1);
|
|
18
|
+
font-weight: normal;
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.summary__description-cost {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
font-size: var(--FONT-SIZES-C1);
|
|
27
|
+
margin-bottom: var(--SPACING-SM-3);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.summary:not(.summary--mobile) {
|
|
31
|
+
padding-top: 0;
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.summary__actions {
|
|
36
|
+
display: flex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.summary__actions--previous {
|
|
40
|
+
transform: rotate(180deg);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.summary__actions > button:last-of-type {
|
|
44
|
+
flex: 1 auto;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
margin-left: var(--SPACING-SM-3);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media screen and (min-width: 768px) {
|
|
50
|
+
.summary:not(.summary--mobile) {
|
|
51
|
+
display: flex;
|
|
52
|
+
justify-content: space-between;
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.summary--mobile {
|
|
57
|
+
display: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.summary__description-title {
|
|
61
|
+
color: var(--GREY-900);
|
|
62
|
+
font-size: var(--FONT-SIZES-H5);
|
|
63
|
+
line-height: 26px;
|
|
64
|
+
margin-bottom: var(--SPACING-XS-2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.summary__confirmation-btn:last-child {
|
|
68
|
+
margin-left: var(--SPACING-SM-1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.seat-map__tab-select {
|
|
2
|
+
width: 100%;
|
|
3
|
+
max-width: 400px;
|
|
4
|
+
display: flex;
|
|
5
|
+
text-align: center;
|
|
6
|
+
min-height: var(--SPACING-LG-1);
|
|
7
|
+
margin-bottom: var(--SPACING-MD-3);
|
|
8
|
+
border: 2px solid var(--GREY-200);
|
|
9
|
+
border-radius: 3px;
|
|
10
|
+
background-color: var(--GREY-200);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.seat-map__tab-select-option {
|
|
14
|
+
appearance: none;
|
|
15
|
+
outline: none;
|
|
16
|
+
margin: 0;
|
|
17
|
+
border: none;
|
|
18
|
+
padding: var(--SPACING-XS-2) var(--SPACING-SM-3);
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
font-size: var(--FONT-SIZES-C2);
|
|
21
|
+
width: 100%;
|
|
22
|
+
color: var(--GREY-900);
|
|
23
|
+
background-color: var(--GREY-200);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
border-radius: 3px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.seat-map__tab-select-option:hover,
|
|
29
|
+
.seat-map__tab-select-option:focus,
|
|
30
|
+
.seat-map__tab-select-option:active {
|
|
31
|
+
color: rgba(var(--ACCENT), var(--ACCENT-LIGHT-1000));
|
|
32
|
+
background-color: rgba(var(--ACCENT), var(--ACCENT-LIGHT-200));
|
|
33
|
+
transition: var(--TRANSITIONS-CUBIC-BEZIER);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.seat-map__tab-select-option--selected {
|
|
37
|
+
color: var(--GREY-900);
|
|
38
|
+
background-color: rgba(var(--WHITE), 1);
|
|
39
|
+
box-shadow: 0px 0px 0px 1px rgba(var(--BLACK), 0.05),
|
|
40
|
+
0px 2px 12px rgba(var(--BLACK), 0.08);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.seat-map__tab-select-option:first-child {
|
|
44
|
+
margin-right: 1px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.seat-map__tab-select-option:last-child {
|
|
48
|
+
margin-left: 1px;
|
|
49
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.p1--semibold {
|
|
2
|
+
font-family: var(--FONT-FAMILY);
|
|
3
|
+
font-size: 16px;
|
|
4
|
+
font-weight: 600;
|
|
5
|
+
line-height: 24px;
|
|
6
|
+
letter-spacing: 0em;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.p1--regular {
|
|
10
|
+
font-family: var(--FONT-FAMILY);
|
|
11
|
+
font-size: 16px;
|
|
12
|
+
font-weight: 400;
|
|
13
|
+
line-height: 24px;
|
|
14
|
+
letter-spacing: 0em;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.p2--regular {
|
|
18
|
+
font-family: var(--FONT-FAMILY);
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
font-weight: 400;
|
|
21
|
+
line-height: 20px;
|
|
22
|
+
letter-spacing: 0em;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.p2--semibold {
|
|
26
|
+
font-family: var(--FONT-FAMILY);
|
|
27
|
+
font-size: 14px;
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
line-height: 20px;
|
|
30
|
+
letter-spacing: 0em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.p3--regular {
|
|
34
|
+
font-family: var(--FONT-FAMILY);
|
|
35
|
+
font-size: 12px;
|
|
36
|
+
font-weight: 400;
|
|
37
|
+
line-height: 16px;
|
|
38
|
+
letter-spacing: 0em;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.h3--semibold {
|
|
42
|
+
font-family: var(--FONT-FAMILY);
|
|
43
|
+
font-size: 20px;
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
line-height: 28px;
|
|
46
|
+
letter-spacing: 0em;
|
|
47
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@import "./colors.css";
|
|
2
|
+
@import "./flex.css";
|
|
3
|
+
@import "./font-families.css";
|
|
4
|
+
@import "./margin.css";
|
|
5
|
+
@import "./spacing.css";
|
|
6
|
+
@import "./transitions.css";
|
|
7
|
+
@import "./typography.css";
|
|
8
|
+
|
|
9
|
+
@import "./components/Amenity.css";
|
|
10
|
+
@import "./components/BaggageDisplay.css";
|
|
11
|
+
@import "./components/Button.css";
|
|
12
|
+
@import "./components/CfarSelectionModal.css";
|
|
13
|
+
@import "./components/Card.css";
|
|
14
|
+
@import "./components/Counter.css";
|
|
15
|
+
@import "./components/IconButton.css";
|
|
16
|
+
@import "./components/Legend.css";
|
|
17
|
+
@import "./components/Loader.css";
|
|
18
|
+
@import "./components/LoadingState.css";
|
|
19
|
+
@import "./components/Modal.css";
|
|
20
|
+
@import "./components/PassengerSelect.css";
|
|
21
|
+
@import "./components/PassengersLayout.css";
|
|
22
|
+
@import "./components/Row.css";
|
|
23
|
+
@import "./components/Seat.css";
|
|
24
|
+
@import "./components/SeatInfo.css";
|
|
25
|
+
@import "./components/SeatMap.css";
|
|
26
|
+
@import "./components/SeatSelect.css";
|
|
27
|
+
@import "./components/Segment.css";
|
|
28
|
+
@import "./components/SelectionSegment.css";
|
|
29
|
+
@import "./components/Summary.css";
|
|
30
|
+
@import "./components/Tabs.css";
|
|
31
|
+
|
|
32
|
+
.duffel-components {
|
|
33
|
+
--BUTTON-RADIUS: 5px;
|
|
34
|
+
--TRANSITION-CUBIC-BEZIER: cubic-bezier(0.25, 0.8, 0.25, 1);
|
|
35
|
+
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
-webkit-overflow-scrolling: touch;
|
|
38
|
+
-webkit-font-smoothing: antialiased;
|
|
39
|
+
font-family: var(--FONT-FAMILY);
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
height: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
h1,
|
|
45
|
+
h2,
|
|
46
|
+
h3,
|
|
47
|
+
h4,
|
|
48
|
+
p {
|
|
49
|
+
margin: 0;
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.duffel-components {
|
|
2
|
+
--SPACING-XL-3: 128px;
|
|
3
|
+
--SPACING-XL-2: 64px;
|
|
4
|
+
--SPACING-XL-1: 56px;
|
|
5
|
+
--SPACING-LG-3: 48px;
|
|
6
|
+
--SPACING-LG-2: 40px;
|
|
7
|
+
--SPACING-LG-1: 32px;
|
|
8
|
+
--SPACING-MD-3: 24px;
|
|
9
|
+
--SPACING-MD-2: 20px;
|
|
10
|
+
--SPACING-MD-1: 18px;
|
|
11
|
+
--SPACING-SM-3: 16px;
|
|
12
|
+
--SPACING-SM-2: 12px;
|
|
13
|
+
--SPACING-SM-1: 8px;
|
|
14
|
+
--SPACING-XS-3: 6px;
|
|
15
|
+
--SPACING-XS-2: 4px;
|
|
16
|
+
--SPACING-XS-1: 2px;
|
|
17
|
+
--SPACING-NONE: 0;
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.duffel-components {
|
|
2
|
+
--FONT-FAMILY: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
|
|
3
|
+
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
|
4
|
+
sans-serif;
|
|
5
|
+
--FONT-SIZES-C0: 20px;
|
|
6
|
+
--FONT-SIZES-C1: 16px;
|
|
7
|
+
--FONT-SIZES-C2: 14px;
|
|
8
|
+
--FONT-SIZES-C3: 12px;
|
|
9
|
+
--FONT-SIZES-H2: 32px;
|
|
10
|
+
--FONT-SIZES-H3: 28px;
|
|
11
|
+
--FONT-SIZES-H4: 24px;
|
|
12
|
+
--FONT-SIZES-H5: 20px;
|
|
13
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { fireEvent, render } from "@testing-library/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { DuffelAncillaries } from "../../components/DuffelAncillaries";
|
|
4
|
+
import mockPassengers from "../../fixtures/passengers/mock_passengers";
|
|
5
|
+
import {
|
|
6
|
+
DuffelAncillariesPropsWithOffersAndSeatMaps,
|
|
7
|
+
OnPayloadReady,
|
|
8
|
+
} from "../../types/DuffelAncillariesProps";
|
|
9
|
+
import { Offer } from "../../types/Offer";
|
|
10
|
+
import { SeatMap } from "../../types/SeatMap";
|
|
11
|
+
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
13
|
+
const MOCK_OFFER: Offer = require("../../fixtures/offers/off_1.json");
|
|
14
|
+
const MOCK_SEAT_MAPS: SeatMap[] = require("../../fixtures/seat-maps/off_1.json");
|
|
15
|
+
/* eslint-enable @typescript-eslint/no-var-requires */
|
|
16
|
+
|
|
17
|
+
const defaultProps: Omit<
|
|
18
|
+
DuffelAncillariesPropsWithOffersAndSeatMaps,
|
|
19
|
+
"onPayloadReady"
|
|
20
|
+
> = {
|
|
21
|
+
offer: MOCK_OFFER,
|
|
22
|
+
seat_maps: MOCK_SEAT_MAPS,
|
|
23
|
+
passengers: mockPassengers,
|
|
24
|
+
services: ["bags", "seats", "cancel_for_any_reason"],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const ExampleWithoutServices: React.FC = () => (
|
|
28
|
+
<DuffelAncillaries
|
|
29
|
+
onPayloadReady={jest.fn()}
|
|
30
|
+
passengers={[]}
|
|
31
|
+
services={[]}
|
|
32
|
+
offer_id="offer_id"
|
|
33
|
+
client_key="client_key"
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
describe("DuffelAncillaries", () => {
|
|
38
|
+
test("should throw an error when services is empty", () => {
|
|
39
|
+
expect(() => render(<ExampleWithoutServices />)).toThrow(
|
|
40
|
+
`You must provide at least one service in the "services" prop. Valid services: ["bags", "seats", "cancel_for_any_reason"]`
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("should select baggage services", async () => {
|
|
45
|
+
let onPayloadReadyCallCount = 0;
|
|
46
|
+
const onPayloadReady: OnPayloadReady = jest.fn((data, metadata) => {
|
|
47
|
+
if (++onPayloadReadyCallCount === 2) {
|
|
48
|
+
expect(data.selected_offers[0]).toBe(MOCK_OFFER.id);
|
|
49
|
+
expect(metadata.baggage_services.length).toBe(2);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const { getByText, getByTestId, getByTitle } = render(
|
|
53
|
+
<DuffelAncillaries {...defaultProps} onPayloadReady={onPayloadReady} />
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
fireEvent.click(getByTitle("Select extra baggage"));
|
|
57
|
+
|
|
58
|
+
// There are no services for the first segment of the offer.
|
|
59
|
+
fireEvent.click(getByTestId("confirm-selection-for-baggage"));
|
|
60
|
+
|
|
61
|
+
for (const available_service of MOCK_OFFER.available_services) {
|
|
62
|
+
if (available_service.type !== "baggage") continue;
|
|
63
|
+
|
|
64
|
+
for (const passengerId of available_service.passenger_ids) {
|
|
65
|
+
const testId = `counter--${available_service.id}--${passengerId}-plus`;
|
|
66
|
+
const addBaggageButton = getByTestId(testId);
|
|
67
|
+
fireEvent.click(addBaggageButton);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fireEvent.click(getByTestId("confirm-selection-for-baggage"));
|
|
72
|
+
expect(getByText(/2 bags added/i));
|
|
73
|
+
|
|
74
|
+
// The component is always called at least once
|
|
75
|
+
// when the state is set with an offer.
|
|
76
|
+
expect(onPayloadReady).toBeCalledTimes(2);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("should select seat services", () => {
|
|
80
|
+
let onPayloadReadyCallCount = 0;
|
|
81
|
+
const onPayloadReady: OnPayloadReady = jest.fn((data, metadata) => {
|
|
82
|
+
if (++onPayloadReadyCallCount === 2) {
|
|
83
|
+
expect(data.selected_offers[0]).toBe(MOCK_OFFER.id);
|
|
84
|
+
expect(metadata.seat_services.length).toBe(4);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const { getByText, getByTestId, getByTitle } = render(
|
|
88
|
+
<DuffelAncillaries {...defaultProps} onPayloadReady={onPayloadReady} />
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const seatCard = getByTitle("Select seats");
|
|
92
|
+
fireEvent.click(seatCard);
|
|
93
|
+
|
|
94
|
+
fireEvent.click(getByTestId("seat-28E"));
|
|
95
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
96
|
+
|
|
97
|
+
fireEvent.click(getByTestId("seat-28F"));
|
|
98
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
99
|
+
|
|
100
|
+
fireEvent.click(getByTestId("seat-28E"));
|
|
101
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
102
|
+
|
|
103
|
+
fireEvent.click(getByTestId("seat-28F"));
|
|
104
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
105
|
+
|
|
106
|
+
expect(getByText(/4 seats selected/i));
|
|
107
|
+
|
|
108
|
+
// The component is always called at least once
|
|
109
|
+
// when the state is set with an offer.
|
|
110
|
+
expect(onPayloadReady).toBeCalledTimes(2);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("should select CFAR service", () => {
|
|
114
|
+
let onPayloadReadyCallCount = 0;
|
|
115
|
+
const onPayloadReady: OnPayloadReady = jest.fn((data, metadata) => {
|
|
116
|
+
if (++onPayloadReadyCallCount === 2) {
|
|
117
|
+
expect(data.selected_offers[0]).toBe(MOCK_OFFER.id);
|
|
118
|
+
expect(metadata.cancel_for_any_reason_services.length).toBe(1);
|
|
119
|
+
expect(data.services.length).toBe(1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const { getByText, getByTestId, getByTitle } = render(
|
|
123
|
+
<DuffelAncillaries {...defaultProps} onPayloadReady={onPayloadReady} />
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
fireEvent.click(getByTitle("Add cancel for any reason"));
|
|
127
|
+
|
|
128
|
+
fireEvent.click(getByTestId("confirm-selection-for-cfar"));
|
|
129
|
+
expect(getByText(/Your trip is protected for £97.45/i));
|
|
130
|
+
|
|
131
|
+
// The component is always called at least once
|
|
132
|
+
// when the state is set with an offer.
|
|
133
|
+
expect(onPayloadReady).toBeCalledTimes(2);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("should work with markup", () => {
|
|
137
|
+
let onPayloadReadyCallCount = 0;
|
|
138
|
+
const onPayloadReady: OnPayloadReady = jest.fn((data, metadata) => {
|
|
139
|
+
if (++onPayloadReadyCallCount === 2) {
|
|
140
|
+
expect(data.selected_offers[0]).toBe(MOCK_OFFER.id);
|
|
141
|
+
expect(metadata.baggage_services.length).toBe(2);
|
|
142
|
+
|
|
143
|
+
// Confirm that the markup is applied.
|
|
144
|
+
expect(
|
|
145
|
+
metadata.baggage_services[0].serviceInformation?.total_amount
|
|
146
|
+
).toBe("23");
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const { getByText, getByTestId, getByTitle } = render(
|
|
150
|
+
<DuffelAncillaries
|
|
151
|
+
{...defaultProps}
|
|
152
|
+
onPayloadReady={onPayloadReady}
|
|
153
|
+
markup={{
|
|
154
|
+
bags: { amount: 1, rate: 0.1 },
|
|
155
|
+
seats: { amount: 2, rate: 0.2 },
|
|
156
|
+
cancel_for_any_reason: { amount: 3, rate: 0.3 },
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* First, select bags.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
fireEvent.click(getByTitle("Select extra baggage"));
|
|
166
|
+
|
|
167
|
+
// There are no services for the first segment of the offer.
|
|
168
|
+
fireEvent.click(getByTestId("confirm-selection-for-baggage"));
|
|
169
|
+
|
|
170
|
+
const totalPriceLabel = getByTestId("baggage-total-amount-label");
|
|
171
|
+
expect(totalPriceLabel.textContent).toBe("+ £0.00");
|
|
172
|
+
|
|
173
|
+
for (const available_service of MOCK_OFFER.available_services) {
|
|
174
|
+
if (available_service.type !== "baggage") continue;
|
|
175
|
+
|
|
176
|
+
for (const passengerId of available_service.passenger_ids) {
|
|
177
|
+
const priceLabelTestId = `price-label--${available_service.id}--${passengerId}`;
|
|
178
|
+
const priceLabel = getByTestId(priceLabelTestId);
|
|
179
|
+
expect(priceLabel.textContent).toBe("£23.00");
|
|
180
|
+
|
|
181
|
+
const addButtonTestId = `counter--${available_service.id}--${passengerId}-plus`;
|
|
182
|
+
const addBaggageButton = getByTestId(addButtonTestId);
|
|
183
|
+
fireEvent.click(addBaggageButton);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Price should now have been updated.
|
|
188
|
+
expect(totalPriceLabel.textContent).toBe("+ £46.00");
|
|
189
|
+
|
|
190
|
+
fireEvent.click(getByTestId("confirm-selection-for-baggage"));
|
|
191
|
+
expect(getByText(/2 bags added for £46.00/i));
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Now, select seats.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
const seatCard = getByTitle("Select seats");
|
|
198
|
+
fireEvent.click(seatCard);
|
|
199
|
+
|
|
200
|
+
fireEvent.click(getByTestId("seat-28E"));
|
|
201
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
202
|
+
|
|
203
|
+
fireEvent.click(getByTestId("seat-28F"));
|
|
204
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
205
|
+
|
|
206
|
+
fireEvent.click(getByTestId("seat-28E"));
|
|
207
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
208
|
+
|
|
209
|
+
fireEvent.click(getByTestId("seat-28F"));
|
|
210
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
211
|
+
|
|
212
|
+
expect(getByText(/4 seats selected for £104.00/i));
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Now, select CFAR.
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
const cfarCard = getByTitle("Add cancel for any reason");
|
|
219
|
+
fireEvent.click(cfarCard);
|
|
220
|
+
|
|
221
|
+
fireEvent.click(getByTestId("confirm-selection-for-cfar"));
|
|
222
|
+
|
|
223
|
+
expect(getByText(/Your trip is protected for £129.69/i));
|
|
224
|
+
|
|
225
|
+
// The component is always called at least once
|
|
226
|
+
// when the state is set with an offer.
|
|
227
|
+
expect(onPayloadReady).toBeCalledTimes(4);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("should work with priceFormatters", () => {
|
|
231
|
+
let onPayloadReadyCallCount = 0;
|
|
232
|
+
const onPayloadReady: OnPayloadReady = jest.fn((data, metadata) => {
|
|
233
|
+
if (++onPayloadReadyCallCount === 2) {
|
|
234
|
+
expect(data.selected_offers[0]).toBe(MOCK_OFFER.id);
|
|
235
|
+
expect(metadata.baggage_services.length).toBe(2);
|
|
236
|
+
|
|
237
|
+
// Confirm that the markup is applied.
|
|
238
|
+
expect(
|
|
239
|
+
metadata.baggage_services[0].serviceInformation?.total_amount
|
|
240
|
+
).toBe("40");
|
|
241
|
+
expect(
|
|
242
|
+
metadata.baggage_services[0].serviceInformation?.total_currency
|
|
243
|
+
).toBe("Duffel house points");
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
const currency = "Duffel house points";
|
|
247
|
+
const { getByText, getByTestId, getByTitle } = render(
|
|
248
|
+
<DuffelAncillaries
|
|
249
|
+
{...defaultProps}
|
|
250
|
+
onPayloadReady={onPayloadReady}
|
|
251
|
+
priceFormatters={{
|
|
252
|
+
bags: (amount) => {
|
|
253
|
+
return {
|
|
254
|
+
amount: amount * 2,
|
|
255
|
+
currency,
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
seats: (amount) => {
|
|
259
|
+
return {
|
|
260
|
+
amount: amount / 2,
|
|
261
|
+
currency,
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
cancel_for_any_reason: () => {
|
|
265
|
+
return {
|
|
266
|
+
amount: 100,
|
|
267
|
+
currency,
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
}}
|
|
271
|
+
/>
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* First, select bags.
|
|
276
|
+
*/
|
|
277
|
+
|
|
278
|
+
fireEvent.click(getByTitle("Select extra baggage"));
|
|
279
|
+
|
|
280
|
+
// There are no services for the first segment of the offer.
|
|
281
|
+
fireEvent.click(getByTestId("confirm-selection-for-baggage"));
|
|
282
|
+
|
|
283
|
+
const totalPriceLabel = getByTestId("baggage-total-amount-label");
|
|
284
|
+
expect(totalPriceLabel.textContent).toBe("+ 0 Duffel house points");
|
|
285
|
+
|
|
286
|
+
for (const available_service of MOCK_OFFER.available_services) {
|
|
287
|
+
if (available_service.type !== "baggage") continue;
|
|
288
|
+
|
|
289
|
+
for (const passengerId of available_service.passenger_ids) {
|
|
290
|
+
const priceLabelTestId = `price-label--${available_service.id}--${passengerId}`;
|
|
291
|
+
const priceLabel = getByTestId(priceLabelTestId);
|
|
292
|
+
expect(priceLabel.textContent).toBe("40 Duffel house points");
|
|
293
|
+
|
|
294
|
+
const addButtonTestId = `counter--${available_service.id}--${passengerId}-plus`;
|
|
295
|
+
const addBaggageButton = getByTestId(addButtonTestId);
|
|
296
|
+
fireEvent.click(addBaggageButton);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Price should now have been updated.
|
|
301
|
+
expect(totalPriceLabel.textContent).toBe("+ 80 Duffel house points");
|
|
302
|
+
|
|
303
|
+
fireEvent.click(getByTestId("confirm-selection-for-baggage"));
|
|
304
|
+
expect(getByText(/2 bags added for 80 Duffel house points/i));
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Now, select seats.
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
const seatCard = getByTitle("Select seats");
|
|
311
|
+
fireEvent.click(seatCard);
|
|
312
|
+
|
|
313
|
+
fireEvent.click(getByTestId("seat-28E"));
|
|
314
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
315
|
+
|
|
316
|
+
fireEvent.click(getByTestId("seat-28F"));
|
|
317
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
318
|
+
|
|
319
|
+
fireEvent.click(getByTestId("seat-28E"));
|
|
320
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
321
|
+
|
|
322
|
+
fireEvent.click(getByTestId("seat-28F"));
|
|
323
|
+
fireEvent.click(getByTestId("confirm-selection-for-seats"));
|
|
324
|
+
|
|
325
|
+
expect(getByText(/4 seats selected for 40 Duffel house points/i));
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Now, select CFAR.
|
|
329
|
+
*/
|
|
330
|
+
|
|
331
|
+
const cfarCard = getByTitle("Add cancel for any reason");
|
|
332
|
+
fireEvent.click(cfarCard);
|
|
333
|
+
|
|
334
|
+
fireEvent.click(getByTestId("confirm-selection-for-cfar"));
|
|
335
|
+
|
|
336
|
+
expect(getByText(/Your trip is protected for 100 Duffel house points/i));
|
|
337
|
+
|
|
338
|
+
// The component is always called at least once
|
|
339
|
+
// when the state is set with an offer.
|
|
340
|
+
expect(onPayloadReady).toBeCalledTimes(4);
|
|
341
|
+
});
|
|
342
|
+
});
|