@eldrajs/theme-cli 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/LICENSE +21 -0
- package/README.md +26 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +203 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +3 -0
- package/dist/validate-C6jB8_Oc.js +510 -0
- package/package.json +50 -2
- package/template/.eldra/block-types.d.ts +429 -0
- package/template/.eldra/manifest.json +9377 -0
- package/template/.eldra/previews.json +36 -0
- package/template/.github/workflows/eldra-deploy.yml +24 -0
- package/template/.gitlab-ci.yml +16 -0
- package/template/.storybook/eldra.ts +123 -0
- package/template/.storybook/i18n.ts +23 -0
- package/template/.storybook/main.ts +59 -0
- package/template/.storybook/nuxt-link-stub.ts +23 -0
- package/template/.storybook/preview.ts +52 -0
- package/template/.storybook/shims-vue.d.ts +10 -0
- package/template/.storybook/virtual-eldra.d.ts +27 -0
- package/template/README.md +288 -0
- package/template/app/app.vue +126 -0
- package/template/app/assets/main.css +404 -0
- package/template/app/components/EldraIcon.vue +66 -0
- package/template/app/components/EldraRouterLink.vue +62 -0
- package/template/app/components/ui/UiImage.stories.ts +30 -0
- package/template/app/components/ui/UiImage.vue +224 -0
- package/template/app/components/ui/__tests__/UiImage.spec.ts +292 -0
- package/template/app/composables/iconComponent.ts +84 -0
- package/template/app/composables/iconFetcher.ts +14 -0
- package/template/app/composables/useBlockData.ts +30 -0
- package/template/app/composables/useEditing.ts +31 -0
- package/template/app/composables/useEldraIcon.ts +46 -0
- package/template/app/composables/useRevalidating.ts +69 -0
- package/template/app/composables/useRichTextScrollRegions.ts +80 -0
- package/template/app/composables/useStorefront.ts +18 -0
- package/template/app/composables/useStorefrontFeedback.ts +49 -0
- package/template/app/composables/useUiId.ts +18 -0
- package/template/app/composables/useWishlist.ts +42 -0
- package/template/app/i18n.d.ts +28 -0
- package/template/app/icons.ts +185 -0
- package/template/app/pages/[...slug].vue +134 -0
- package/template/app/plugins/eldra-i18n.ts +98 -0
- package/template/app/plugins/eldra-storefront.ts +288 -0
- package/template/app/plugins/eldra-ui-messages.ts +112 -0
- package/template/app/storefront/cart.ts +245 -0
- package/template/app/storefront/categories.ts +283 -0
- package/template/app/storefront/collectionSelector.ts +60 -0
- package/template/app/storefront/commerce.ts +58 -0
- package/template/app/storefront/demo.ts +1313 -0
- package/template/app/storefront/facets.ts +476 -0
- package/template/app/storefront/feedback.ts +122 -0
- package/template/app/storefront/gateway.ts +2256 -0
- package/template/app/storefront/history.ts +233 -0
- package/template/app/storefront/money.ts +247 -0
- package/template/app/storefront/options.ts +71 -0
- package/template/app/storefront/prerender.ts +77 -0
- package/template/app/storefront/refresh.ts +222 -0
- package/template/app/storefront/toProductCard.ts +154 -0
- package/template/app/storefront/types.ts +815 -0
- package/template/app/storefront/volatile.ts +211 -0
- package/template/app/templates.ts +544 -0
- package/template/app/utils/classes.ts +40 -0
- package/template/app/utils/links.ts +70 -0
- package/template/app/utils/pageStructure.ts +77 -0
- package/template/app/utils/pageTitle.ts +37 -0
- package/template/app/virtual-eldra.d.ts +12 -0
- package/template/bitbucket-pipelines.yml +19 -0
- package/template/blocks/announcement-bar/Block.vue +203 -0
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +227 -0
- package/template/blocks/announcement-bar/block.json +45 -0
- package/template/blocks/announcement-bar/mock.json +7 -0
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +317 -0
- package/template/blocks/article/__tests__/Block.spec.ts +229 -0
- package/template/blocks/article/block.json +148 -0
- package/template/blocks/article/mock.json +512 -0
- package/template/blocks/article/preview.json +16 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +343 -0
- package/template/blocks/article-list/__tests__/Block.spec.ts +279 -0
- package/template/blocks/article-list/block.json +181 -0
- package/template/blocks/article-list/mock.json +68 -0
- package/template/blocks/article-list/preview.json +84 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +278 -0
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +461 -0
- package/template/blocks/breadcrumbs/block.json +89 -0
- package/template/blocks/breadcrumbs/mock.json +11 -0
- package/template/blocks/breadcrumbs/preview.json +3 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +372 -0
- package/template/blocks/cart/__tests__/Block.spec.ts +561 -0
- package/template/blocks/cart/__tests__/ShippingBar.spec.ts +78 -0
- package/template/blocks/cart/__tests__/Summary.spec.ts +245 -0
- package/template/blocks/cart/block.json +74 -0
- package/template/blocks/cart/mock.json +11 -0
- package/template/blocks/cart/parts/CartLines.vue +257 -0
- package/template/blocks/cart/parts/ShippingBar.vue +105 -0
- package/template/blocks/cart/parts/Summary.vue +291 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +1832 -0
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +3037 -0
- package/template/blocks/collection-grid/__tests__/groups.spec.ts +731 -0
- package/template/blocks/collection-grid/block.json +187 -0
- package/template/blocks/collection-grid/mock.json +23 -0
- package/template/blocks/collection-grid/parts/groups.ts +861 -0
- package/template/blocks/collection-grid/preview.json +7 -0
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +533 -0
- package/template/blocks/collection-header/__tests__/Block.spec.ts +381 -0
- package/template/blocks/collection-header/block.json +140 -0
- package/template/blocks/collection-header/mock.json +28 -0
- package/template/blocks/collection-header/preview.json +14 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/Block.vue +621 -0
- package/template/blocks/contact/__tests__/Block.spec.ts +347 -0
- package/template/blocks/contact/block.json +174 -0
- package/template/blocks/contact/mock.json +28 -0
- package/template/blocks/contact/preview.json +9 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/Block.vue +383 -0
- package/template/blocks/cta/__tests__/Block.spec.ts +309 -0
- package/template/blocks/cta/block.json +86 -0
- package/template/blocks/cta/mock.json +10 -0
- package/template/blocks/cta/preview.json +9 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/Block.vue +254 -0
- package/template/blocks/faq/__tests__/Block.spec.ts +312 -0
- package/template/blocks/faq/block.json +113 -0
- package/template/blocks/faq/mock.json +115 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +241 -0
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +311 -0
- package/template/blocks/feature-grid/block.json +106 -0
- package/template/blocks/feature-grid/mock.json +29 -0
- package/template/blocks/feature-grid/preview.json +45 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +652 -0
- package/template/blocks/footer/__tests__/Block.spec.ts +700 -0
- package/template/blocks/footer/block.json +240 -0
- package/template/blocks/footer/mock.json +161 -0
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/gallery/Block.vue +416 -0
- package/template/blocks/gallery/__tests__/Block.spec.ts +289 -0
- package/template/blocks/gallery/block.json +87 -0
- package/template/blocks/gallery/mock.json +16 -0
- package/template/blocks/gallery/preview.json +64 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +378 -0
- package/template/blocks/hero/__tests__/Block.spec.ts +324 -0
- package/template/blocks/hero/block.json +146 -0
- package/template/blocks/hero/mock.json +11 -0
- package/template/blocks/hero/preview.json +55 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/Block.vue +232 -0
- package/template/blocks/image/__tests__/Block.spec.ts +224 -0
- package/template/blocks/image/block.json +67 -0
- package/template/blocks/image/mock.json +7 -0
- package/template/blocks/image/preview.json +9 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/Block.vue +206 -0
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +210 -0
- package/template/blocks/logo-cloud/block.json +79 -0
- package/template/blocks/logo-cloud/mock.json +15 -0
- package/template/blocks/logo-cloud/preview.json +92 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +1348 -0
- package/template/blocks/navigation/__tests__/Block.spec.ts +2030 -0
- package/template/blocks/navigation/block.json +167 -0
- package/template/blocks/navigation/mock.json +191 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/navigation/useMegaMenuKeys.ts +276 -0
- package/template/blocks/newsletter/Block.vue +399 -0
- package/template/blocks/newsletter/__tests__/Block.spec.ts +365 -0
- package/template/blocks/newsletter/block.json +105 -0
- package/template/blocks/newsletter/mock.json +31 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +754 -0
- package/template/blocks/order-status/__tests__/Block.spec.ts +515 -0
- package/template/blocks/order-status/block.json +138 -0
- package/template/blocks/order-status/mock.json +19 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/Block.vue +297 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +357 -0
- package/template/blocks/pricing-table/block.json +155 -0
- package/template/blocks/pricing-table/mock.json +47 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +459 -0
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +957 -0
- package/template/blocks/product-carousel/block.json +71 -0
- package/template/blocks/product-carousel/mock.json +9 -0
- package/template/blocks/product-carousel/preview.json +7 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +886 -0
- package/template/blocks/product-detail/__tests__/Block.spec.ts +1495 -0
- package/template/blocks/product-detail/__tests__/stock.spec.ts +119 -0
- package/template/blocks/product-detail/block.json +155 -0
- package/template/blocks/product-detail/mock.json +113 -0
- package/template/blocks/product-detail/parts/Gallery.vue +181 -0
- package/template/blocks/product-detail/parts/StickyBuyBar.vue +99 -0
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/product-detail/stock.ts +150 -0
- package/template/blocks/quote/Block.vue +206 -0
- package/template/blocks/quote/__tests__/Block.spec.ts +265 -0
- package/template/blocks/quote/block.json +76 -0
- package/template/blocks/quote/mock.json +9 -0
- package/template/blocks/quote/preview.json +16 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/Block.vue +143 -0
- package/template/blocks/rich-text/__tests__/Block.spec.ts +191 -0
- package/template/blocks/rich-text/block.json +57 -0
- package/template/blocks/rich-text/mock.json +87 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +589 -0
- package/template/blocks/search/PopularChips.vue +40 -0
- package/template/blocks/search/TypeSection.vue +148 -0
- package/template/blocks/search/__tests__/Block.spec.ts +718 -0
- package/template/blocks/search/__tests__/results.spec.ts +166 -0
- package/template/blocks/search/block.json +102 -0
- package/template/blocks/search/mock.json +18 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/search/results.ts +85 -0
- package/template/blocks/split-content/Block.vue +195 -0
- package/template/blocks/split-content/__tests__/Block.spec.ts +225 -0
- package/template/blocks/split-content/block.json +70 -0
- package/template/blocks/split-content/mock.json +45 -0
- package/template/blocks/split-content/preview.json +58 -0
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/Block.vue +159 -0
- package/template/blocks/stats/__tests__/Block.spec.ts +194 -0
- package/template/blocks/stats/block.json +73 -0
- package/template/blocks/stats/mock.json +12 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +278 -0
- package/template/blocks/tabs/__tests__/Block.spec.ts +303 -0
- package/template/blocks/tabs/block.json +97 -0
- package/template/blocks/tabs/mock.json +129 -0
- package/template/blocks/tabs/preview.json +153 -0
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/Block.vue +288 -0
- package/template/blocks/team/__tests__/Block.spec.ts +221 -0
- package/template/blocks/team/block.json +125 -0
- package/template/blocks/team/mock.json +39 -0
- package/template/blocks/team/preview.json +62 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/Block.vue +408 -0
- package/template/blocks/testimonials/__tests__/Block.spec.ts +319 -0
- package/template/blocks/testimonials/block.json +121 -0
- package/template/blocks/testimonials/mock.json +46 -0
- package/template/blocks/testimonials/preview.json +68 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/Block.vue +274 -0
- package/template/blocks/timeline/__tests__/Block.spec.ts +310 -0
- package/template/blocks/timeline/block.json +98 -0
- package/template/blocks/timeline/mock.json +27 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +330 -0
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +290 -0
- package/template/blocks/trust-strip/block.json +117 -0
- package/template/blocks/trust-strip/mock.json +37 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/Block.vue +354 -0
- package/template/blocks/video-embed/__tests__/Block.spec.ts +219 -0
- package/template/blocks/video-embed/__tests__/embed.spec.ts +76 -0
- package/template/blocks/video-embed/block.json +94 -0
- package/template/blocks/video-embed/embed.ts +84 -0
- package/template/blocks/video-embed/mock.json +13 -0
- package/template/blocks/video-embed/preview.json +9 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +367 -0
- package/template/blocks/wishlist/__tests__/Block.spec.ts +508 -0
- package/template/blocks/wishlist/block.json +42 -0
- package/template/blocks/wishlist/mock.json +9 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +602 -0
- package/template/i18n/is-IS.json +602 -0
- package/template/nuxt.config.ts +148 -0
- package/template/package.json +55 -0
- package/template/pages/article.page.json +731 -0
- package/template/pages/cart.page.json +85 -0
- package/template/pages/category.page.json +133 -0
- package/template/pages/collection.page.json +194 -0
- package/template/pages/home.page.json +353 -0
- package/template/pages/product.page.json +323 -0
- package/template/pages/products.page.json +144 -0
- package/template/pages/search.page.json +83 -0
- package/template/pages/wishlist.page.json +88 -0
- package/template/public/demo/article-cover.svg +1 -0
- package/template/public/demo/article-figure.svg +1 -0
- package/template/public/demo/avatar-1.svg +3 -0
- package/template/public/demo/avatar-2.svg +3 -0
- package/template/public/demo/avatar-3.svg +3 -0
- package/template/public/demo/avatar-4.svg +3 -0
- package/template/public/demo/avatar-5.svg +3 -0
- package/template/public/demo/avatar-6.svg +3 -0
- package/template/public/demo/avatar-7.svg +3 -0
- package/template/public/demo/avatar-8.svg +3 -0
- package/template/public/demo/collection-1.svg +1 -0
- package/template/public/demo/collection-2.svg +1 -0
- package/template/public/demo/cta-split.svg +1 -0
- package/template/public/demo/feature-1.svg +1 -0
- package/template/public/demo/feature-2.svg +1 -0
- package/template/public/demo/feature-3.svg +1 -0
- package/template/public/demo/feature-4.svg +1 -0
- package/template/public/demo/gallery-1.svg +1 -0
- package/template/public/demo/gallery-2.svg +1 -0
- package/template/public/demo/gallery-3.svg +1 -0
- package/template/public/demo/gallery-4.svg +1 -0
- package/template/public/demo/gallery-5.svg +1 -0
- package/template/public/demo/gallery-6.svg +1 -0
- package/template/public/demo/gallery-7.svg +1 -0
- package/template/public/demo/gallery-8.svg +1 -0
- package/template/public/demo/hero-slide-1.svg +1 -0
- package/template/public/demo/hero-slide-2.svg +1 -0
- package/template/public/demo/hero-slide-3.svg +1 -0
- package/template/public/demo/hero-slide-4.svg +1 -0
- package/template/public/demo/hero-wide.svg +1 -0
- package/template/public/demo/hero.svg +1 -0
- package/template/public/demo/logo-1.svg +4 -0
- package/template/public/demo/logo-2.svg +4 -0
- package/template/public/demo/logo-3.svg +4 -0
- package/template/public/demo/logo-4.svg +4 -0
- package/template/public/demo/logo-5.svg +4 -0
- package/template/public/demo/logo-6.svg +4 -0
- package/template/public/demo/logo-7.svg +4 -0
- package/template/public/demo/logo-8.svg +4 -0
- package/template/public/demo/logo.svg +3 -0
- package/template/public/demo/map.svg +1 -0
- package/template/public/demo/poster.svg +1 -0
- package/template/public/demo/product-1.svg +4 -0
- package/template/public/demo/product-10.svg +4 -0
- package/template/public/demo/product-11.svg +4 -0
- package/template/public/demo/product-12.svg +4 -0
- package/template/public/demo/product-2.svg +4 -0
- package/template/public/demo/product-3.svg +4 -0
- package/template/public/demo/product-4.svg +4 -0
- package/template/public/demo/product-5.svg +4 -0
- package/template/public/demo/product-6.svg +4 -0
- package/template/public/demo/product-7.svg +4 -0
- package/template/public/demo/product-8.svg +4 -0
- package/template/public/demo/product-9.svg +4 -0
- package/template/public/demo/product-square-1.svg +4 -0
- package/template/public/demo/product-square-2.svg +4 -0
- package/template/public/demo/product-square-3.svg +4 -0
- package/template/public/demo/product-square-4.svg +4 -0
- package/template/public/demo/product-square-5.svg +4 -0
- package/template/public/demo/product-square-6.svg +4 -0
- package/template/public/demo/quote-portrait.svg +4 -0
- package/template/public/demo/split-1.svg +1 -0
- package/template/public/demo/split-2.svg +1 -0
- package/template/public/demo/split-3.svg +1 -0
- package/template/public/demo/split-4.svg +1 -0
- package/template/public/demo/team-1.svg +4 -0
- package/template/public/demo/team-2.svg +4 -0
- package/template/public/demo/team-3.svg +4 -0
- package/template/public/demo/team-4.svg +4 -0
- package/template/scripts/demo-images.mjs +393 -0
- package/template/scripts/generate-stories.mjs +156 -0
- package/template/scripts/previewHash.mjs +125 -0
- package/template/scripts/previews.mjs +149 -0
- package/template/stories/generated/announcement-bar.stories.ts +44 -0
- package/template/stories/generated/article-list.stories.ts +87 -0
- package/template/stories/generated/article.stories.ts +27 -0
- package/template/stories/generated/breadcrumbs.stories.ts +39 -0
- package/template/stories/generated/cart.stories.ts +38 -0
- package/template/stories/generated/collection-grid.stories.ts +117 -0
- package/template/stories/generated/collection-header.stories.ts +51 -0
- package/template/stories/generated/contact.stories.ts +45 -0
- package/template/stories/generated/cta.stories.ts +51 -0
- package/template/stories/generated/faq.stories.ts +56 -0
- package/template/stories/generated/feature-grid.stories.ts +69 -0
- package/template/stories/generated/footer.stories.ts +50 -0
- package/template/stories/generated/gallery.stories.ts +81 -0
- package/template/stories/generated/hero.stories.ts +75 -0
- package/template/stories/generated/image.stories.ts +99 -0
- package/template/stories/generated/logo-cloud.stories.ts +57 -0
- package/template/stories/generated/navigation.stories.ts +62 -0
- package/template/stories/generated/newsletter.stories.ts +68 -0
- package/template/stories/generated/order-status.stories.ts +32 -0
- package/template/stories/generated/pricing-table.stories.ts +44 -0
- package/template/stories/generated/product-carousel.stories.ts +75 -0
- package/template/stories/generated/product-detail.stories.ts +62 -0
- package/template/stories/generated/quote.stories.ts +69 -0
- package/template/stories/generated/rich-text.stories.ts +50 -0
- package/template/stories/generated/search.stories.ts +56 -0
- package/template/stories/generated/split-content.stories.ts +39 -0
- package/template/stories/generated/stats.stories.ts +68 -0
- package/template/stories/generated/tabs.stories.ts +45 -0
- package/template/stories/generated/team.stories.ts +45 -0
- package/template/stories/generated/testimonials.stories.ts +69 -0
- package/template/stories/generated/timeline.stories.ts +80 -0
- package/template/stories/generated/trust-strip.stories.ts +62 -0
- package/template/stories/generated/video-embed.stories.ts +63 -0
- package/template/stories/generated/wishlist.stories.ts +26 -0
- package/template/stories/pages/article.stories.ts +51 -0
- package/template/stories/pages/cart.stories.ts +56 -0
- package/template/stories/pages/category.stories.ts +56 -0
- package/template/stories/pages/collection.stories.ts +51 -0
- package/template/stories/pages/home.stories.ts +51 -0
- package/template/stories/pages/product.stories.ts +47 -0
- package/template/stories/pages/products.stories.ts +58 -0
- package/template/stories/pages/search.stories.ts +54 -0
- package/template/stories/pages/wishlist.stories.ts +53 -0
- package/template/stories/support/pageBlocks.ts +115 -0
- package/template/test/blocksEmptyData.spec.ts +52 -0
- package/template/test/carouselKeyboard.spec.ts +272 -0
- package/template/test/carouselRing.browser.spec.ts +193 -0
- package/template/test/carouselSlideWidth.browser.spec.ts +102 -0
- package/template/test/cartDrawer.spec.ts +295 -0
- package/template/test/cartToast.spec.ts +86 -0
- package/template/test/countPill.browser.spec.ts +196 -0
- package/template/test/demoImages.spec.ts +140 -0
- package/template/test/deps.spec.ts +102 -0
- package/template/test/eldraIcon.spec.ts +58 -0
- package/template/test/framing.spec.ts +76 -0
- package/template/test/i18n.spec.ts +200 -0
- package/template/test/iconComponent.spec.ts +91 -0
- package/template/test/inlineEditable.spec.ts +334 -0
- package/template/test/localePrefix.spec.ts +342 -0
- package/template/test/mainCss.spec.ts +107 -0
- package/template/test/mockGatewayContract.spec.ts +122 -0
- package/template/test/mocks/blocks.ts +20 -0
- package/template/test/mocks/breakpoints.ts +7 -0
- package/template/test/mocks/manifest.ts +11 -0
- package/template/test/moneyFormatting.spec.ts +89 -0
- package/template/test/pageTitle.spec.ts +49 -0
- package/template/test/pages/article.spec.ts +231 -0
- package/template/test/pages/category.spec.ts +185 -0
- package/template/test/pages/collection.spec.ts +396 -0
- package/template/test/pages/home.spec.ts +295 -0
- package/template/test/pages/hydration.spec.ts +557 -0
- package/template/test/pages/product.spec.ts +396 -0
- package/template/test/pages/seededPages.spec.ts +190 -0
- package/template/test/pages/ssr.spec.ts +393 -0
- package/template/test/prerenderCommerce.spec.ts +134 -0
- package/template/test/prerenderFailure.spec.ts +130 -0
- package/template/test/prerenderRefresh.browser.spec.ts +1431 -0
- package/template/test/previewsFresh.spec.ts +56 -0
- package/template/test/richText.spec.ts +161 -0
- package/template/test/richTextTypography.spec.ts +182 -0
- package/template/test/setup.ts +21 -0
- package/template/test/slugPage.spec.ts +244 -0
- package/template/test/slugPageTemplate.spec.ts +194 -0
- package/template/test/starter.spec.ts +1416 -0
- package/template/test/storefront/cart.spec.ts +404 -0
- package/template/test/storefront/categories.spec.ts +235 -0
- package/template/test/storefront/collectionSelector.spec.ts +74 -0
- package/template/test/storefront/demo.spec.ts +555 -0
- package/template/test/storefront/facets.spec.ts +425 -0
- package/template/test/storefront/feedback.spec.ts +97 -0
- package/template/test/storefront/gateway.spec.ts +2673 -0
- package/template/test/storefront/gatewayCart.spec.ts +289 -0
- package/template/test/storefront/gatewayPrerender.spec.ts +1037 -0
- package/template/test/storefront/history.spec.ts +341 -0
- package/template/test/storefront/money.spec.ts +171 -0
- package/template/test/storefront/toProductCard.spec.ts +138 -0
- package/template/test/storefront/volatile.spec.ts +284 -0
- package/template/test/support/axe.ts +14 -0
- package/template/test/support/dialog.ts +51 -0
- package/template/test/support/hydrate.ts +118 -0
- package/template/test/support/i18nText.ts +11 -0
- package/template/test/support/mockGateway.ts +1017 -0
- package/template/test/support/mountBlock.ts +194 -0
- package/template/test/support/mountPage.spec.ts +72 -0
- package/template/test/support/mountPage.ts +254 -0
- package/template/test/support/mountProbe.client.ts +69 -0
- package/template/test/support/renderSsr.ts +97 -0
- package/template/test/support/staticServer.ts +96 -0
- package/template/test/themeIcons.spec.ts +140 -0
- package/template/test/toastAnnouncement.spec.ts +133 -0
- package/template/test/tokens.spec.ts +102 -0
- package/template/test/uiMessagesPlugin.spec.ts +104 -0
- package/template/test/useBlockData.spec.ts +46 -0
- package/template/test/useEditing.spec.ts +54 -0
- package/template/test/useEldraIcon.spec.ts +126 -0
- package/template/test/useUiId.spec.ts +40 -0
- package/template/tokens.json +149 -0
- package/template/tsconfig.json +3 -0
- package/template/tsconfig.storybook.json +17 -0
- package/template/vitest-axe.d.ts +13 -0
- package/template/vitest.config.ts +44 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Pricing table: side-by-side subscription or service plans, each with a price, a billing note, a
|
|
4
|
+
* call to action and a checklist of feature rows compared across every plan (spec `02-blocks.md`
|
|
5
|
+
* 1524–1641, "Pricing table"). No `variant` field — one layout; the highlighted plan is a state
|
|
6
|
+
* driven by `highlightedPlan` (a plain `string` matched against `plans[].name`, since the spec's
|
|
7
|
+
* own "`none` or a plan name" `select` cannot be a static one — see Global Constraints).
|
|
8
|
+
*
|
|
9
|
+
* **Layout.** Below `@tablet` (48rem of the block's own width) plans stack in one column and each
|
|
10
|
+
* card is a plain `flex flex-col` — no need for a shared grid since there is only one column.
|
|
11
|
+
* From `@tablet`, the `<ul>` becomes `grid-cols-[repeat(auto-fit,minmax(13rem,1fr))]` with an
|
|
12
|
+
* explicit 4-row template (`grid-rows-[repeat(4,auto)]`), and every `<li>` switches to
|
|
13
|
+
* `grid grid-rows-subgrid row-span-4`: its four direct children (top, price, call to action,
|
|
14
|
+
* features) each land in one shared row *track*, so a track's height is driven by the tallest
|
|
15
|
+
* card at that position — which is exactly what makes prices, buttons and first feature rows line
|
|
16
|
+
* up across plans even when descriptions differ in length (spec → Layout, "48–64rem" /
|
|
17
|
+
* "From 64rem"), with no manual height sync.
|
|
18
|
+
*
|
|
19
|
+
* **Highlight.** Never colour alone (spec Acceptance): the highlighted plan gets a 2px `primary`
|
|
20
|
+
* border, a `surface` fill, a `Badge tone="primary" pill` (with a star icon) carrying the
|
|
21
|
+
* `highlightLabel` text, and a filled `primary` `Button`; every other plan gets a 1px `border`
|
|
22
|
+
* border, a `background` fill and an `outline` `Button`. The highlighted card's padding is 1px
|
|
23
|
+
* less than the default at every breakpoint (`calc(...- 1px)`) so the extra border width doesn't
|
|
24
|
+
* shift its content out of alignment with the other cards' (spec → Layout, "Highlighted plan").
|
|
25
|
+
*
|
|
26
|
+
* **Feature rows.** `featureRows` is the shared, ordered list of comparison rows; each plan's own
|
|
27
|
+
* `included` is a bare `bool[]` (Core's `list` of a plain `bool` item, not a composite),
|
|
28
|
+
* one entry per `featureRows` index in the same order. A short `included` array (or a
|
|
29
|
+
* plan with none at all) is read as "not included" for the missing rows (`isIncluded` below), per
|
|
30
|
+
* the field's own `helpText`. Every row carries the state three ways at once (spec Acceptance,
|
|
31
|
+
* 1.4.1): a check/minus icon shape, visually hidden "Included:"/"Not included:" text before the
|
|
32
|
+
* label, and `muted` colour on excluded rows — colour is never the only signal.
|
|
33
|
+
*
|
|
34
|
+
* **Icons.** The check/minus feature-row icons go through `EldraIcon` (name-based, decorative:
|
|
35
|
+
* no `label`, so `Icon.vue` marks them `aria-hidden` itself) at its `md` size (1.25rem, matching
|
|
36
|
+
* the spec's literal icon size) — like `footer`'s own `circle-check`, this accepts the package's
|
|
37
|
+
* fixed 1.75 stroke rather than the spec's literal 2.25, the same "package wins" trade `Badge`'s
|
|
38
|
+
* own icon doc comment makes explicit for exactly this reason. The badge's star icon can't go
|
|
39
|
+
* through `EldraIcon` at all: `Badge.icon` takes a bare, already-bound `IconComponent` it renders
|
|
40
|
+
* directly (`<component :is="icon" :stroke-width="…" aria-hidden focusable="false">`), the same
|
|
41
|
+
* contract `FeatureCard.icon` has — so `StarIcon` below comes from the theme's one shared
|
|
42
|
+
* name→component adapter (`app/composables/iconComponent.ts`), fixed to one name.
|
|
43
|
+
*
|
|
44
|
+
* **Buttons.** The spec's own literal "2.75rem below 48rem" for the call-to-action `Button md` is
|
|
45
|
+
* the same in-between control height the package doesn't have (`tailwind.css`'s own comment:
|
|
46
|
+
* "`Button` no longer grows at any container [width]" — the old target-touch-below-48rem growth
|
|
47
|
+
* rule is gone). `cta`'s `banner` variant already documents this exact trade for its own `lg`
|
|
48
|
+
* button; here it means `Button size="md" block` renders at the package's one fixed `md` height
|
|
49
|
+
* (2.5rem) at every width, a deliberate, already-precedented deviation from the spec's literal
|
|
50
|
+
* number, not a bug.
|
|
51
|
+
*/
|
|
52
|
+
import { computed, defineComponent, h, type Component } from 'vue';
|
|
53
|
+
import {
|
|
54
|
+
Badge,
|
|
55
|
+
Button,
|
|
56
|
+
Container,
|
|
57
|
+
EditorPlaceholder,
|
|
58
|
+
Section,
|
|
59
|
+
VisuallyHidden,
|
|
60
|
+
type SectionBackground,
|
|
61
|
+
} from '@eldrajs/ui';
|
|
62
|
+
import { useBlockData } from '../../app/composables/useBlockData';
|
|
63
|
+
import { useEditing } from '../../app/composables/useEditing';
|
|
64
|
+
import { iconComponent } from '../../app/composables/iconComponent';
|
|
65
|
+
import { useI18n } from 'vue-i18n';
|
|
66
|
+
import { useUiId } from '../../app/composables/useUiId';
|
|
67
|
+
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
68
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
69
|
+
import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
70
|
+
|
|
71
|
+
const props = defineProps<{ entry: EldraBlockEntry<'pricing-table'> }>();
|
|
72
|
+
const { data } = useBlockData(props, 'pricing-table');
|
|
73
|
+
const { t } = useI18n();
|
|
74
|
+
const isEditing = useEditing();
|
|
75
|
+
const uid = useUiId();
|
|
76
|
+
const headingId = `pricing-table-heading-${uid}`;
|
|
77
|
+
|
|
78
|
+
const sectionBackground = computed<SectionBackground>(() => data.value.sectionBackground ?? 'none');
|
|
79
|
+
|
|
80
|
+
const heading = computed(() => (data.value.heading ?? '').trim());
|
|
81
|
+
const hasHeading = computed(() => heading.value !== '');
|
|
82
|
+
const showHeadingHint = computed(() => isEditing.value && !hasHeading.value);
|
|
83
|
+
|
|
84
|
+
const intro = computed(() => (data.value.intro ?? '').trim());
|
|
85
|
+
const hasIntro = computed(() => intro.value !== '');
|
|
86
|
+
const showIntroHint = computed(() => isEditing.value && !hasIntro.value);
|
|
87
|
+
|
|
88
|
+
const footnote = computed(() => (data.value.footnote ?? '').trim());
|
|
89
|
+
|
|
90
|
+
interface FeatureRow {
|
|
91
|
+
label?: string;
|
|
92
|
+
}
|
|
93
|
+
interface Plan {
|
|
94
|
+
name?: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
price?: string;
|
|
97
|
+
period?: string;
|
|
98
|
+
note?: string;
|
|
99
|
+
ctaLabel?: string;
|
|
100
|
+
ctaHref?: string;
|
|
101
|
+
included?: boolean[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const featureRows = computed<FeatureRow[]>(() => data.value.featureRows ?? []);
|
|
105
|
+
const allPlans = computed<Plan[]>(() => data.value.plans ?? []);
|
|
106
|
+
|
|
107
|
+
function isPlanEmpty(plan: Plan): boolean {
|
|
108
|
+
return (plan.name ?? '').trim() === '' && (plan.price ?? '').trim() === '';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Live: only plans with at least a name or price render (Global Constraints, "Editor vs live").
|
|
112
|
+
* Editing: every plan renders, so an empty one keeps its place and can show a hint instead of
|
|
113
|
+
* vanishing while an editor is filling it in. */
|
|
114
|
+
const renderedPlans = computed<Plan[]>(() =>
|
|
115
|
+
isEditing.value ? allPlans.value : allPlans.value.filter((plan) => !isPlanEmpty(plan))
|
|
116
|
+
);
|
|
117
|
+
/** Spec → States, "Minimal content": "1 plan, which spans the full width." `auto-fit` already
|
|
118
|
+
* stretches a single grid item to the full row on its own; `col-span-full` makes that explicit
|
|
119
|
+
* and keeps it true however many empty (auto-fit-starving) tracks a browser might otherwise try
|
|
120
|
+
* to reserve. */
|
|
121
|
+
const isSingleItem = computed(() => renderedPlans.value.length === 1);
|
|
122
|
+
|
|
123
|
+
const highlightedPlanName = computed(() => (data.value.highlightedPlan ?? '').trim());
|
|
124
|
+
function isHighlighted(plan: Plan): boolean {
|
|
125
|
+
const name = (plan.name ?? '').trim();
|
|
126
|
+
return highlightedPlanName.value !== '' && name === highlightedPlanName.value;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const highlightLabel = computed(() => data.value.highlightLabel || t('pricing.mostPopular'));
|
|
130
|
+
|
|
131
|
+
/** A short (or absent) `included` array reads as "not included" for the rows past its end (the
|
|
132
|
+
* field's own `helpText`). */
|
|
133
|
+
function isIncluded(plan: Plan, index: number): boolean {
|
|
134
|
+
return plan.included?.[index] === true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function ctaHref(plan: Plan): string | null {
|
|
138
|
+
return safeHref(plan.ctaHref);
|
|
139
|
+
}
|
|
140
|
+
function ctaAs(plan: Plan) {
|
|
141
|
+
const href = ctaHref(plan);
|
|
142
|
+
return href !== null && isInternalHref(href) ? EldraRouterLink : undefined;
|
|
143
|
+
}
|
|
144
|
+
function hasCta(plan: Plan): boolean {
|
|
145
|
+
return (plan.ctaLabel ?? '').trim() !== '' && ctaHref(plan) !== null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* `Badge.icon` (like `FeatureCard.icon`) takes a bare, already-bound icon component with no props
|
|
150
|
+
* of its own — `EldraIcon` needs a `name` bound and so can't be handed straight through. The
|
|
151
|
+
* theme's shared name→component adapter (`app/composables/iconComponent.ts`) caches per name at
|
|
152
|
+
* module scope, so a reactive re-render never creates a new identity for the same icon, which would
|
|
153
|
+
* otherwise remount — and re-fetch — it on every keystroke in the Studio editor.
|
|
154
|
+
*/
|
|
155
|
+
const StarIcon: Component = iconComponent('star');
|
|
156
|
+
|
|
157
|
+
/** Spec → Layout, plan card padding at each width: 1.5rem below `@tablet`, 1.25rem `@tablet`–
|
|
158
|
+
* `@content`, 2rem from `@content`. The highlighted card keeps the same three numbers minus the
|
|
159
|
+
* 1px its thicker border adds, so its content stays aligned with every other card's. */
|
|
160
|
+
function cardPaddingClass(highlighted: boolean): string {
|
|
161
|
+
return highlighted
|
|
162
|
+
? 'p-[calc(1.5rem-1px)] @tablet:p-[calc(1.25rem-1px)] @content:p-[calc(2rem-1px)]'
|
|
163
|
+
: 'p-6 @tablet:p-5 @content:p-8';
|
|
164
|
+
}
|
|
165
|
+
function cardClass(highlighted: boolean, singleItem: boolean): (string | boolean)[] {
|
|
166
|
+
return [
|
|
167
|
+
'rounded-lg',
|
|
168
|
+
'flex flex-col gap-5',
|
|
169
|
+
'@tablet:grid @tablet:grid-rows-subgrid @tablet:row-span-4',
|
|
170
|
+
cardPaddingClass(highlighted),
|
|
171
|
+
highlighted ? 'border-2 border-primary bg-surface' : 'border border-border bg-background',
|
|
172
|
+
singleItem ? '@tablet:col-span-full' : '',
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
<template>
|
|
178
|
+
<Section :background="sectionBackground" spacing="md" :labelled-by="headingId">
|
|
179
|
+
<Container width="content">
|
|
180
|
+
<div class="mx-auto mb-8 max-w-[40rem] text-center">
|
|
181
|
+
<h2
|
|
182
|
+
v-if="hasHeading"
|
|
183
|
+
:id="headingId"
|
|
184
|
+
class="font-heading @tablet:text-[2rem] text-[1.625rem] leading-[1.15] font-bold tracking-[-0.015em] text-balance"
|
|
185
|
+
>
|
|
186
|
+
{{ heading }}
|
|
187
|
+
</h2>
|
|
188
|
+
<EditorPlaceholder
|
|
189
|
+
v-else-if="showHeadingHint"
|
|
190
|
+
:id="headingId"
|
|
191
|
+
inline
|
|
192
|
+
:label="t('pricing.headingHintLabel')"
|
|
193
|
+
/>
|
|
194
|
+
<p v-if="hasIntro" class="text-muted mt-3 text-base">{{ intro }}</p>
|
|
195
|
+
<EditorPlaceholder
|
|
196
|
+
v-else-if="showIntroHint"
|
|
197
|
+
inline
|
|
198
|
+
:label="t('pricing.introHintLabel')"
|
|
199
|
+
class="mt-3"
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<ul
|
|
204
|
+
role="list"
|
|
205
|
+
class="@tablet:grid-cols-[repeat(auto-fit,minmax(13rem,1fr))] @tablet:grid-rows-[repeat(4,auto)] @content:gap-6 grid grid-cols-1 items-start gap-4"
|
|
206
|
+
>
|
|
207
|
+
<li
|
|
208
|
+
v-for="(plan, index) in renderedPlans"
|
|
209
|
+
:key="index"
|
|
210
|
+
:aria-labelledby="`pricing-table-plan-${uid}-${index}`"
|
|
211
|
+
:class="cardClass(isHighlighted(plan), isSingleItem)"
|
|
212
|
+
>
|
|
213
|
+
<template v-if="isEditing && isPlanEmpty(plan)">
|
|
214
|
+
<EditorPlaceholder
|
|
215
|
+
inline
|
|
216
|
+
:label="t('pricing.planHintLabel')"
|
|
217
|
+
:help="t('pricing.planHintHelp')"
|
|
218
|
+
/>
|
|
219
|
+
</template>
|
|
220
|
+
<template v-else>
|
|
221
|
+
<!-- top: name + highlight badge, description -->
|
|
222
|
+
<div class="flex flex-col gap-2">
|
|
223
|
+
<div class="flex min-h-[1.75rem] flex-wrap items-start justify-between gap-2">
|
|
224
|
+
<h3
|
|
225
|
+
:id="`pricing-table-plan-${uid}-${index}`"
|
|
226
|
+
class="font-heading text-base leading-[1.4] font-bold"
|
|
227
|
+
>
|
|
228
|
+
{{ plan.name }}
|
|
229
|
+
</h3>
|
|
230
|
+
<Badge v-if="isHighlighted(plan)" tone="primary" pill :icon="StarIcon">
|
|
231
|
+
{{ highlightLabel }}
|
|
232
|
+
</Badge>
|
|
233
|
+
</div>
|
|
234
|
+
<p v-if="plan.description" class="text-muted text-body-sm">
|
|
235
|
+
{{ plan.description }}
|
|
236
|
+
</p>
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
<!-- price -->
|
|
240
|
+
<div class="flex flex-col gap-1">
|
|
241
|
+
<p class="flex items-baseline gap-1">
|
|
242
|
+
<span
|
|
243
|
+
class="font-heading text-[2rem] leading-[1.1] font-bold tracking-[-0.02em] tabular-nums"
|
|
244
|
+
>{{ plan.price }}</span
|
|
245
|
+
>
|
|
246
|
+
<span class="text-muted text-body-sm">{{ plan.period }}</span>
|
|
247
|
+
</p>
|
|
248
|
+
<p v-if="plan.note" class="text-muted text-body-sm">{{ plan.note }}</p>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<!-- call to action -->
|
|
252
|
+
<div>
|
|
253
|
+
<Button
|
|
254
|
+
v-if="hasCta(plan)"
|
|
255
|
+
:variant="isHighlighted(plan) ? 'primary' : 'outline'"
|
|
256
|
+
size="md"
|
|
257
|
+
block
|
|
258
|
+
:href="ctaHref(plan)!"
|
|
259
|
+
:as="ctaAs(plan)"
|
|
260
|
+
>
|
|
261
|
+
{{ plan.ctaLabel }}
|
|
262
|
+
</Button>
|
|
263
|
+
</div>
|
|
264
|
+
|
|
265
|
+
<!-- features -->
|
|
266
|
+
<ul
|
|
267
|
+
role="list"
|
|
268
|
+
:aria-label="t('pricing.includedIn', { name: plan.name ?? '' })"
|
|
269
|
+
class="border-border flex flex-col gap-3 border-t pt-5"
|
|
270
|
+
>
|
|
271
|
+
<li
|
|
272
|
+
v-for="(row, rowIndex) in featureRows"
|
|
273
|
+
:key="rowIndex"
|
|
274
|
+
class="flex items-start gap-2 leading-[1.45]"
|
|
275
|
+
:class="isIncluded(plan, rowIndex) ? '' : 'text-muted'"
|
|
276
|
+
>
|
|
277
|
+
<EldraIcon
|
|
278
|
+
:name="isIncluded(plan, rowIndex) ? 'check' : 'minus'"
|
|
279
|
+
size="md"
|
|
280
|
+
class="mt-px shrink-0"
|
|
281
|
+
/>
|
|
282
|
+
<span
|
|
283
|
+
><VisuallyHidden>{{
|
|
284
|
+
isIncluded(plan, rowIndex) ? t('pricing.included') : t('pricing.notIncluded')
|
|
285
|
+
}}</VisuallyHidden
|
|
286
|
+
>{{ row.label }}</span
|
|
287
|
+
>
|
|
288
|
+
</li>
|
|
289
|
+
</ul>
|
|
290
|
+
</template>
|
|
291
|
+
</li>
|
|
292
|
+
</ul>
|
|
293
|
+
|
|
294
|
+
<p v-if="footnote" class="text-muted text-body-sm mt-6 text-center">{{ footnote }}</p>
|
|
295
|
+
</Container>
|
|
296
|
+
</Section>
|
|
297
|
+
</template>
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { ELDRA_KEY } from '@eldrajs/theme-vue';
|
|
5
|
+
import { Button } from '@eldrajs/ui';
|
|
6
|
+
import { axe } from '../../../test/support/axe';
|
|
7
|
+
import Block from '../Block.vue';
|
|
8
|
+
import mock from '../mock.json';
|
|
9
|
+
import { mountOptions } from '../../../test/support/mountBlock';
|
|
10
|
+
|
|
11
|
+
/** No media fields, so — like `stats` — there is no `preview.json` to merge onto `mock.json`.
|
|
12
|
+
* `mock.json` is the block's one full content fixture; `bare` below is the genuinely minimal one,
|
|
13
|
+
* only the fields the block requires. */
|
|
14
|
+
const bare = {
|
|
15
|
+
heading: 'Membership plans',
|
|
16
|
+
featureRows: [{ label: 'Free shipping' }],
|
|
17
|
+
plans: [
|
|
18
|
+
{
|
|
19
|
+
name: 'Basic',
|
|
20
|
+
price: '$10',
|
|
21
|
+
period: '/ month',
|
|
22
|
+
ctaLabel: 'Join',
|
|
23
|
+
ctaHref: '/join',
|
|
24
|
+
included: [true],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** `mock.json`'s `plans[].ctaHref` ship empty — an empty href renders no anchor, and the seed
|
|
30
|
+
* links to no demo path nothing serves — so tests whose whole point is exercising a working
|
|
31
|
+
* call-to-action supply their own, the same real-looking demo paths the seed used to carry. */
|
|
32
|
+
const DEMO_CTA_HREFS = [
|
|
33
|
+
'/products/pantry-club-monthly',
|
|
34
|
+
'/products/pantry-club-seasonal',
|
|
35
|
+
'/products/pantry-club-annual',
|
|
36
|
+
];
|
|
37
|
+
const mockWithCta = {
|
|
38
|
+
...mock,
|
|
39
|
+
plans: mock.plans.map((plan, index) => ({ ...plan, ctaHref: DEMO_CTA_HREFS[index] })),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function mountBlock(data: Record<string, unknown>, options: { editing?: boolean } = {}) {
|
|
43
|
+
const base = mountOptions({ entry: { id: 'e1', data } });
|
|
44
|
+
const opts = {
|
|
45
|
+
...base,
|
|
46
|
+
};
|
|
47
|
+
if (options.editing) {
|
|
48
|
+
const context = opts.global.provide[ELDRA_KEY] as {
|
|
49
|
+
preview: { active: boolean; mode: string };
|
|
50
|
+
};
|
|
51
|
+
context.preview.active = true;
|
|
52
|
+
context.preview.mode = 'edit';
|
|
53
|
+
}
|
|
54
|
+
return mount(Block, opts);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The outer plans `<ul>` is the first `<ul>` in document order; its direct `<li>` children are
|
|
58
|
+
* the plan cards, not the feature-row `<li>`s nested two levels inside them. */
|
|
59
|
+
function planItems(wrapper: ReturnType<typeof mountBlock>) {
|
|
60
|
+
return Array.from(wrapper.get('ul').element.querySelectorAll(':scope > li'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function flush() {
|
|
64
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
describe('pricing-table block', () => {
|
|
68
|
+
it('renders the full mock.json content with no axe violations', async () => {
|
|
69
|
+
const wrapper = mountBlock(mockWithCta);
|
|
70
|
+
await flush();
|
|
71
|
+
expect(wrapper.text()).toContain(mock.heading);
|
|
72
|
+
expect(wrapper.text()).toContain(mock.intro);
|
|
73
|
+
expect(wrapper.text()).toContain(mock.footnote);
|
|
74
|
+
for (const plan of mock.plans) {
|
|
75
|
+
expect(wrapper.text()).toContain(plan.name);
|
|
76
|
+
expect(wrapper.text()).toContain(plan.price);
|
|
77
|
+
expect(wrapper.text()).toContain(plan.ctaLabel);
|
|
78
|
+
}
|
|
79
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('renders no call-to-action button for a plan whose ctaHref is empty — the seeded state', async () => {
|
|
83
|
+
const wrapper = mountBlock(mock);
|
|
84
|
+
await flush();
|
|
85
|
+
expect(wrapper.findAll('a')).toHaveLength(0);
|
|
86
|
+
for (const plan of mock.plans) expect(wrapper.text()).not.toContain(plan.ctaLabel);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('renders the bare, required-fields-only content with no axe violations', async () => {
|
|
90
|
+
const wrapper = mountBlock(bare);
|
|
91
|
+
await flush();
|
|
92
|
+
expect(wrapper.text()).toContain(bare.heading);
|
|
93
|
+
expect(wrapper.text()).toContain(bare.plans[0]!.name);
|
|
94
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it.each(['none', 'surface', 'surface-strong'] as const)(
|
|
98
|
+
'renders the %s section background with no axe violations',
|
|
99
|
+
async (sectionBackground) => {
|
|
100
|
+
const wrapper = mountBlock({ ...mock, sectionBackground });
|
|
101
|
+
await flush();
|
|
102
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
it('roots the block in a labelled <section> that measures its own width (@container)', () => {
|
|
107
|
+
const wrapper = mountBlock(mock);
|
|
108
|
+
const section = wrapper.get('section');
|
|
109
|
+
expect(section.classes()).toContain('@container');
|
|
110
|
+
expect(section.attributes('aria-labelledby')).toBe(wrapper.get('h2').attributes('id'));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('plans are a ul whose items are labelled by their own h3', () => {
|
|
114
|
+
const wrapper = mountBlock(mock);
|
|
115
|
+
const items = planItems(wrapper);
|
|
116
|
+
expect(items).toHaveLength(mock.plans.length);
|
|
117
|
+
items.forEach((item, index) => {
|
|
118
|
+
const labelledBy = item.getAttribute('aria-labelledby')!;
|
|
119
|
+
const name = wrapper.get(`#${labelledBy}`);
|
|
120
|
+
expect(name.element.tagName).toBe('H3');
|
|
121
|
+
expect(name.text()).toBe(mock.plans[index]!.name);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('each feature list is named "What\'s included in {name}"', () => {
|
|
126
|
+
const wrapper = mountBlock(mock);
|
|
127
|
+
for (const plan of mock.plans) {
|
|
128
|
+
const list = wrapper.get(`ul[aria-label="What's included in ${plan.name}"]`);
|
|
129
|
+
expect(list.exists()).toBe(true);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('every feature row exposes "Included:"/"Not included:" text, matching its own inclusion', async () => {
|
|
134
|
+
const wrapper = mountBlock(mock);
|
|
135
|
+
await flush();
|
|
136
|
+
mock.plans.forEach((plan, planIndex) => {
|
|
137
|
+
const item = planItems(wrapper)[planIndex]!;
|
|
138
|
+
const rows = Array.from(item.querySelectorAll('ul[aria-label] > li'));
|
|
139
|
+
expect(rows).toHaveLength(mock.featureRows.length);
|
|
140
|
+
rows.forEach((row, rowIndex) => {
|
|
141
|
+
const included = plan.included[rowIndex] === true;
|
|
142
|
+
expect(row.textContent).toContain(included ? 'Included:' : 'Not included:');
|
|
143
|
+
expect(row.querySelector('svg')).not.toBeNull();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('an included row and an excluded row render a differing icon', async () => {
|
|
149
|
+
// Monthly: included = [true, false, ...] — row 0 is included, row 1 is not.
|
|
150
|
+
const wrapper = mountBlock(mock);
|
|
151
|
+
await flush();
|
|
152
|
+
const monthly = planItems(wrapper)[0]!;
|
|
153
|
+
const rows = Array.from(monthly.querySelectorAll('ul[aria-label] > li'));
|
|
154
|
+
const includedSvg = rows[0]!.querySelector('svg')!;
|
|
155
|
+
const excludedSvg = rows[1]!.querySelector('svg')!;
|
|
156
|
+
expect(includedSvg.innerHTML).not.toBe(excludedSvg.innerHTML);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Field `helpText`: "a short list is treated as 'not included' for the
|
|
161
|
+
* missing rows." Mutation check (manual): changing `isIncluded` to
|
|
162
|
+
* `return plan.included?.[index] !== false;` (treating a missing/`undefined` entry as included
|
|
163
|
+
* rather than not) leaves every earlier test passing — the mock fixture's `included` arrays are
|
|
164
|
+
* always exactly `featureRows.length` long — and only fails this test, which is the one that
|
|
165
|
+
* actually exercises a shorter `included` array.
|
|
166
|
+
*/
|
|
167
|
+
it('a plan with fewer `included` entries than featureRows treats the missing rows as not included', () => {
|
|
168
|
+
const wrapper = mountBlock({
|
|
169
|
+
...mock,
|
|
170
|
+
featureRows: [...mock.featureRows, { label: 'A sixth row with no included entry' }],
|
|
171
|
+
});
|
|
172
|
+
const monthly = planItems(wrapper)[0]!; // Monthly's `included` has only 5 entries.
|
|
173
|
+
const rows = Array.from(monthly.querySelectorAll('ul[aria-label] > li'));
|
|
174
|
+
expect(rows).toHaveLength(6);
|
|
175
|
+
const lastRow = rows[5]!;
|
|
176
|
+
expect(lastRow.textContent).toContain('Not included:');
|
|
177
|
+
expect(lastRow.className).toContain('text-muted');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('excluded rows are also muted — colour, shape and hidden text all carry the state', () => {
|
|
181
|
+
const wrapper = mountBlock(mock);
|
|
182
|
+
const monthly = planItems(wrapper)[0]!; // Monthly: included = [true, false, true, false, false]
|
|
183
|
+
const rows = Array.from(monthly.querySelectorAll('ul[aria-label] > li'));
|
|
184
|
+
expect(rows[1]!.className).toContain('text-muted');
|
|
185
|
+
expect(rows[0]!.className).not.toContain('text-muted');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('the highlighted plan is carried by badge text, a thicker border and a filled button — never colour alone', () => {
|
|
189
|
+
const wrapper = mountBlock(mockWithCta);
|
|
190
|
+
const items = planItems(wrapper);
|
|
191
|
+
const highlightedIndex = mock.plans.findIndex((p) => p.name === mock.highlightedPlan);
|
|
192
|
+
items.forEach((item, index) => {
|
|
193
|
+
const buttons = wrapper.findAllComponents(Button).filter((b) => item.contains(b.element));
|
|
194
|
+
expect(buttons).toHaveLength(1);
|
|
195
|
+
if (index === highlightedIndex) {
|
|
196
|
+
expect(item.className).toContain('border-2');
|
|
197
|
+
expect(buttons[0]!.props('variant')).toBe('primary');
|
|
198
|
+
expect(item.textContent).toContain(mock.highlightLabel);
|
|
199
|
+
} else {
|
|
200
|
+
expect(item.className).not.toContain('border-2');
|
|
201
|
+
expect(item.className).toContain('border');
|
|
202
|
+
expect(buttons[0]!.props('variant')).toBe('outline');
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('an empty highlightedPlan gives every plan the outline button', () => {
|
|
208
|
+
const wrapper = mountBlock({ ...mockWithCta, highlightedPlan: '' });
|
|
209
|
+
const buttons = wrapper.findAllComponents(Button);
|
|
210
|
+
expect(buttons).toHaveLength(mock.plans.length);
|
|
211
|
+
for (const button of buttons) expect(button.props('variant')).toBe('outline');
|
|
212
|
+
for (const item of planItems(wrapper)) expect(item.className).not.toContain('border-2');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('a highlightedPlan that matches no plan name highlights nothing', () => {
|
|
216
|
+
const wrapper = mountBlock({ ...mockWithCta, highlightedPlan: 'Lifetime' });
|
|
217
|
+
for (const button of wrapper.findAllComponents(Button)) {
|
|
218
|
+
expect(button.props('variant')).toBe('outline');
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Guards `isHighlighted`'s `highlightedPlanName.value !== ''` check: without it, an empty
|
|
224
|
+
* `highlightedPlan` (`''`) would equality-match a plan whose own `name` is also still empty
|
|
225
|
+
* (an in-progress, editor-only plan) and wrongly highlight it. Mutation check (manual):
|
|
226
|
+
* changing `isHighlighted` to `return name === highlightedPlanName.value;` (dropping the
|
|
227
|
+
* empty-string guard) leaves this test passing only because none of the *other* fixtures have
|
|
228
|
+
* an empty plan name — this test is the one that actually exercises the guard, and fails
|
|
229
|
+
* without it (the unnamed plan's Button renders `primary` instead of `outline`).
|
|
230
|
+
*/
|
|
231
|
+
it('an empty highlightedPlan never highlights a plan with an empty name', () => {
|
|
232
|
+
const wrapper = mountBlock({
|
|
233
|
+
...mockWithCta,
|
|
234
|
+
highlightedPlan: '',
|
|
235
|
+
plans: [...mockWithCta.plans, { name: '', price: '$1', period: '/ month', included: [] }],
|
|
236
|
+
});
|
|
237
|
+
for (const button of wrapper.findAllComponents(Button)) {
|
|
238
|
+
expect(button.props('variant')).toBe('outline');
|
|
239
|
+
}
|
|
240
|
+
for (const item of planItems(wrapper)) {
|
|
241
|
+
expect(item.className).not.toContain('border-2');
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('a single plan renders full width', () => {
|
|
246
|
+
const wrapper = mountBlock({ ...mock, plans: [mock.plans[0]!] });
|
|
247
|
+
const items = planItems(wrapper);
|
|
248
|
+
expect(items).toHaveLength(1);
|
|
249
|
+
expect(items[0]!.className).toContain('col-span-full');
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('does not span the full width when there is more than one plan', () => {
|
|
253
|
+
const wrapper = mountBlock(mockWithCta);
|
|
254
|
+
for (const item of planItems(wrapper)) {
|
|
255
|
+
expect(item.className).not.toContain('col-span-full');
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('renders 4 plans as 4 list items', () => {
|
|
260
|
+
const plans = Array.from({ length: 4 }, (_, index) => ({
|
|
261
|
+
name: `Plan ${index + 1}`,
|
|
262
|
+
price: '$10',
|
|
263
|
+
period: '/ month',
|
|
264
|
+
ctaLabel: 'Choose',
|
|
265
|
+
ctaHref: `/plan-${index + 1}`,
|
|
266
|
+
included: [true],
|
|
267
|
+
}));
|
|
268
|
+
const wrapper = mountBlock({ ...mock, plans, highlightedPlan: '' });
|
|
269
|
+
expect(planItems(wrapper)).toHaveLength(4);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('keyboard path', () => {
|
|
273
|
+
it('Tab visits the calls to action plan by plan, in the visible order; feature rows are not focusable', () => {
|
|
274
|
+
const wrapper = mountBlock(mockWithCta);
|
|
275
|
+
const links = wrapper.findAll('a');
|
|
276
|
+
expect(links.map((link) => link.text())).toEqual(mock.plans.map((p) => p.ctaLabel));
|
|
277
|
+
for (const link of links) expect(link.attributes('tabindex')).toBeUndefined();
|
|
278
|
+
|
|
279
|
+
// Nothing anywhere in the block carries an explicit tabindex, and no feature row contains
|
|
280
|
+
// an interactive element of its own.
|
|
281
|
+
expect(wrapper.findAll('[tabindex]')).toHaveLength(0);
|
|
282
|
+
for (const item of planItems(wrapper)) {
|
|
283
|
+
const featureRows = Array.from(item.querySelectorAll('ul[aria-label] > li'));
|
|
284
|
+
for (const row of featureRows) {
|
|
285
|
+
expect(row.querySelector('a, button, input')).toBeNull();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* jsdom does not run a native `<a href>`'s default Enter activation (see `cta`'s own spec
|
|
292
|
+
* for the same note). This asserts the contract that gives Enter its meaning: nothing in this
|
|
293
|
+
* block cancels the keydown, so the platform's own default action still runs.
|
|
294
|
+
*/
|
|
295
|
+
it('activates a call to action with a native Enter contract', () => {
|
|
296
|
+
const base = mountOptions({ entry: { id: 'e1', data: mockWithCta } });
|
|
297
|
+
const wrapper = mount(Block, {
|
|
298
|
+
...base,
|
|
299
|
+
attachTo: document.body,
|
|
300
|
+
});
|
|
301
|
+
const link = wrapper.get(`a[href="${mockWithCta.plans[0]!.ctaHref}"]`)
|
|
302
|
+
.element as HTMLAnchorElement;
|
|
303
|
+
link.focus();
|
|
304
|
+
expect(document.activeElement).toBe(link);
|
|
305
|
+
const enter = new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true });
|
|
306
|
+
link.dispatchEvent(enter);
|
|
307
|
+
expect(enter.defaultPrevented).toBe(false);
|
|
308
|
+
wrapper.unmount();
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
describe('editor hints (spec "Empty (freshly inserted)")', () => {
|
|
313
|
+
it('shows the heading hint only in the editor when heading is empty, with no axe violations', async () => {
|
|
314
|
+
const data = { ...mock, heading: '' };
|
|
315
|
+
const live = mountBlock(data);
|
|
316
|
+
expect(live.text()).not.toContain('Add a heading');
|
|
317
|
+
expect(live.find('h2').exists()).toBe(false);
|
|
318
|
+
|
|
319
|
+
const editing = mountBlock(data, { editing: true });
|
|
320
|
+
expect(editing.text()).toContain('Add a heading');
|
|
321
|
+
expect(await axe(editing.element)).toHaveNoViolations();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('shows the intro hint only in the editor when intro is empty', () => {
|
|
325
|
+
const data = { ...mock, intro: '' };
|
|
326
|
+
const live = mountBlock(data);
|
|
327
|
+
expect(live.text()).not.toContain('Add an intro');
|
|
328
|
+
|
|
329
|
+
const editing = mountBlock(data, { editing: true });
|
|
330
|
+
expect(editing.text()).toContain('Add an intro (optional)');
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('shows a per-plan hint in the editor for an empty plan, and renders it live as nothing', async () => {
|
|
334
|
+
const emptyPlan = { name: '', price: '' };
|
|
335
|
+
const data = { ...mock, plans: [...mock.plans, emptyPlan] };
|
|
336
|
+
const live = mountBlock(data);
|
|
337
|
+
expect(planItems(live)).toHaveLength(mock.plans.length);
|
|
338
|
+
|
|
339
|
+
const editing = mountBlock(data, { editing: true });
|
|
340
|
+
expect(planItems(editing)).toHaveLength(mock.plans.length + 1);
|
|
341
|
+
expect(editing.text()).toContain('Add a plan');
|
|
342
|
+
expect(await axe(editing.element)).toHaveNoViolations();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('defaults sectionBackground to none when unset', () => {
|
|
347
|
+
const { sectionBackground: _omit, ...withoutBackground } = mock;
|
|
348
|
+
const wrapper = mountBlock(withoutBackground);
|
|
349
|
+
const section = wrapper.get('section');
|
|
350
|
+
expect(section.attributes('data-section-bg')).toBe('none');
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('omits the footnote paragraph entirely when empty', () => {
|
|
354
|
+
const wrapper = mountBlock({ ...mock, footnote: '' });
|
|
355
|
+
expect(wrapper.findAll('p').some((p) => p.text() === mock.footnote)).toBe(false);
|
|
356
|
+
});
|
|
357
|
+
});
|