@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,515 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils';
|
|
3
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
|
+
import { ref } from 'vue';
|
|
5
|
+
import { Button } from '@eldrajs/ui';
|
|
6
|
+
import { ELDRA_KEY } from '@eldrajs/theme-vue';
|
|
7
|
+
import { axe } from '../../../test/support/axe';
|
|
8
|
+
import Block from '../Block.vue';
|
|
9
|
+
import mock from '../mock.json';
|
|
10
|
+
import { mountOptions } from '../../../test/support/mountBlock';
|
|
11
|
+
import { createDemoStorefront, buildOrder } from '../../../app/storefront/demo';
|
|
12
|
+
import { STOREFRONT_KEY } from '../../../app/storefront/types';
|
|
13
|
+
import type {
|
|
14
|
+
StorefrontOrder,
|
|
15
|
+
StorefrontOrderStatus,
|
|
16
|
+
StorefrontSource,
|
|
17
|
+
} from '../../../app/storefront/types';
|
|
18
|
+
import enUS from '../../../i18n/en-US.json';
|
|
19
|
+
|
|
20
|
+
/** Only the required fields (the freshly-inserted seed): every optional part (text, links,
|
|
21
|
+
* help links) is absent, exercising every "optional part renders nothing" branch at once. */
|
|
22
|
+
const bare = {
|
|
23
|
+
variant: 'default',
|
|
24
|
+
processingTitle: mock.processingTitle,
|
|
25
|
+
shippedTitle: mock.shippedTitle,
|
|
26
|
+
deliveredTitle: mock.deliveredTitle,
|
|
27
|
+
delayedTitle: mock.delayedTitle,
|
|
28
|
+
cancelledTitle: mock.cancelledTitle,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const STATUSES: StorefrontOrderStatus[] = [
|
|
32
|
+
'processing',
|
|
33
|
+
'shipped',
|
|
34
|
+
'delivered',
|
|
35
|
+
'delayed',
|
|
36
|
+
'cancelled',
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/** A 14-line order (the shipped fixture's own other fields, its three real lines cycled out to
|
|
40
|
+
* fourteen) for the "many items" collapse — `app/storefront/demo.ts`'s own Northwind fixture
|
|
41
|
+
* keeps to the spec's exact three-line default content, so a longer order is built here instead
|
|
42
|
+
* of extending that shared fixture. */
|
|
43
|
+
function manyItemsOrder(): StorefrontOrder {
|
|
44
|
+
const base = buildOrder('shipped');
|
|
45
|
+
const lines = Array.from({ length: 14 }, (_, index) => {
|
|
46
|
+
const source = base.lines[index % base.lines.length]!;
|
|
47
|
+
return { ...source, id: `many-${index + 1}` };
|
|
48
|
+
});
|
|
49
|
+
const subtotal = lines.reduce((sum, line) => sum + line.lineTotal, 0);
|
|
50
|
+
return {
|
|
51
|
+
...base,
|
|
52
|
+
lines,
|
|
53
|
+
totals: { ...base.totals, subtotal, total: subtotal + (base.totals.tax ?? 0) },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function storefrontFor(status: StorefrontOrderStatus): StorefrontSource {
|
|
58
|
+
return createDemoStorefront({ orderStatus: status });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function storefrontWithOrder(order: StorefrontOrder): StorefrontSource {
|
|
62
|
+
const base = createDemoStorefront();
|
|
63
|
+
return {
|
|
64
|
+
...base,
|
|
65
|
+
orders: {
|
|
66
|
+
current: () => ({
|
|
67
|
+
data: ref(order),
|
|
68
|
+
pending: ref(false),
|
|
69
|
+
error: ref(null),
|
|
70
|
+
refresh: async () => {},
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** No order bound at all (`orders.current()` resolves `null`) — the real-page "no `?token=`"
|
|
77
|
+
* case, spec → States, "Freshly inserted (editor)". */
|
|
78
|
+
function storefrontWithNoOrder(): StorefrontSource {
|
|
79
|
+
const base = createDemoStorefront();
|
|
80
|
+
return {
|
|
81
|
+
...base,
|
|
82
|
+
route: { ...base.route, orderToken: null },
|
|
83
|
+
orders: {
|
|
84
|
+
current: () => ({
|
|
85
|
+
data: ref(null),
|
|
86
|
+
pending: ref(false),
|
|
87
|
+
error: ref(null),
|
|
88
|
+
refresh: async () => {},
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A real order token in the URL (`route.orderToken` stays the demo default), but the fetch it
|
|
95
|
+
* drives never resolves — the loading state a real order page shows before the gateway answers. */
|
|
96
|
+
function storefrontPendingForever(): StorefrontSource {
|
|
97
|
+
const base = createDemoStorefront();
|
|
98
|
+
return {
|
|
99
|
+
...base,
|
|
100
|
+
orders: {
|
|
101
|
+
current: () => ({
|
|
102
|
+
data: ref(null),
|
|
103
|
+
pending: ref(true),
|
|
104
|
+
error: ref(null),
|
|
105
|
+
refresh: async () => {},
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A real order token, but the fetch failed — `StorefrontResult.error` set. */
|
|
112
|
+
function storefrontWithError(message: string): StorefrontSource {
|
|
113
|
+
const base = createDemoStorefront();
|
|
114
|
+
return {
|
|
115
|
+
...base,
|
|
116
|
+
orders: {
|
|
117
|
+
current: () => ({
|
|
118
|
+
data: ref(null),
|
|
119
|
+
pending: ref(false),
|
|
120
|
+
error: ref(message),
|
|
121
|
+
refresh: async () => {},
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const trackedWrappers: VueWrapper[] = [];
|
|
128
|
+
afterEach(() => {
|
|
129
|
+
for (const wrapper of trackedWrappers.splice(0)) wrapper.unmount();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
function mountBlock(
|
|
133
|
+
data: Record<string, unknown>,
|
|
134
|
+
options: { source?: StorefrontSource; editing?: boolean } = {}
|
|
135
|
+
) {
|
|
136
|
+
const opts = mountOptions({ entry: { id: 'e1', data } });
|
|
137
|
+
if (options.editing) {
|
|
138
|
+
const context = opts.global.provide[ELDRA_KEY] as {
|
|
139
|
+
preview: { active: boolean; mode: string };
|
|
140
|
+
};
|
|
141
|
+
context.preview.active = true;
|
|
142
|
+
context.preview.mode = 'edit';
|
|
143
|
+
}
|
|
144
|
+
const wrapper = mount(Block, {
|
|
145
|
+
...opts,
|
|
146
|
+
global: {
|
|
147
|
+
...opts.global,
|
|
148
|
+
provide: {
|
|
149
|
+
...opts.global.provide,
|
|
150
|
+
...(options.source ? { [STOREFRONT_KEY]: options.source } : {}),
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
trackedWrappers.push(wrapper);
|
|
155
|
+
return wrapper;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function mountStatus(status: StorefrontOrderStatus, data: Record<string, unknown> = mock) {
|
|
159
|
+
const wrapper = mountBlock(data, { source: storefrontFor(status) });
|
|
160
|
+
await flushPromises();
|
|
161
|
+
return wrapper;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
describe('order-status block', () => {
|
|
165
|
+
describe('accessibility', () => {
|
|
166
|
+
it('renders the full mock.json content (shipped, the demo default) with no axe violations', async () => {
|
|
167
|
+
const wrapper = await mountStatus('shipped');
|
|
168
|
+
expect(wrapper.text()).toContain('NW-10482');
|
|
169
|
+
expect(wrapper.text()).toContain(mock.shippedTitle);
|
|
170
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('renders the bare, required-fields-only content with no axe violations', async () => {
|
|
174
|
+
const wrapper = mountBlock(bare, { source: storefrontFor('shipped') });
|
|
175
|
+
await flushPromises();
|
|
176
|
+
expect(wrapper.text()).toContain(bare.shippedTitle);
|
|
177
|
+
// No returnLink/shopAgainLink/helpLinks fields at all: no Need Help section.
|
|
178
|
+
expect(wrapper.text()).not.toContain(enUS.order.needHelp);
|
|
179
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it.each(STATUSES)('renders the %s status with no axe violations', async (status) => {
|
|
183
|
+
const wrapper = await mountStatus(status);
|
|
184
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('has exactly one h1 (the order number) and one h2 per region', async () => {
|
|
189
|
+
const wrapper = await mountStatus('shipped');
|
|
190
|
+
expect(wrapper.findAll('h1')).toHaveLength(1);
|
|
191
|
+
expect(wrapper.get('h1').text()).toContain('NW-10482');
|
|
192
|
+
// Panel, Items, Delivery address, Payment, Need help?
|
|
193
|
+
expect(wrapper.findAll('h2')).toHaveLength(5);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe('status badge', () => {
|
|
197
|
+
/** The badge is the first (outermost) `<span>` whose text names the state — scoped past the
|
|
198
|
+
* status prefix so a future decorative element elsewhere carrying the same word can't be
|
|
199
|
+
* picked up by accident. */
|
|
200
|
+
function badgeFor(wrapper: VueWrapper, word: string) {
|
|
201
|
+
return wrapper
|
|
202
|
+
.findAll('span')
|
|
203
|
+
.find(
|
|
204
|
+
(el) => el.text().includes(enUS.order.statusPrefix.trim()) && el.text().includes(word)
|
|
205
|
+
)!;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
it.each([
|
|
209
|
+
['processing', enUS.storefront.orderStatus.processing],
|
|
210
|
+
['shipped', enUS.storefront.orderStatus.shipped],
|
|
211
|
+
['delivered', enUS.storefront.orderStatus.delivered],
|
|
212
|
+
['delayed', enUS.storefront.orderStatus.delayed],
|
|
213
|
+
['cancelled', enUS.storefront.orderStatus.cancelled],
|
|
214
|
+
] as const)(
|
|
215
|
+
'pairs an icon with the word for %s, behind a hidden "Status:" prefix',
|
|
216
|
+
async (status, word) => {
|
|
217
|
+
const wrapper = await mountStatus(status);
|
|
218
|
+
const badge = badgeFor(wrapper, word);
|
|
219
|
+
expect(badge.exists()).toBe(true);
|
|
220
|
+
expect(badge.text()).toContain(enUS.order.statusPrefix.trim());
|
|
221
|
+
expect(badge.find('svg').exists()).toBe(true);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
/** `Badge`'s own `outline` look ignores `tone` entirely (`bg-background text-text
|
|
226
|
+
* border-border-strong` regardless of the prop), so without an explicit override every status
|
|
227
|
+
* would render in the same neutral colour — this pins the per-state `classes.root` override
|
|
228
|
+
* that recolours the icon/word/border for the three non-neutral states. */
|
|
229
|
+
it.each([
|
|
230
|
+
['delivered', enUS.storefront.orderStatus.delivered, 'success'],
|
|
231
|
+
['delayed', enUS.storefront.orderStatus.delayed, 'warning'],
|
|
232
|
+
['cancelled', enUS.storefront.orderStatus.cancelled, 'danger'],
|
|
233
|
+
] as const)(
|
|
234
|
+
'the %s badge carries its own %s tone, not the neutral outline default',
|
|
235
|
+
async (status, word, tone) => {
|
|
236
|
+
const wrapper = await mountStatus(status);
|
|
237
|
+
const badge = badgeFor(wrapper, word);
|
|
238
|
+
expect(badge.classes()).toContain(`text-${tone}`);
|
|
239
|
+
expect(badge.classes()).toContain(`border-${tone}`);
|
|
240
|
+
expect(badge.classes()).not.toContain('text-text');
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
it.each([
|
|
245
|
+
['processing', enUS.storefront.orderStatus.processing],
|
|
246
|
+
['shipped', enUS.storefront.orderStatus.shipped],
|
|
247
|
+
] as const)(
|
|
248
|
+
'the %s badge keeps the neutral outline look (no tone override)',
|
|
249
|
+
async (status, word) => {
|
|
250
|
+
const wrapper = await mountStatus(status);
|
|
251
|
+
const badge = badgeFor(wrapper, word);
|
|
252
|
+
expect(badge.classes()).not.toContain('text-success');
|
|
253
|
+
expect(badge.classes()).not.toContain('text-warning');
|
|
254
|
+
expect(badge.classes()).not.toContain('text-danger');
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('tracker', () => {
|
|
260
|
+
it('is an <ol> naming the current step with aria-current="step", each step\'s state in words, and aria-hidden discs', async () => {
|
|
261
|
+
const wrapper = await mountStatus('shipped');
|
|
262
|
+
const list = wrapper.get('ol');
|
|
263
|
+
expect(list.attributes('aria-label')).toBe(enUS.order.progress);
|
|
264
|
+
const items = list.findAll('li');
|
|
265
|
+
expect(items).toHaveLength(4);
|
|
266
|
+
|
|
267
|
+
const current = items.filter((li) => li.attributes('aria-current') === 'step');
|
|
268
|
+
expect(current).toHaveLength(1);
|
|
269
|
+
expect(current[0]!.text()).toContain('Shipped');
|
|
270
|
+
|
|
271
|
+
for (const li of items) {
|
|
272
|
+
const disc = li.find('span[aria-hidden="true"]');
|
|
273
|
+
expect(disc.exists()).toBe(true);
|
|
274
|
+
}
|
|
275
|
+
const doneCount = items.filter((li) =>
|
|
276
|
+
li.text().includes(enUS.order.completed.trim())
|
|
277
|
+
).length;
|
|
278
|
+
const notYetCount = items.filter((li) => li.text().includes(enUS.order.notYet.trim())).length;
|
|
279
|
+
expect(doneCount).toBe(2); // Ordered, Packed
|
|
280
|
+
expect(notYetCount).toBe(2); // Shipped (current), Delivered (upcoming)
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('shows "In progress" for the current step with no date yet (processing)', async () => {
|
|
284
|
+
const wrapper = await mountStatus('processing');
|
|
285
|
+
const current = wrapper
|
|
286
|
+
.get('ol')
|
|
287
|
+
.findAll('li')
|
|
288
|
+
.find((li) => li.attributes('aria-current') === 'step')!;
|
|
289
|
+
expect(current.text()).toContain(enUS.order.inProgress);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('shows the new estimate ("Est. 30 Sept") on the warning step\'s date — the spec\'s own worked example — not the literal word "Delayed", while the marker stays the warning/alert-triangle disc and the step is still aria-current', async () => {
|
|
293
|
+
const wrapper = await mountStatus('delayed');
|
|
294
|
+
const items = wrapper.get('ol').findAll('li');
|
|
295
|
+
const current = items.filter((li) => li.attributes('aria-current') === 'step');
|
|
296
|
+
expect(current).toHaveLength(1);
|
|
297
|
+
expect(current[0]!.text()).toContain('Delivered');
|
|
298
|
+
expect(current[0]!.text()).toContain('Sep 30, 2026');
|
|
299
|
+
expect(current[0]!.text()).toContain(enUS.order.estimated.replace('{date}', '').trim());
|
|
300
|
+
expect(current[0]!.text()).not.toContain(enUS.storefront.orderStatus.delayed);
|
|
301
|
+
expect(wrapper.text()).toContain(enUS.order.trackingNumber);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('renders no tracker and no tracking row for a cancelled order', async () => {
|
|
305
|
+
const wrapper = await mountStatus('cancelled');
|
|
306
|
+
expect(wrapper.find('ol').exists()).toBe(false);
|
|
307
|
+
expect(wrapper.text()).not.toContain(enUS.order.trackingNumber);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('switches from a vertical list to a 4-column horizontal grid at 36rem block width (@two-col:)', async () => {
|
|
311
|
+
const wrapper = await mountStatus('shipped');
|
|
312
|
+
const list = wrapper.get('ol');
|
|
313
|
+
expect(list.classes()).toContain('flex-col');
|
|
314
|
+
expect(list.classes()).toContain('@two-col:grid');
|
|
315
|
+
expect(list.classes()).toContain('@two-col:grid-cols-4');
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
describe('call to action', () => {
|
|
320
|
+
it('Track package opens the carrier site: an accessible name saying so, target _blank', async () => {
|
|
321
|
+
const wrapper = await mountStatus('shipped');
|
|
322
|
+
const button = wrapper
|
|
323
|
+
.findAll('a')
|
|
324
|
+
.find((el) => el.text().includes(enUS.order.trackPackage))!;
|
|
325
|
+
expect(button.exists()).toBe(true);
|
|
326
|
+
expect(button.text()).toContain(enUS.order.trackOpens.trim());
|
|
327
|
+
expect(button.attributes('target')).toBe('_blank');
|
|
328
|
+
expect(button.attributes('rel')).toContain('noopener');
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('offers Start a return once an order is delivered', async () => {
|
|
332
|
+
// `returnLinkHref` ships empty in the seed, so this test gives the primary CTA its own
|
|
333
|
+
// destination — the same override the "Shop again" test below already needed. Scoped to the
|
|
334
|
+
// `Button` component (the primary CTA), not any `<a>`: `helpLinks` renders its own "Start a
|
|
335
|
+
// return" `Link` with the same label text in the "Need help?" section, which would otherwise
|
|
336
|
+
// make this test pass even if the primary CTA stopped rendering.
|
|
337
|
+
const wrapper = await mountStatus('delivered', { ...mock, returnLinkHref: '/pages/returns' });
|
|
338
|
+
const button = wrapper
|
|
339
|
+
.findAllComponents(Button)
|
|
340
|
+
.find((el) => el.text().includes(mock.returnLinkLabel));
|
|
341
|
+
expect(button?.exists()).toBe(true);
|
|
342
|
+
expect(wrapper.text()).not.toContain(enUS.order.trackPackage);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('offers Shop again once an order is cancelled', async () => {
|
|
346
|
+
const wrapper = await mountStatus('cancelled', {
|
|
347
|
+
...mock,
|
|
348
|
+
shopAgainLinkHref: '/collections/all',
|
|
349
|
+
});
|
|
350
|
+
const button = wrapper
|
|
351
|
+
.findAllComponents(Button)
|
|
352
|
+
.find((el) => el.text().includes(mock.shopAgainLinkLabel));
|
|
353
|
+
expect(button?.exists()).toBe(true);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('renders no primary CTA button for the seeded empty-href state (delivered and cancelled)', async () => {
|
|
357
|
+
// `returnLinkHref`/`shopAgainLinkHref` both ship empty in the seed — no block links to a
|
|
358
|
+
// demo path nothing serves — so the bare `mock` default must render no primary CTA at all
|
|
359
|
+
// for either status, even though `helpLinks` still carries its own unrelated "Start a
|
|
360
|
+
// return" link in the "Need help?" section.
|
|
361
|
+
const delivered = await mountStatus('delivered');
|
|
362
|
+
expect(delivered.findAllComponents(Button)).toHaveLength(0);
|
|
363
|
+
|
|
364
|
+
const cancelled = await mountStatus('cancelled');
|
|
365
|
+
expect(cancelled.findAllComponents(Button)).toHaveLength(0);
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
describe('keyboard', () => {
|
|
370
|
+
it('Tab order is the call-to-action button, then item title links, then help links — every real operable element, nothing else in the way', async () => {
|
|
371
|
+
const wrapper = await mountStatus('shipped');
|
|
372
|
+
const focusables = wrapper.findAll('a, button');
|
|
373
|
+
const labels = focusables.map((el) => el.text());
|
|
374
|
+
const trackIndex = labels.findIndex((label) => label.includes(enUS.order.trackPackage));
|
|
375
|
+
const firstItemIndex = labels.findIndex((label) => label.includes('Fell crew sweater'));
|
|
376
|
+
const firstHelpIndex = labels.findIndex((label) => label.includes(mock.helpLinks[0]!.label));
|
|
377
|
+
expect(trackIndex).toBeGreaterThanOrEqual(0);
|
|
378
|
+
expect(firstItemIndex).toBeGreaterThan(trackIndex);
|
|
379
|
+
expect(firstHelpIndex).toBeGreaterThan(firstItemIndex);
|
|
380
|
+
// Nothing carries an explicit tabindex of its own (native elements only).
|
|
381
|
+
expect(wrapper.findAll('[tabindex]')).toHaveLength(0);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('a native click activates "Show all N items" (Enter/Space activate a real <button> natively)', async () => {
|
|
385
|
+
const wrapper = mountBlock(mock, { source: storefrontWithOrder(manyItemsOrder()) });
|
|
386
|
+
await flushPromises();
|
|
387
|
+
const button = wrapper
|
|
388
|
+
.findAll('button')
|
|
389
|
+
.find((el) => el.text().includes('Show all 14 items'))!;
|
|
390
|
+
expect(button.element.tagName).toBe('BUTTON');
|
|
391
|
+
expect(button.attributes('type')).toBe('button');
|
|
392
|
+
await button.trigger('click');
|
|
393
|
+
expect(wrapper.get('ul').findAll('li')).toHaveLength(14);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
describe('the delay/cancel note', () => {
|
|
398
|
+
it('is a role="status" alert under the delayed title', async () => {
|
|
399
|
+
const wrapper = await mountStatus('delayed');
|
|
400
|
+
const status = wrapper.find('[role="status"]');
|
|
401
|
+
expect(status.exists()).toBe(true);
|
|
402
|
+
expect(status.text()).toContain('North Sea');
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('is a role="status" alert under the cancelled title', async () => {
|
|
406
|
+
const wrapper = await mountStatus('cancelled');
|
|
407
|
+
const status = wrapper.find('[role="status"]');
|
|
408
|
+
expect(status.exists()).toBe(true);
|
|
409
|
+
expect(status.text()).toContain('refund');
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
describe('items', () => {
|
|
414
|
+
it('renders 10 of 14 lines behind a "Show all 14 items" button that reveals the rest', async () => {
|
|
415
|
+
const wrapper = mountBlock(mock, { source: storefrontWithOrder(manyItemsOrder()) });
|
|
416
|
+
await flushPromises();
|
|
417
|
+
const rows = () => wrapper.get('ul').findAll('li');
|
|
418
|
+
expect(rows()).toHaveLength(10);
|
|
419
|
+
|
|
420
|
+
const button = wrapper
|
|
421
|
+
.findAll('button')
|
|
422
|
+
.find((el) => el.text().includes('Show all 14 items'))!;
|
|
423
|
+
expect(button.exists()).toBe(true);
|
|
424
|
+
await button.trigger('click');
|
|
425
|
+
expect(rows()).toHaveLength(14);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it('is a description list for the totals, right at full width', async () => {
|
|
429
|
+
const wrapper = await mountStatus('shipped');
|
|
430
|
+
const dl = wrapper.find('dl');
|
|
431
|
+
expect(dl.exists()).toBe(true);
|
|
432
|
+
expect(dl.text()).toContain(enUS.order.subtotal);
|
|
433
|
+
expect(dl.text()).toContain(enUS.order.total);
|
|
434
|
+
expect(dl.text()).toContain(enUS.order.shippingFree);
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
describe('details', () => {
|
|
439
|
+
it('names the aside "Order details" and lists the delivery address, payment and help links', async () => {
|
|
440
|
+
const wrapper = await mountStatus('shipped');
|
|
441
|
+
const aside = wrapper.get('aside');
|
|
442
|
+
expect(aside.attributes('aria-label')).toBe(enUS.order.detailsLabel);
|
|
443
|
+
expect(aside.text()).toContain('Maren Holt');
|
|
444
|
+
expect(aside.text()).toContain('Visa');
|
|
445
|
+
expect(aside.text()).toContain('4242');
|
|
446
|
+
for (const link of mock.helpLinks) expect(aside.text()).toContain(link.label);
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('renders the sample order when the editor has no order bound yet (no empty layout)', async () => {
|
|
451
|
+
const wrapper = mountBlock(mock, { source: storefrontWithNoOrder(), editing: true });
|
|
452
|
+
await flushPromises();
|
|
453
|
+
expect(wrapper.text()).toContain('NW-10482');
|
|
454
|
+
expect(wrapper.text()).toContain(enUS.storefront.orderStatus.shipped);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('renders nothing on the live site with no order bound', async () => {
|
|
458
|
+
const wrapper = mountBlock(mock, { source: storefrontWithNoOrder(), editing: false });
|
|
459
|
+
await flushPromises();
|
|
460
|
+
expect(wrapper.find('section').exists()).toBe(false);
|
|
461
|
+
expect(wrapper.text()).toBe('');
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
describe('loading and error', () => {
|
|
465
|
+
it('shows a Skeleton placeholder, announced through a labelled busy region, while the order is still loading', async () => {
|
|
466
|
+
const wrapper = mountBlock(mock, { source: storefrontPendingForever() });
|
|
467
|
+
await flushPromises();
|
|
468
|
+
const busyRegion = wrapper.get('[role="status"][aria-busy="true"]');
|
|
469
|
+
expect(busyRegion.attributes('aria-label')).toBe(enUS.storefront.loading);
|
|
470
|
+
// The decorative shimmering shapes carry no accessible name of their own.
|
|
471
|
+
expect(wrapper.findAll('[aria-hidden="true"]').length).toBeGreaterThan(0);
|
|
472
|
+
// Nothing from the real content (title, panel, items) is rendered yet.
|
|
473
|
+
expect(wrapper.find('h1').exists()).toBe(false);
|
|
474
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('shows an EmptyState variant="error" (role="alert") when the fetch fails', async () => {
|
|
478
|
+
const wrapper = mountBlock(mock, { source: storefrontWithError('failed') });
|
|
479
|
+
await flushPromises();
|
|
480
|
+
const alert = wrapper.get('[role="alert"]');
|
|
481
|
+
expect(alert.text()).toContain(enUS.storefront.error);
|
|
482
|
+
expect(wrapper.find('h1').exists()).toBe(false);
|
|
483
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('renders nothing (not even a loading/error state) with no order token in the URL at all', async () => {
|
|
487
|
+
const wrapper = mountBlock(mock, { source: storefrontWithNoOrder() });
|
|
488
|
+
await flushPromises();
|
|
489
|
+
expect(wrapper.find('[role="status"]').exists()).toBe(false);
|
|
490
|
+
expect(wrapper.find('[role="alert"]').exists()).toBe(false);
|
|
491
|
+
expect(wrapper.text()).toBe('');
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
describe('status panel layout', () => {
|
|
496
|
+
it('the summary and the call-to-action sit in one row from @tablet: (stacked below it)', async () => {
|
|
497
|
+
const wrapper = await mountStatus('shipped');
|
|
498
|
+
const heading = wrapper.get('h2');
|
|
499
|
+
// The row wrapper is the heading's grandparent: h2 -> summary column -> row.
|
|
500
|
+
const row = heading.element.parentElement!.parentElement!;
|
|
501
|
+
expect(row.classList.contains('flex-col')).toBe(true);
|
|
502
|
+
expect(row.classList.contains('@tablet:flex-row')).toBe(true);
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
it('carries no motion class anywhere', async () => {
|
|
507
|
+
const wrapper = await mountStatus('shipped');
|
|
508
|
+
for (const element of wrapper.element.querySelectorAll('*')) {
|
|
509
|
+
for (const className of element.classList) {
|
|
510
|
+
expect(className.startsWith('animate-')).toBe(false);
|
|
511
|
+
expect(className.startsWith('transition-')).toBe(false);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiId": "order-status",
|
|
3
|
+
"name": "Order status",
|
|
4
|
+
"description": "The order confirmation and tracking page: order number and date, a status badge, a delivery tracker, the items and totals, the delivery address, payment and help links. Order data is bound at runtime; editors fill in only the copy.",
|
|
5
|
+
"icon": "package",
|
|
6
|
+
"category": "commerce",
|
|
7
|
+
"version": 1,
|
|
8
|
+
"fields": [
|
|
9
|
+
{
|
|
10
|
+
"fieldId": "variant",
|
|
11
|
+
"name": "Variant",
|
|
12
|
+
"type": "select",
|
|
13
|
+
"helpText": "Reserved. The state comes from the order, not from a field.",
|
|
14
|
+
"metadata": { "options": ["default"] }
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"fieldId": "processingTitle",
|
|
18
|
+
"name": "Processing title",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"localized": true,
|
|
21
|
+
"default": "We're packing your order",
|
|
22
|
+
"validators": { "required": true }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"fieldId": "processingText",
|
|
26
|
+
"name": "Processing text",
|
|
27
|
+
"type": "text",
|
|
28
|
+
"localized": true,
|
|
29
|
+
"default": "Most orders leave our Portland studio within 2 business days. We'll email your tracking link as soon as it ships."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"fieldId": "shippedTitle",
|
|
33
|
+
"name": "Shipped title",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"localized": true,
|
|
36
|
+
"default": "On its way",
|
|
37
|
+
"validators": { "required": true }
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"fieldId": "deliveredTitle",
|
|
41
|
+
"name": "Delivered title",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"localized": true,
|
|
44
|
+
"default": "Delivered on {date}",
|
|
45
|
+
"helpText": "{date} is replaced with the delivery date.",
|
|
46
|
+
"validators": { "required": true }
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"fieldId": "deliveredText",
|
|
50
|
+
"name": "Delivered text",
|
|
51
|
+
"type": "text",
|
|
52
|
+
"localized": true,
|
|
53
|
+
"default": "Something not right? You have 30 days to start a return."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"fieldId": "delayedTitle",
|
|
57
|
+
"name": "Delayed title",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"localized": true,
|
|
60
|
+
"default": "Running a little late",
|
|
61
|
+
"validators": { "required": true }
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"fieldId": "cancelledTitle",
|
|
65
|
+
"name": "Cancelled title",
|
|
66
|
+
"type": "string",
|
|
67
|
+
"localized": true,
|
|
68
|
+
"default": "This order was cancelled",
|
|
69
|
+
"validators": { "required": true }
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"fieldId": "returnLinkLabel",
|
|
73
|
+
"name": "Return link label",
|
|
74
|
+
"type": "string",
|
|
75
|
+
"localized": true,
|
|
76
|
+
"default": "Start a return",
|
|
77
|
+
"helpText": "The Delivered call to action, and a help link."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"fieldId": "returnLinkHref",
|
|
81
|
+
"name": "Return link URL",
|
|
82
|
+
"type": "string",
|
|
83
|
+
"default": "/pages/returns"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"fieldId": "shopAgainLinkLabel",
|
|
87
|
+
"name": "Shop again link label",
|
|
88
|
+
"type": "string",
|
|
89
|
+
"localized": true,
|
|
90
|
+
"default": "Shop again",
|
|
91
|
+
"helpText": "The Cancelled call to action."
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"fieldId": "shopAgainLinkHref",
|
|
95
|
+
"name": "Shop again link URL",
|
|
96
|
+
"type": "string",
|
|
97
|
+
"default": "/collections/all"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"fieldId": "helpLinks",
|
|
101
|
+
"name": "Help links",
|
|
102
|
+
"type": "list",
|
|
103
|
+
"helpText": "Up to 4.",
|
|
104
|
+
"metadata": {
|
|
105
|
+
"item": {
|
|
106
|
+
"fieldId": "item",
|
|
107
|
+
"name": "Help link",
|
|
108
|
+
"type": "composite",
|
|
109
|
+
"metadata": {
|
|
110
|
+
"fields": [
|
|
111
|
+
{
|
|
112
|
+
"fieldId": "label",
|
|
113
|
+
"name": "Label",
|
|
114
|
+
"type": "string",
|
|
115
|
+
"localized": true,
|
|
116
|
+
"validators": { "required": true }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"fieldId": "href",
|
|
120
|
+
"name": "Link URL",
|
|
121
|
+
"type": "string",
|
|
122
|
+
"validators": { "required": true }
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"fieldId": "icon",
|
|
126
|
+
"name": "Icon",
|
|
127
|
+
"type": "select",
|
|
128
|
+
"metadata": {
|
|
129
|
+
"options": ["mail", "arrow-back-up", "info-circle", "phone", "truck"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"variant": "default",
|
|
3
|
+
"processingTitle": "We're packing your order",
|
|
4
|
+
"processingText": "Most orders leave our Portland studio within 2 business days. We'll email your tracking link as soon as it ships.",
|
|
5
|
+
"shippedTitle": "On its way",
|
|
6
|
+
"deliveredTitle": "Delivered on {date}",
|
|
7
|
+
"deliveredText": "Something not right? You have 30 days to start a return.",
|
|
8
|
+
"delayedTitle": "Running a little late",
|
|
9
|
+
"cancelledTitle": "This order was cancelled",
|
|
10
|
+
"returnLinkLabel": "Start a return",
|
|
11
|
+
"returnLinkHref": "",
|
|
12
|
+
"shopAgainLinkLabel": "Shop again",
|
|
13
|
+
"shopAgainLinkHref": "",
|
|
14
|
+
"helpLinks": [
|
|
15
|
+
{ "label": "Contact us", "href": "/pages/contact", "icon": "mail" },
|
|
16
|
+
{ "label": "Start a return", "href": "/pages/returns", "icon": "arrow-back-up" },
|
|
17
|
+
{ "label": "Shipping & delivery FAQ", "href": "/pages/shipping", "icon": "info-circle" }
|
|
18
|
+
]
|
|
19
|
+
}
|
|
Binary file
|