create-tanqory-theme 0.0.0-stage → 0.2.3
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/LICENSE +21 -0
- package/README.md +55 -2
- package/bin/create-tanqory-theme.mjs +13 -0
- package/lib/agents.mjs +118 -0
- package/lib/create.mjs +245 -0
- package/package.json +39 -4
- package/templates/blank/README.md +13 -0
- package/templates/blank/config/settings.json +3 -0
- package/templates/blank/locales/en.json +22 -0
- package/templates/blank/locales/th.json +22 -0
- package/templates/blank/package.json +34 -0
- package/templates/blank/regions/footer.json +35 -0
- package/templates/blank/regions/header.json +13 -0
- package/templates/blank/scripts/build.mjs +193 -0
- package/templates/blank/scripts/probe.ts +4 -0
- package/templates/blank/src/bundle.ts +15 -0
- package/templates/blank/src/components/parts.tsx +32 -0
- package/templates/blank/src/entry.client.tsx +6 -0
- package/templates/blank/src/entry.server.tsx +13 -0
- package/templates/blank/src/sections/chrome.tsx +132 -0
- package/templates/blank/src/sections/commerce.tsx +242 -0
- package/templates/blank/src/sections/content.tsx +111 -0
- package/templates/blank/src/sections/editorial.tsx +107 -0
- package/templates/blank/src/settings.ts +15 -0
- package/templates/blank/src/styles/theme.css +195 -0
- package/templates/blank/src/templates.ts +14 -0
- package/templates/blank/src/theme.tsx +76 -0
- package/templates/blank/template.json +24 -0
- package/templates/blank/templates/404.json +14 -0
- package/templates/blank/templates/account.json +14 -0
- package/templates/blank/templates/article.json +14 -0
- package/templates/blank/templates/blog.json +14 -0
- package/templates/blank/templates/cart.json +14 -0
- package/templates/blank/templates/collection.json +14 -0
- package/templates/blank/templates/index.json +36 -0
- package/templates/blank/templates/page.contact.json +18 -0
- package/templates/blank/templates/page.json +14 -0
- package/templates/blank/templates/product.json +18 -0
- package/templates/blank/templates/search.json +14 -0
- package/templates/blank/tests/theme.test.ts +49 -0
- package/templates/blank/tsconfig.json +17 -0
- package/templates/blank/vite.client.config.ts +17 -0
- package/templates/blank/vite.probe.config.ts +16 -0
- package/templates/blank/vite.server.config.ts +32 -0
- package/templates/blank/vitest.config.ts +9 -0
- package/templates/common/.claude/settings.json +8 -0
- package/templates/common/.codex/config.toml +4 -0
- package/templates/common/.gemini/settings.json +12 -0
- package/templates/common/.github/workflows/theme-check.yml +44 -0
- package/templates/common/.mcp.json +12 -0
- package/templates/common/.vscode/mcp.json +9 -0
- package/templates/common/_gitignore +9 -0
- package/templates/common/scripts/check.mjs +44 -0
- package/templates/common/scripts/dev.mjs +30 -0
- package/templates/common/tanqory.config.json +6 -0
- package/templates/nova/.gitattributes +3 -0
- package/templates/nova/.tanqory/contracts/LOCK.json +66 -0
- package/templates/nova/.tanqory/contracts/nova-01.json +1092 -0
- package/templates/nova/.tanqory/contracts/nova-12A.json +2674 -0
- package/templates/nova/.tanqory/contracts/nova-12B.json +2285 -0
- package/templates/nova/.tanqory/contracts/nova-12C.json +2848 -0
- package/templates/nova/.tanqory/contracts/nova-12D.json +3039 -0
- package/templates/nova/.tanqory/contracts/nova-12E.json +1473 -0
- package/templates/nova/.tanqory/contracts/nova-12F.json +1670 -0
- package/templates/nova/.tanqory/contracts/nova-12G.json +1661 -0
- package/templates/nova/.tanqory/contracts/nova-13.json +301 -0
- package/templates/nova/.tanqory/contracts/nova-14.json +172 -0
- package/templates/nova/.tanqory/legacy-settings.json +1121 -0
- package/templates/nova/README.md +150 -0
- package/templates/nova/_gitignore +28 -0
- package/templates/nova/assets/ai-tokens.css +6 -0
- package/templates/nova/assets/starter/starter-art-1200x800-0b773ac4.svg +1 -0
- package/templates/nova/assets/starter/starter-art-1200x900-59600290.svg +1 -0
- package/templates/nova/assets/starter/starter-art-1200x900-c549d496.svg +1 -0
- package/templates/nova/assets/starter/starter-art-1600x900-8f979fcb.svg +1 -0
- package/templates/nova/assets/starter/starter-art-2100x900-cbb71bfd.svg +1 -0
- package/templates/nova/config/legacy-settings.json +438 -0
- package/templates/nova/config/promotion-popup.schema.ts +29 -0
- package/templates/nova/config/settings.json +23 -0
- package/templates/nova/config/settings.schema.ts +231 -0
- package/templates/nova/entry.abi.tsx +27 -0
- package/templates/nova/groups/footer.json +39 -0
- package/templates/nova/groups/header.json +11 -0
- package/templates/nova/lib/abi/abi.css +41 -0
- package/templates/nova/lib/bundle-core.ts +35 -0
- package/templates/nova/lib/bundle.client.ts +15 -0
- package/templates/nova/lib/bundle.ts +15 -0
- package/templates/nova/lib/legacy-settings.ts +104 -0
- package/templates/nova/locales/ar.json +590 -0
- package/templates/nova/locales/en.json +590 -0
- package/templates/nova/locales/th.json +590 -0
- package/templates/nova/main.abi.tsx +12 -0
- package/templates/nova/package.json +44 -0
- package/templates/nova/scripts/abi/build.mjs +145 -0
- package/templates/nova/scripts/abi/check-content.mjs +99 -0
- package/templates/nova/scripts/abi/jcs.mjs +27 -0
- package/templates/nova/scripts/abi/local-host.mjs +294 -0
- package/templates/nova/scripts/abi/manifest.mjs +392 -0
- package/templates/nova/scripts/abi/starter-assets.mjs +32 -0
- package/templates/nova/scripts/compiler/checks/check-a11y.mjs +88 -0
- package/templates/nova/scripts/compiler/checks/check-layout-sanity.mjs +169 -0
- package/templates/nova/scripts/compiler/checks/check-page-headings.mjs +67 -0
- package/templates/nova/scripts/compiler/checks/check-product-jsonld.mjs +80 -0
- package/templates/nova/scripts/compiler/checks/theme-spec/check.mjs +88 -0
- package/templates/nova/scripts/compiler/contracts/extract.mjs +188 -0
- package/templates/nova/scripts/compiler/contracts/index.ts +125 -0
- package/templates/nova/scripts/compiler/contracts/validate.ts +347 -0
- package/templates/nova/scripts/compiler/manifest/gen-manifest.mjs +156 -0
- package/templates/nova/scripts/compiler/manifest/manifest-entry.ts +386 -0
- package/templates/nova/scripts/compiler/manifest/manifest-sections.ts +247 -0
- package/templates/nova/scripts/compiler/migrate/migrate-content.mjs +171 -0
- package/templates/nova/scripts/compiler/migrate/migrate-groups.mjs +159 -0
- package/templates/nova/scripts/parity/case-shim.ts +14 -0
- package/templates/nova/scripts/parity/emit.ts +206 -0
- package/templates/nova/scripts/parity/index.html +12 -0
- package/templates/nova/scripts/parity/main.tsx +23 -0
- package/templates/nova/scripts/parity/pages.tsx +123 -0
- package/templates/nova/scripts/parity/vite.config.ts +29 -0
- package/templates/nova/src/components/base/Accordion.css +20 -0
- package/templates/nova/src/components/base/Accordion.tsx +50 -0
- package/templates/nova/src/components/base/Badge.css +17 -0
- package/templates/nova/src/components/base/Badge.tsx +26 -0
- package/templates/nova/src/components/base/Button.css +73 -0
- package/templates/nova/src/components/base/Button.tsx +64 -0
- package/templates/nova/src/components/base/Checkbox.tsx +18 -0
- package/templates/nova/src/components/base/Chip.css +20 -0
- package/templates/nova/src/components/base/Chip.tsx +33 -0
- package/templates/nova/src/components/base/Divider.css +6 -0
- package/templates/nova/src/components/base/Divider.tsx +28 -0
- package/templates/nova/src/components/base/IconButton.css +34 -0
- package/templates/nova/src/components/base/IconButton.tsx +41 -0
- package/templates/nova/src/components/base/Input.css +21 -0
- package/templates/nova/src/components/base/Input.tsx +24 -0
- package/templates/nova/src/components/base/Link.css +15 -0
- package/templates/nova/src/components/base/Link.tsx +23 -0
- package/templates/nova/src/components/base/Radio.tsx +13 -0
- package/templates/nova/src/components/base/Select.css +18 -0
- package/templates/nova/src/components/base/Select.tsx +34 -0
- package/templates/nova/src/components/base/Skeleton.css +17 -0
- package/templates/nova/src/components/base/Skeleton.tsx +23 -0
- package/templates/nova/src/components/base/Spinner.css +13 -0
- package/templates/nova/src/components/base/Spinner.tsx +8 -0
- package/templates/nova/src/components/base/Switch.tsx +16 -0
- package/templates/nova/src/components/base/Tabs.css +24 -0
- package/templates/nova/src/components/base/Tabs.tsx +61 -0
- package/templates/nova/src/components/base/Textarea.css +1 -0
- package/templates/nova/src/components/base/Textarea.tsx +8 -0
- package/templates/nova/src/components/base/choice-props.ts +9 -0
- package/templates/nova/src/components/base/choice.css +69 -0
- package/templates/nova/src/components/commerce/AddToCart.css +4 -0
- package/templates/nova/src/components/commerce/AddToCart.tsx +77 -0
- package/templates/nova/src/components/commerce/CartLine.css +26 -0
- package/templates/nova/src/components/commerce/CartLine.tsx +82 -0
- package/templates/nova/src/components/commerce/CartSummary.css +23 -0
- package/templates/nova/src/components/commerce/CartSummary.tsx +120 -0
- package/templates/nova/src/components/commerce/CollectionCard.css +66 -0
- package/templates/nova/src/components/commerce/CollectionCard.tsx +57 -0
- package/templates/nova/src/components/commerce/ComparisonTable.css +33 -0
- package/templates/nova/src/components/commerce/ComparisonTable.tsx +113 -0
- package/templates/nova/src/components/commerce/EarnHint.css +3 -0
- package/templates/nova/src/components/commerce/EarnHint.tsx +31 -0
- package/templates/nova/src/components/commerce/Hotspot.css +16 -0
- package/templates/nova/src/components/commerce/Hotspot.tsx +64 -0
- package/templates/nova/src/components/commerce/ListingParts.css +79 -0
- package/templates/nova/src/components/commerce/ListingParts.tsx +211 -0
- package/templates/nova/src/components/commerce/LookItem.css +19 -0
- package/templates/nova/src/components/commerce/LookItem.tsx +41 -0
- package/templates/nova/src/components/commerce/MiniCartLine.css +20 -0
- package/templates/nova/src/components/commerce/MiniCartLine.tsx +93 -0
- package/templates/nova/src/components/commerce/PaymentMark.css +2 -0
- package/templates/nova/src/components/commerce/PaymentMark.tsx +55 -0
- package/templates/nova/src/components/commerce/Price.css +27 -0
- package/templates/nova/src/components/commerce/Price.tsx +55 -0
- package/templates/nova/src/components/commerce/ProductCard.css +66 -0
- package/templates/nova/src/components/commerce/ProductCard.tsx +117 -0
- package/templates/nova/src/components/commerce/ProductGallery.css +72 -0
- package/templates/nova/src/components/commerce/ProductGallery.tsx +98 -0
- package/templates/nova/src/components/commerce/QuantitySelector.css +23 -0
- package/templates/nova/src/components/commerce/QuantitySelector.tsx +45 -0
- package/templates/nova/src/components/commerce/Reviews.css +34 -0
- package/templates/nova/src/components/commerce/Reviews.tsx +112 -0
- package/templates/nova/src/components/commerce/Stars.css +7 -0
- package/templates/nova/src/components/commerce/Stars.tsx +38 -0
- package/templates/nova/src/components/commerce/VariantPicker.css +31 -0
- package/templates/nova/src/components/commerce/VariantPicker.tsx +122 -0
- package/templates/nova/src/components/commerce/blocks/Badge.css +6 -0
- package/templates/nova/src/components/commerce/blocks/Badge.tsx +33 -0
- package/templates/nova/src/components/commerce/blocks/PaymentIcons.tsx +43 -0
- package/templates/nova/src/components/commerce/blocks/Swatches.tsx +17 -0
- package/templates/nova/src/components/commerce/blocks/payment.css +2 -0
- package/templates/nova/src/components/commerce/cart-limit.ts +11 -0
- package/templates/nova/src/components/commerce/money.ts +34 -0
- package/templates/nova/src/components/commerce/swatch.ts +54 -0
- package/templates/nova/src/components/content/ArticleCard.css +22 -0
- package/templates/nova/src/components/content/ArticleCard.tsx +53 -0
- package/templates/nova/src/components/content/BeforeAfterSlider.css +38 -0
- package/templates/nova/src/components/content/BeforeAfterSlider.tsx +87 -0
- package/templates/nova/src/components/content/CardRow.css +80 -0
- package/templates/nova/src/components/content/CardRow.tsx +140 -0
- package/templates/nova/src/components/content/CarouselControls.css +61 -0
- package/templates/nova/src/components/content/CarouselControls.tsx +90 -0
- package/templates/nova/src/components/content/ContentsNav.css +16 -0
- package/templates/nova/src/components/content/ContentsNav.tsx +55 -0
- package/templates/nova/src/components/content/Countdown.css +24 -0
- package/templates/nova/src/components/content/Countdown.tsx +115 -0
- package/templates/nova/src/components/content/HeroCopy.css +92 -0
- package/templates/nova/src/components/content/HeroCopy.tsx +148 -0
- package/templates/nova/src/components/content/HeroFrame.css +75 -0
- package/templates/nova/src/components/content/HeroFrame.tsx +49 -0
- package/templates/nova/src/components/content/HeroMedia.css +40 -0
- package/templates/nova/src/components/content/HeroMedia.tsx +170 -0
- package/templates/nova/src/components/content/LongForm.css +40 -0
- package/templates/nova/src/components/content/LongForm.tsx +56 -0
- package/templates/nova/src/components/content/MediaFrame.css +5 -0
- package/templates/nova/src/components/content/MediaFrame.tsx +52 -0
- package/templates/nova/src/components/content/RichText.tsx +30 -0
- package/templates/nova/src/components/content/SectionHead.css +8 -0
- package/templates/nova/src/components/content/SectionHead.tsx +34 -0
- package/templates/nova/src/components/content/ShareButtons.css +2 -0
- package/templates/nova/src/components/content/ShareButtons.tsx +40 -0
- package/templates/nova/src/components/content/StoreCard.css +14 -0
- package/templates/nova/src/components/content/StoreCard.tsx +60 -0
- package/templates/nova/src/components/content/TestimonialCard.css +36 -0
- package/templates/nova/src/components/content/TestimonialCard.tsx +102 -0
- package/templates/nova/src/components/content/UgcTile.css +8 -0
- package/templates/nova/src/components/content/UgcTile.tsx +33 -0
- package/templates/nova/src/components/content/blocks/Button.tsx +36 -0
- package/templates/nova/src/components/content/blocks/Column.tsx +30 -0
- package/templates/nova/src/components/content/blocks/Heading.tsx +31 -0
- package/templates/nova/src/components/content/blocks/Icon.tsx +25 -0
- package/templates/nova/src/components/content/blocks/Image.tsx +42 -0
- package/templates/nova/src/components/content/blocks/Text.tsx +26 -0
- package/templates/nova/src/components/content/blocks/Video.tsx +44 -0
- package/templates/nova/src/components/content/blocks/content.css +25 -0
- package/templates/nova/src/components/content/blocks/shared.ts +5 -0
- package/templates/nova/src/components/forms/ContactForm.css +19 -0
- package/templates/nova/src/components/forms/ContactForm.tsx +139 -0
- package/templates/nova/src/components/forms/FormField.css +15 -0
- package/templates/nova/src/components/forms/FormField.tsx +77 -0
- package/templates/nova/src/components/forms/GatewayFields.tsx +79 -0
- package/templates/nova/src/components/forms/NewsletterForm.css +9 -0
- package/templates/nova/src/components/forms/NewsletterForm.tsx +141 -0
- package/templates/nova/src/components/forms/SearchField.css +7 -0
- package/templates/nova/src/components/forms/SearchField.tsx +68 -0
- package/templates/nova/src/components/forms/blocks/Newsletter.css +5 -0
- package/templates/nova/src/components/forms/blocks/Newsletter.tsx +71 -0
- package/templates/nova/src/components/forms/validate.ts +4 -0
- package/templates/nova/src/components/listing/ProductListing.tsx +200 -0
- package/templates/nova/src/components/navigation/BrandLogo.tsx +35 -0
- package/templates/nova/src/components/navigation/Breadcrumb.css +16 -0
- package/templates/nova/src/components/navigation/Breadcrumb.tsx +59 -0
- package/templates/nova/src/components/navigation/LineAddFriend.css +5 -0
- package/templates/nova/src/components/navigation/LineAddFriend.tsx +42 -0
- package/templates/nova/src/components/navigation/LocaleSelector.css +33 -0
- package/templates/nova/src/components/navigation/LocaleSelector.tsx +64 -0
- package/templates/nova/src/components/navigation/Menu.tsx +26 -0
- package/templates/nova/src/components/navigation/Pagination.css +24 -0
- package/templates/nova/src/components/navigation/Pagination.tsx +74 -0
- package/templates/nova/src/components/navigation/RecoveryLinks.css +8 -0
- package/templates/nova/src/components/navigation/RecoveryLinks.tsx +23 -0
- package/templates/nova/src/components/navigation/SocialLinks.css +5 -0
- package/templates/nova/src/components/navigation/SocialLinks.tsx +51 -0
- package/templates/nova/src/components/navigation/blocks/SocialLinks.tsx +23 -0
- package/templates/nova/src/components/overlays/AccountMenu.css +11 -0
- package/templates/nova/src/components/overlays/AccountMenu.tsx +91 -0
- package/templates/nova/src/components/overlays/CartDrawer.css +17 -0
- package/templates/nova/src/components/overlays/CartDrawer.tsx +118 -0
- package/templates/nova/src/components/overlays/ConfirmationDialog.tsx +49 -0
- package/templates/nova/src/components/overlays/CookieConsent.css +56 -0
- package/templates/nova/src/components/overlays/CookieConsent.tsx +170 -0
- package/templates/nova/src/components/overlays/Drawer.css +38 -0
- package/templates/nova/src/components/overlays/Drawer.tsx +66 -0
- package/templates/nova/src/components/overlays/FriendOfferPanel.tsx +79 -0
- package/templates/nova/src/components/overlays/MarketSelector.css +111 -0
- package/templates/nova/src/components/overlays/MarketSelector.tsx +450 -0
- package/templates/nova/src/components/overlays/Menu.css +9 -0
- package/templates/nova/src/components/overlays/Menu.tsx +124 -0
- package/templates/nova/src/components/overlays/MobileNavDrawer.css +28 -0
- package/templates/nova/src/components/overlays/MobileNavDrawer.tsx +166 -0
- package/templates/nova/src/components/overlays/Modal.css +52 -0
- package/templates/nova/src/components/overlays/Modal.tsx +88 -0
- package/templates/nova/src/components/overlays/Popover.css +4 -0
- package/templates/nova/src/components/overlays/Popover.tsx +115 -0
- package/templates/nova/src/components/overlays/ProductLightbox.css +20 -0
- package/templates/nova/src/components/overlays/ProductLightbox.tsx +70 -0
- package/templates/nova/src/components/overlays/PromoPopup.css +32 -0
- package/templates/nova/src/components/overlays/PromoPopup.tsx +198 -0
- package/templates/nova/src/components/overlays/QuickView.css +31 -0
- package/templates/nova/src/components/overlays/QuickView.tsx +127 -0
- package/templates/nova/src/components/overlays/ReferralPanel.css +16 -0
- package/templates/nova/src/components/overlays/ReferralPanel.tsx +138 -0
- package/templates/nova/src/components/overlays/RewardsLauncher.css +22 -0
- package/templates/nova/src/components/overlays/RewardsLauncher.tsx +270 -0
- package/templates/nova/src/components/overlays/SearchModal.css +48 -0
- package/templates/nova/src/components/overlays/SearchModal.tsx +302 -0
- package/templates/nova/src/components/overlays/Sheet.css +16 -0
- package/templates/nova/src/components/overlays/Sheet.tsx +48 -0
- package/templates/nova/src/components/overlays/SizeGuide.css +8 -0
- package/templates/nova/src/components/overlays/SizeGuide.tsx +74 -0
- package/templates/nova/src/components/overlays/Toast.css +20 -0
- package/templates/nova/src/components/overlays/Toast.tsx +164 -0
- package/templates/nova/src/components/overlays/Tooltip.css +6 -0
- package/templates/nova/src/components/overlays/Tooltip.tsx +59 -0
- package/templates/nova/src/components/overlays/use-dialog.ts +74 -0
- package/templates/nova/src/components/section/shared.css +42 -0
- package/templates/nova/src/components/section/shared.ts +120 -0
- package/templates/nova/src/components/section/shell.tsx +29 -0
- package/templates/nova/src/components/states/Alert.css +10 -0
- package/templates/nova/src/components/states/Alert.tsx +50 -0
- package/templates/nova/src/components/states/EditorFrame.css +31 -0
- package/templates/nova/src/components/states/EditorFrame.tsx +43 -0
- package/templates/nova/src/components/states/MediaState.css +1 -0
- package/templates/nova/src/components/states/MediaState.tsx +49 -0
- package/templates/nova/src/components/states/OfflineNotice.css +4 -0
- package/templates/nova/src/components/states/OfflineNotice.tsx +24 -0
- package/templates/nova/src/components/states/SkeletonLayout.css +22 -0
- package/templates/nova/src/components/states/SkeletonLayout.tsx +104 -0
- package/templates/nova/src/components/states/StateBlock.css +22 -0
- package/templates/nova/src/components/states/StateBlock.tsx +39 -0
- package/templates/nova/src/components/states/media/MediaError.css +6 -0
- package/templates/nova/src/components/states/media/MediaError.tsx +49 -0
- package/templates/nova/src/components/states/media/MediaPlaceholder.css +24 -0
- package/templates/nova/src/components/states/media/MediaPlaceholder.tsx +101 -0
- package/templates/nova/src/components/states/media/placeholder-art.ts +142 -0
- package/templates/nova/src/layouts/Main.tsx +80 -0
- package/templates/nova/src/sections/Account/Account.tsx +109 -0
- package/templates/nova/src/sections/Account/index.ts +22 -0
- package/templates/nova/src/sections/Account/presets.ts +6 -0
- package/templates/nova/src/sections/Account/schema.ts +29 -0
- package/templates/nova/src/sections/AnnouncementBar/AnnouncementBar.css +37 -0
- package/templates/nova/src/sections/AnnouncementBar/AnnouncementBar.tsx +151 -0
- package/templates/nova/src/sections/AnnouncementBar/index.ts +20 -0
- package/templates/nova/src/sections/AnnouncementBar/presets.ts +10 -0
- package/templates/nova/src/sections/AnnouncementBar/schema.ts +26 -0
- package/templates/nova/src/sections/ArticleBody/ArticleBody.tsx +129 -0
- package/templates/nova/src/sections/ArticleBody/index.ts +21 -0
- package/templates/nova/src/sections/ArticleBody/presets.ts +10 -0
- package/templates/nova/src/sections/ArticleBody/schema.ts +40 -0
- package/templates/nova/src/sections/BeforeAfter/BeforeAfter.tsx +47 -0
- package/templates/nova/src/sections/BeforeAfter/blocks/Comparison.tsx +20 -0
- package/templates/nova/src/sections/BeforeAfter/index.ts +28 -0
- package/templates/nova/src/sections/BeforeAfter/presets.ts +10 -0
- package/templates/nova/src/sections/BeforeAfter/schema.ts +34 -0
- package/templates/nova/src/sections/BlogPosts/BlogPosts.tsx +106 -0
- package/templates/nova/src/sections/BlogPosts/index.ts +30 -0
- package/templates/nova/src/sections/BlogPosts/presets.ts +10 -0
- package/templates/nova/src/sections/BlogPosts/schema.ts +42 -0
- package/templates/nova/src/sections/Breadcrumbs/Breadcrumbs.css +10 -0
- package/templates/nova/src/sections/Breadcrumbs/Breadcrumbs.tsx +41 -0
- package/templates/nova/src/sections/Breadcrumbs/index.ts +20 -0
- package/templates/nova/src/sections/Breadcrumbs/presets.ts +6 -0
- package/templates/nova/src/sections/Breadcrumbs/schema.ts +24 -0
- package/templates/nova/src/sections/CartItems/CartItems.tsx +170 -0
- package/templates/nova/src/sections/CartItems/blocks/CartBadge.tsx +14 -0
- package/templates/nova/src/sections/CartItems/index.ts +37 -0
- package/templates/nova/src/sections/CartItems/presets.ts +8 -0
- package/templates/nova/src/sections/CartItems/schema.ts +34 -0
- package/templates/nova/src/sections/CollectionBanner/CollectionBanner.tsx +120 -0
- package/templates/nova/src/sections/CollectionBanner/index.ts +25 -0
- package/templates/nova/src/sections/CollectionBanner/presets.ts +10 -0
- package/templates/nova/src/sections/CollectionBanner/schema.ts +37 -0
- package/templates/nova/src/sections/CollectionLinks/CollectionLinks.tsx +47 -0
- package/templates/nova/src/sections/CollectionLinks/index.ts +20 -0
- package/templates/nova/src/sections/CollectionLinks/presets.ts +8 -0
- package/templates/nova/src/sections/CollectionLinks/schema.ts +33 -0
- package/templates/nova/src/sections/CollectionList/CollectionList.tsx +89 -0
- package/templates/nova/src/sections/CollectionList/blocks/CollectionItem.tsx +25 -0
- package/templates/nova/src/sections/CollectionList/index.ts +33 -0
- package/templates/nova/src/sections/CollectionList/presets.ts +10 -0
- package/templates/nova/src/sections/CollectionList/schema.ts +41 -0
- package/templates/nova/src/sections/ComparisonTable/ComparisonTable.tsx +52 -0
- package/templates/nova/src/sections/ComparisonTable/blocks/CompareItem.tsx +26 -0
- package/templates/nova/src/sections/ComparisonTable/index.ts +31 -0
- package/templates/nova/src/sections/ComparisonTable/presets.ts +8 -0
- package/templates/nova/src/sections/ComparisonTable/schema.ts +31 -0
- package/templates/nova/src/sections/ContactForm/ContactForm.tsx +83 -0
- package/templates/nova/src/sections/ContactForm/blocks/ContactDetail.tsx +13 -0
- package/templates/nova/src/sections/ContactForm/index.ts +29 -0
- package/templates/nova/src/sections/ContactForm/presets.ts +8 -0
- package/templates/nova/src/sections/ContactForm/schema.ts +34 -0
- package/templates/nova/src/sections/Divider/Divider.css +17 -0
- package/templates/nova/src/sections/Divider/Divider.tsx +21 -0
- package/templates/nova/src/sections/Divider/index.ts +20 -0
- package/templates/nova/src/sections/Divider/presets.ts +10 -0
- package/templates/nova/src/sections/Divider/schema.ts +24 -0
- package/templates/nova/src/sections/Faq/Faq.tsx +51 -0
- package/templates/nova/src/sections/Faq/blocks/FaqItem.tsx +13 -0
- package/templates/nova/src/sections/Faq/index.ts +28 -0
- package/templates/nova/src/sections/Faq/presets.ts +8 -0
- package/templates/nova/src/sections/Faq/schema.ts +32 -0
- package/templates/nova/src/sections/FeatureGridBlocks/FeatureGridBlocks.tsx +90 -0
- package/templates/nova/src/sections/FeatureGridBlocks/index.ts +35 -0
- package/templates/nova/src/sections/FeatureGridBlocks/presets.ts +8 -0
- package/templates/nova/src/sections/FeatureGridBlocks/schema.ts +35 -0
- package/templates/nova/src/sections/FeatureHighlights/FeatureHighlights.tsx +56 -0
- package/templates/nova/src/sections/FeatureHighlights/index.ts +20 -0
- package/templates/nova/src/sections/FeatureHighlights/presets.ts +6 -0
- package/templates/nova/src/sections/FeatureHighlights/schema.ts +27 -0
- package/templates/nova/src/sections/FeaturedCollection/FeaturedCollection.tsx +67 -0
- package/templates/nova/src/sections/FeaturedCollection/index.ts +21 -0
- package/templates/nova/src/sections/FeaturedCollection/presets.ts +10 -0
- package/templates/nova/src/sections/FeaturedCollection/schema.ts +39 -0
- package/templates/nova/src/sections/FeaturedProduct/FeaturedProduct.tsx +107 -0
- package/templates/nova/src/sections/FeaturedProduct/index.ts +23 -0
- package/templates/nova/src/sections/FeaturedProduct/presets.ts +8 -0
- package/templates/nova/src/sections/FeaturedProduct/schema.ts +35 -0
- package/templates/nova/src/sections/Footer/Footer.css +81 -0
- package/templates/nova/src/sections/Footer/Footer.tsx +256 -0
- package/templates/nova/src/sections/Footer/blocks/FooterBrand.tsx +40 -0
- package/templates/nova/src/sections/Footer/blocks/FooterLine.tsx +11 -0
- package/templates/nova/src/sections/Footer/blocks/FooterMenu.tsx +14 -0
- package/templates/nova/src/sections/Footer/blocks/FooterText.tsx +8 -0
- package/templates/nova/src/sections/Footer/blocks/footer.css +7 -0
- package/templates/nova/src/sections/Footer/index.ts +38 -0
- package/templates/nova/src/sections/Footer/presets.ts +10 -0
- package/templates/nova/src/sections/Footer/schema.ts +27 -0
- package/templates/nova/src/sections/Group/Group.css +59 -0
- package/templates/nova/src/sections/Group/Group.tsx +167 -0
- package/templates/nova/src/sections/Group/blocks/Accordion.tsx +26 -0
- package/templates/nova/src/sections/Group/blocks/JumboText.tsx +20 -0
- package/templates/nova/src/sections/Group/blocks/Spacer.tsx +16 -0
- package/templates/nova/src/sections/Group/index.ts +36 -0
- package/templates/nova/src/sections/Group/presets.ts +12 -0
- package/templates/nova/src/sections/Group/schema.ts +35 -0
- package/templates/nova/src/sections/Header/Header.css +185 -0
- package/templates/nova/src/sections/Header/Header.tsx +478 -0
- package/templates/nova/src/sections/Header/index.ts +32 -0
- package/templates/nova/src/sections/Header/presets.ts +10 -0
- package/templates/nova/src/sections/Header/schema.ts +32 -0
- package/templates/nova/src/sections/Hero/Hero.tsx +128 -0
- package/templates/nova/src/sections/Hero/index.ts +24 -0
- package/templates/nova/src/sections/Hero/presets.ts +16 -0
- package/templates/nova/src/sections/Hero/schema.ts +56 -0
- package/templates/nova/src/sections/ImageGallery/ImageGallery.tsx +86 -0
- package/templates/nova/src/sections/ImageGallery/index.ts +28 -0
- package/templates/nova/src/sections/ImageGallery/presets.ts +10 -0
- package/templates/nova/src/sections/ImageGallery/schema.ts +34 -0
- package/templates/nova/src/sections/ImageWithText/ImageWithText.tsx +62 -0
- package/templates/nova/src/sections/ImageWithText/index.ts +23 -0
- package/templates/nova/src/sections/ImageWithText/presets.ts +12 -0
- package/templates/nova/src/sections/ImageWithText/schema.ts +45 -0
- package/templates/nova/src/sections/LineAddFriend/LineAddFriend.tsx +25 -0
- package/templates/nova/src/sections/LineAddFriend/index.ts +20 -0
- package/templates/nova/src/sections/LineAddFriend/presets.ts +3 -0
- package/templates/nova/src/sections/LineAddFriend/schema.ts +25 -0
- package/templates/nova/src/sections/LogoList/LogoList.tsx +40 -0
- package/templates/nova/src/sections/LogoList/blocks/Logo.tsx +18 -0
- package/templates/nova/src/sections/LogoList/index.ts +29 -0
- package/templates/nova/src/sections/LogoList/presets.ts +8 -0
- package/templates/nova/src/sections/LogoList/schema.ts +29 -0
- package/templates/nova/src/sections/MainCollection/MainCollection.tsx +51 -0
- package/templates/nova/src/sections/MainCollection/index.ts +26 -0
- package/templates/nova/src/sections/MainCollection/presets.ts +10 -0
- package/templates/nova/src/sections/MainCollection/schema.ts +29 -0
- package/templates/nova/src/sections/Marquee/Marquee.tsx +114 -0
- package/templates/nova/src/sections/Marquee/index.ts +20 -0
- package/templates/nova/src/sections/Marquee/presets.ts +10 -0
- package/templates/nova/src/sections/Marquee/schema.ts +23 -0
- package/templates/nova/src/sections/Multicolumn/Multicolumn.tsx +56 -0
- package/templates/nova/src/sections/Multicolumn/index.ts +25 -0
- package/templates/nova/src/sections/Multicolumn/presets.ts +8 -0
- package/templates/nova/src/sections/Multicolumn/schema.ts +34 -0
- package/templates/nova/src/sections/Newsletter/Newsletter.tsx +64 -0
- package/templates/nova/src/sections/Newsletter/index.ts +20 -0
- package/templates/nova/src/sections/Newsletter/presets.ts +10 -0
- package/templates/nova/src/sections/Newsletter/schema.ts +36 -0
- package/templates/nova/src/sections/NotFound/NotFound.tsx +41 -0
- package/templates/nova/src/sections/NotFound/index.ts +20 -0
- package/templates/nova/src/sections/NotFound/presets.ts +6 -0
- package/templates/nova/src/sections/NotFound/schema.ts +30 -0
- package/templates/nova/src/sections/PageBody/PageBody.tsx +35 -0
- package/templates/nova/src/sections/PageBody/index.ts +21 -0
- package/templates/nova/src/sections/PageBody/presets.ts +6 -0
- package/templates/nova/src/sections/PageBody/schema.ts +29 -0
- package/templates/nova/src/sections/PolicyPage/PolicyPage.tsx +62 -0
- package/templates/nova/src/sections/PolicyPage/index.ts +23 -0
- package/templates/nova/src/sections/PolicyPage/presets.ts +6 -0
- package/templates/nova/src/sections/PolicyPage/schema.ts +27 -0
- package/templates/nova/src/sections/ProductDetails/ProductDetails.tsx +269 -0
- package/templates/nova/src/sections/ProductDetails/blocks/AddToCartBlock.tsx +15 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductDescription.tsx +15 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductInventory.tsx +38 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductPrice.tsx +19 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductSku.tsx +15 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductTitle.tsx +17 -0
- package/templates/nova/src/sections/ProductDetails/blocks/Quantity.tsx +14 -0
- package/templates/nova/src/sections/ProductDetails/blocks/Tab.tsx +23 -0
- package/templates/nova/src/sections/ProductDetails/blocks/VariantPickerBlock.tsx +44 -0
- package/templates/nova/src/sections/ProductDetails/blocks/commerce-blocks.css +13 -0
- package/templates/nova/src/sections/ProductDetails/index.ts +44 -0
- package/templates/nova/src/sections/ProductDetails/presets.ts +10 -0
- package/templates/nova/src/sections/ProductDetails/schema.ts +44 -0
- package/templates/nova/src/sections/ProductGrid/ProductGrid.tsx +38 -0
- package/templates/nova/src/sections/ProductGrid/index.ts +25 -0
- package/templates/nova/src/sections/ProductGrid/presets.ts +6 -0
- package/templates/nova/src/sections/ProductGrid/schema.ts +37 -0
- package/templates/nova/src/sections/ProductRecommendations/ProductRecommendations.tsx +45 -0
- package/templates/nova/src/sections/ProductRecommendations/index.ts +20 -0
- package/templates/nova/src/sections/ProductRecommendations/presets.ts +8 -0
- package/templates/nova/src/sections/ProductRecommendations/schema.ts +28 -0
- package/templates/nova/src/sections/ProductReviews/ProductReviews.tsx +136 -0
- package/templates/nova/src/sections/ProductReviews/index.ts +22 -0
- package/templates/nova/src/sections/ProductReviews/presets.ts +6 -0
- package/templates/nova/src/sections/ProductReviews/schema.ts +31 -0
- package/templates/nova/src/sections/PromoBanner/PromoBanner.tsx +78 -0
- package/templates/nova/src/sections/PromoBanner/index.ts +20 -0
- package/templates/nova/src/sections/PromoBanner/presets.ts +10 -0
- package/templates/nova/src/sections/PromoBanner/schema.ts +38 -0
- package/templates/nova/src/sections/RecentlyViewed/RecentlyViewed.tsx +53 -0
- package/templates/nova/src/sections/RecentlyViewed/index.ts +20 -0
- package/templates/nova/src/sections/RecentlyViewed/presets.ts +6 -0
- package/templates/nova/src/sections/RecentlyViewed/schema.ts +26 -0
- package/templates/nova/src/sections/RichText/RichText.tsx +38 -0
- package/templates/nova/src/sections/RichText/index.ts +20 -0
- package/templates/nova/src/sections/RichText/presets.ts +10 -0
- package/templates/nova/src/sections/RichText/schema.ts +37 -0
- package/templates/nova/src/sections/SearchResults/SearchResults.tsx +112 -0
- package/templates/nova/src/sections/SearchResults/index.ts +26 -0
- package/templates/nova/src/sections/SearchResults/presets.ts +8 -0
- package/templates/nova/src/sections/SearchResults/schema.ts +30 -0
- package/templates/nova/src/sections/ShopTheLook/ShopTheLook.tsx +112 -0
- package/templates/nova/src/sections/ShopTheLook/blocks/Hotspot.tsx +22 -0
- package/templates/nova/src/sections/ShopTheLook/index.ts +33 -0
- package/templates/nova/src/sections/ShopTheLook/presets.ts +8 -0
- package/templates/nova/src/sections/ShopTheLook/schema.ts +31 -0
- package/templates/nova/src/sections/Slideshow/Slideshow.tsx +199 -0
- package/templates/nova/src/sections/Slideshow/blocks/Slide.tsx +93 -0
- package/templates/nova/src/sections/Slideshow/index.ts +30 -0
- package/templates/nova/src/sections/Slideshow/presets.ts +10 -0
- package/templates/nova/src/sections/Slideshow/schema.ts +36 -0
- package/templates/nova/src/sections/StoreLocator/StoreLocator.tsx +66 -0
- package/templates/nova/src/sections/StoreLocator/index.ts +20 -0
- package/templates/nova/src/sections/StoreLocator/presets.ts +6 -0
- package/templates/nova/src/sections/StoreLocator/schema.ts +34 -0
- package/templates/nova/src/sections/TeamFounders/TeamFounders.tsx +74 -0
- package/templates/nova/src/sections/TeamFounders/blocks/Person.tsx +28 -0
- package/templates/nova/src/sections/TeamFounders/index.ts +28 -0
- package/templates/nova/src/sections/TeamFounders/presets.ts +10 -0
- package/templates/nova/src/sections/TeamFounders/schema.ts +36 -0
- package/templates/nova/src/sections/Testimonials/Testimonials.tsx +83 -0
- package/templates/nova/src/sections/Testimonials/blocks/Testimonial.tsx +30 -0
- package/templates/nova/src/sections/Testimonials/index.ts +29 -0
- package/templates/nova/src/sections/Testimonials/presets.ts +10 -0
- package/templates/nova/src/sections/Testimonials/schema.ts +35 -0
- package/templates/nova/src/sections/Timeline/Timeline.tsx +43 -0
- package/templates/nova/src/sections/Timeline/blocks/Step.tsx +19 -0
- package/templates/nova/src/sections/Timeline/index.ts +28 -0
- package/templates/nova/src/sections/Timeline/presets.ts +8 -0
- package/templates/nova/src/sections/Timeline/schema.ts +31 -0
- package/templates/nova/src/sections/TrustBadges/TrustBadges.tsx +42 -0
- package/templates/nova/src/sections/TrustBadges/index.ts +29 -0
- package/templates/nova/src/sections/TrustBadges/presets.ts +8 -0
- package/templates/nova/src/sections/TrustBadges/schema.ts +29 -0
- package/templates/nova/src/sections/UgcGallery/UgcGallery.tsx +58 -0
- package/templates/nova/src/sections/UgcGallery/blocks/UgcImage.tsx +27 -0
- package/templates/nova/src/sections/UgcGallery/index.ts +31 -0
- package/templates/nova/src/sections/UgcGallery/presets.ts +8 -0
- package/templates/nova/src/sections/UgcGallery/schema.ts +35 -0
- package/templates/nova/src/sections/VideoHero/VideoHero.tsx +75 -0
- package/templates/nova/src/sections/VideoHero/index.ts +22 -0
- package/templates/nova/src/sections/VideoHero/presets.ts +8 -0
- package/templates/nova/src/sections/VideoHero/schema.ts +43 -0
- package/templates/nova/src/sections/data.ts +115 -0
- package/templates/nova/src/sections/shipped-copy.ts +25 -0
- package/templates/nova/src/sections/starter.ts +49 -0
- package/templates/nova/src/styles/Container.css +6 -0
- package/templates/nova/src/styles/Container.tsx +13 -0
- package/templates/nova/src/styles/Icon.css +2 -0
- package/templates/nova/src/styles/Icon.tsx +101 -0
- package/templates/nova/src/styles/NovaProvider.tsx +91 -0
- package/templates/nova/src/styles/base.css +142 -0
- package/templates/nova/src/styles/blocks.css +6 -0
- package/templates/nova/src/styles/fonts/OFL.txt +93 -0
- package/templates/nova/src/styles/fonts/geist-cyrillic-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-cyrillic.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-latin-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-latin.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-cyrillic-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-cyrillic.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-latin-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-latin.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-vietnamese.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-vietnamese.woff2 +0 -0
- package/templates/nova/src/styles/fonts.css +95 -0
- package/templates/nova/src/styles/global-settings.css +88 -0
- package/templates/nova/src/styles/index.css +6 -0
- package/templates/nova/src/styles/motion.ts +53 -0
- package/templates/nova/src/styles/scroll.ts +24 -0
- package/templates/nova/src/styles/sections/commerce.css +147 -0
- package/templates/nova/src/styles/sections/content.css +304 -0
- package/templates/nova/src/styles/sections/editorial.css +131 -0
- package/templates/nova/src/styles/sections/promotion.css +336 -0
- package/templates/nova/src/styles/sections/trust.css +117 -0
- package/templates/nova/src/styles/sections/utility.css +190 -0
- package/templates/nova/src/styles/strings.ts +492 -0
- package/templates/nova/src/styles/text.ts +4 -0
- package/templates/nova/src/styles/theme.ts +171 -0
- package/templates/nova/src/styles/tokens.css +600 -0
- package/templates/nova/src/styles/viewport.ts +23 -0
- package/templates/nova/template.json +94 -0
- package/templates/nova/templates/404.json +30 -0
- package/templates/nova/templates/account.json +15 -0
- package/templates/nova/templates/article.json +41 -0
- package/templates/nova/templates/article.longform.json +17 -0
- package/templates/nova/templates/blog.featured.json +22 -0
- package/templates/nova/templates/blog.json +29 -0
- package/templates/nova/templates/cart.json +67 -0
- package/templates/nova/templates/collection.featured.json +43 -0
- package/templates/nova/templates/collection.json +30 -0
- package/templates/nova/templates/contact.json +65 -0
- package/templates/nova/templates/index.json +167 -0
- package/templates/nova/templates/list-collections.json +19 -0
- package/templates/nova/templates/page.about.json +134 -0
- package/templates/nova/templates/page.contact.json +27 -0
- package/templates/nova/templates/page.json +27 -0
- package/templates/nova/templates/policy.json +23 -0
- package/templates/nova/templates/product.bundle.json +145 -0
- package/templates/nova/templates/product.json +119 -0
- package/templates/nova/templates/search.json +17 -0
- package/templates/nova/tests/abi-ai-contract.test.ts +99 -0
- package/templates/nova/tests/abi-forms.test.tsx +269 -0
- package/templates/nova/tests/abi-inventory.test.tsx +197 -0
- package/templates/nova/tests/abi-legacy-settings.test.tsx +105 -0
- package/templates/nova/tests/abi-opt-in.test.tsx +100 -0
- package/templates/nova/tests/abi-parity.test.tsx +95 -0
- package/templates/nova/tests/abi-r5-store-settings.test.tsx +337 -0
- package/templates/nova/tests/abi-render.test.tsx +178 -0
- package/templates/nova/tests/abi-shop-links.test.tsx +141 -0
- package/templates/nova/tests/abi-storefront-basics.test.tsx +233 -0
- package/templates/nova/tests/abi-variant-url.test.tsx +73 -0
- package/templates/nova/tests/add-refused-no-success.test.tsx +193 -0
- package/templates/nova/tests/architecture.test.ts +63 -0
- package/templates/nova/tests/architecture.ts +160 -0
- package/templates/nova/tests/audit-guards.test.ts +31 -0
- package/templates/nova/tests/bundle-split.test.ts +29 -0
- package/templates/nova/tests/cart-limit-message.test.tsx +212 -0
- package/templates/nova/tests/cart-link-message.test.tsx +98 -0
- package/templates/nova/tests/cases/components/Overview.cases.tsx +8 -0
- package/templates/nova/tests/cases/components/base/Accordion.cases.tsx +40 -0
- package/templates/nova/tests/cases/components/base/Badge.cases.tsx +30 -0
- package/templates/nova/tests/cases/components/base/Button.cases.tsx +73 -0
- package/templates/nova/tests/cases/components/base/Checkbox.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/base/Chip.cases.tsx +37 -0
- package/templates/nova/tests/cases/components/base/Divider.cases.tsx +26 -0
- package/templates/nova/tests/cases/components/base/IconButton.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/base/Input.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/base/Link.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/base/Radio.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/base/Select.cases.tsx +26 -0
- package/templates/nova/tests/cases/components/base/Skeleton.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/base/Spinner.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/base/Switch.cases.tsx +26 -0
- package/templates/nova/tests/cases/components/base/Tabs.cases.tsx +39 -0
- package/templates/nova/tests/cases/components/base/Textarea.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/commerce/AddToCart.cases.tsx +36 -0
- package/templates/nova/tests/cases/components/commerce/CartLine.cases.tsx +20 -0
- package/templates/nova/tests/cases/components/commerce/CartSummary.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/commerce/CollectionCard.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/commerce/ComparisonTable.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/commerce/Hotspot.cases.tsx +25 -0
- package/templates/nova/tests/cases/components/commerce/LookItem.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/commerce/PaymentMark.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/commerce/Price.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/commerce/ProductCard.cases.tsx +67 -0
- package/templates/nova/tests/cases/components/commerce/ProductGallery.cases.tsx +39 -0
- package/templates/nova/tests/cases/components/commerce/QuantitySelector.cases.tsx +31 -0
- package/templates/nova/tests/cases/components/commerce/Reviews.cases.tsx +35 -0
- package/templates/nova/tests/cases/components/commerce/Stars.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/commerce/VariantPicker.cases.tsx +38 -0
- package/templates/nova/tests/cases/components/commerce/blocks/Badge.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/commerce/blocks/PaymentIcons.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/commerce/blocks/Swatches.cases.tsx +22 -0
- package/templates/nova/tests/cases/components/content/ArticleCard.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/BeforeAfterSlider.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/CardRow.cases.tsx +23 -0
- package/templates/nova/tests/cases/components/content/CarouselControls.cases.tsx +48 -0
- package/templates/nova/tests/cases/components/content/ContentsNav.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/Countdown.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/content/HeroCopy.cases.tsx +42 -0
- package/templates/nova/tests/cases/components/content/HeroFrame.cases.tsx +22 -0
- package/templates/nova/tests/cases/components/content/HeroMedia.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/LongForm.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/MediaFrame.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/content/RichText.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/content/SectionHead.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/content/ShareButtons.cases.tsx +24 -0
- package/templates/nova/tests/cases/components/content/StoreCard.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/TestimonialCard.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/content/UgcTile.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/blocks/Button.cases.tsx +20 -0
- package/templates/nova/tests/cases/components/content/blocks/Column.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/blocks/Heading.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/blocks/Icon.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/blocks/Image.cases.tsx +22 -0
- package/templates/nova/tests/cases/components/content/blocks/Text.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/blocks/Video.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/forms/ContactForm.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/forms/FormField.cases.tsx +61 -0
- package/templates/nova/tests/cases/components/forms/NewsletterForm.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/forms/SearchField.cases.tsx +25 -0
- package/templates/nova/tests/cases/components/forms/blocks/Newsletter.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/navigation/BrandLogo.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/navigation/Breadcrumb.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/navigation/LocaleSelector.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/navigation/Menu.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/navigation/Pagination.cases.tsx +25 -0
- package/templates/nova/tests/cases/components/navigation/RecoveryLinks.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/navigation/SocialLinks.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/navigation/blocks/SocialLinks.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/overlays/AccountMenu.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/overlays/CartDrawer.cases.tsx +30 -0
- package/templates/nova/tests/cases/components/overlays/ConfirmationDialog.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/overlays/CookieConsent.cases.tsx +23 -0
- package/templates/nova/tests/cases/components/overlays/CookiePreferences.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/overlays/Drawer.cases.tsx +52 -0
- package/templates/nova/tests/cases/components/overlays/MarketSelector.cases.tsx +82 -0
- package/templates/nova/tests/cases/components/overlays/Menu.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/overlays/MobileNavDrawer.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/overlays/Modal.cases.tsx +71 -0
- package/templates/nova/tests/cases/components/overlays/Popover.cases.tsx +50 -0
- package/templates/nova/tests/cases/components/overlays/PromoPopup.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/overlays/QuickView.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/overlays/SearchModal.cases.tsx +60 -0
- package/templates/nova/tests/cases/components/overlays/Sheet.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/overlays/SizeGuide.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/overlays/Toast.cases.tsx +48 -0
- package/templates/nova/tests/cases/components/overlays/Tooltip.cases.tsx +33 -0
- package/templates/nova/tests/cases/components/states/Alert.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/states/EditorFrame.cases.tsx +36 -0
- package/templates/nova/tests/cases/components/states/Empty.cases.tsx +30 -0
- package/templates/nova/tests/cases/components/states/Error.cases.tsx +38 -0
- package/templates/nova/tests/cases/components/states/Loading.cases.tsx +15 -0
- package/templates/nova/tests/cases/components/states/MediaState.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/states/SkeletonLayout.cases.tsx +20 -0
- package/templates/nova/tests/cases/components/states/Unavailable.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/states/media/MediaError.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/states/media/MediaPlaceholder.cases.tsx +87 -0
- package/templates/nova/tests/cases/sections/Overview.cases.tsx +8 -0
- package/templates/nova/tests/cases/sections/commerce/collection-list/CollectionList.cases.tsx +46 -0
- package/templates/nova/tests/cases/sections/commerce/collection-list/blocks/CollectionItem.cases.tsx +18 -0
- package/templates/nova/tests/cases/sections/commerce/featured-collection/FeaturedCollection.cases.tsx +46 -0
- package/templates/nova/tests/cases/sections/commerce/featured-product/FeaturedProduct.cases.tsx +40 -0
- package/templates/nova/tests/cases/sections/commerce/main-collection/MainCollection.cases.tsx +81 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/ProductDetails.cases.tsx +110 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/AddToCartBlock.cases.tsx +21 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductDescription.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductInventory.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductPrice.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductSku.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductTitle.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/Quantity.cases.tsx +20 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/Tab.cases.tsx +29 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/VariantPickerBlock.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/commerce/product-grid/ProductGrid.cases.tsx +48 -0
- package/templates/nova/tests/cases/sections/commerce/product-recommendations/ProductRecommendations.cases.tsx +27 -0
- package/templates/nova/tests/cases/sections/commerce/recently-viewed/RecentlyViewed.cases.tsx +36 -0
- package/templates/nova/tests/cases/sections/content/article-body/ArticleBody.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/content/before-after/BeforeAfter.cases.tsx +40 -0
- package/templates/nova/tests/cases/sections/content/before-after/blocks/Comparison.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/content/blog-posts/BlogPosts.cases.tsx +47 -0
- package/templates/nova/tests/cases/sections/content/collection-links/CollectionLinks.cases.tsx +36 -0
- package/templates/nova/tests/cases/sections/content/faq/Faq.cases.tsx +38 -0
- package/templates/nova/tests/cases/sections/content/faq/blocks/FaqItem.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/content/feature-grid-blocks/FeatureGridBlocks.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/feature-highlights/FeatureHighlights.cases.tsx +26 -0
- package/templates/nova/tests/cases/sections/content/image-gallery/ImageGallery.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/image-with-text/ImageWithText.cases.tsx +35 -0
- package/templates/nova/tests/cases/sections/content/multicolumn/Multicolumn.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/content/page-body/PageBody.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/rich-text/RichTextSection.cases.tsx +33 -0
- package/templates/nova/tests/cases/sections/content/team-founders/TeamFounders.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/team-founders/blocks/Person.cases.tsx +18 -0
- package/templates/nova/tests/cases/sections/content/timeline/Timeline.cases.tsx +27 -0
- package/templates/nova/tests/cases/sections/content/timeline/blocks/Step.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/layout/announcement-bar/AnnouncementBar.cases.tsx +119 -0
- package/templates/nova/tests/cases/sections/layout/breadcrumbs/Breadcrumbs.cases.tsx +73 -0
- package/templates/nova/tests/cases/sections/layout/divider/Divider.cases.tsx +81 -0
- package/templates/nova/tests/cases/sections/layout/footer/Footer.cases.tsx +116 -0
- package/templates/nova/tests/cases/sections/layout/footer/blocks/FooterBrand.cases.tsx +27 -0
- package/templates/nova/tests/cases/sections/layout/footer/blocks/FooterMenu.cases.tsx +22 -0
- package/templates/nova/tests/cases/sections/layout/footer/blocks/FooterText.cases.tsx +20 -0
- package/templates/nova/tests/cases/sections/layout/group/Group.cases.tsx +185 -0
- package/templates/nova/tests/cases/sections/layout/group/blocks/Accordion.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/layout/group/blocks/JumboText.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/layout/group/blocks/Spacer.cases.tsx +33 -0
- package/templates/nova/tests/cases/sections/layout/header/Header.cases.tsx +277 -0
- package/templates/nova/tests/cases/sections/marketing/collection-banner/CollectionBanner.cases.tsx +62 -0
- package/templates/nova/tests/cases/sections/marketing/hero/Hero.cases.tsx +138 -0
- package/templates/nova/tests/cases/sections/marketing/marquee/Marquee.cases.tsx +63 -0
- package/templates/nova/tests/cases/sections/marketing/promo-banner/PromoBanner.cases.tsx +87 -0
- package/templates/nova/tests/cases/sections/marketing/slideshow/Slideshow.cases.tsx +113 -0
- package/templates/nova/tests/cases/sections/marketing/slideshow/blocks/Slide.cases.tsx +26 -0
- package/templates/nova/tests/cases/sections/marketing/video-hero/VideoHero.cases.tsx +72 -0
- package/templates/nova/tests/cases/sections/trust/comparison-table/ComparisonTableSection.cases.tsx +42 -0
- package/templates/nova/tests/cases/sections/trust/comparison-table/blocks/CompareItem.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/logo-list/LogoList.cases.tsx +29 -0
- package/templates/nova/tests/cases/sections/trust/logo-list/blocks/Logo.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/product-reviews/ProductReviews.cases.tsx +51 -0
- package/templates/nova/tests/cases/sections/trust/shop-the-look/ShopTheLook.cases.tsx +51 -0
- package/templates/nova/tests/cases/sections/trust/shop-the-look/blocks/Hotspot.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/testimonials/Testimonials.cases.tsx +61 -0
- package/templates/nova/tests/cases/sections/trust/testimonials/blocks/Testimonial.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/trust-badges/TrustBadges.cases.tsx +30 -0
- package/templates/nova/tests/cases/sections/trust/ugc-gallery/UgcGallery.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/trust/ugc-gallery/blocks/UgcImage.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/utility/account/Account.cases.tsx +44 -0
- package/templates/nova/tests/cases/sections/utility/cart-items/CartItems.cases.tsx +43 -0
- package/templates/nova/tests/cases/sections/utility/cart-items/blocks/CartBadge.cases.tsx +16 -0
- package/templates/nova/tests/cases/sections/utility/contact-form/ContactFormSection.cases.tsx +52 -0
- package/templates/nova/tests/cases/sections/utility/contact-form/blocks/ContactDetail.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/utility/newsletter/NewsletterSection.cases.tsx +109 -0
- package/templates/nova/tests/cases/sections/utility/not-found/NotFound.cases.tsx +28 -0
- package/templates/nova/tests/cases/sections/utility/policy-page/PolicyPage.cases.tsx +29 -0
- package/templates/nova/tests/cases/sections/utility/search-results/SearchResultsSection.cases.tsx +39 -0
- package/templates/nova/tests/cases/sections/utility/store-locator/StoreLocator.cases.tsx +40 -0
- package/templates/nova/tests/cases/styles/Borders.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Breakpoints.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Colors.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Elevation.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Icon.cases.tsx +23 -0
- package/templates/nova/tests/cases/styles/Layout.cases.tsx +8 -0
- package/templates/nova/tests/cases/styles/Motion.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Overview.cases.tsx +8 -0
- package/templates/nova/tests/cases/styles/Radius.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/SharedThemeSettings.cases.tsx +19 -0
- package/templates/nova/tests/cases/styles/Spacing.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Typography.cases.tsx +10 -0
- package/templates/nova/tests/cases.test.tsx +38 -0
- package/templates/nova/tests/components/PromoPopup.test.ts +21 -0
- package/templates/nova/tests/components/RichText.test.tsx +65 -0
- package/templates/nova/tests/components/formatDate.test.ts +10 -0
- package/templates/nova/tests/contract-locks.test.ts +23 -0
- package/templates/nova/tests/contracts.test.ts +153 -0
- package/templates/nova/tests/cookie-consent-privacy.test.tsx +128 -0
- package/templates/nova/tests/empty-store.test.tsx +81 -0
- package/templates/nova/tests/fixtures/commerce.ts +128 -0
- package/templates/nova/tests/fixtures/content.ts +58 -0
- package/templates/nova/tests/fixtures/index.ts +8 -0
- package/templates/nova/tests/fixtures/merch.ts +161 -0
- package/templates/nova/tests/fixtures/navigation.ts +125 -0
- package/templates/nova/tests/fixtures/promotion.ts +43 -0
- package/templates/nova/tests/fixtures/sample-store.json +1674 -0
- package/templates/nova/tests/fixtures/shop.ts +88 -0
- package/templates/nova/tests/fixtures/stress.ts +21 -0
- package/templates/nova/tests/inert.test.tsx +285 -0
- package/templates/nova/tests/line-add-friend.test.tsx +108 -0
- package/templates/nova/tests/localized-copy.test.ts +330 -0
- package/templates/nova/tests/product-template-blocks.test.ts +28 -0
- package/templates/nova/tests/rewards-launcher.test.tsx +401 -0
- package/templates/nova/tests/schema.test.ts +65 -0
- package/templates/nova/tests/schema.typetest.ts +7 -0
- package/templates/nova/tests/section-groups.test.ts +189 -0
- package/templates/nova/tests/sections/Group.test.tsx +37 -0
- package/templates/nova/tests/setup.ts +30 -0
- package/templates/nova/tests/starter.test.ts +56 -0
- package/templates/nova/tests/storefront-click-path.test.tsx +157 -0
- package/templates/nova/tests/styles/button-brand.test.ts +24 -0
- package/templates/nova/tests/styles/theme.test.ts +43 -0
- package/templates/nova/tests/styles/tokens.test.ts +35 -0
- package/templates/nova/tests/support/abi-ctx.ts +136 -0
- package/templates/nova/tests/support/block-stories.tsx +13 -0
- package/templates/nova/tests/support/case.tsx +102 -0
- package/templates/nova/tests/support/contracts.ts +30 -0
- package/templates/nova/tests/support/foundation-pages.tsx +260 -0
- package/templates/nova/tests/support/ia-pages.tsx +154 -0
- package/templates/nova/tests/support/listing-demo.tsx +29 -0
- package/templates/nova/tests/support/presets.ts +14 -0
- package/templates/nova/tests/support/sections.ts +36 -0
- package/templates/nova/tests/support/story-content.ts +321 -0
- package/templates/nova/tests/support/story-helpers.tsx +37 -0
- package/templates/nova/tests/support/with-nova.tsx +26 -0
- package/templates/nova/tests/theme-config.test.ts +82 -0
- package/templates/nova/tests/theme-integrity.test.ts +315 -0
- package/templates/nova/theme.config.ts +134 -0
- package/templates/nova/theme.manifest.json +17495 -0
- package/templates/nova/tsconfig.json +19 -0
- package/templates/nova/vite.abi-ssr.config.ts +37 -0
- package/templates/nova/vite.abi.config.ts +26 -0
- package/templates/nova/vitest.config.ts +20 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storefront rewards (army #7749): the rewards launcher every page shares and the "Earn N points"
|
|
3
|
+
* hint, rendered the way main.abi.tsx hydrates a page (AbiRewardsProvider over the ABI remote,
|
|
4
|
+
* `loyalty.state` / `loyalty.redeem`). The remote here is a recorded host answer; everything the
|
|
5
|
+
* shopper sees is the theme's own. Referrals (army #7751): the launcher's Refer a friend tab, or the launcher
|
|
6
|
+
* itself with loyalty off, and the friend offer a `?ref=CODE` visit shows (AbiReferralsProvider, inside it).
|
|
7
|
+
*/
|
|
8
|
+
import { act } from 'react'
|
|
9
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
10
|
+
import { renderToString } from 'react-dom/server'
|
|
11
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
12
|
+
import { setThemeBundle } from '@tanqory/theme-kit/runtime'
|
|
13
|
+
import { sectionModules } from '@tanqory/theme-kit/runtime'
|
|
14
|
+
import { registerSections } from '@tanqory/theme-kit/runtime'
|
|
15
|
+
import { SectionTree } from '@tanqory/theme-kit/runtime'
|
|
16
|
+
import { DataProvider } from '@tanqory/theme-kit/runtime'
|
|
17
|
+
import { ThemeProvider } from '@tanqory/theme-kit/runtime'
|
|
18
|
+
import { localeStrings } from '@tanqory/theme-kit/runtime'
|
|
19
|
+
import { earnPoints, type RewardsState } from '@tanqory/theme-kit'
|
|
20
|
+
import type { ReferralState } from '@tanqory/theme-kit'
|
|
21
|
+
import { bundle } from '../lib/bundle'
|
|
22
|
+
import { AbiShell } from '@tanqory/theme-kit/runtime'
|
|
23
|
+
import { AbiCartProvider } from '@tanqory/theme-kit/runtime'
|
|
24
|
+
import { AbiRewardsProvider } from '@tanqory/theme-kit/runtime'
|
|
25
|
+
import { AbiWireError, type AbiRemote, type WireEnvelope } from '@tanqory/theme-kit/runtime'
|
|
26
|
+
import { createDataApi } from '@tanqory/theme-kit/runtime'
|
|
27
|
+
import type { PageData } from '@tanqory/theme-kit/runtime'
|
|
28
|
+
import { EarnHint } from '../src/components/commerce/EarnHint'
|
|
29
|
+
|
|
30
|
+
setThemeBundle(bundle)
|
|
31
|
+
registerSections(Object.values(sectionModules()).map((m) => m.default))
|
|
32
|
+
|
|
33
|
+
const LOCALES = Object.fromEntries(
|
|
34
|
+
Object.entries(bundle.locales).map(([path, mod]) => [path.match(/\/([^/]+)\.json$/)?.[1] ?? 'en', (mod as { default: Record<string, string> }).default]),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
const PAGE_DATA = {
|
|
38
|
+
route: 'index',
|
|
39
|
+
shop: { name: 'Demo', description: null, brand: null, policies: {}, primaryDomain: { host: 'demo.example', url: 'https://demo.example', sslEnabled: true } },
|
|
40
|
+
menus: {}, products: {}, collections: {}, collectionList: null, pages: {}, blogs: {}, articles: {},
|
|
41
|
+
search: null, recommendations: {}, policyHandle: null, accountUrls: null, cart: null,
|
|
42
|
+
localization: { country: { isoCode: 'TH', name: 'Thailand', currency: { isoCode: 'THB', name: 'Thai Baht', symbol: '฿' } }, language: { isoCode: 'EN', name: 'English' }, availableCountries: [], availableLanguages: [] },
|
|
43
|
+
signedIn: null, unresolved: [], routeMissing: false,
|
|
44
|
+
} as unknown as PageData
|
|
45
|
+
|
|
46
|
+
const WAYS = [
|
|
47
|
+
{ id: 'w-order', kind: 'PLACE_ORDER', name: 'Place an order', points: null, completed: false },
|
|
48
|
+
{ id: 'w-signup', kind: 'SIGN_UP', name: 'Create an account', points: 100, completed: true },
|
|
49
|
+
]
|
|
50
|
+
const MEMBER: RewardsState = {
|
|
51
|
+
enabled: true,
|
|
52
|
+
signedIn: true,
|
|
53
|
+
member: true,
|
|
54
|
+
program: { name: 'Leaf Club', earnRates: { THB: 0.1 } },
|
|
55
|
+
balance: { available: 1250, pending: 40, lifetimeEarned: 3000 },
|
|
56
|
+
tier: { basis: 'POINTS', currency: null, current: { name: 'Gold', earnMultiplier: 1.5 }, next: { name: 'Platinum', threshold: 5000 }, progress: { qualifying: 3000, remaining: 2000 } },
|
|
57
|
+
rewards: [
|
|
58
|
+
{ id: 'rw-100', name: '฿100 off', kind: 'AMOUNT_OFF', pointsCost: 1000, affordable: true, pointsNeeded: 0, tierLocked: false, limitReached: false },
|
|
59
|
+
{ id: 'rw-500', name: '฿500 off', kind: 'AMOUNT_OFF', pointsCost: 1500, affordable: false, pointsNeeded: 250, tierLocked: false, limitReached: false },
|
|
60
|
+
],
|
|
61
|
+
codes: [{ code: 'LOYALTY-OLD111', rewardName: 'Free shipping', kind: 'FREE_SHIPPING', expiresAt: '2027-01-20T00:00:00.000Z' }],
|
|
62
|
+
ways: WAYS,
|
|
63
|
+
}
|
|
64
|
+
const GUEST: RewardsState = { enabled: true, signedIn: false, program: { name: 'Leaf Club', earnRates: { THB: 0.1 } }, ways: WAYS }
|
|
65
|
+
const AFTER_REDEEM: RewardsState = {
|
|
66
|
+
...MEMBER,
|
|
67
|
+
balance: { available: 250, pending: 40, lifetimeEarned: 3000 },
|
|
68
|
+
codes: [{ code: 'LOYALTY-NEW222', rewardName: '฿100 off', kind: 'AMOUNT_OFF', expiresAt: '2027-01-15T00:00:00.000Z' }, ...MEMBER.codes!],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A host answering `loyalty.state` with `state` and the referral ops with `referral` (`undefined`: not offered). */
|
|
72
|
+
function hostWith(state: unknown, referral: { referral?: unknown; offer?: unknown } = {}) {
|
|
73
|
+
const calls: { kind: 'data' | 'action'; name: string; args: readonly unknown[] }[] = []
|
|
74
|
+
const answers: Record<string, unknown> = { 'loyalty.state': state, 'referral.state': referral.referral, 'referral.offer': referral.offer }
|
|
75
|
+
const remote: AbiRemote = {
|
|
76
|
+
async data(op, args) {
|
|
77
|
+
calls.push({ kind: 'data', name: op, args })
|
|
78
|
+
if (answers[op] !== undefined) return answers[op]
|
|
79
|
+
throw new AbiWireError(404, 'unknown_operation')
|
|
80
|
+
},
|
|
81
|
+
async action(name, args) {
|
|
82
|
+
calls.push({ kind: 'action', name, args })
|
|
83
|
+
if (name === 'loyalty.redeem') return { ok: true, data: { redemption: { code: 'LOYALTY-NEW222' }, state: AFTER_REDEEM }, dataVersion: '1' } as WireEnvelope<unknown>
|
|
84
|
+
if (name === 'referral.claim') {
|
|
85
|
+
return ((args[0] as { email: string }).email === 'mia@example.com'
|
|
86
|
+
? { ok: false, error: { code: 'self', requestId: 'r' } }
|
|
87
|
+
: { ok: true, data: { ok: true, code: 'FRIEND-AB12CD34', expiresAt: null }, dataVersion: '1' }) as WireEnvelope<unknown>
|
|
88
|
+
}
|
|
89
|
+
if (name === 'referral.invite') return { ok: true, data: { ok: true }, dataVersion: '1' } as WireEnvelope<unknown>
|
|
90
|
+
return { ok: false, error: { code: 'unknown_operation', requestId: 'r' } }
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
return { remote, calls }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function Page({ remote, children }: { remote: AbiRemote | null; children?: JSX.Element }): JSX.Element {
|
|
97
|
+
return (
|
|
98
|
+
<DataProvider value={createDataApi(PAGE_DATA, null)}>
|
|
99
|
+
<ThemeProvider settings={{}} locale={localeStrings('en', LOCALES)}>
|
|
100
|
+
<AbiCartProvider initial={null} remote={null}>
|
|
101
|
+
<AbiRewardsProvider remote={remote}>
|
|
102
|
+
<AbiShell location="/" locale="en" settings={{}} preview={false}>
|
|
103
|
+
{children ?? <SectionTree tree={[]} />}
|
|
104
|
+
</AbiShell>
|
|
105
|
+
</AbiRewardsProvider>
|
|
106
|
+
</AbiCartProvider>
|
|
107
|
+
</ThemeProvider>
|
|
108
|
+
</DataProvider>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let root: Root | null = null
|
|
113
|
+
let host: HTMLElement | null = null
|
|
114
|
+
function unmount(): void {
|
|
115
|
+
act(() => root?.unmount())
|
|
116
|
+
host?.remove()
|
|
117
|
+
root = host = null
|
|
118
|
+
}
|
|
119
|
+
afterEach(unmount)
|
|
120
|
+
|
|
121
|
+
const settle = () => act(() => new Promise((r) => setTimeout(r, 30)))
|
|
122
|
+
async function mount(remote: AbiRemote | null, children?: JSX.Element): Promise<HTMLElement> {
|
|
123
|
+
unmount()
|
|
124
|
+
host = document.body.appendChild(document.createElement('div'))
|
|
125
|
+
root = createRoot(host)
|
|
126
|
+
act(() => root!.render(<Page remote={remote}>{children}</Page>))
|
|
127
|
+
await settle()
|
|
128
|
+
return host
|
|
129
|
+
}
|
|
130
|
+
const launcher = (el: HTMLElement) => el.querySelector<HTMLButtonElement>('button[aria-label="Open rewards"]')
|
|
131
|
+
const dialog = (el: HTMLElement) => el.querySelector<HTMLElement>('[role="dialog"][aria-label="Rewards"]')!
|
|
132
|
+
const isOpen = (el: HTMLElement) => dialog(el).closest('.nv-overlay')!.hasAttribute('data-open')
|
|
133
|
+
const key = (k: string, init: KeyboardEventInit = {}) => act(() => void document.dispatchEvent(new KeyboardEvent('keydown', { key: k, bubbles: true, ...init })))
|
|
134
|
+
const itemFor = (el: HTMLElement, text: string) => [...dialog(el).querySelectorAll('li')].find((li) => li.textContent?.includes(text))!
|
|
135
|
+
|
|
136
|
+
describe('rewards launcher', () => {
|
|
137
|
+
it('a member opens it and sees the balance, pending points, tier progress, rewards and codes', async () => {
|
|
138
|
+
const el = await mount(hostWith(MEMBER).remote)
|
|
139
|
+
const button = launcher(el)!
|
|
140
|
+
expect(button.textContent).toBe('Rewards')
|
|
141
|
+
expect(button.getAttribute('aria-haspopup')).toBe('dialog')
|
|
142
|
+
expect(isOpen(el)).toBe(false)
|
|
143
|
+
act(() => button.click())
|
|
144
|
+
await settle()
|
|
145
|
+
expect(isOpen(el)).toBe(true)
|
|
146
|
+
const d = dialog(el)
|
|
147
|
+
expect(d.getAttribute('aria-modal')).toBe('true')
|
|
148
|
+
expect(d.textContent).toContain('1,250 points')
|
|
149
|
+
expect(d.textContent).toContain('40 points pending')
|
|
150
|
+
expect(d.textContent).toContain('Gold')
|
|
151
|
+
const bar = d.querySelector('[role="progressbar"]')!
|
|
152
|
+
expect([bar.getAttribute('aria-valuemin'), bar.getAttribute('aria-valuemax'), bar.getAttribute('aria-valuenow')]).toEqual(['0', '5000', '3000'])
|
|
153
|
+
expect(d.querySelector(`#${CSS.escape(bar.getAttribute('aria-labelledby')!)}`)?.textContent).toBe('2,000 more points to reach Platinum')
|
|
154
|
+
expect(itemFor(el, '฿100 off').querySelector('button')?.textContent).toBe('Get a code')
|
|
155
|
+
expect(itemFor(el, '฿500 off').querySelector('button')).toBeNull()
|
|
156
|
+
expect(itemFor(el, '฿500 off').textContent).toContain('250 more points needed')
|
|
157
|
+
const code = itemFor(el, 'LOYALTY-OLD111')
|
|
158
|
+
expect(code.querySelector('button')?.getAttribute('aria-label')).toBe('Copy LOYALTY-OLD111')
|
|
159
|
+
expect(code.querySelector('a')?.textContent).toBe('Apply to cart')
|
|
160
|
+
expect(code.querySelector('a')?.getAttribute('href')).toBe('/discount/LOYALTY-OLD111?redirect=%2Fcart')
|
|
161
|
+
expect(itemFor(el, 'Place an order').textContent).toContain('10 points for every')
|
|
162
|
+
expect(itemFor(el, 'Create an account').textContent).toContain('Done')
|
|
163
|
+
expect(itemFor(el, 'Place an order').textContent).not.toContain('Done')
|
|
164
|
+
expect(d.querySelector('a[href="/account/rewards"]')?.textContent).toBe('View my rewards')
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('Escape closes it and gives focus back to the launcher; Tab stays inside while it is open', async () => {
|
|
168
|
+
// jsdom lays nothing out (offsetParent is always null): give every element a parent box so the trap sees them.
|
|
169
|
+
const desc = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetParent')!
|
|
170
|
+
Object.defineProperty(HTMLElement.prototype, 'offsetParent', { configurable: true, get() { return this.parentElement } })
|
|
171
|
+
try {
|
|
172
|
+
const el = await mount(hostWith(MEMBER).remote)
|
|
173
|
+
const button = launcher(el)!
|
|
174
|
+
button.focus()
|
|
175
|
+
act(() => button.click())
|
|
176
|
+
await settle()
|
|
177
|
+
const d = dialog(el)
|
|
178
|
+
expect(d.contains(document.activeElement)).toBe(true)
|
|
179
|
+
const focusables = [...d.querySelectorAll<HTMLElement>('a[href], button:not([disabled])')]
|
|
180
|
+
focusables[focusables.length - 1].focus()
|
|
181
|
+
key('Tab')
|
|
182
|
+
expect(document.activeElement).toBe(focusables[0])
|
|
183
|
+
key('Tab', { shiftKey: true })
|
|
184
|
+
expect(document.activeElement).toBe(focusables[focusables.length - 1])
|
|
185
|
+
key('Escape')
|
|
186
|
+
await settle()
|
|
187
|
+
expect(isOpen(el)).toBe(false)
|
|
188
|
+
expect(document.activeElement).toBe(button)
|
|
189
|
+
} finally {
|
|
190
|
+
Object.defineProperty(HTMLElement.prototype, 'offsetParent', desc)
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('Get a code turns points into a code with a fresh idempotency key, says it and lists it with Apply to cart', async () => {
|
|
195
|
+
const { remote, calls } = hostWith(MEMBER)
|
|
196
|
+
const el = await mount(remote)
|
|
197
|
+
act(() => launcher(el)!.click())
|
|
198
|
+
await settle()
|
|
199
|
+
act(() => itemFor(el, '฿100 off').querySelector('button')!.click())
|
|
200
|
+
await settle()
|
|
201
|
+
const redeem = calls.filter((c) => c.kind === 'action' && c.name === 'loyalty.redeem')
|
|
202
|
+
expect(redeem).toHaveLength(1)
|
|
203
|
+
const [arg] = redeem[0].args as [{ rewardId: string; key: string }]
|
|
204
|
+
expect(arg.rewardId).toBe('rw-100')
|
|
205
|
+
expect(arg.key).toMatch(/^[A-Za-z0-9_-]{16,64}$/)
|
|
206
|
+
expect(dialog(el).querySelector('[role="status"]')?.textContent).toBe('Your code is ready: LOYALTY-NEW222')
|
|
207
|
+
expect(dialog(el).textContent).toContain('250 points')
|
|
208
|
+
expect(itemFor(el, 'LOYALTY-NEW222').querySelector('a')?.getAttribute('href')).toBe('/discount/LOYALTY-NEW222?redirect=%2Fcart')
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('a guest sees the program, ways to earn and Join now or Sign in, and no balance', async () => {
|
|
212
|
+
const el = await mount(hostWith(GUEST).remote)
|
|
213
|
+
act(() => launcher(el)!.click())
|
|
214
|
+
await settle()
|
|
215
|
+
const d = dialog(el)
|
|
216
|
+
expect(d.textContent).toContain('Leaf Club')
|
|
217
|
+
expect(d.querySelector('a[href="/account/register"]')?.textContent).toBe('Join now')
|
|
218
|
+
expect(d.querySelector('a[href="/account/login"]')?.textContent).toBe('Sign in')
|
|
219
|
+
expect(itemFor(el, 'Create an account').textContent).toContain('100 points')
|
|
220
|
+
expect(d.querySelector('[role="progressbar"]')).toBeNull()
|
|
221
|
+
expect(d.textContent).not.toContain('Get a code')
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('renders nothing for a store with loyalty off, a host without loyalty, or on the server', async () => {
|
|
225
|
+
const off = hostWith({ enabled: false })
|
|
226
|
+
expect(launcher(await mount(off.remote))).toBeNull()
|
|
227
|
+
expect(off.calls.filter((c) => c.name.startsWith('loyalty.')).map((c) => c.name)).toEqual(['loyalty.state'])
|
|
228
|
+
expect(launcher(await mount(hostWith(undefined).remote))).toBeNull()
|
|
229
|
+
const html = renderToString(<Page remote={null} />)
|
|
230
|
+
expect(html).toContain('data-tq-client-slot="rewards"')
|
|
231
|
+
expect(html).not.toContain('Open rewards')
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
describe('earn hint', () => {
|
|
236
|
+
const PRICE = { amount: 1290, currencyCode: 'THB' }
|
|
237
|
+
const hint = (el: HTMLElement) => el.querySelector('.nv-earn-hint')!
|
|
238
|
+
|
|
239
|
+
it('a member earns at the earn rate times the tier multiplier, rounded down', async () => {
|
|
240
|
+
const el = await mount(hostWith(MEMBER).remote, <EarnHint amount={PRICE} scope="item" />)
|
|
241
|
+
expect(hint(el).textContent).toBe('Earn 193 points with this item')
|
|
242
|
+
expect(hint(el).querySelector('a')).toBeNull()
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('a guest earns at the earn rate and is asked to sign in to collect', async () => {
|
|
246
|
+
const el = await mount(hostWith(GUEST).remote, <EarnHint amount={PRICE} scope="order" />)
|
|
247
|
+
expect(hint(el).querySelector('span')?.textContent).toBe('Earn 129 points with this order')
|
|
248
|
+
expect(hint(el).querySelector('a[href="/account/login"]')?.textContent).toBe('Sign in to collect your points')
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
it('says nothing in a currency the program does not earn in, with loyalty off, or on the server', async () => {
|
|
252
|
+
expect(hint(await mount(hostWith(MEMBER).remote, <EarnHint amount={{ amount: 50, currencyCode: 'USD' }} scope="item" />)).textContent).toBe('')
|
|
253
|
+
expect(hint(await mount(hostWith({ enabled: false }).remote, <EarnHint amount={PRICE} scope="item" />)).textContent).toBe('')
|
|
254
|
+
expect(renderToString(<Page remote={null}><EarnHint amount={PRICE} scope="item" /></Page>)).toContain('<p class="nv-earn-hint" data-tq-client-slot="earn-hint"></p>')
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
it('earnPoints: floor of amount x rate x multiplier, without float noise', () => {
|
|
258
|
+
expect(earnPoints(29.9, 'THB', { ...GUEST, program: { name: '', earnRates: { THB: 10 } } })).toBe(299)
|
|
259
|
+
expect(earnPoints(5, 'THB', GUEST)).toBe(0)
|
|
260
|
+
expect(earnPoints(1290, 'THB', MEMBER)).toBe(193)
|
|
261
|
+
expect(earnPoints(1290, 'THB', null)).toBeNull()
|
|
262
|
+
expect(earnPoints(0, 'THB', GUEST)).toBeNull()
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
const LINK = 'https://leaf.example/?ref=MIA7K3QX'
|
|
267
|
+
const ADVOCATE: ReferralState = {
|
|
268
|
+
...{ enabled: true, code: 'MIA7K3QX', shareUrl: LINK, offer: { type: 'PERCENTAGE', value: '15', currency: 'THB' } },
|
|
269
|
+
...{ reward: { type: 'FIXED_CODE', value: '200.00', points: 0, currency: 'THB' }, stats: { clicks: 12, friendOrders: 3, pending: 2, rewarded: 1 } },
|
|
270
|
+
}
|
|
271
|
+
const OFFER = { enabled: true, code: 'MIA7K3QX', offer: { type: 'FIXED_AMOUNT', value: '100', currency: 'THB' }, minimumOrder: '500.00', advocateFirstName: 'Mia' }
|
|
272
|
+
const button = (el: HTMLElement, label: string) => [...el.querySelectorAll<HTMLButtonElement>('button')].find((b) => (b.getAttribute('aria-label') ?? b.textContent) === label)
|
|
273
|
+
const named = (el: HTMLElement, name: string) => el.querySelector<HTMLElement>(`[role="dialog"][aria-label="${name}"]`)!
|
|
274
|
+
const linkNamed = (el: HTMLElement, name: string) => [...el.querySelectorAll('a')].find((a) => a.textContent === name)
|
|
275
|
+
const offerPanel = (el: HTMLElement) => [...el.querySelectorAll('[role="region"]')].find((r) => r.textContent?.includes('A gift from your friend')) as HTMLElement | undefined
|
|
276
|
+
function type(input: HTMLInputElement, value: string): void {
|
|
277
|
+
const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!
|
|
278
|
+
act(() => {
|
|
279
|
+
set.call(input, value)
|
|
280
|
+
input.dispatchEvent(new Event('input', { bubbles: true }))
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
beforeEach(() => {
|
|
284
|
+
sessionStorage.clear()
|
|
285
|
+
for (const c of document.cookie.split('; ').filter(Boolean)) document.cookie = `${c.split('=')[0]}=; Path=/; Max-Age=0`
|
|
286
|
+
window.history.replaceState(null, '', '/')
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
describe('referral tab', () => {
|
|
290
|
+
it('with loyalty on it is the Refer a friend tab: the link, Copy, LINE, WhatsApp, Messenger and X links carrying it, stats', async () => {
|
|
291
|
+
const el = await mount(hostWith(MEMBER, { referral: ADVOCATE }).remote)
|
|
292
|
+
act(() => button(el, 'Open rewards')!.click())
|
|
293
|
+
await settle()
|
|
294
|
+
const d = named(el, 'Rewards')
|
|
295
|
+
const tab = [...d.querySelectorAll<HTMLButtonElement>('[role="tab"]')].find((t) => t.textContent === 'Refer a friend')!
|
|
296
|
+
act(() => tab.click())
|
|
297
|
+
const panel = d.querySelector<HTMLElement>(`#${CSS.escape(tab.getAttribute('aria-controls')!)}`)!
|
|
298
|
+
expect(panel.hidden).toBe(false)
|
|
299
|
+
expect(panel.textContent).toContain('Your friends get 15% off their first order.')
|
|
300
|
+
expect(panel.textContent).toContain('You get a THB\u00a0200.00 off code for each friend who orders.')
|
|
301
|
+
const input = panel.querySelector<HTMLInputElement>('input[readonly]')!
|
|
302
|
+
expect(input.value).toBe(LINK)
|
|
303
|
+
expect(panel.querySelector(`label[for="${input.id}"]`)?.textContent).toContain('Your link')
|
|
304
|
+
expect(button(panel, 'Copy link')).toBeTruthy()
|
|
305
|
+
const href = (name: string) => linkNamed(panel, name)!.getAttribute('href')!
|
|
306
|
+
expect(href('Share on LINE')).toBe(`https://social-plugins.line.me/lineit/share?url=${encodeURIComponent(LINK)}&text=${encodeURIComponent('Here is 15% off your first order:')}`)
|
|
307
|
+
expect(decodeURIComponent(href('Share on WhatsApp'))).toBe(`https://wa.me/?text=Here is 15% off your first order: ${LINK}`)
|
|
308
|
+
expect(href('Share on Messenger')).toBe(`fb-messenger://share/?link=${encodeURIComponent(LINK)}`)
|
|
309
|
+
expect(href('Share on X')).toContain(`&url=${encodeURIComponent(LINK)}`)
|
|
310
|
+
expect(linkNamed(panel, 'Share on LINE')!.getAttribute('rel')).toBe('noopener noreferrer')
|
|
311
|
+
const stats = [...panel.querySelectorAll('dl > div')].map((r) => r.textContent)
|
|
312
|
+
expect(stats).toEqual(['Link visits12', 'Friends who ordered3', 'Rewards on the way2', 'Rewards earned1'])
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
it('Share by email opens a field and posts the invite', async () => {
|
|
316
|
+
const { remote, calls } = hostWith(undefined, { referral: ADVOCATE })
|
|
317
|
+
const el = await mount(remote)
|
|
318
|
+
act(() => button(el, 'Open refer a friend')!.click())
|
|
319
|
+
await settle()
|
|
320
|
+
const d = named(el, 'Refer a friend')
|
|
321
|
+
const share = button(d, 'Share by email')!
|
|
322
|
+
expect(share.getAttribute('aria-expanded')).toBe('false')
|
|
323
|
+
act(() => share.click())
|
|
324
|
+
expect(share.getAttribute('aria-expanded')).toBe('true')
|
|
325
|
+
const form = d.querySelector<HTMLFormElement>('form[aria-label="Share by email"]')!
|
|
326
|
+
type(form.querySelector('input[type="email"]')!, 'ben@example.com')
|
|
327
|
+
act(() => button(form, 'Send invite')!.click())
|
|
328
|
+
await settle()
|
|
329
|
+
expect(calls.filter((c) => c.name === 'referral.invite').map((c) => c.args)).toEqual([[{ email: 'ben@example.com' }]])
|
|
330
|
+
expect(d.querySelector('.nv-referral [role="status"]')?.textContent).toBe('Invite sent to ben@example.com')
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
it('with loyalty off the launcher is Refer a friend on its own; with both off, or on the server, nothing renders', async () => {
|
|
334
|
+
const el = await mount(hostWith({ enabled: false }, { referral: ADVOCATE }).remote)
|
|
335
|
+
expect(button(el, 'Open rewards')).toBeUndefined()
|
|
336
|
+
act(() => button(el, 'Open refer a friend')!.click())
|
|
337
|
+
await settle()
|
|
338
|
+
const d = named(el, 'Refer a friend')
|
|
339
|
+
expect(d.querySelector('[role="tablist"]')).toBeNull()
|
|
340
|
+
expect(d.querySelector<HTMLInputElement>('input[readonly]')!.value).toBe(LINK)
|
|
341
|
+
|
|
342
|
+
const off = await mount(hostWith({ enabled: false }, { referral: { enabled: false } }).remote)
|
|
343
|
+
expect(off.querySelector('.nv-rewards-launcher')).toBeNull()
|
|
344
|
+
const html = renderToString(<Page remote={null} />)
|
|
345
|
+
expect(html).toContain('data-tq-client-slot="friend-offer"')
|
|
346
|
+
expect(html).not.toContain('Refer a friend')
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
describe('friend offer on ?ref=CODE', () => {
|
|
351
|
+
it('a new visitor sees the offer, claims it by email, and the code is kept for the session and checkout', async () => {
|
|
352
|
+
window.history.replaceState(null, '', '/?ref=MIA7K3QX')
|
|
353
|
+
const { remote, calls } = hostWith(undefined, { referral: { enabled: false }, offer: OFFER })
|
|
354
|
+
const el = await mount(remote)
|
|
355
|
+
expect(calls.find((c) => c.name === 'referral.offer')?.args).toEqual(['MIA7K3QX'])
|
|
356
|
+
expect(document.cookie).toContain('tanqory_ref=MIA7K3QX')
|
|
357
|
+
const panel = offerPanel(el)!
|
|
358
|
+
expect(panel.getAttribute('aria-labelledby')).toBe(panel.querySelector('h2')!.id)
|
|
359
|
+
expect(panel.textContent).toContain('Mia sent you THB\u00a0100.00 off your first order.')
|
|
360
|
+
expect(panel.textContent).toContain('On orders of THB\u00a0500.00 or more.')
|
|
361
|
+
const email = panel.querySelector<HTMLInputElement>('input[type="email"]')!
|
|
362
|
+
expect(panel.querySelector(`label[for="${email.id}"]`)?.textContent).toContain('Email')
|
|
363
|
+
type(email, 'ben@example.com')
|
|
364
|
+
act(() => button(panel, 'Claim your offer')!.click())
|
|
365
|
+
await settle()
|
|
366
|
+
expect(calls.filter((c) => c.name === 'referral.claim').map((c) => c.args)).toEqual([[{ code: 'MIA7K3QX', email: 'ben@example.com' }]])
|
|
367
|
+
expect(panel.querySelector('[role="status"]')?.textContent).toBe('Offer claimed. Your discount will be applied at checkout.')
|
|
368
|
+
expect(document.cookie).toContain('tanqory_ref_claim=FRIEND-AB12CD34')
|
|
369
|
+
|
|
370
|
+
// Another page of the same session, without the parameter: the code is still the session's, the panel stays away.
|
|
371
|
+
window.history.replaceState(null, '', '/products/tea')
|
|
372
|
+
const next = hostWith(undefined, { referral: { enabled: false }, offer: OFFER })
|
|
373
|
+
const later = await mount(next.remote)
|
|
374
|
+
expect(next.calls.find((c) => c.name === 'referral.offer')?.args).toEqual(['MIA7K3QX'])
|
|
375
|
+
expect(offerPanel(later)).toBeUndefined()
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
it('says why a claim failed; Escape and Close put the panel away for the session', async () => {
|
|
379
|
+
window.history.replaceState(null, '', '/?ref=MIA7K3QX')
|
|
380
|
+
const el = await mount(hostWith(undefined, { offer: OFFER }).remote)
|
|
381
|
+
const panel = offerPanel(el)!
|
|
382
|
+
type(panel.querySelector<HTMLInputElement>('input[type="email"]')!, 'mia@example.com')
|
|
383
|
+
act(() => button(panel, 'Claim your offer')!.click())
|
|
384
|
+
await settle()
|
|
385
|
+
expect(panel.querySelector('[role="alert"]')?.textContent).toBe('This is your own link. Share it with a friend instead.')
|
|
386
|
+
act(() => void panel.querySelector('input')!.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })))
|
|
387
|
+
expect(offerPanel(el)).toBeUndefined()
|
|
388
|
+
expect(offerPanel(await mount(hostWith(undefined, { offer: OFFER }).remote))).toBeUndefined()
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
it('shows nothing to a returning customer, with referrals off, for a host without the op, or without a code', async () => {
|
|
392
|
+
window.history.replaceState(null, '', '/?ref=MIA7K3QX')
|
|
393
|
+
expect(offerPanel(await mount(hostWith(undefined, { offer: { enabled: false } }).remote))).toBeUndefined()
|
|
394
|
+
expect(offerPanel(await mount(hostWith(undefined).remote))).toBeUndefined()
|
|
395
|
+
sessionStorage.clear()
|
|
396
|
+
window.history.replaceState(null, '', '/?ref=%3Cscript%3E')
|
|
397
|
+
const { remote, calls } = hostWith(undefined, { offer: OFFER })
|
|
398
|
+
expect(offerPanel(await mount(remote))).toBeUndefined()
|
|
399
|
+
expect(calls.map((c) => c.name)).not.toContain('referral.offer')
|
|
400
|
+
})
|
|
401
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { defaultsOf, resolveSettings } from '@tanqory/theme-kit'
|
|
3
|
+
import { headerSchema } from '../src/sections/Header/schema'
|
|
4
|
+
import { announcementBarSchema } from '../src/sections/AnnouncementBar/schema'
|
|
5
|
+
import { dividerSchema } from '../src/sections/Divider/schema'
|
|
6
|
+
import { breadcrumbsSchema } from '../src/sections/Breadcrumbs/schema'
|
|
7
|
+
import { groupSchema } from '../src/sections/Group/schema'
|
|
8
|
+
import { iconSchema } from '../src/components/content/blocks/Icon'
|
|
9
|
+
import { spacerSchema } from '../src/sections/Group/blocks/Spacer'
|
|
10
|
+
import { FAMILIES } from '../scripts/compiler/contracts/index'
|
|
11
|
+
|
|
12
|
+
describe('resolveSettings — the adapter core', () => {
|
|
13
|
+
it('fills every visible default and omits unsaved legacy fields', () => {
|
|
14
|
+
const d = defaultsOf(headerSchema)
|
|
15
|
+
expect(d).toMatchObject({ layout: 'logo-left', sticky: 'always', menuStyle: 'mega', background: 'surface', showCart: true })
|
|
16
|
+
expect('bg' in d).toBe(false)
|
|
17
|
+
expect('menu' in d).toBe(false) // a handle, not a prop
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('defaults equal the approved contract for every 12A row', () => {
|
|
21
|
+
for (const s of FAMILIES['12A'].sections) {
|
|
22
|
+
const schema = [headerSchema, announcementBarSchema, dividerSchema, breadcrumbsSchema, groupSchema].find((x) => x.name === s.name)
|
|
23
|
+
if (!schema) continue
|
|
24
|
+
const r = resolveSettings(schema, {})
|
|
25
|
+
for (const row of s.rows) {
|
|
26
|
+
const f = (schema.fields as Record<string, { binding: string } | undefined>)[row.name]
|
|
27
|
+
if (row.status === 'LEGACY-HIDDEN' || f?.binding === 'adapter') continue
|
|
28
|
+
expect([s.name, row.name, (r.settings as Record<string, unknown>)[row.name]]).toEqual([s.name, row.name, row.def])
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('maps legacy option values to what they render as, and reports them', () => {
|
|
34
|
+
const r = resolveSettings(announcementBarSchema, { background: 'surface-secondary' })
|
|
35
|
+
expect(r.settings.background).toBe('muted')
|
|
36
|
+
expect(r.issues).toContainEqual({ key: 'background', code: 'legacy-value', value: 'surface-secondary', resolved: 'muted' })
|
|
37
|
+
expect(resolveSettings(announcementBarSchema, { background: 'primary' }).settings.background).toBe('brand')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('keeps saved LEGACY-HIDDEN values', () => {
|
|
41
|
+
expect(resolveSettings(headerSchema, { bg: '#F3EDE4' }).settings.bg).toBe('#F3EDE4')
|
|
42
|
+
expect(resolveSettings(dividerSchema, { thickness: 2 }).settings.thickness).toBe('2')
|
|
43
|
+
expect(resolveSettings(breadcrumbsSchema, { hideOnMobile: true }).settings.hideOnMobile).toBe(true)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('falls back to the default for an unknown option, never throws', () => {
|
|
47
|
+
const r = resolveSettings(headerSchema, { layout: 'logo-right' })
|
|
48
|
+
expect(r.settings.layout).toBe('logo-left')
|
|
49
|
+
expect(r.issues[0]).toMatchObject({ key: 'layout', code: 'unknown-option' })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('coerces string booleans and numbers, clamps and snaps ranges', () => {
|
|
53
|
+
expect(resolveSettings(headerSchema, { showCart: 'false' }).settings.showCart).toBe(false)
|
|
54
|
+
expect(resolveSettings(groupSchema, { columns: '3' }).settings.columns).toBe(3)
|
|
55
|
+
expect(resolveSettings(groupSchema, { columns: 9 }).settings.columns).toBe(4)
|
|
56
|
+
expect(resolveSettings(iconSchema, { size: 36 }).settings.size).toBe(32)
|
|
57
|
+
expect(resolveSettings(spacerSchema, { height: 60 }).settings.height).toBe(48)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('separates handles from props and reports unknown settings', () => {
|
|
61
|
+
const r = resolveSettings(headerSchema, { menu: 'main-menu', nonsense: 1 })
|
|
62
|
+
expect(r.handles.menu).toBe('main-menu')
|
|
63
|
+
expect(r.issues).toContainEqual({ key: 'nonsense', code: 'unknown-setting', value: 1 })
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Compile-time assertions: legacy-hidden fields are optional, adapter fields are not props.
|
|
2
|
+
import type { HeaderSettings } from '../src/sections/Header/Header'
|
|
3
|
+
type Expect<T extends true> = T
|
|
4
|
+
type IsOptional<T, K extends keyof T> = {} extends Pick<T, K> ? true : false
|
|
5
|
+
export type _bgOptional = Expect<IsOptional<HeaderSettings, 'bg'>>
|
|
6
|
+
export type _layoutRequired = Expect<IsOptional<HeaderSettings, 'layout'> extends false ? true : false>
|
|
7
|
+
export type _menuNotAProp = Expect<'menu' extends keyof HeaderSettings ? false : true>
|