@shopbite-de/storefront 2.6.0 → 2.7.0
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/.env.example +13 -0
- package/.github/workflows/ci.yaml +2 -0
- package/CLAUDE.md +54 -30
- package/GLOSSARY.md +327 -0
- package/README.md +5 -6
- package/app/app.vue +50 -40
- package/app/components/Address/Card.vue +2 -2
- package/app/components/Address/Detail.vue +17 -45
- package/app/components/Address/Form.vue +38 -26
- package/app/components/BranchSwitch.vue +40 -0
- package/app/components/Cart/Bar.vue +9 -9
- package/app/components/Cart/Item.vue +27 -36
- package/app/components/Cart/QuickView.vue +17 -16
- package/app/components/Cart/Upsell.vue +19 -27
- package/app/components/Category/Breadcrumb.vue +3 -8
- package/app/components/Category/FilterGroup.vue +6 -6
- package/app/components/Category/Listing.vue +44 -66
- package/app/components/Checkout/DeliveryTimeSelect.vue +21 -48
- package/app/components/Checkout/OrderMessage.vue +29 -0
- package/app/components/Checkout/OrdererAddress.vue +40 -0
- package/app/components/Checkout/PaymentAndDelivery.vue +40 -35
- package/app/components/Checkout/Summary.vue +89 -74
- package/app/components/Checkout/VoucherInput.vue +8 -8
- package/app/components/Contact/Form.vue +97 -13
- package/app/components/Footer.vue +2 -2
- package/app/components/Header.vue +9 -9
- package/app/components/Home/Categories.vue +13 -17
- package/app/components/Home/Facts.vue +6 -4
- package/app/components/Home/Hero.vue +1 -1
- package/app/components/Home/Highlights.vue +8 -8
- package/app/components/Home/Restaurant.vue +2 -2
- package/app/components/Menu/BonCard.vue +21 -37
- package/app/components/Menu/CartPanel.vue +2 -2
- package/app/components/Menu/CategoryIndex.vue +8 -12
- package/app/components/Menu/OrderMode.vue +2 -2
- package/app/components/Menu/SectionHeader.vue +6 -10
- package/app/components/Navigation/MobileTop.vue +12 -20
- package/app/components/Order/Confirmation.vue +10 -10
- package/app/components/Order/Detail.vue +47 -49
- package/app/components/Product/Configurator.vue +46 -30
- package/app/components/Product/CrossSelling.vue +56 -71
- package/app/components/Product/DeselectIngredient.vue +10 -11
- package/app/components/Product/Detail.vue +62 -55
- package/app/components/Product/FoodLabels.vue +4 -9
- package/app/components/Product/QuickView.vue +22 -30
- package/app/components/User/Detail.vue +20 -43
- package/app/components/User/LoginForm.vue +11 -17
- package/app/components/User/RegistrationForm.vue +3 -3
- package/app/components/Wishlist.vue +99 -106
- package/app/components/WishlistSaveButton.vue +17 -9
- package/app/composables/useAccountAddresses.ts +89 -0
- package/app/composables/useAccountOrders.ts +35 -0
- package/app/composables/useAddToCart.ts +63 -110
- package/app/composables/useCartData.ts +55 -0
- package/app/composables/useCartMutations.ts +93 -85
- package/app/composables/useCartUpsell.ts +27 -71
- package/app/composables/useCategoryListing.ts +36 -59
- package/app/composables/useCategorySeo.ts +11 -16
- package/app/composables/useCheckoutMethodGuard.ts +22 -46
- package/app/composables/useCheckoutMethods.ts +89 -0
- package/app/composables/useCheckoutOrderMessage.ts +19 -0
- package/app/composables/useCheckoutOrderer.ts +69 -0
- package/app/composables/useCommercePrice.ts +46 -9
- package/app/composables/useContactForm.ts +25 -32
- package/app/composables/useCustomer.ts +169 -0
- package/app/composables/useDeliveryTime.ts +112 -122
- package/app/composables/useHolidays.ts +12 -62
- package/app/composables/useHomeMenuCategories.ts +5 -5
- package/app/composables/useListingSearch.ts +9 -8
- package/app/composables/useLiveShopData.ts +15 -9
- package/app/composables/useMenuRootId.ts +3 -6
- package/app/composables/useMenuSection.ts +14 -0
- package/app/composables/useMenuSectionSchema.ts +23 -30
- package/app/composables/useNavigation.ts +24 -29
- package/app/composables/useOpeningHours.ts +21 -0
- package/app/composables/useOpeningHoursData.ts +9 -9
- package/app/composables/useOrder.ts +37 -0
- package/app/composables/useOrderMode.ts +18 -16
- package/app/composables/usePlaceOrder.ts +37 -0
- package/app/composables/useProductCartQuantity.ts +6 -6
- package/app/composables/useProductDetail.ts +28 -53
- package/app/composables/useProductEvents.ts +6 -5
- package/app/composables/useProductQuickView.ts +35 -68
- package/app/composables/useRegistrationForm.ts +85 -34
- package/app/composables/useRestaurantSchema.ts +7 -7
- package/app/composables/useSearchTracking.ts +6 -6
- package/app/composables/useSectionRoute.ts +48 -0
- package/app/composables/useServiceSchedule.ts +23 -0
- package/app/composables/useShippingLeadTime.ts +8 -6
- package/app/composables/useShippingMethodChoice.ts +13 -23
- package/app/composables/useShippingMethods.ts +31 -0
- package/app/composables/useShopConfig.ts +60 -0
- package/app/composables/useShopData.ts +20 -0
- package/app/composables/useSortingSelection.ts +5 -8
- package/app/composables/useStoreStatus.ts +13 -37
- package/app/composables/useTopSellers.ts +3 -3
- package/app/composables/useTrackEvent.ts +29 -24
- package/app/composables/useVoucherCode.ts +47 -12
- package/app/composables/useWishlistEntries.ts +233 -177
- package/app/error.vue +3 -2
- package/app/layouts/account.vue +4 -3
- package/app/pages/[...all].vue +6 -16
- package/app/pages/account/recover/password/index.vue +6 -14
- package/app/pages/anmelden.vue +1 -1
- package/app/pages/bestellung/[id]/erfolg.vue +3 -3
- package/app/pages/bestellung/[id]/fehler.vue +18 -29
- package/app/pages/bestellung/kasse.vue +24 -7
- package/app/pages/konto/adressen.vue +95 -40
- package/app/pages/konto/bestellungen.vue +10 -13
- package/app/pages/konto/index.vue +12 -2
- package/app/pages/konto/profil.vue +241 -42
- package/app/pages/passwort-vergessen.vue +5 -10
- package/app/pages/registrierung/bestaetigen.vue +9 -23
- package/app/pages/registrierung/index.vue +19 -11
- package/app/pages/suche.vue +29 -29
- package/app/plugins/shopware-layer-offline.ts +38 -0
- package/app/plugins/visitor-has-session.server.ts +19 -0
- package/app/utils/accountMessages.ts +74 -0
- package/app/utils/accountReads.ts +34 -0
- package/app/utils/bffWrite.ts +89 -0
- package/app/utils/dish.ts +121 -0
- package/app/utils/leadTime.ts +25 -29
- package/app/utils/media.ts +11 -17
- package/app/utils/menuGroups.ts +22 -35
- package/app/utils/money.ts +41 -0
- package/app/utils/openingHours.ts +30 -30
- package/app/utils/orderStatus.ts +17 -0
- package/app/utils/productUrl.ts +14 -31
- package/app/utils/restaurantTime.ts +326 -0
- package/app/utils/schema.ts +39 -42
- package/app/utils/wishlist.ts +139 -0
- package/docs/adr/0001-backend-agnostic-storefront.md +409 -0
- package/eslint.config.mjs +42 -2
- package/nuxt.config.ts +28 -0
- package/package.json +1 -1
- package/server/adapters/memory/cart.ts +370 -0
- package/server/adapters/memory/catalog.ts +367 -0
- package/server/adapters/memory/contact.ts +89 -0
- package/server/adapters/memory/customer.ts +458 -0
- package/server/adapters/memory/demo-menu.json +1190 -0
- package/server/adapters/memory/demoImages.ts +13 -0
- package/server/adapters/memory/demoMenu.ts +234 -0
- package/server/adapters/memory/demoNavigation.ts +71 -0
- package/server/adapters/memory/index.ts +122 -0
- package/server/adapters/memory/navigation.ts +168 -0
- package/server/adapters/memory/ordering.ts +379 -0
- package/server/adapters/memory/seed.ts +136 -0
- package/server/adapters/memory/wishlist.ts +166 -0
- package/server/adapters/notImplemented.ts +67 -0
- package/server/adapters/registry.ts +32 -0
- package/server/adapters/runtimeConfig.ts +14 -0
- package/server/adapters/shopware/cart.ts +792 -0
- package/server/adapters/shopware/catalog.ts +850 -0
- package/server/adapters/shopware/checkout.ts +138 -0
- package/server/adapters/shopware/contact.ts +255 -0
- package/server/adapters/shopware/customer.ts +460 -0
- package/server/adapters/shopware/index.ts +165 -0
- package/server/adapters/shopware/menuRoot.ts +24 -0
- package/server/adapters/shopware/navigation.ts +426 -0
- package/server/adapters/shopware/ordering.ts +1185 -0
- package/server/adapters/shopware/request.ts +67 -0
- package/server/adapters/shopware/shop.ts +249 -0
- package/server/adapters/shopware/storeApi.ts +62 -0
- package/server/adapters/shopware/wishlist.ts +473 -0
- package/server/api/__sitemap__/urls.get.ts +10 -38
- package/server/api/account/addresses/[addressId]/default.post.ts +13 -0
- package/server/api/account/addresses/[addressId].delete.ts +14 -0
- package/server/api/account/addresses/[addressId].patch.ts +15 -0
- package/server/api/account/addresses/index.get.ts +6 -0
- package/server/api/account/addresses/index.post.ts +9 -0
- package/server/api/account/email.post.ts +10 -0
- package/server/api/account/index.delete.ts +11 -0
- package/server/api/account/index.get.ts +9 -0
- package/server/api/account/login.post.ts +14 -0
- package/server/api/account/logout.post.ts +11 -0
- package/server/api/account/orders.get.ts +13 -0
- package/server/api/account/password-reset/confirm.post.ts +13 -0
- package/server/api/account/password-reset.post.ts +16 -0
- package/server/api/account/password.post.ts +18 -0
- package/server/api/account/profile.patch.ts +6 -0
- package/server/api/account/register/confirm.post.ts +13 -0
- package/server/api/account/register.post.ts +15 -0
- package/server/api/breadcrumb/[sectionId].get.ts +33 -0
- package/server/api/cart/index.get.ts +4 -0
- package/server/api/cart/lines/[lineId].delete.ts +6 -0
- package/server/api/cart/lines/[lineId].patch.ts +10 -0
- package/server/api/cart/lines.post.ts +10 -0
- package/server/api/cart/vouchers/[code].delete.ts +9 -0
- package/server/api/cart/vouchers.post.ts +12 -0
- package/server/api/checkout/guest.post.ts +13 -0
- package/server/api/checkout/orderer/addresses/[addressId].patch.ts +16 -0
- package/server/api/checkout/orderer.get.ts +10 -0
- package/server/api/checkout/orders.post.ts +60 -0
- package/server/api/checkout/payment-methods.get.ts +9 -0
- package/server/api/checkout/selection.get.ts +10 -0
- package/server/api/checkout/selection.post.ts +14 -0
- package/server/api/checkout/shipping-methods.get.ts +9 -0
- package/server/api/contact/form.get.ts +13 -0
- package/server/api/contact/index.post.ts +24 -0
- package/server/api/listing/[sectionId].get.ts +33 -0
- package/server/api/menu/dishes/[dishId]/variant.get.ts +29 -0
- package/server/api/menu/dishes/[dishId].get.ts +19 -0
- package/server/api/menu/dishes/index.get.ts +26 -0
- package/server/api/menu/media/[name].get.ts +18 -0
- package/server/api/menu/root.get.ts +12 -0
- package/server/api/menu/sections/[sectionId].get.ts +18 -0
- package/server/api/menu/upsell.get.ts +12 -0
- package/server/api/navigation/[kind].get.ts +75 -0
- package/server/api/orders/[orderId]/payment.post.ts +24 -0
- package/server/api/orders/[orderId].get.ts +13 -0
- package/server/api/payment-methods.get.ts +11 -15
- package/server/api/resolve-path.get.ts +20 -0
- package/server/api/search.get.ts +16 -80
- package/server/api/session.post.ts +18 -0
- package/server/api/shop/branches.get.ts +9 -0
- package/server/api/shop/config.get.ts +9 -0
- package/server/api/shop/holidays.get.ts +9 -0
- package/server/api/shop/opening-hours.get.ts +9 -0
- package/server/api/top-sellers.get.ts +14 -50
- package/server/api/wishlist/entries/[entryId].delete.ts +8 -0
- package/server/api/wishlist/entries.post.ts +13 -0
- package/server/api/wishlist/index.get.ts +13 -0
- package/server/api/wishlist/merge.post.ts +12 -0
- package/server/plugins/visitor-session.ts +35 -0
- package/server/ports/CartPort.ts +48 -0
- package/server/ports/CatalogPort.ts +66 -0
- package/server/ports/CheckoutPort.ts +128 -0
- package/server/ports/ContactPort.ts +38 -0
- package/server/ports/CustomerPort.ts +154 -0
- package/server/ports/NavigationPort.ts +58 -0
- package/server/ports/OrderPort.ts +31 -0
- package/server/ports/ShopPort.ts +29 -0
- package/server/ports/WishlistPort.ts +47 -0
- package/server/ports/index.ts +42 -0
- package/server/ports/session.ts +22 -0
- package/server/routes/llms.txt.ts +28 -154
- package/server/session/forwardedFor.ts +24 -0
- package/server/session/sameOrigin.ts +47 -0
- package/server/session/seal.ts +147 -0
- package/server/session/visitorSession.ts +288 -0
- package/server/utils/accountRoutes.ts +173 -0
- package/server/utils/backend.ts +21 -0
- package/server/utils/backoff.ts +18 -5
- package/server/utils/cacheKeys.ts +11 -0
- package/server/utils/cachePurge.ts +47 -27
- package/server/utils/cartRoutes.ts +124 -0
- package/server/utils/catalogData.ts +24 -0
- package/server/utils/checkoutRoutes.ts +326 -0
- package/server/utils/contactRoutes.ts +86 -0
- package/server/utils/domainHttp.ts +73 -0
- package/server/utils/listingParams.ts +49 -20
- package/server/utils/llmsTxt.ts +64 -19
- package/server/utils/navigationData.ts +14 -0
- package/server/utils/orderPlacement.ts +322 -0
- package/server/utils/outageBreaker.ts +126 -0
- package/server/utils/pathRoutes.ts +160 -0
- package/server/utils/requestBody.ts +43 -0
- package/server/utils/shopData.ts +132 -0
- package/server/utils/sitemap.ts +14 -36
- package/server/utils/storeApi.ts +71 -23
- package/server/utils/visitorSession.ts +209 -0
- package/server/utils/wishlistRoutes.ts +55 -0
- package/shared/domain/customer/index.ts +2 -0
- package/shared/domain/customer/types.ts +88 -0
- package/shared/domain/discoverability/index.ts +4 -0
- package/shared/domain/discoverability/paths.ts +93 -0
- package/shared/domain/discoverability/route.ts +32 -0
- package/shared/domain/discoverability/types.ts +75 -0
- package/shared/domain/index.ts +11 -0
- package/shared/domain/kernel/calendar.ts +88 -0
- package/shared/domain/kernel/errors.ts +100 -0
- package/shared/domain/kernel/freeze.ts +13 -0
- package/shared/domain/kernel/ids.ts +6 -0
- package/shared/domain/kernel/index.ts +8 -0
- package/shared/domain/kernel/media.ts +17 -0
- package/shared/domain/kernel/money.ts +104 -0
- package/shared/domain/kernel/timeOfDay.ts +39 -0
- package/shared/domain/menu/dishConfiguration.ts +72 -0
- package/shared/domain/menu/index.ts +3 -0
- package/shared/domain/menu/types.ts +185 -0
- package/shared/domain/ordering/index.ts +3 -0
- package/shared/domain/ordering/time.ts +114 -0
- package/shared/domain/ordering/types.ts +195 -0
- package/shared/domain/restaurant/holiday.ts +38 -0
- package/shared/domain/restaurant/index.ts +4 -0
- package/shared/domain/restaurant/openingInterval.ts +97 -0
- package/shared/domain/restaurant/types.ts +75 -0
- package/test/a11y/presets.test.ts +49 -31
- package/test/contract/cart.contract.ts +592 -0
- package/test/contract/cart.spec.ts +5 -0
- package/test/contract/cartFixtures.ts +573 -0
- package/test/contract/catalog.contract.ts +714 -0
- package/test/contract/catalog.spec.ts +5 -0
- package/test/contract/catalogFixtures.ts +572 -0
- package/test/contract/checkout.contract.ts +123 -0
- package/test/contract/checkout.spec.ts +5 -0
- package/test/contract/contact.contract.ts +149 -0
- package/test/contract/contact.spec.ts +4 -0
- package/test/contract/contactFixtures.ts +148 -0
- package/test/contract/customer.contract.ts +831 -0
- package/test/contract/customer.spec.ts +4 -0
- package/test/contract/customerFixtures.ts +468 -0
- package/test/contract/fixtures.ts +260 -0
- package/test/contract/harness.ts +45 -0
- package/test/contract/navigation.contract.ts +336 -0
- package/test/contract/navigation.spec.ts +5 -0
- package/test/contract/navigationFixtures.ts +311 -0
- package/test/contract/ordering.contract.ts +655 -0
- package/test/contract/ordering.spec.ts +4 -0
- package/test/contract/orderingFixtures.ts +498 -0
- package/test/contract/shop.contract.ts +164 -0
- package/test/contract/shop.spec.ts +5 -0
- package/test/contract/wishlist.contract.ts +375 -0
- package/test/contract/wishlist.spec.ts +4 -0
- package/test/contract/wishlistFixtures.ts +199 -0
- package/test/nuxt/AccountPagesPreset.test.ts +320 -83
- package/test/nuxt/AuthPagesPreset.test.ts +17 -24
- package/test/nuxt/CartBar.test.ts +12 -8
- package/test/nuxt/CartCheckoutPreset.test.ts +36 -33
- package/test/nuxt/CartItem.test.ts +39 -20
- package/test/nuxt/CartQuickView.test.ts +106 -0
- package/test/nuxt/CartUpsell.test.ts +37 -39
- package/test/nuxt/CategoryBreadcrumb.test.ts +26 -0
- package/test/nuxt/CheckoutFormsPreset.test.ts +92 -13
- package/test/nuxt/CheckoutOnePage.test.ts +28 -21
- package/test/nuxt/CheckoutPageMessage.test.ts +31 -0
- package/test/nuxt/CheckoutSummary.test.ts +163 -48
- package/test/nuxt/CheckoutVoucherInput.test.ts +77 -80
- package/test/nuxt/ContactFormPreset.test.ts +97 -36
- package/test/nuxt/DeliveryTimeSelect.test.ts +72 -45
- package/test/nuxt/FooterStoreStatus.test.ts +2 -2
- package/test/nuxt/HeaderFooterPreset.test.ts +11 -19
- package/test/nuxt/HomeCategories.test.ts +47 -0
- package/test/nuxt/HomeLeadTimes.test.ts +3 -3
- package/test/nuxt/MenuBonCard.test.ts +45 -32
- package/test/nuxt/NavigationMobileTop.test.ts +30 -28
- package/test/nuxt/OrderPagesPreset.test.ts +83 -52
- package/test/nuxt/PaymentAndDelivery.test.ts +25 -26
- package/test/nuxt/ProductConfigurator.test.ts +81 -0
- package/test/nuxt/ProductCrossSelling.test.ts +23 -20
- package/test/nuxt/ProductDeselectIngredient.test.ts +6 -9
- package/test/nuxt/ProductFoodLabels.test.ts +7 -24
- package/test/nuxt/ProductSheetPreset.test.ts +24 -24
- package/test/nuxt/RegisterConfirmPage.test.ts +26 -45
- package/test/nuxt/RegistrationForm.test.ts +57 -53
- package/test/nuxt/RegistrationPage.test.ts +37 -0
- package/test/nuxt/WishlistPage.test.ts +119 -43
- package/test/nuxt/WishlistSaveButton.test.ts +39 -12
- package/test/nuxt/accountSwitch.test.ts +106 -0
- package/test/nuxt/bffWrite.test.ts +41 -0
- package/test/nuxt/liveShopData.test.ts +36 -68
- package/test/nuxt/shopwareLayerOffline.test.ts +32 -0
- package/test/nuxt/useAddToCart.test.ts +142 -115
- package/test/nuxt/useCartMutations.test.ts +165 -113
- package/test/nuxt/useCartUpsell.test.ts +36 -63
- package/test/nuxt/useCategoryListing.test.ts +75 -118
- package/test/nuxt/useCheckoutMethodGuard.test.ts +54 -105
- package/test/nuxt/useCustomer.test.ts +127 -0
- package/test/nuxt/useDeliveryTime.test.ts +169 -157
- package/test/nuxt/useNavigation.test.ts +81 -0
- package/test/nuxt/useOpeningHoursData.test.ts +18 -18
- package/test/nuxt/useOrder.test.ts +38 -0
- package/test/nuxt/usePlaceOrder.test.ts +88 -0
- package/test/nuxt/useSearchTracking.test.ts +2 -2
- package/test/nuxt/useSectionRoute.test.ts +86 -0
- package/test/nuxt/useShippingLeadTime.test.ts +17 -17
- package/test/nuxt/useShippingMethodChoice.test.ts +22 -22
- package/test/nuxt/useShippingMethods.test.ts +71 -0
- package/test/nuxt/useShopConfig.test.ts +64 -0
- package/test/nuxt/useStoreStatus.test.ts +34 -50
- package/test/nuxt/useTopSellers.test.ts +6 -5
- package/test/nuxt/useTrackEvent.test.ts +68 -6
- package/test/nuxt/useWishlistEntries.test.ts +392 -128
- package/test/support/cart.ts +43 -0
- package/test/support/dishes.ts +116 -0
- package/test/support/navigation.ts +17 -0
- package/test/unit/accountMessages.spec.ts +53 -0
- package/test/unit/accountRoutes.spec.ts +637 -0
- package/test/unit/adapters/memoryCustomer.spec.ts +67 -0
- package/test/unit/adapters/memoryDemoMenu.spec.ts +174 -0
- package/test/unit/adapters/registry.spec.ts +100 -0
- package/test/unit/adapters/shopwareCart.spec.ts +636 -0
- package/test/unit/adapters/shopwareCatalog.spec.ts +486 -0
- package/test/unit/adapters/shopwareCheckout.spec.ts +197 -0
- package/test/unit/adapters/shopwareContact.spec.ts +296 -0
- package/test/unit/adapters/shopwareCustomer.spec.ts +256 -0
- package/test/unit/adapters/shopwareNavigation.spec.ts +594 -0
- package/test/unit/adapters/shopwareOrdering.spec.ts +620 -0
- package/test/unit/adapters/shopwareShop.spec.ts +259 -0
- package/test/unit/adapters/shopwareWishlist.spec.ts +306 -0
- package/test/unit/adapters/useBackend.spec.ts +41 -0
- package/test/unit/backoff.spec.ts +47 -0
- package/test/unit/boundedCache.spec.ts +59 -59
- package/test/unit/cacheKeys.spec.ts +44 -0
- package/test/unit/cachePurge.spec.ts +44 -19
- package/test/unit/cartRoutes.spec.ts +567 -0
- package/test/unit/catalogRoutes.spec.ts +287 -0
- package/test/unit/checkoutRoutes.spec.ts +545 -0
- package/test/unit/dish.spec.ts +128 -0
- package/test/unit/domain/discoverability.spec.ts +154 -0
- package/test/unit/domain/dishConfiguration.spec.ts +85 -0
- package/test/unit/domain/money.spec.ts +102 -0
- package/test/unit/domain/time.spec.ts +336 -0
- package/test/unit/domainHttp.spec.ts +74 -0
- package/test/unit/forwardedFor.spec.ts +24 -0
- package/test/unit/layoutCacheRoutes.spec.ts +47 -471
- package/test/unit/leadTime.spec.ts +28 -23
- package/test/unit/llmsTxt.spec.ts +120 -9
- package/test/unit/media.spec.ts +25 -26
- package/test/unit/menuGroups.spec.ts +31 -21
- package/test/unit/navigationRoutes.spec.ts +648 -0
- package/test/unit/nitroStubs.ts +6 -1
- package/test/unit/openingHours.spec.ts +57 -34
- package/test/unit/orderPlacement.spec.ts +362 -0
- package/test/unit/outageBreaker.spec.ts +213 -0
- package/test/unit/productUrl.spec.ts +10 -28
- package/test/unit/requestBody.spec.ts +56 -0
- package/test/unit/restaurantTime.spec.ts +295 -0
- package/test/unit/schema.spec.ts +58 -26
- package/test/unit/session/sameOrigin.spec.ts +76 -0
- package/test/unit/session/seal.spec.ts +128 -0
- package/test/unit/session/visitorSession.spec.ts +439 -0
- package/test/unit/shopRoutes.spec.ts +257 -0
- package/test/unit/sitemap.spec.ts +11 -47
- package/test/unit/storeApiForVisitor.spec.ts +109 -0
- package/test/unit/useCategorySeo.spec.ts +57 -31
- package/test/unit/wishlistContactRoutes.spec.ts +607 -0
- package/vitest.config.ts +5 -1
- package/app/components/SalesChannelSwitch.vue +0 -73
- package/app/composables/useBusinessHours.ts +0 -192
- package/app/composables/useCategoryById.ts +0 -10
- package/app/composables/useNavigationSearch.ts +0 -45
- package/app/composables/useProductConfigurator.ts +0 -70
- package/app/composables/useProductCrossSelling.ts +0 -42
- package/app/composables/useProductVariants.ts +0 -61
- package/app/composables/useProductVariantsZwei.ts +0 -62
- package/app/composables/useSeoUrlRoute.ts +0 -124
- package/app/composables/useShopBiteConfig.ts +0 -69
- package/app/composables/useSyncWishlist.ts +0 -119
- package/app/types/Association.d.ts +0 -14
- package/app/utils/product.ts +0 -139
- package/app/utils/seoPath.ts +0 -68
- package/app/utils/time.ts +0 -20
- package/server/api/breadcrumb/[categoryId].get.ts +0 -31
- package/server/api/category/[categoryId].get.ts +0 -37
- package/server/api/listing/[categoryId].get.ts +0 -102
- package/server/api/navigation/[type].get.ts +0 -97
- package/server/api/product/[productId]/cross-selling.get.ts +0 -26
- package/server/api/product/[productId].get.ts +0 -76
- package/server/api/product/variant.get.ts +0 -98
- package/server/api/seo-url/index.get.ts +0 -17
- package/server/api/seo-url/known.get.ts +0 -33
- package/server/api/shopbite/business-hours.get.ts +0 -22
- package/server/api/shopbite/config.get.ts +0 -6
- package/server/api/shopbite/holidays.get.ts +0 -20
- package/server/utils/menuRoot.ts +0 -31
- package/server/utils/seoPaths.ts +0 -130
- package/server/utils/seoUrlCache.ts +0 -98
- package/server/utils/shopBiteConfig.ts +0 -30
- package/test/nuxt/useBusinessHours.test.ts +0 -106
- package/test/nuxt/useProductConfigurator.test.ts +0 -87
- package/test/nuxt/useProductVariants.test.ts +0 -95
- package/test/nuxt/useProductVariantsZwei.test.ts +0 -52
- package/test/nuxt/useSeoUrlRoute.test.ts +0 -176
- package/test/nuxt/useShopBiteConfig.test.ts +0 -131
- package/test/nuxt/useSyncWishlist.test.ts +0 -85
- package/test/unit/product.spec.ts +0 -160
- package/test/unit/seoPath.spec.ts +0 -161
- package/test/unit/seoPaths.spec.ts +0 -117
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
isDomainError,
|
|
4
|
+
money,
|
|
5
|
+
type Dish,
|
|
6
|
+
type ExtraGroup,
|
|
7
|
+
type FoodLabels,
|
|
8
|
+
type Id,
|
|
9
|
+
type Ingredient,
|
|
10
|
+
type Media,
|
|
11
|
+
type MenuSection,
|
|
12
|
+
type VariantGroup,
|
|
13
|
+
} from "../../shared/domain";
|
|
14
|
+
import { defineContract } from "./harness";
|
|
15
|
+
|
|
16
|
+
/** A dish of the scenario as the restaurant keeps it, in domain terms. */
|
|
17
|
+
export type ScenarioDish = Readonly<{
|
|
18
|
+
id: Id;
|
|
19
|
+
number: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
/** For a dish with variants: the price of the dish itself. */
|
|
23
|
+
price: number;
|
|
24
|
+
listPrice?: number;
|
|
25
|
+
sectionIds: readonly Id[];
|
|
26
|
+
ingredients: readonly Ingredient[];
|
|
27
|
+
diets: Dish["diets"];
|
|
28
|
+
kitchen?: string;
|
|
29
|
+
foodLabels: FoodLabels;
|
|
30
|
+
available: boolean;
|
|
31
|
+
media?: Media;
|
|
32
|
+
/** The link the backend keeps for the dish, if any. */
|
|
33
|
+
path?: string;
|
|
34
|
+
topSeller?: boolean;
|
|
35
|
+
upsell?: boolean;
|
|
36
|
+
variantGroups?: readonly VariantGroup[];
|
|
37
|
+
/**
|
|
38
|
+
* In the dish's order (by id, as a backend without positions lists them);
|
|
39
|
+
* the first available one is the default.
|
|
40
|
+
*/
|
|
41
|
+
variants?: readonly Readonly<{
|
|
42
|
+
id: Id;
|
|
43
|
+
number: string;
|
|
44
|
+
optionIds: readonly Id[];
|
|
45
|
+
price: number;
|
|
46
|
+
available: boolean;
|
|
47
|
+
}>[];
|
|
48
|
+
extraGroups?: readonly ExtraGroup[];
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
/** A menu as the CatalogPort suite describes it, in domain terms. */
|
|
52
|
+
export type CatalogScenario = Readonly<{
|
|
53
|
+
currency: string;
|
|
54
|
+
/** The menu tree, in menu order. */
|
|
55
|
+
sections: readonly MenuSection[];
|
|
56
|
+
/** Sections taken off the menu that still have their page. */
|
|
57
|
+
offMenuSections: readonly MenuSection[];
|
|
58
|
+
dishes: readonly ScenarioDish[];
|
|
59
|
+
/** The diet filters: group and option ("Ja") ids. */
|
|
60
|
+
dietFilters: Readonly<
|
|
61
|
+
Record<Dish["diets"][number], { id: Id; name: string; optionId: Id }>
|
|
62
|
+
>;
|
|
63
|
+
sortings: readonly Readonly<{ key: string; label: string }>[];
|
|
64
|
+
/** The sortings of a search: `sortings` plus the relevance sorting. */
|
|
65
|
+
searchSortings: readonly Readonly<{ key: string; label: string }>[];
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
const NO_LABELS: FoodLabels = { allergens: [], additives: [], checked: false };
|
|
69
|
+
const ingredient = (id: string, name: string): Ingredient => ({ id, name });
|
|
70
|
+
const TOMATO = ingredient("tomatensosse", "Tomatensoße");
|
|
71
|
+
const CHEESE = ingredient("kaese", "Käse");
|
|
72
|
+
|
|
73
|
+
const section = (
|
|
74
|
+
id: string,
|
|
75
|
+
name: string,
|
|
76
|
+
path: string,
|
|
77
|
+
extra: Partial<MenuSection> = {},
|
|
78
|
+
): MenuSection => ({
|
|
79
|
+
id,
|
|
80
|
+
name,
|
|
81
|
+
description: null,
|
|
82
|
+
icon: null,
|
|
83
|
+
media: null,
|
|
84
|
+
path,
|
|
85
|
+
seo: { title: null, description: null, indexable: true },
|
|
86
|
+
children: [],
|
|
87
|
+
...extra,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const SPEZIAL = section(
|
|
91
|
+
"pizza-spezial",
|
|
92
|
+
"Spezial",
|
|
93
|
+
"/Speisekarte/Pizza/Spezial/",
|
|
94
|
+
);
|
|
95
|
+
const PIZZA = section("pizza", "Pizza", "/Speisekarte/Pizza/", {
|
|
96
|
+
description: "Aus dem Steinofen",
|
|
97
|
+
icon: "i-lucide-pizza",
|
|
98
|
+
media: {
|
|
99
|
+
url: "https://cdn.example.com/pizza.webp",
|
|
100
|
+
alt: "Pizza",
|
|
101
|
+
width: 1600,
|
|
102
|
+
height: 900,
|
|
103
|
+
sources: [{ url: "https://cdn.example.com/pizza-800.webp", width: 800 }],
|
|
104
|
+
},
|
|
105
|
+
seo: {
|
|
106
|
+
title: "Pizza bestellen",
|
|
107
|
+
description: "Pizza aus dem Steinofen, geliefert.",
|
|
108
|
+
indexable: true,
|
|
109
|
+
},
|
|
110
|
+
children: [SPEZIAL],
|
|
111
|
+
});
|
|
112
|
+
const SALATE = section("salate", "Salate", "/Speisekarte/Salate/");
|
|
113
|
+
const FLEISCH = section(
|
|
114
|
+
"fleisch",
|
|
115
|
+
"Fleischgerichte",
|
|
116
|
+
"/Speisekarte/Fleischgerichte/",
|
|
117
|
+
);
|
|
118
|
+
const NACHTISCH = section("nachtisch", "Nachtisch", "/Speisekarte/Nachtisch/", {
|
|
119
|
+
seo: { title: null, description: null, indexable: false },
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const EXTRAS: ExtraGroup = {
|
|
123
|
+
id: "pizza-extras",
|
|
124
|
+
name: "Extras",
|
|
125
|
+
extras: [
|
|
126
|
+
{
|
|
127
|
+
id: "extra-kaese",
|
|
128
|
+
number: "900",
|
|
129
|
+
name: "Extra Käse",
|
|
130
|
+
price: money(100, "EUR"),
|
|
131
|
+
available: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "extra-salami",
|
|
135
|
+
number: "901",
|
|
136
|
+
name: "Extra Salami",
|
|
137
|
+
price: money(150, "EUR"),
|
|
138
|
+
available: false,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const MARGHERITA_MEDIA: Media = {
|
|
144
|
+
url: "https://cdn.example.com/21.webp",
|
|
145
|
+
alt: null,
|
|
146
|
+
width: 1200,
|
|
147
|
+
height: 900,
|
|
148
|
+
sources: [
|
|
149
|
+
{ url: "https://cdn.example.com/21-400.webp", width: 400 },
|
|
150
|
+
{ url: "https://cdn.example.com/21-800.webp", width: 800 },
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const MENU: CatalogScenario = {
|
|
155
|
+
currency: "EUR",
|
|
156
|
+
sections: [PIZZA, SALATE, FLEISCH],
|
|
157
|
+
offMenuSections: [NACHTISCH],
|
|
158
|
+
dietFilters: {
|
|
159
|
+
vegetarian: {
|
|
160
|
+
id: "vegetarisch",
|
|
161
|
+
name: "Vegetarisch",
|
|
162
|
+
optionId: "vegetarisch-ja",
|
|
163
|
+
},
|
|
164
|
+
vegan: { id: "vegan", name: "Vegan", optionId: "vegan-ja" },
|
|
165
|
+
},
|
|
166
|
+
sortings: [
|
|
167
|
+
{ key: "name-asc", label: "Name A-Z" },
|
|
168
|
+
{ key: "name-desc", label: "Name Z-A" },
|
|
169
|
+
{ key: "price-asc", label: "Preis aufsteigend" },
|
|
170
|
+
{ key: "price-desc", label: "Preis absteigend" },
|
|
171
|
+
],
|
|
172
|
+
searchSortings: [
|
|
173
|
+
{ key: "name-asc", label: "Name A-Z" },
|
|
174
|
+
{ key: "name-desc", label: "Name Z-A" },
|
|
175
|
+
{ key: "price-asc", label: "Preis aufsteigend" },
|
|
176
|
+
{ key: "price-desc", label: "Preis absteigend" },
|
|
177
|
+
{ key: "score", label: "Beste Ergebnisse" },
|
|
178
|
+
],
|
|
179
|
+
dishes: [
|
|
180
|
+
{
|
|
181
|
+
id: "margherita",
|
|
182
|
+
number: "21",
|
|
183
|
+
name: "Pizza Margherita",
|
|
184
|
+
description: "Mit Tomatensoße und Käse",
|
|
185
|
+
price: 7,
|
|
186
|
+
sectionIds: ["pizza"],
|
|
187
|
+
ingredients: [TOMATO, CHEESE],
|
|
188
|
+
diets: ["vegetarian"],
|
|
189
|
+
kitchen: "Italienisch",
|
|
190
|
+
foodLabels: {
|
|
191
|
+
allergens: [
|
|
192
|
+
{ code: "A", name: "Weizen" },
|
|
193
|
+
{ code: "G", name: "Milch (inkl. Laktose)" },
|
|
194
|
+
],
|
|
195
|
+
additives: [{ code: "1", name: "mit Farbstoff" }],
|
|
196
|
+
checked: true,
|
|
197
|
+
},
|
|
198
|
+
available: true,
|
|
199
|
+
media: MARGHERITA_MEDIA,
|
|
200
|
+
path: "/Speisekarte/Pizza/?produkt=21",
|
|
201
|
+
upsell: true,
|
|
202
|
+
variantGroups: [
|
|
203
|
+
{
|
|
204
|
+
id: "groesse",
|
|
205
|
+
name: "Größe",
|
|
206
|
+
options: [
|
|
207
|
+
{ id: "normal", name: "Normal 30 cm" },
|
|
208
|
+
{ id: "gross", name: "Groß 40 cm" },
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
variants: [
|
|
213
|
+
{
|
|
214
|
+
id: "margherita-1-normal",
|
|
215
|
+
number: "21-normal",
|
|
216
|
+
optionIds: ["normal"],
|
|
217
|
+
price: 7,
|
|
218
|
+
available: true,
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "margherita-2-gross",
|
|
222
|
+
number: "21-groß",
|
|
223
|
+
optionIds: ["gross"],
|
|
224
|
+
price: 10,
|
|
225
|
+
available: true,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
extraGroups: [EXTRAS],
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: "salami",
|
|
232
|
+
number: "22",
|
|
233
|
+
name: "Pizza Salami",
|
|
234
|
+
description: null,
|
|
235
|
+
price: 8,
|
|
236
|
+
sectionIds: ["pizza-spezial"],
|
|
237
|
+
ingredients: [TOMATO, CHEESE, ingredient("salami", "Salami")],
|
|
238
|
+
diets: [],
|
|
239
|
+
foodLabels: NO_LABELS,
|
|
240
|
+
available: true,
|
|
241
|
+
topSeller: true,
|
|
242
|
+
extraGroups: [EXTRAS],
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
id: "caprese",
|
|
246
|
+
number: "3",
|
|
247
|
+
name: "Mozzarella Caprese",
|
|
248
|
+
description: "Tomaten und Mozzarella mit Basilikum",
|
|
249
|
+
price: 9.5,
|
|
250
|
+
sectionIds: ["salate"],
|
|
251
|
+
ingredients: [
|
|
252
|
+
ingredient("tomaten", "Tomaten"),
|
|
253
|
+
ingredient("mozzarella", "Mozzarella"),
|
|
254
|
+
],
|
|
255
|
+
diets: ["vegetarian"],
|
|
256
|
+
foodLabels: { allergens: [], additives: [], checked: true },
|
|
257
|
+
available: true,
|
|
258
|
+
topSeller: true,
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
id: "verde",
|
|
262
|
+
number: "12",
|
|
263
|
+
name: "Insalata verde",
|
|
264
|
+
description: null,
|
|
265
|
+
price: 5,
|
|
266
|
+
listPrice: 6,
|
|
267
|
+
sectionIds: ["salate"],
|
|
268
|
+
ingredients: [ingredient("eisberg", "Eisbergsalat")],
|
|
269
|
+
diets: ["vegan"],
|
|
270
|
+
foodLabels: NO_LABELS,
|
|
271
|
+
available: true,
|
|
272
|
+
upsell: true,
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: "camembert",
|
|
276
|
+
number: "4",
|
|
277
|
+
name: "Gebackener Camembert",
|
|
278
|
+
description: null,
|
|
279
|
+
price: 6.5,
|
|
280
|
+
sectionIds: ["salate"],
|
|
281
|
+
ingredients: [],
|
|
282
|
+
diets: ["vegetarian"],
|
|
283
|
+
foodLabels: NO_LABELS,
|
|
284
|
+
available: false,
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
id: "bistecca",
|
|
288
|
+
number: "123",
|
|
289
|
+
name: "Bistecca alla Griglia",
|
|
290
|
+
description: "Gegrilltes Rumpsteak",
|
|
291
|
+
price: 24,
|
|
292
|
+
sectionIds: ["fleisch"],
|
|
293
|
+
ingredients: [],
|
|
294
|
+
diets: [],
|
|
295
|
+
foodLabels: NO_LABELS,
|
|
296
|
+
available: true,
|
|
297
|
+
variantGroups: [
|
|
298
|
+
{
|
|
299
|
+
id: "beilage",
|
|
300
|
+
name: "Beilage",
|
|
301
|
+
options: [
|
|
302
|
+
{ id: "pommes", name: "Pommes frites" },
|
|
303
|
+
{ id: "reis", name: "Reis" },
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: "garstufe",
|
|
308
|
+
name: "Garstufe",
|
|
309
|
+
options: [
|
|
310
|
+
{ id: "medium", name: "Medium" },
|
|
311
|
+
{ id: "durch", name: "Durchgebraten" },
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
variants: [
|
|
316
|
+
{
|
|
317
|
+
id: "bistecca-1-pommes-medium",
|
|
318
|
+
number: "123-pommes-medium",
|
|
319
|
+
optionIds: ["pommes", "medium"],
|
|
320
|
+
price: 24,
|
|
321
|
+
available: false,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: "bistecca-2-pommes-durch",
|
|
325
|
+
number: "123-pommes-durch",
|
|
326
|
+
optionIds: ["pommes", "durch"],
|
|
327
|
+
price: 24,
|
|
328
|
+
available: true,
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
id: "bistecca-3-reis-medium",
|
|
332
|
+
number: "123-reis-medium",
|
|
333
|
+
optionIds: ["reis", "medium"],
|
|
334
|
+
price: 25,
|
|
335
|
+
available: true,
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
id: "bistecca-4-reis-durch",
|
|
339
|
+
number: "123-reis-durch",
|
|
340
|
+
optionIds: ["reis", "durch"],
|
|
341
|
+
price: 25,
|
|
342
|
+
available: true,
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const EUR = (cents: number) => money(cents, "EUR");
|
|
350
|
+
|
|
351
|
+
/** Pizza Margherita as its menu card shows it. */
|
|
352
|
+
const MARGHERITA: Dish = {
|
|
353
|
+
id: "margherita",
|
|
354
|
+
number: "21",
|
|
355
|
+
name: "Pizza Margherita",
|
|
356
|
+
description: "Mit Tomatensoße und Käse",
|
|
357
|
+
price: EUR(700),
|
|
358
|
+
listPrice: null,
|
|
359
|
+
priceFrom: true,
|
|
360
|
+
media: MARGHERITA_MEDIA,
|
|
361
|
+
ingredients: [TOMATO, CHEESE],
|
|
362
|
+
diets: ["vegetarian"],
|
|
363
|
+
kitchen: "Italienisch",
|
|
364
|
+
foodLabels: MENU.dishes[0]!.foodLabels,
|
|
365
|
+
available: true,
|
|
366
|
+
needsChoice: true,
|
|
367
|
+
sectionIds: ["pizza"],
|
|
368
|
+
path: "/Speisekarte/Pizza/?produkt=21",
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const names = (dishes: readonly Dish[]) => dishes.map((dish) => dish.name);
|
|
372
|
+
const ids = (dishes: readonly { id: Id }[]) => dishes.map((dish) => dish.id);
|
|
373
|
+
|
|
374
|
+
async function rejection(promise: Promise<unknown>): Promise<unknown> {
|
|
375
|
+
try {
|
|
376
|
+
await promise;
|
|
377
|
+
} catch (error) {
|
|
378
|
+
return error;
|
|
379
|
+
}
|
|
380
|
+
throw new Error("expected a rejection");
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export const catalogContract = defineContract<"catalog", CatalogScenario>(
|
|
384
|
+
"catalog",
|
|
385
|
+
(given) => {
|
|
386
|
+
it("answers the menu as a tree of sections in menu order", async () => {
|
|
387
|
+
const catalog = await given(MENU);
|
|
388
|
+
expect(await catalog.getMenu()).toEqual([PIZZA, SALATE, FLEISCH]);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it("answers a section with its sub-sections and SEO data", async () => {
|
|
392
|
+
const catalog = await given(MENU);
|
|
393
|
+
expect(await catalog.getSection("pizza")).toEqual(PIZZA);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it("keeps the page of a section taken off the menu, not indexable", async () => {
|
|
397
|
+
const catalog = await given(MENU);
|
|
398
|
+
expect(await catalog.getSection("nachtisch")).toEqual(NACHTISCH);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("rejects an unknown section with not_found", async () => {
|
|
402
|
+
const catalog = await given(MENU);
|
|
403
|
+
const error = await rejection(catalog.getSection("unbekannt"));
|
|
404
|
+
expect(isDomainError(error, "not_found")).toBe(true);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it("lists the dishes of a section and its sub-sections, never variants", async () => {
|
|
408
|
+
const catalog = await given(MENU);
|
|
409
|
+
const listing = await catalog.listDishes("pizza");
|
|
410
|
+
expect(listing.dishes).toEqual([
|
|
411
|
+
MARGHERITA,
|
|
412
|
+
expect.objectContaining({
|
|
413
|
+
id: "salami",
|
|
414
|
+
sectionIds: ["pizza-spezial"],
|
|
415
|
+
}),
|
|
416
|
+
]);
|
|
417
|
+
expect(listing).toMatchObject({ total: 2, page: 1, filterOptionIds: [] });
|
|
418
|
+
expect(listing.limit).toBeGreaterThanOrEqual(2);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it("maps a dish without variants, its link left to the storefront", async () => {
|
|
422
|
+
const catalog = await given(MENU);
|
|
423
|
+
const [salami] = (await catalog.listDishes("pizza-spezial")).dishes;
|
|
424
|
+
expect(salami).toEqual({
|
|
425
|
+
id: "salami",
|
|
426
|
+
number: "22",
|
|
427
|
+
name: "Pizza Salami",
|
|
428
|
+
description: null,
|
|
429
|
+
price: EUR(800),
|
|
430
|
+
listPrice: null,
|
|
431
|
+
priceFrom: false,
|
|
432
|
+
media: null,
|
|
433
|
+
ingredients: [TOMATO, CHEESE, { id: "salami", name: "Salami" }],
|
|
434
|
+
diets: [],
|
|
435
|
+
kitchen: null,
|
|
436
|
+
foodLabels: NO_LABELS,
|
|
437
|
+
available: true,
|
|
438
|
+
needsChoice: false,
|
|
439
|
+
sectionIds: ["pizza-spezial"],
|
|
440
|
+
path: null,
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it("says which dishes are sold out and which have a former price", async () => {
|
|
445
|
+
const catalog = await given(MENU);
|
|
446
|
+
const { dishes } = await catalog.listDishes("salate");
|
|
447
|
+
expect(dishes.find((dish) => dish.id === "camembert")?.available).toBe(
|
|
448
|
+
false,
|
|
449
|
+
);
|
|
450
|
+
expect(dishes.find((dish) => dish.id === "verde")?.listPrice).toEqual(
|
|
451
|
+
EUR(600),
|
|
452
|
+
);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it("sorts by name unless the guest chooses another of the offered sortings", async () => {
|
|
456
|
+
const catalog = await given(MENU);
|
|
457
|
+
const listing = await catalog.listDishes("salate");
|
|
458
|
+
expect(listing.sortings).toEqual(MENU.sortings);
|
|
459
|
+
expect(listing.sorting).toBe("name-asc");
|
|
460
|
+
expect(names(listing.dishes)).toEqual([
|
|
461
|
+
"Gebackener Camembert",
|
|
462
|
+
"Insalata verde",
|
|
463
|
+
"Mozzarella Caprese",
|
|
464
|
+
]);
|
|
465
|
+
const byPrice = await catalog.listDishes("salate", {
|
|
466
|
+
sorting: "price-desc",
|
|
467
|
+
});
|
|
468
|
+
expect(byPrice.sorting).toBe("price-desc");
|
|
469
|
+
expect(ids(byPrice.dishes)).toEqual(["caprese", "camembert", "verde"]);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
it("rejects a sorting the listing does not offer", async () => {
|
|
473
|
+
const catalog = await given(MENU);
|
|
474
|
+
const error = await rejection(
|
|
475
|
+
catalog.listDishes("salate", { sorting: "unbekannt" }),
|
|
476
|
+
);
|
|
477
|
+
expect(isDomainError(error, "invalid_value")).toBe(true);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it("offers the diets of the section's dishes as filters", async () => {
|
|
481
|
+
const catalog = await given(MENU);
|
|
482
|
+
const vegetarian = {
|
|
483
|
+
id: "vegetarisch",
|
|
484
|
+
name: "Vegetarisch",
|
|
485
|
+
options: [{ id: "vegetarisch-ja", name: "Ja" }],
|
|
486
|
+
};
|
|
487
|
+
const vegan = {
|
|
488
|
+
id: "vegan",
|
|
489
|
+
name: "Vegan",
|
|
490
|
+
options: [{ id: "vegan-ja", name: "Ja" }],
|
|
491
|
+
};
|
|
492
|
+
expect((await catalog.listDishes("pizza")).filters).toEqual([vegetarian]);
|
|
493
|
+
expect((await catalog.listDishes("salate")).filters).toEqual([
|
|
494
|
+
vegetarian,
|
|
495
|
+
vegan,
|
|
496
|
+
]);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it("lists only the dishes that match the selected filter options", async () => {
|
|
500
|
+
const catalog = await given(MENU);
|
|
501
|
+
const listing = await catalog.listDishes("salate", {
|
|
502
|
+
filterOptionIds: ["vegetarisch-ja"],
|
|
503
|
+
});
|
|
504
|
+
expect(ids(listing.dishes)).toEqual(["camembert", "caprese"]);
|
|
505
|
+
expect(listing.filterOptionIds).toEqual(["vegetarisch-ja"]);
|
|
506
|
+
expect(listing.total).toBe(2);
|
|
507
|
+
const both = await catalog.listDishes("salate", {
|
|
508
|
+
filterOptionIds: ["vegetarisch-ja", "vegan-ja"],
|
|
509
|
+
});
|
|
510
|
+
// one option of each filter: no dish is both
|
|
511
|
+
expect(both.dishes).toEqual([]);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
it("answers a page after the last one empty", async () => {
|
|
515
|
+
const catalog = await given(MENU);
|
|
516
|
+
const listing = await catalog.listDishes("salate", { page: 2 });
|
|
517
|
+
expect(listing).toMatchObject({ dishes: [], page: 2 });
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it("rejects the listing of an unknown section with not_found", async () => {
|
|
521
|
+
const catalog = await given(MENU);
|
|
522
|
+
const error = await rejection(catalog.listDishes("unbekannt"));
|
|
523
|
+
expect(isDomainError(error, "not_found")).toBe(true);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it("finds dishes by a word of their name, by relevance first", async () => {
|
|
527
|
+
const catalog = await given(MENU);
|
|
528
|
+
const result = await catalog.searchDishes("pizza");
|
|
529
|
+
expect(ids(result.dishes).sort()).toEqual(["margherita", "salami"]);
|
|
530
|
+
expect(result.dishes.find((dish) => dish.id === "margherita")).toEqual(
|
|
531
|
+
MARGHERITA,
|
|
532
|
+
);
|
|
533
|
+
expect(result.sortings).toEqual(MENU.searchSortings);
|
|
534
|
+
expect(result.sorting).toBe("score");
|
|
535
|
+
const byName = await catalog.searchDishes("PIZZA", {
|
|
536
|
+
sorting: "name-desc",
|
|
537
|
+
});
|
|
538
|
+
expect(names(byName.dishes)).toEqual([
|
|
539
|
+
"Pizza Salami",
|
|
540
|
+
"Pizza Margherita",
|
|
541
|
+
]);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
it("finds nothing for an empty or unknown text", async () => {
|
|
545
|
+
const catalog = await given(MENU);
|
|
546
|
+
expect((await catalog.searchDishes(" ")).dishes).toEqual([]);
|
|
547
|
+
expect((await catalog.searchDishes("xyzxyz")).dishes).toEqual([]);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it("lists every dish on the menu once, without variants and extras", async () => {
|
|
551
|
+
const catalog = await given(MENU);
|
|
552
|
+
const dishes = await catalog.listMenuDishes();
|
|
553
|
+
expect(ids(dishes).sort()).toEqual([
|
|
554
|
+
"bistecca",
|
|
555
|
+
"camembert",
|
|
556
|
+
"caprese",
|
|
557
|
+
"margherita",
|
|
558
|
+
"salami",
|
|
559
|
+
"verde",
|
|
560
|
+
]);
|
|
561
|
+
expect(dishes.find((dish) => dish.id === "margherita")).toEqual(
|
|
562
|
+
MARGHERITA,
|
|
563
|
+
);
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
it("answers a dish with variants for the sheet, its default variant selected", async () => {
|
|
567
|
+
const catalog = await given(MENU);
|
|
568
|
+
expect(await catalog.getDish("margherita")).toEqual({
|
|
569
|
+
...MARGHERITA,
|
|
570
|
+
variantGroups: MENU.dishes[0]!.variantGroups,
|
|
571
|
+
variants: [
|
|
572
|
+
{
|
|
573
|
+
id: "margherita-1-normal",
|
|
574
|
+
number: "21-normal",
|
|
575
|
+
name: "Pizza Margherita",
|
|
576
|
+
optionIds: ["normal"],
|
|
577
|
+
price: EUR(700),
|
|
578
|
+
listPrice: null,
|
|
579
|
+
available: true,
|
|
580
|
+
media: MARGHERITA_MEDIA,
|
|
581
|
+
ingredients: [TOMATO, CHEESE],
|
|
582
|
+
},
|
|
583
|
+
expect.objectContaining({
|
|
584
|
+
id: "margherita-2-gross",
|
|
585
|
+
number: "21-groß",
|
|
586
|
+
price: EUR(1000),
|
|
587
|
+
}),
|
|
588
|
+
],
|
|
589
|
+
selectedVariantId: "margherita-1-normal",
|
|
590
|
+
extraGroups: [EXTRAS],
|
|
591
|
+
upsell: true,
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
it("starts with the first available variant", async () => {
|
|
596
|
+
const catalog = await given(MENU);
|
|
597
|
+
const bistecca = await catalog.getDish("bistecca");
|
|
598
|
+
expect(bistecca.selectedVariantId).toBe("bistecca-2-pommes-durch");
|
|
599
|
+
expect(bistecca.variantGroups.map((group) => group.name)).toEqual([
|
|
600
|
+
"Beilage",
|
|
601
|
+
"Garstufe",
|
|
602
|
+
]);
|
|
603
|
+
expect(bistecca.variants).toHaveLength(4);
|
|
604
|
+
expect(bistecca.extraGroups).toEqual([]);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
it("answers the id of a variant with its dish and that variant selected", async () => {
|
|
608
|
+
const catalog = await given(MENU);
|
|
609
|
+
const detail = await catalog.getDish("margherita-2-gross");
|
|
610
|
+
expect(detail).toMatchObject({
|
|
611
|
+
id: "margherita",
|
|
612
|
+
number: "21",
|
|
613
|
+
selectedVariantId: "margherita-2-gross",
|
|
614
|
+
extraGroups: [EXTRAS],
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it("answers a dish without variants with its extras", async () => {
|
|
619
|
+
const catalog = await given(MENU);
|
|
620
|
+
expect(await catalog.getDish("salami")).toMatchObject({
|
|
621
|
+
id: "salami",
|
|
622
|
+
variantGroups: [],
|
|
623
|
+
variants: [],
|
|
624
|
+
selectedVariantId: null,
|
|
625
|
+
extraGroups: [EXTRAS],
|
|
626
|
+
upsell: false,
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
it("rejects an unknown dish with not_found", async () => {
|
|
631
|
+
const catalog = await given(MENU);
|
|
632
|
+
const error = await rejection(catalog.getDish("unbekannt"));
|
|
633
|
+
expect(isDomainError(error, "not_found")).toBe(true);
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
it("finds a dish and a variant by menu number", async () => {
|
|
637
|
+
const catalog = await given(MENU);
|
|
638
|
+
expect(await catalog.findDishByNumber("3")).toMatchObject({
|
|
639
|
+
id: "caprese",
|
|
640
|
+
selectedVariantId: null,
|
|
641
|
+
});
|
|
642
|
+
expect(await catalog.findDishByNumber("21-groß")).toMatchObject({
|
|
643
|
+
id: "margherita",
|
|
644
|
+
selectedVariantId: "margherita-2-gross",
|
|
645
|
+
});
|
|
646
|
+
expect(await catalog.findDishByNumber("999")).toBeNull();
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
it("finds the variant with the chosen options", async () => {
|
|
650
|
+
const catalog = await given(MENU);
|
|
651
|
+
expect(await catalog.findVariant("margherita", ["gross"])).toEqual({
|
|
652
|
+
id: "margherita-2-gross",
|
|
653
|
+
number: "21-groß",
|
|
654
|
+
name: "Pizza Margherita",
|
|
655
|
+
optionIds: ["gross"],
|
|
656
|
+
price: EUR(1000),
|
|
657
|
+
listPrice: null,
|
|
658
|
+
available: true,
|
|
659
|
+
media: MARGHERITA_MEDIA,
|
|
660
|
+
ingredients: [TOMATO, CHEESE],
|
|
661
|
+
});
|
|
662
|
+
expect(
|
|
663
|
+
(await catalog.findVariant("bistecca", ["durch", "reis"]))?.id,
|
|
664
|
+
).toBe("bistecca-4-reis-durch");
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
it("takes the first variant that has a partial choice", async () => {
|
|
668
|
+
const catalog = await given(MENU);
|
|
669
|
+
expect((await catalog.findVariant("bistecca", ["reis"]))?.id).toBe(
|
|
670
|
+
"bistecca-3-reis-medium",
|
|
671
|
+
);
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
it("finds no variant for unknown options or dishes", async () => {
|
|
675
|
+
const catalog = await given(MENU);
|
|
676
|
+
expect(await catalog.findVariant("margherita", ["unbekannt"])).toBeNull();
|
|
677
|
+
expect(await catalog.findVariant("unbekannt", ["gross"])).toBeNull();
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
it("lists the top sellers, at most the limit", async () => {
|
|
681
|
+
const catalog = await given(MENU);
|
|
682
|
+
expect(ids(await catalog.listTopSellers(8)).sort()).toEqual([
|
|
683
|
+
"caprese",
|
|
684
|
+
"salami",
|
|
685
|
+
]);
|
|
686
|
+
expect(await catalog.listTopSellers(1)).toHaveLength(1);
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
it("suggests the marked dishes and the variants of a marked parent, by name", async () => {
|
|
690
|
+
const catalog = await given(MENU);
|
|
691
|
+
const upsell = await catalog.listUpsellDishes(6);
|
|
692
|
+
expect(names(upsell)).toEqual([
|
|
693
|
+
"Insalata verde",
|
|
694
|
+
"Pizza Margherita",
|
|
695
|
+
"Pizza Margherita",
|
|
696
|
+
]);
|
|
697
|
+
expect(ids(upsell).sort()).toEqual([
|
|
698
|
+
"margherita-1-normal",
|
|
699
|
+
"margherita-2-gross",
|
|
700
|
+
"verde",
|
|
701
|
+
]);
|
|
702
|
+
expect(upsell.every((dish) => !dish.needsChoice && !dish.priceFrom)).toBe(
|
|
703
|
+
true,
|
|
704
|
+
);
|
|
705
|
+
expect(
|
|
706
|
+
upsell.find((dish) => dish.id === "margherita-2-gross"),
|
|
707
|
+
).toMatchObject({
|
|
708
|
+
number: "21-groß",
|
|
709
|
+
price: EUR(1000),
|
|
710
|
+
});
|
|
711
|
+
expect(await catalog.listUpsellDishes(1)).toHaveLength(1);
|
|
712
|
+
});
|
|
713
|
+
},
|
|
714
|
+
);
|