@eldrajs/theme-cli 0.0.0-stage → 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 +27 -2
- 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 +56 -3
- 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,89 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, relative } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { formatCurrency } from '@eldrajs/ui';
|
|
6
|
+
import { formatMoney } from '../app/storefront/money';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One formatter for every currency on the storefront, and it is the public one.
|
|
10
|
+
*
|
|
11
|
+
* `@eldrajs/ui`'s `formatCurrency` (and the `<Price>`/`<ProductCard>`/`<CurrencyInput>` components
|
|
12
|
+
* that format through it) writes the currency's **narrow** sign — `kr 2,800` on an English page,
|
|
13
|
+
* `2.800 kr.` on an Icelandic one. A hand-built `Intl.NumberFormat({ style: 'currency' })` writes
|
|
14
|
+
* the *wide* sign instead (`ISK 2,800`), and the two look nothing alike on the same page: that is
|
|
15
|
+
* exactly how this theme came to show `ISK 2,800` in an Add-to-cart label beside a `<Price>`
|
|
16
|
+
* reading `kr 2,800` for the same money.
|
|
17
|
+
*
|
|
18
|
+
* So no block and no app module may build a currency formatter of its own. `app/storefront/money.ts`
|
|
19
|
+
* is the single exception — it is the module that calls the public util — and it builds only a
|
|
20
|
+
* plain `style: 'decimal'` formatter for the store that publishes no currency at all.
|
|
21
|
+
*
|
|
22
|
+
* This is a source scan rather than a convention, because the failure is silent: a second formatter
|
|
23
|
+
* renders perfectly good-looking money that simply disagrees with the money beside it.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const rootDir = fileURLToPath(new URL('..', import.meta.url));
|
|
27
|
+
|
|
28
|
+
const SCAN_DIRS = ['app', 'blocks'];
|
|
29
|
+
const SCAN_EXTENSIONS = new Set(['.ts', '.vue']);
|
|
30
|
+
|
|
31
|
+
/** The one module allowed to reach for `Intl.NumberFormat`, and why — see the note above. */
|
|
32
|
+
const ALLOWED = new Set(['app/storefront/money.ts']);
|
|
33
|
+
|
|
34
|
+
function listSourceFiles(dir: string): string[] {
|
|
35
|
+
const files: string[] = [];
|
|
36
|
+
for (const name of readdirSync(dir)) {
|
|
37
|
+
const full = join(dir, name);
|
|
38
|
+
if (statSync(full).isDirectory()) {
|
|
39
|
+
// A block's own tests are not shipped output and may assert against raw `Intl` to prove what
|
|
40
|
+
// the theme's formatter produces.
|
|
41
|
+
if (name === '__tests__') continue;
|
|
42
|
+
files.push(...listSourceFiles(full));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (SCAN_EXTENSIONS.has(name.slice(name.lastIndexOf('.')))) files.push(full);
|
|
46
|
+
}
|
|
47
|
+
return files;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const sourceFiles = SCAN_DIRS.flatMap((dir) => listSourceFiles(join(rootDir, dir)))
|
|
51
|
+
.map((file) => relative(rootDir, file))
|
|
52
|
+
.filter((file) => !ALLOWED.has(file))
|
|
53
|
+
.sort();
|
|
54
|
+
|
|
55
|
+
describe('money is formatted in exactly one place', () => {
|
|
56
|
+
it('scans a real set of files, so a passing scan is not an empty one', () => {
|
|
57
|
+
expect(sourceFiles.length).toBeGreaterThan(80);
|
|
58
|
+
expect(sourceFiles).toContain('blocks/product-detail/Block.vue');
|
|
59
|
+
expect(sourceFiles).not.toContain('app/storefront/money.ts');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('builds no Intl.NumberFormat outside app/storefront/money.ts', () => {
|
|
63
|
+
// A *call* — with or without `new`, the way the private library writes it — not a mention: the
|
|
64
|
+
// name appears in prose in `app/storefront/commerce.ts`, explaining which codes it rejects.
|
|
65
|
+
const offenders = sourceFiles.filter((file) =>
|
|
66
|
+
/(?:new\s+)?Intl\.NumberFormat\s*\(/.test(readFileSync(join(rootDir, file), 'utf8'))
|
|
67
|
+
);
|
|
68
|
+
expect(offenders).toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('asks for no currency style outside app/storefront/money.ts', () => {
|
|
72
|
+
// Catches a currency formatter built through `@eldrajs/ui`'s own `createNumberFormat` too,
|
|
73
|
+
// which would be a second set of options rather than a second constructor.
|
|
74
|
+
const offenders = sourceFiles.filter((file) => {
|
|
75
|
+
const source = readFileSync(join(rootDir, file), 'utf8');
|
|
76
|
+
return /style:\s*['"]currency['"]/.test(source) || source.includes('currencyDisplay');
|
|
77
|
+
});
|
|
78
|
+
expect(offenders).toEqual([]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('formats through the public util, which is what gives every price the narrow sign', () => {
|
|
82
|
+
// The module under the exception, held to the util it exists to call.
|
|
83
|
+
expect(formatMoney(2800, 'ISK', 'en-US')).toBe(
|
|
84
|
+
formatCurrency(2800, 'en-US', 'ISK', true, 0, 0)
|
|
85
|
+
);
|
|
86
|
+
expect(formatMoney(2800, 'ISK', 'en-US')).toBe('kr\u00a02,800');
|
|
87
|
+
expect(formatMoney(2800, 'ISK', 'is-IS')).toBe('2.800\u00a0kr.');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { pageTitle } from '../app/utils/pageTitle';
|
|
3
|
+
|
|
4
|
+
const notFoundTitle = 'Page not found';
|
|
5
|
+
|
|
6
|
+
describe('pageTitle', () => {
|
|
7
|
+
it('names a catalog route after the object it is showing, not its template', () => {
|
|
8
|
+
// The defect this closes: every product page's tab read "Product" — the route template's own
|
|
9
|
+
// title — because that is the document the page renders through.
|
|
10
|
+
expect(
|
|
11
|
+
pageTitle({
|
|
12
|
+
isNotFound: false,
|
|
13
|
+
notFoundTitle,
|
|
14
|
+
catalogTitle: 'Ash glaze mug',
|
|
15
|
+
documentTitle: 'Product',
|
|
16
|
+
})
|
|
17
|
+
).toBe('Ash glaze mug');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('names an ordinary page after its own document', () => {
|
|
21
|
+
expect(
|
|
22
|
+
pageTitle({ isNotFound: false, notFoundTitle, catalogTitle: null, documentTitle: 'About us' })
|
|
23
|
+
).toBe('About us');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('falls back to the document when a catalog object has no usable title', () => {
|
|
27
|
+
for (const catalogTitle of [null, undefined, '', ' ', 42]) {
|
|
28
|
+
expect(
|
|
29
|
+
pageTitle({ isNotFound: false, notFoundTitle, catalogTitle, documentTitle: 'Product' })
|
|
30
|
+
).toBe('Product');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('falls back to the site name when nothing names the page', () => {
|
|
35
|
+
expect(pageTitle({ isNotFound: false, notFoundTitle })).toBe('Site');
|
|
36
|
+
expect(pageTitle({ isNotFound: false, notFoundTitle, documentTitle: ' ' })).toBe('Site');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('names the not-found shell itself, whatever else resolved', () => {
|
|
40
|
+
expect(
|
|
41
|
+
pageTitle({
|
|
42
|
+
isNotFound: true,
|
|
43
|
+
notFoundTitle,
|
|
44
|
+
catalogTitle: 'Ash glaze mug',
|
|
45
|
+
documentTitle: 'Product',
|
|
46
|
+
})
|
|
47
|
+
).toBe(notFoundTitle);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { axe } from '../support/axe';
|
|
4
|
+
import {
|
|
5
|
+
expectPageLandmarks,
|
|
6
|
+
expectSkipLinkLandsAfterTheHeader,
|
|
7
|
+
mountPage,
|
|
8
|
+
mountPageWithSkipLink,
|
|
9
|
+
pageBlockRoots,
|
|
10
|
+
type PageFixture,
|
|
11
|
+
} from '../support/mountPage';
|
|
12
|
+
import fixture from '../../pages/article.page.json';
|
|
13
|
+
|
|
14
|
+
const page = fixture as unknown as PageFixture;
|
|
15
|
+
|
|
16
|
+
const ARTICLE_TITLE = 'How we glaze our stoneware';
|
|
17
|
+
const RELATED_TITLES = [
|
|
18
|
+
'Inside the Porto linen mill',
|
|
19
|
+
'Caring for merino: a winter guide',
|
|
20
|
+
'Five-minute brown butter oats',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
describe('article sample page', () => {
|
|
24
|
+
it('renders the six blocks, in order, on their documented grounds and containers', async () => {
|
|
25
|
+
const wrapper = await mountPage(page);
|
|
26
|
+
// Every block root in document order across the page's three landmark regions (the header
|
|
27
|
+
// before `<main>`, the footer after it — see `app/utils/pageStructure.ts`).
|
|
28
|
+
const children = pageBlockRoots(wrapper);
|
|
29
|
+
expect(children).toHaveLength(6);
|
|
30
|
+
const [headerEl, breadcrumbsEl, articleEl, articleListEl, newsletterEl, footerEl] = children;
|
|
31
|
+
|
|
32
|
+
// Tag + landmark identity, in document order.
|
|
33
|
+
expect(headerEl!.tagName).toBe('HEADER');
|
|
34
|
+
expect(headerEl!.querySelector('nav')).not.toBeNull();
|
|
35
|
+
expect(breadcrumbsEl!.tagName).toBe('DIV');
|
|
36
|
+
expect(breadcrumbsEl!.querySelector('nav[aria-label]')).not.toBeNull();
|
|
37
|
+
expect(articleEl!.querySelector('article')).not.toBeNull();
|
|
38
|
+
expect(articleListEl!.tagName).toBe('SECTION');
|
|
39
|
+
expect(newsletterEl!.tagName).toBe('SECTION');
|
|
40
|
+
expect(footerEl!.tagName).toBe('FOOTER');
|
|
41
|
+
|
|
42
|
+
// The ground each block sits on (Section's data-section-bg), in order. The header and
|
|
43
|
+
// breadcrumbs are not Sections (spec "Header" / "Breadcrumbs": neither takes part in the
|
|
44
|
+
// adjacent-background collapse rule, so the block after each one keeps its own top padding),
|
|
45
|
+
// so both carry no attribute at all.
|
|
46
|
+
const grounds = children.map((el) => el.getAttribute('data-section-bg'));
|
|
47
|
+
expect(grounds).toEqual([null, null, 'none', 'none', 'surface', 'surface-strong']);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("keeps the article's full top padding after breadcrumbs (breadcrumbs takes no part in the adjacent-background collapse rule)", async () => {
|
|
51
|
+
const wrapper = await mountPage(page);
|
|
52
|
+
const [, breadcrumbsEl, articleEl] = pageBlockRoots(wrapper);
|
|
53
|
+
|
|
54
|
+
// Breadcrumbs renders no `data-section`/`data-section-bg` at all, so the package's
|
|
55
|
+
// `[data-section-bg='x'] + [data-section-bg='x']` CSS rule has nothing to match against and
|
|
56
|
+
// the article keeps its normal `section-md` top padding instead of having it dropped to 0.
|
|
57
|
+
expect(breadcrumbsEl!.hasAttribute('data-section-bg')).toBe(false);
|
|
58
|
+
expect(breadcrumbsEl!.hasAttribute('data-section')).toBe(false);
|
|
59
|
+
expect(articleEl!.getAttribute('data-section-bg')).toBe('none');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('has exactly one h1 (the article title); the related list heading is h2 and its cards are h3', async () => {
|
|
63
|
+
const wrapper = await mountPage(page);
|
|
64
|
+
const roots = pageBlockRoots(wrapper);
|
|
65
|
+
|
|
66
|
+
const h1s = wrapper.findAll('h1');
|
|
67
|
+
expect(h1s).toHaveLength(1);
|
|
68
|
+
expect(h1s[0]!.text()).toBe(ARTICLE_TITLE);
|
|
69
|
+
|
|
70
|
+
const articleListEl = roots[3]!;
|
|
71
|
+
const relatedHeading = articleListEl.querySelector('h2');
|
|
72
|
+
expect(relatedHeading?.textContent).toBe('More from the journal');
|
|
73
|
+
|
|
74
|
+
const cardHeadings = Array.from(articleListEl.querySelectorAll('h3'));
|
|
75
|
+
expect(cardHeadings.map((h) => h.textContent)).toEqual(RELATED_TITLES);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("sits the related list on the article block's own ground so its top padding collapses, while the newsletter and footer change ground and keep full padding", async () => {
|
|
79
|
+
const wrapper = await mountPage(page);
|
|
80
|
+
const [, , articleEl, articleListEl, newsletterEl, footerEl] = pageBlockRoots(wrapper);
|
|
81
|
+
|
|
82
|
+
// Same background as the immediately preceding sibling: the package's adjacent-background
|
|
83
|
+
// CSS rule (`[data-section-bg='x'] + [data-section-bg='x']`) drops the second one's own top
|
|
84
|
+
// padding for exactly this pair.
|
|
85
|
+
expect(articleListEl!.getAttribute('data-section-bg')).toBe(
|
|
86
|
+
articleEl!.getAttribute('data-section-bg')
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// The newsletter and footer each change ground relative to the sibling before them, so
|
|
90
|
+
// neither one's top padding is touched by that rule — both keep a full section gap.
|
|
91
|
+
expect(newsletterEl!.getAttribute('data-section-bg')).not.toBe(
|
|
92
|
+
articleListEl!.getAttribute('data-section-bg')
|
|
93
|
+
);
|
|
94
|
+
expect(footerEl!.getAttribute('data-section-bg')).not.toBe(
|
|
95
|
+
newsletterEl!.getAttribute('data-section-bg')
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('leaves the current post out of the related list and renders exactly one newsletter sign-up', async () => {
|
|
100
|
+
const wrapper = await mountPage(page);
|
|
101
|
+
const roots = pageBlockRoots(wrapper);
|
|
102
|
+
|
|
103
|
+
const articleListEl = roots[3]!;
|
|
104
|
+
const cardTitles = Array.from(articleListEl.querySelectorAll('h3')).map((h) => h.textContent);
|
|
105
|
+
expect(cardTitles).not.toContain(ARTICLE_TITLE);
|
|
106
|
+
expect(cardTitles).toHaveLength(3);
|
|
107
|
+
|
|
108
|
+
// One newsletter sign-up on the whole page: exactly one email field (the footer's own is
|
|
109
|
+
// switched off — `showNewsletter: false` — and the header's search form has no email input).
|
|
110
|
+
const emailFields = wrapper.element.querySelectorAll('input[type="email"]');
|
|
111
|
+
expect(emailFields).toHaveLength(1);
|
|
112
|
+
expect(roots[4]!.contains(emailFields[0]!)).toBe(true);
|
|
113
|
+
|
|
114
|
+
// The footer itself renders no `<form>` at all with its newsletter off.
|
|
115
|
+
expect(roots[5]!.querySelectorAll('form')).toHaveLength(0);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('keeps the article header and cover in the 64rem content container and the body/author card in the 40rem narrow container', async () => {
|
|
119
|
+
const wrapper = await mountPage(page);
|
|
120
|
+
const roots = pageBlockRoots(wrapper);
|
|
121
|
+
const articleEl = roots[2]!;
|
|
122
|
+
|
|
123
|
+
const contentContainers = articleEl.querySelectorAll('.eldra-container-content');
|
|
124
|
+
const narrowContainers = articleEl.querySelectorAll('.eldra-container-narrow');
|
|
125
|
+
expect(contentContainers.length).toBeGreaterThan(0);
|
|
126
|
+
expect(narrowContainers.length).toBeGreaterThan(0);
|
|
127
|
+
expect(articleEl.querySelectorAll('.eldra-container-wide')).toHaveLength(0);
|
|
128
|
+
|
|
129
|
+
// The content container (header + cover) precedes the narrow one (body + author card).
|
|
130
|
+
const firstContent = contentContainers[0]!;
|
|
131
|
+
const firstNarrow = narrowContainers[0]!;
|
|
132
|
+
expect(
|
|
133
|
+
firstContent.compareDocumentPosition(firstNarrow) & Node.DOCUMENT_POSITION_FOLLOWING
|
|
134
|
+
).toBeTruthy();
|
|
135
|
+
|
|
136
|
+
// The header/breadcrumbs stay on the 80rem wide container.
|
|
137
|
+
expect(roots[0]!.querySelector('.eldra-container-wide')).not.toBeNull();
|
|
138
|
+
expect(roots[1]!.querySelector('.eldra-container-wide')).not.toBeNull();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('wraps the body table in a named, focusable region and marks its code block focusable', async () => {
|
|
142
|
+
const wrapper = await mountPage(page);
|
|
143
|
+
const articleEl = pageBlockRoots(wrapper)[2]!;
|
|
144
|
+
|
|
145
|
+
const region = articleEl.querySelector('[role="region"]');
|
|
146
|
+
expect(region).not.toBeNull();
|
|
147
|
+
expect(region!.getAttribute('tabindex')).toBe('0');
|
|
148
|
+
expect(region!.getAttribute('aria-label')).toBeTruthy();
|
|
149
|
+
expect(region!.querySelector('table')).not.toBeNull();
|
|
150
|
+
expect(region!.textContent).toContain('Fjord');
|
|
151
|
+
|
|
152
|
+
const pre = articleEl.querySelector('pre');
|
|
153
|
+
expect(pre).not.toBeNull();
|
|
154
|
+
expect(pre!.getAttribute('tabindex')).toBe('0');
|
|
155
|
+
expect(pre!.textContent).toContain('2,264');
|
|
156
|
+
|
|
157
|
+
// The reactive-glaze batch code stamp renders as inline code, next to the firing schedule.
|
|
158
|
+
const inlineCode = Array.from(articleEl.querySelectorAll('code')).find(
|
|
159
|
+
(el) => el.textContent === 'FJ-26-09'
|
|
160
|
+
);
|
|
161
|
+
expect(inlineCode).toBeDefined();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('follows the visual order header → breadcrumbs → article (links, then the author link) → related list → newsletter → footer', async () => {
|
|
165
|
+
const wrapper = await mountPage(page);
|
|
166
|
+
const [headerEl, breadcrumbsEl, articleEl, articleListEl, newsletterEl, footerEl] =
|
|
167
|
+
pageBlockRoots(wrapper);
|
|
168
|
+
|
|
169
|
+
// Every block contributes at least one focusable element, and each one sits inside its own
|
|
170
|
+
// block's root — proving the page's tab order runs through the blocks in fixture order.
|
|
171
|
+
for (const el of [headerEl, breadcrumbsEl, articleEl, articleListEl, newsletterEl, footerEl]) {
|
|
172
|
+
const focusable = el!.querySelectorAll('a[href], button, input, [tabindex]');
|
|
173
|
+
expect(focusable.length).toBeGreaterThan(0);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Within the article block, every in-body link precedes the author card's own link — the
|
|
177
|
+
// author card closes the post, so its link is the last one inside the block.
|
|
178
|
+
const articleLinks = Array.from(articleEl!.querySelectorAll('a[href]'));
|
|
179
|
+
const authorLink = articleLinks.find((a) => a.textContent?.trim() === 'More from Ingrid');
|
|
180
|
+
expect(authorLink).toBeDefined();
|
|
181
|
+
expect(articleLinks.at(-1)).toBe(authorLink);
|
|
182
|
+
expect(articleLinks.length).toBeGreaterThan(1);
|
|
183
|
+
|
|
184
|
+
// Within the related list, "View all stories" sits in the block's head row, so it is reached
|
|
185
|
+
// before the three story cards: the article-list block's own layout (heading + standalone link
|
|
186
|
+
// in one row, then the grid) decides this order, and the cards follow it in reading order.
|
|
187
|
+
const listLinks = Array.from(articleListEl!.querySelectorAll('a[href]'));
|
|
188
|
+
const viewAllIndex = listLinks.findIndex((a) => a.textContent?.trim() === 'View all stories');
|
|
189
|
+
expect(viewAllIndex).toBeGreaterThanOrEqual(0);
|
|
190
|
+
const cardIndexes = RELATED_TITLES.map((title) =>
|
|
191
|
+
listLinks.findIndex((a) => a.textContent?.includes(title))
|
|
192
|
+
);
|
|
193
|
+
expect(cardIndexes.every((index) => index > viewAllIndex)).toBe(true);
|
|
194
|
+
expect(cardIndexes).toEqual([...cardIndexes].sort((a, b) => a - b));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('reads Portland everywhere the studio is named, and never Bergen', async () => {
|
|
198
|
+
const wrapper = await mountPage(page);
|
|
199
|
+
const roots = pageBlockRoots(wrapper);
|
|
200
|
+
const articleEl = roots[2]!;
|
|
201
|
+
const footerEl = roots[5]!;
|
|
202
|
+
|
|
203
|
+
expect(articleEl.textContent).toContain(
|
|
204
|
+
'Bisqueware waiting for its glaze bath in the Portland studio.'
|
|
205
|
+
);
|
|
206
|
+
expect(articleEl.textContent).toContain(
|
|
207
|
+
'Ingrid has thrown pots in Portland for eighteen years'
|
|
208
|
+
);
|
|
209
|
+
expect(footerEl.textContent).toContain('Studio and shop in Portland, Oregon.');
|
|
210
|
+
expect(wrapper.text()).not.toContain('Bergen');
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('exposes exactly one banner, one main and one contentinfo landmark', async () => {
|
|
214
|
+
// The route renders `navigation` before `<main id="main">` and `footer` after it
|
|
215
|
+
// (`app/utils/pageStructure.ts`), which is what gives those two elements their landmark roles
|
|
216
|
+
// at all — inside `<main>` a `<header>`/`<footer>` carries none.
|
|
217
|
+
const wrapper = await mountPage(page);
|
|
218
|
+
expectPageLandmarks(wrapper);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('puts the skip link first, landing the visitor after the header', async () => {
|
|
222
|
+
const wrapper = await mountPageWithSkipLink(page);
|
|
223
|
+
expectSkipLinkLandsAfterTheHeader(wrapper);
|
|
224
|
+
wrapper.unmount();
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('has no axe violations over the whole rendered page', async () => {
|
|
228
|
+
const wrapper = await mountPage(page);
|
|
229
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
230
|
+
});
|
|
231
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import { flushPromises, type VueWrapper } from '@vue/test-utils';
|
|
4
|
+
import { axe } from '../support/axe';
|
|
5
|
+
import {
|
|
6
|
+
expectPageLandmarks,
|
|
7
|
+
expectSkipLinkLandsAfterTheHeader,
|
|
8
|
+
mountPage,
|
|
9
|
+
mountPageWithSkipLink,
|
|
10
|
+
pageBlockRoots,
|
|
11
|
+
type PageFixture,
|
|
12
|
+
} from '../support/mountPage';
|
|
13
|
+
import { createDemoStorefront } from '../../app/storefront/demo';
|
|
14
|
+
import fixture from '../../pages/category.page.json';
|
|
15
|
+
|
|
16
|
+
const page = fixture as unknown as PageFixture;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The **category sample page** (`pages/category.page.json`) — the seed behind the
|
|
20
|
+
* `/categories/:path*` route template, where a category is addressed by its canonical path (the
|
|
21
|
+
* slugs of its ancestors, root first, then its own).
|
|
22
|
+
*
|
|
23
|
+
* Every block on it reads the route rather than a field: `breadcrumbs` takes the levels above the
|
|
24
|
+
* category from the store (`fromCategory`), `collection-header` in `scope: 'category'` takes the
|
|
25
|
+
* title and the strip of sibling categories from it, and `collection-grid` in `scope: 'category'`
|
|
26
|
+
* lists that category's whole subtree. So the one thing this page needs that no other page spec
|
|
27
|
+
* does is a demo route that *is* a category page — `home/ceramics`, the demo tree's own nested
|
|
28
|
+
* branch (`Homeware › Ceramics`, with `Kitchen` as the sibling the strip never shows and the
|
|
29
|
+
* children the strip would show when a category has any).
|
|
30
|
+
*/
|
|
31
|
+
const CATEGORY_PATH = 'home/ceramics';
|
|
32
|
+
const CATEGORY_TITLE = 'Ceramics';
|
|
33
|
+
|
|
34
|
+
const wrappers: VueWrapper[] = [];
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
for (const wrapper of wrappers.splice(0)) {
|
|
37
|
+
const container = wrapper.element;
|
|
38
|
+
wrapper.unmount();
|
|
39
|
+
container?.remove();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function categoryStorefront(categoryPath: string | undefined = CATEGORY_PATH) {
|
|
44
|
+
return createDemoStorefront({ categoryPath });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function mountCategoryPage(categoryPath?: string): Promise<VueWrapper> {
|
|
48
|
+
const wrapper = await mountPage(page, { storefront: categoryStorefront(categoryPath) });
|
|
49
|
+
await flushPromises();
|
|
50
|
+
wrappers.push(wrapper);
|
|
51
|
+
return wrapper;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('category sample page', () => {
|
|
55
|
+
it('renders the five blocks, in order, on their documented grounds', async () => {
|
|
56
|
+
const wrapper = await mountCategoryPage();
|
|
57
|
+
const children = pageBlockRoots(wrapper);
|
|
58
|
+
expect(children).toHaveLength(5);
|
|
59
|
+
const [navEl, breadcrumbsEl, headerEl, gridEl, footerEl] = children;
|
|
60
|
+
|
|
61
|
+
expect(navEl!.tagName).toBe('HEADER');
|
|
62
|
+
expect(breadcrumbsEl!.querySelector('nav[aria-label]')).not.toBeNull();
|
|
63
|
+
expect(headerEl!.tagName).toBe('HEADER');
|
|
64
|
+
expect(headerEl!.querySelector('h1')).not.toBeNull();
|
|
65
|
+
expect(gridEl!.tagName).toBe('SECTION');
|
|
66
|
+
expect(footerEl!.tagName).toBe('FOOTER');
|
|
67
|
+
|
|
68
|
+
// The header and the breadcrumbs are not `Section`s, so they carry no ground at all and never
|
|
69
|
+
// take part in the adjacent-section padding collapse — the same shape the collection page has.
|
|
70
|
+
expect(children.map((el) => el.getAttribute('data-section-bg'))).toEqual([
|
|
71
|
+
null,
|
|
72
|
+
null,
|
|
73
|
+
'none',
|
|
74
|
+
'none',
|
|
75
|
+
'surface-strong',
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('has exactly one h1 — the category title — and one breadcrumb nav', async () => {
|
|
80
|
+
const wrapper = await mountCategoryPage();
|
|
81
|
+
const h1s = wrapper.findAll('h1');
|
|
82
|
+
expect(h1s).toHaveLength(1);
|
|
83
|
+
expect(h1s[0]!.text()).toBe(CATEGORY_TITLE);
|
|
84
|
+
expect(wrapper.findAll('nav[aria-label="Breadcrumb"]')).toHaveLength(1);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* **Home → the category's ancestors → the category itself**, each ancestor linking to its own
|
|
89
|
+
* canonical path. The seed authors no `trail` levels — a route template cannot, since it renders
|
|
90
|
+
* whatever category its path matched — so every level between Home and the current page is the
|
|
91
|
+
* store's own tree.
|
|
92
|
+
*/
|
|
93
|
+
it('builds the trail from the store’s own tree, each level a canonical path', async () => {
|
|
94
|
+
const wrapper = await mountCategoryPage();
|
|
95
|
+
const trail = wrapper.get('nav[aria-label="Breadcrumb"]');
|
|
96
|
+
expect(trail.findAll('a').map((link) => link.attributes('href'))).toEqual([
|
|
97
|
+
'/',
|
|
98
|
+
'/categories/home',
|
|
99
|
+
]);
|
|
100
|
+
expect(trail.text()).toContain('Homeware');
|
|
101
|
+
expect(trail.text()).toContain(CATEGORY_TITLE);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The strip under the title is the current category's **children**, each linking to its own page —
|
|
106
|
+
* and `Ceramics` is a leaf in the demo tree, so there is no strip at all rather than an empty row.
|
|
107
|
+
* The parent's own page is what shows one.
|
|
108
|
+
*/
|
|
109
|
+
it('shows a strip of child categories only where the category has children', async () => {
|
|
110
|
+
const leaf = await mountCategoryPage();
|
|
111
|
+
expect(leaf.find('ul[aria-label="Categories in this one"]').exists()).toBe(false);
|
|
112
|
+
|
|
113
|
+
const parent = await mountCategoryPage('home');
|
|
114
|
+
const strip = parent.get('ul[aria-label="Categories in this one"]');
|
|
115
|
+
expect(strip.findAll('a').map((link) => link.attributes('href'))).toEqual([
|
|
116
|
+
'/categories/home/ceramics',
|
|
117
|
+
'/categories/home/kitchen',
|
|
118
|
+
]);
|
|
119
|
+
// Never a `current` chip: the open category is the page's own `h1`, and its children are all
|
|
120
|
+
// somewhere else.
|
|
121
|
+
expect(strip.findAll('[aria-current="page"]')).toHaveLength(0);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* **The grid lists the category's whole subtree, and its `category` filter group offers that
|
|
126
|
+
* category's children** — the only values that divide the page, because everything in it is
|
|
127
|
+
* already in the category.
|
|
128
|
+
*/
|
|
129
|
+
it('lists the category’s own products and offers its children as the category filter', async () => {
|
|
130
|
+
const wrapper = await mountCategoryPage('home');
|
|
131
|
+
const grid = pageBlockRoots(wrapper)[3]!;
|
|
132
|
+
const cards = grid.querySelectorAll('[data-eldra-product-card], article');
|
|
133
|
+
expect(cards.length).toBeGreaterThan(0);
|
|
134
|
+
|
|
135
|
+
// **The scope is the subtree, not the catalogue.** Every card on the page is in `Homeware` or
|
|
136
|
+
// under it, so the demo's knitwear — a root category of its own — is nowhere on it, and the
|
|
137
|
+
// count the grid quotes is the subtree's rather than the store's.
|
|
138
|
+
const gridText = grid.textContent ?? '';
|
|
139
|
+
expect(gridText).not.toContain('Merino crew sweater');
|
|
140
|
+
const wholeStore = await mountPage(page, { storefront: createDemoStorefront({}) });
|
|
141
|
+
await flushPromises();
|
|
142
|
+
wrappers.push(wholeStore);
|
|
143
|
+
const unscopedText = pageBlockRoots(wholeStore)[3]!.textContent ?? '';
|
|
144
|
+
const countOf = (text: string) => Number(/(\d+)\s+products/.exec(text)?.[1] ?? '0');
|
|
145
|
+
expect(countOf(gridText)).toBeGreaterThan(0);
|
|
146
|
+
// The unscoped mount has no category at all, so its grid falls back to nothing rather than to
|
|
147
|
+
// the catalogue — the editor hint's own state. Either way it must not quote the subtree's count.
|
|
148
|
+
expect(countOf(unscopedText)).not.toBe(countOf(gridText));
|
|
149
|
+
|
|
150
|
+
const legends = Array.from(grid.querySelectorAll('legend')).map((el) => el.textContent);
|
|
151
|
+
expect(legends).toContain('Category');
|
|
152
|
+
const categoryPanel = Array.from(grid.querySelectorAll('fieldset')).find(
|
|
153
|
+
(set) => set.querySelector('legend')?.textContent === 'Category'
|
|
154
|
+
)!;
|
|
155
|
+
const labels = Array.from(categoryPanel.querySelectorAll('label')).map((el) =>
|
|
156
|
+
(el.textContent ?? '').trim()
|
|
157
|
+
);
|
|
158
|
+
// Its two children, and neither the category itself nor the unrelated root.
|
|
159
|
+
expect(labels.some((label) => label.startsWith('Ceramics'))).toBe(true);
|
|
160
|
+
expect(labels.some((label) => label.startsWith('Kitchen'))).toBe(true);
|
|
161
|
+
expect(labels.some((label) => label.startsWith('Homeware'))).toBe(false);
|
|
162
|
+
expect(labels.some((label) => label.startsWith('Knitwear'))).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('declares the three landmark regions and lands the skip link after the header', async () => {
|
|
166
|
+
const wrapper = await mountPageWithSkipLink(page, { storefront: categoryStorefront() });
|
|
167
|
+
await flushPromises();
|
|
168
|
+
wrappers.push(wrapper);
|
|
169
|
+
expectPageLandmarks(wrapper);
|
|
170
|
+
expectSkipLinkLandsAfterTheHeader(wrapper);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('is axe-clean as a whole page', async () => {
|
|
174
|
+
const wrapper = await mountCategoryPage('home');
|
|
175
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/** Unique ids across every block instance on the page — the page-level gate every sample page
|
|
179
|
+
* shares (two blocks minting the same id is an `aria-controls` pointing at the wrong element). */
|
|
180
|
+
it('mints unique ids across block instances', async () => {
|
|
181
|
+
const wrapper = await mountCategoryPage('home');
|
|
182
|
+
const ids = Array.from(wrapper.element.querySelectorAll('[id]')).map((el) => el.id);
|
|
183
|
+
expect(new Set(ids).size).toBe(ids.length);
|
|
184
|
+
});
|
|
185
|
+
});
|