@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,396 @@
|
|
|
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 fixture from '../../pages/collection.page.json';
|
|
14
|
+
|
|
15
|
+
const page = fixture as unknown as PageFixture;
|
|
16
|
+
|
|
17
|
+
const COLLECTION_TITLE = 'The winter edit';
|
|
18
|
+
const ACTIVE_FILTERS_LABEL = 'Active filters';
|
|
19
|
+
|
|
20
|
+
/** jsdom reports `scrollHeight`/`clientHeight` as `0`/`0` for every element, so `collection-header`'s
|
|
21
|
+
* clamp never "overflows" on its own — the same limitation that block's own spec works around.
|
|
22
|
+
* Stubbing both on the element prototype (restored after each test) is what lets a test drive its
|
|
23
|
+
* Read more disclosure deterministically, which the tab-order assertion below needs present. */
|
|
24
|
+
let restoreOverflowStub: (() => void) | null = null;
|
|
25
|
+
function stubOverflow(scrollHeight: number, clientHeight: number): void {
|
|
26
|
+
const scrollDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollHeight');
|
|
27
|
+
const clientDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'clientHeight');
|
|
28
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
|
|
29
|
+
configurable: true,
|
|
30
|
+
value: scrollHeight,
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(HTMLElement.prototype, 'clientHeight', {
|
|
33
|
+
configurable: true,
|
|
34
|
+
value: clientHeight,
|
|
35
|
+
});
|
|
36
|
+
restoreOverflowStub = () => {
|
|
37
|
+
if (scrollDescriptor)
|
|
38
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', scrollDescriptor);
|
|
39
|
+
else delete (HTMLElement.prototype as Record<string, unknown>).scrollHeight;
|
|
40
|
+
if (clientDescriptor)
|
|
41
|
+
Object.defineProperty(HTMLElement.prototype, 'clientHeight', clientDescriptor);
|
|
42
|
+
else delete (HTMLElement.prototype as Record<string, unknown>).clientHeight;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const wrappers: VueWrapper[] = [];
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
for (const wrapper of wrappers.splice(0)) {
|
|
49
|
+
// Read the container before unmounting: the page harness has three root nodes (banner, main,
|
|
50
|
+
// contentinfo), so `wrapper.element` is the mount container — and `@vue/test-utils` reports it
|
|
51
|
+
// as `null` once the component is gone.
|
|
52
|
+
const container = wrapper.element;
|
|
53
|
+
wrapper.unmount();
|
|
54
|
+
container?.remove();
|
|
55
|
+
}
|
|
56
|
+
restoreOverflowStub?.();
|
|
57
|
+
restoreOverflowStub = null;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* `mountPage` does not attach its harness to `document.body` (most page specs never need real
|
|
62
|
+
* focus tracking). The filter drawer's own dialog contract does — `document.activeElement` only
|
|
63
|
+
* reflects reality for a node that is actually in the live document — so this appends the mounted
|
|
64
|
+
* root the same way `collection-grid`'s own block spec passes `attachTo: document.body`.
|
|
65
|
+
*/
|
|
66
|
+
async function mountAttached(): Promise<VueWrapper> {
|
|
67
|
+
const wrapper = await mountPage(page);
|
|
68
|
+
document.body.appendChild(wrapper.element);
|
|
69
|
+
wrappers.push(wrapper);
|
|
70
|
+
return wrapper;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The filter-group disclosure triggers — a `<button>` inside an `h3`, the same shape
|
|
74
|
+
* `collection-grid`'s own spec keys off (nothing else on the page nests a button in an `h3`). */
|
|
75
|
+
function groupTriggers(root: Element): HTMLButtonElement[] {
|
|
76
|
+
return Array.from(root.querySelectorAll<HTMLButtonElement>('h3 > button[aria-expanded]'));
|
|
77
|
+
}
|
|
78
|
+
/** A group's panel, found by its own visually hidden `<legend>` text, scoped to `root` — pass the
|
|
79
|
+
* sidebar (excluding the drawer) or the open `<dialog>` to pick the right one of the two copies. */
|
|
80
|
+
function panelFor(root: Element, legend: string): Element {
|
|
81
|
+
const trigger = groupTriggers(root).find(
|
|
82
|
+
(candidate) =>
|
|
83
|
+
root.querySelector(`#${candidate.getAttribute('aria-controls')}`)?.querySelector('legend')
|
|
84
|
+
?.textContent === legend
|
|
85
|
+
);
|
|
86
|
+
if (!trigger) throw new Error(`No filter group panel named "${legend}" found.`);
|
|
87
|
+
return root.querySelector(`#${trigger.getAttribute('aria-controls')}`)!;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* jsdom (30.x, this repo's pin) runs a checkbox's native click activation — `checked` flips — but
|
|
92
|
+
* does not follow it with an `input`/`change` event the way a real browser does, so a plain
|
|
93
|
+
* `.click()` never reaches the block's own `@change` handler (Vue Test Utils' own `setValue()`
|
|
94
|
+
* works around exactly this by setting `checked` and dispatching `change` by hand, rather than
|
|
95
|
+
* clicking). This does the same for a raw DOM reference.
|
|
96
|
+
*/
|
|
97
|
+
function checkBox(input: HTMLInputElement): void {
|
|
98
|
+
input.checked = true;
|
|
99
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
describe('collection sample page', () => {
|
|
103
|
+
it('renders the six blocks, in order, on their documented grounds and containers', async () => {
|
|
104
|
+
const wrapper = await mountPage(page);
|
|
105
|
+
// Every block root in document order across the page's three landmark regions: `navigation`
|
|
106
|
+
// renders before `<main id="main">` and `footer` after it (`app/utils/pageStructure.ts`).
|
|
107
|
+
const children = pageBlockRoots(wrapper);
|
|
108
|
+
expect(children).toHaveLength(6);
|
|
109
|
+
const [navEl, breadcrumbsEl, headerEl, gridEl, ctaEl, footerEl] = children;
|
|
110
|
+
|
|
111
|
+
expect(navEl!.tagName).toBe('HEADER');
|
|
112
|
+
expect(navEl!.querySelector('nav')).not.toBeNull();
|
|
113
|
+
expect(breadcrumbsEl!.tagName).toBe('DIV');
|
|
114
|
+
expect(breadcrumbsEl!.querySelector('nav[aria-label]')).not.toBeNull();
|
|
115
|
+
expect(headerEl!.tagName).toBe('HEADER');
|
|
116
|
+
expect(headerEl!.querySelector('h1')).not.toBeNull();
|
|
117
|
+
expect(gridEl!.tagName).toBe('SECTION');
|
|
118
|
+
expect(ctaEl!.tagName).toBe('SECTION');
|
|
119
|
+
expect(footerEl!.tagName).toBe('FOOTER');
|
|
120
|
+
|
|
121
|
+
// The ground each block sits on (Section's `data-section-bg`), in order. The header and the
|
|
122
|
+
// breadcrumbs are not Sections, so they carry no ground at all and never take part in the
|
|
123
|
+
// adjacent-section padding collapse.
|
|
124
|
+
const grounds = children.map((el) => el.getAttribute('data-section-bg'));
|
|
125
|
+
expect(grounds).toEqual([null, null, 'none', 'none', 'surface', 'surface-strong']);
|
|
126
|
+
|
|
127
|
+
// The grid starts directly under the collection header with its own short 1.5rem top padding
|
|
128
|
+
// (`pt-6`) rather than the shared spacing scale, and the call to action keeps a full band of
|
|
129
|
+
// padding on its `surface` ground (`pt-[var(--eldra-section-md)]`) — both blocks hand-roll
|
|
130
|
+
// their own padding rather than reading `Section`'s `spacing` prop (see each block's own
|
|
131
|
+
// top-of-file comment), so this is what proves the page actually renders those literal values.
|
|
132
|
+
expect(gridEl!.classList.contains('pt-6')).toBe(true);
|
|
133
|
+
expect(ctaEl!.classList.contains('pt-[var(--eldra-section-md)]')).toBe(true);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('has exactly one h1 (the collection title) and one breadcrumb nav on the page', async () => {
|
|
137
|
+
const wrapper = await mountPage(page);
|
|
138
|
+
wrapper.get('main#main'); // throws when the landmark is missing
|
|
139
|
+
|
|
140
|
+
const h1s = wrapper.findAll('h1');
|
|
141
|
+
expect(h1s).toHaveLength(1);
|
|
142
|
+
expect(h1s[0]!.text()).toBe(COLLECTION_TITLE);
|
|
143
|
+
|
|
144
|
+
// `showBreadcrumb: false` on the collection-header block: its own breadcrumb never renders, so
|
|
145
|
+
// the standalone Breadcrumbs block's own trail is the only one on the page.
|
|
146
|
+
const crumbs = wrapper.findAll('nav[aria-label="Breadcrumb"]');
|
|
147
|
+
expect(crumbs).toHaveLength(1);
|
|
148
|
+
expect(crumbs[0]!.text()).toContain('Shop');
|
|
149
|
+
expect(crumbs[0]!.text()).toContain(COLLECTION_TITLE);
|
|
150
|
+
|
|
151
|
+
const headerEl = pageBlockRoots(wrapper)[2]!;
|
|
152
|
+
expect(headerEl.querySelector('nav[aria-label="Breadcrumb"]')).toBeNull();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("names the grid section, and keeps the header's own count non-live while the grid's is a polite status", async () => {
|
|
156
|
+
const wrapper = await mountPage(page);
|
|
157
|
+
const [, , headerEl, gridEl] = pageBlockRoots(wrapper);
|
|
158
|
+
|
|
159
|
+
expect(gridEl!.getAttribute('aria-label')).toBe('The winter edit products');
|
|
160
|
+
|
|
161
|
+
// The collection header's own "N products" line is a plain `<p>` — never announced live.
|
|
162
|
+
const headerCount = Array.from(headerEl!.querySelectorAll('p')).find((p) =>
|
|
163
|
+
p.textContent?.includes('products')
|
|
164
|
+
);
|
|
165
|
+
expect(headerCount).toBeDefined();
|
|
166
|
+
expect(headerCount!.textContent).toContain('48 products');
|
|
167
|
+
expect(headerCount!.hasAttribute('aria-live')).toBe(false);
|
|
168
|
+
|
|
169
|
+
// The grid's own count is the block's polite status line — a `<p>` with `tabindex="-1"`, which
|
|
170
|
+
// is what tells it apart from a searchable list facet's own `role="status"` "No matches" line
|
|
171
|
+
// in the sidebar (also persistent, with no `aria-live` of its own — a native `role="status"`
|
|
172
|
+
// needs none).
|
|
173
|
+
const gridCount = gridEl!.querySelector('p[role="status"][tabindex="-1"]');
|
|
174
|
+
expect(gridCount).not.toBeNull();
|
|
175
|
+
expect(gridCount!.getAttribute('aria-live')).toBe('polite');
|
|
176
|
+
expect(gridCount!.textContent).toContain('48 products');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('opens the filter drawer as a dialog from the Filter button, returns focus on Esc, and applies nothing until "Show 48 products" is pressed', async () => {
|
|
180
|
+
const wrapper = await mountAttached();
|
|
181
|
+
const gridEl = pageBlockRoots(wrapper)[3]!;
|
|
182
|
+
|
|
183
|
+
const filterButton = gridEl.querySelector<HTMLButtonElement>('button[aria-haspopup="dialog"]')!;
|
|
184
|
+
filterButton.focus();
|
|
185
|
+
filterButton.click();
|
|
186
|
+
// `useDialog` calls the native `showModal()` from a `watch(open, …)` callback, then applies
|
|
187
|
+
// initial focus a tick *after that* (`void nextTick(focusInitial)`) so slot content has time to
|
|
188
|
+
// render first — two ticks, not one, before focus actually lands on the close button.
|
|
189
|
+
await wrapper.vm.$nextTick();
|
|
190
|
+
await wrapper.vm.$nextTick();
|
|
191
|
+
|
|
192
|
+
const dialog = gridEl.querySelector('dialog')!;
|
|
193
|
+
expect(dialog.getAttribute('open')).toBe('');
|
|
194
|
+
expect(filterButton.getAttribute('aria-expanded')).toBe('true');
|
|
195
|
+
expect(filterButton.getAttribute('aria-controls')).toBe(dialog.id);
|
|
196
|
+
expect(document.activeElement).toBe(dialog.querySelector('[data-part="close"]'));
|
|
197
|
+
|
|
198
|
+
// The drawer's own primary button always reads the demo collection's full count.
|
|
199
|
+
const applyButton = Array.from(dialog.querySelectorAll('button')).find((button) =>
|
|
200
|
+
button.textContent?.trim().startsWith('Show ')
|
|
201
|
+
)!;
|
|
202
|
+
expect(applyButton.textContent?.trim()).toBe('Show 48 products');
|
|
203
|
+
|
|
204
|
+
// Ticking a box in the drawer's own copy of the groups changes nothing live yet.
|
|
205
|
+
const drawerColour = panelFor(dialog, 'Colour');
|
|
206
|
+
const drawerOatCheckbox =
|
|
207
|
+
drawerColour.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[0]!;
|
|
208
|
+
checkBox(drawerOatCheckbox);
|
|
209
|
+
await wrapper.vm.$nextTick();
|
|
210
|
+
// Nothing live has moved — the drawer's own chip row shows its still-pending tick (its own
|
|
211
|
+
// preview of what applying would do), but the sidebar's own applied panel has none.
|
|
212
|
+
const sidebarForChips = Array.from(gridEl.querySelectorAll('aside')).find(
|
|
213
|
+
(el) => el.closest('dialog') === null
|
|
214
|
+
)!;
|
|
215
|
+
expect(sidebarForChips.querySelector(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)).toBeNull();
|
|
216
|
+
|
|
217
|
+
applyButton.click();
|
|
218
|
+
await wrapper.vm.$nextTick();
|
|
219
|
+
|
|
220
|
+
// The visible chip text is just the value's own label; the facet name rides in its remove
|
|
221
|
+
// button's own aria-label instead. Both panels now agree (the drawer's own pending copy
|
|
222
|
+
// matches the just-applied selection), so the sidebar's own row is found by element rather
|
|
223
|
+
// than by the (now ambiguous) aria-label alone.
|
|
224
|
+
const chipsEl = sidebarForChips.querySelector(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)!;
|
|
225
|
+
expect(chipsEl.textContent).toContain('Oat');
|
|
226
|
+
expect(chipsEl.querySelector('[data-part="removeButton"]')!.getAttribute('aria-label')).toBe(
|
|
227
|
+
'Remove filter Colour: Oat'
|
|
228
|
+
);
|
|
229
|
+
expect(dialog.getAttribute('open')).toBeNull();
|
|
230
|
+
|
|
231
|
+
// Reopen, then Esc closes it and returns focus to the Filter button. Waits out the same two
|
|
232
|
+
// ticks as the first open (see above) so the drawer's own initial-focus placement has already
|
|
233
|
+
// landed on the close button before Esc is pressed — otherwise that still-pending focus call
|
|
234
|
+
// fires *after* Esc's own focus-return and steals it back.
|
|
235
|
+
filterButton.click();
|
|
236
|
+
await wrapper.vm.$nextTick();
|
|
237
|
+
await wrapper.vm.$nextTick();
|
|
238
|
+
expect(dialog.getAttribute('open')).toBe('');
|
|
239
|
+
|
|
240
|
+
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
|
241
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
242
|
+
await wrapper.vm.$nextTick();
|
|
243
|
+
|
|
244
|
+
expect(dialog.getAttribute('open')).toBeNull();
|
|
245
|
+
expect(document.activeElement).toBe(filterButton);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('live-applies exactly the three chips Size: M, Colour: Oat and Availability: In stock, in that order, from the sidebar', async () => {
|
|
249
|
+
const wrapper = await mountPage(page);
|
|
250
|
+
const main = wrapper.get('main#main');
|
|
251
|
+
const gridEl = pageBlockRoots(wrapper)[3]!;
|
|
252
|
+
// The sidebar's own copies of the groups — excluding the drawer's duplicate set, which sits
|
|
253
|
+
// inside a `<dialog>` the same page also renders.
|
|
254
|
+
const sidebar = Array.from(gridEl.querySelectorAll('aside')).find(
|
|
255
|
+
(el) => el.closest('dialog') === null
|
|
256
|
+
)!;
|
|
257
|
+
|
|
258
|
+
// Each tick is awaited before the next: the panel is a *controlled* component now (its own
|
|
259
|
+
// `modelValue` prop is the parent's `selection`, round-tripped through a render), so a second
|
|
260
|
+
// change read back through a prop that has not re-rendered yet would overwrite the first
|
|
261
|
+
// rather than add to it — unlike the old uncontrolled `FilterGroups.vue`, which read the
|
|
262
|
+
// parent's own ref directly.
|
|
263
|
+
const sizePanel = panelFor(sidebar, 'Size');
|
|
264
|
+
// XS, S, M, L, XL — M is the third pill.
|
|
265
|
+
checkBox(sizePanel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[2]!);
|
|
266
|
+
await wrapper.vm.$nextTick();
|
|
267
|
+
const colourPanel = panelFor(sidebar, 'Colour');
|
|
268
|
+
// Oat is the demo catalogue's first colour value.
|
|
269
|
+
checkBox(colourPanel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[0]!);
|
|
270
|
+
await wrapper.vm.$nextTick();
|
|
271
|
+
// Availability is a `toggle` facet now (a real `<button role="switch">`, not a checkbox).
|
|
272
|
+
const availabilityPanel = panelFor(sidebar, 'Availability');
|
|
273
|
+
const availabilitySwitch =
|
|
274
|
+
availabilityPanel.querySelector<HTMLButtonElement>('[role="switch"]')!;
|
|
275
|
+
availabilitySwitch.click();
|
|
276
|
+
await wrapper.vm.$nextTick();
|
|
277
|
+
|
|
278
|
+
const chips = main.get(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`).findAll('li');
|
|
279
|
+
expect(chips).toHaveLength(3);
|
|
280
|
+
// The visible chip text is just the value's own label; the facet rides in each remove
|
|
281
|
+
// button's own aria-label.
|
|
282
|
+
expect(chips[0]!.text()).toContain('M');
|
|
283
|
+
expect(chips[0]!.get('[data-part="removeButton"]').attributes('aria-label')).toBe(
|
|
284
|
+
'Remove filter Size: M'
|
|
285
|
+
);
|
|
286
|
+
expect(chips[1]!.text()).toContain('Oat');
|
|
287
|
+
expect(chips[1]!.get('[data-part="removeButton"]').attributes('aria-label')).toBe(
|
|
288
|
+
'Remove filter Colour: Oat'
|
|
289
|
+
);
|
|
290
|
+
expect(chips[2]!.text()).toContain('In stock only');
|
|
291
|
+
expect(chips[2]!.get('[data-part="removeButton"]').attributes('aria-label')).toBe(
|
|
292
|
+
'Remove filter Availability: In stock only'
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The panel's own head — **Clear all** and the applied chips — comes before its group triggers
|
|
298
|
+
* now (the panel owns applied state), so a chip for an already-ticked filter sits before
|
|
299
|
+
* every facet control in the sidebar, including the one that produced it.
|
|
300
|
+
*/
|
|
301
|
+
it('follows the tab order header → breadcrumbs → Read more → sidebar chips → filters → cards → Load more → call to action → footer', async () => {
|
|
302
|
+
stubOverflow(200, 100);
|
|
303
|
+
const wrapper = await mountPage(page);
|
|
304
|
+
const main = wrapper.get('main#main');
|
|
305
|
+
const [navEl, breadcrumbsEl, headerEl, gridEl, ctaEl, footerEl] = pageBlockRoots(wrapper);
|
|
306
|
+
|
|
307
|
+
const sidebar = Array.from(gridEl!.querySelectorAll('aside')).find(
|
|
308
|
+
(el) => el.closest('dialog') === null
|
|
309
|
+
)!;
|
|
310
|
+
// Availability → In stock rather than Size → M: the demo source honours `filters` now
|
|
311
|
+
// (`app/storefront/demo.ts`), and 44 of this collection's 48 items are in stock, so the grid
|
|
312
|
+
// still has more than one page and a real Load more button in the tab order — Size → M leaves
|
|
313
|
+
// 12, i.e. everything already shown, and no Load more at all.
|
|
314
|
+
const availabilitySwitch = panelFor(sidebar, 'Availability').querySelector<HTMLButtonElement>(
|
|
315
|
+
'[role="switch"]'
|
|
316
|
+
)!;
|
|
317
|
+
availabilitySwitch.click();
|
|
318
|
+
// Ticking a sidebar filter starts a new (demo-async) `collectionProducts` request — the grid
|
|
319
|
+
// shows skeletons (an `aria-hidden` list) until it resolves, so this waits for the real card
|
|
320
|
+
// list to come back rather than a single `nextTick`.
|
|
321
|
+
await flushPromises();
|
|
322
|
+
|
|
323
|
+
const readMore = Array.from(headerEl!.querySelectorAll('button')).find(
|
|
324
|
+
(button) => button.textContent?.trim() === 'Read more'
|
|
325
|
+
)!;
|
|
326
|
+
expect(readMore).toBeDefined();
|
|
327
|
+
|
|
328
|
+
const chipRemove = main
|
|
329
|
+
.get(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)
|
|
330
|
+
.element.querySelector('[data-part="removeButton"]')!;
|
|
331
|
+
const firstCardLink = gridEl!.querySelector(
|
|
332
|
+
'ul[aria-labelledby]:not([aria-hidden]) li a[href]'
|
|
333
|
+
)!;
|
|
334
|
+
const loadMoreButton = gridEl!.querySelector('[data-part="button"]')!;
|
|
335
|
+
const ctaButton = Array.from(ctaEl!.querySelectorAll('a, button')).find(
|
|
336
|
+
(el) => el.textContent?.trim() === 'Send a gift card'
|
|
337
|
+
)!;
|
|
338
|
+
const footerFirstLink = footerEl!.querySelector('a[href]')!;
|
|
339
|
+
|
|
340
|
+
// Whole page, not just `<main>`: the header block is a sibling of it now, and its own controls
|
|
341
|
+
// are the first stop in the page's tab order.
|
|
342
|
+
const focusable = Array.from(
|
|
343
|
+
wrapper.element.querySelectorAll<HTMLElement>('a[href], button, input, [tabindex]')
|
|
344
|
+
).filter((el) => el.getAttribute('tabindex') !== '-1' && el.closest('dialog') === null);
|
|
345
|
+
const indexOf = (el: Element | null) => focusable.indexOf(el as HTMLElement);
|
|
346
|
+
|
|
347
|
+
const navFirst = navEl!.querySelector('a[href], button')!;
|
|
348
|
+
const breadcrumbShopLink = Array.from(breadcrumbsEl!.querySelectorAll('a[href]')).find(
|
|
349
|
+
(a) => a.textContent?.trim() === 'Shop'
|
|
350
|
+
)!;
|
|
351
|
+
|
|
352
|
+
expect(indexOf(navFirst)).toBeGreaterThanOrEqual(0);
|
|
353
|
+
expect(indexOf(navFirst)).toBeLessThan(indexOf(breadcrumbShopLink));
|
|
354
|
+
expect(indexOf(breadcrumbShopLink)).toBeLessThan(indexOf(readMore));
|
|
355
|
+
expect(indexOf(readMore)).toBeLessThan(indexOf(chipRemove));
|
|
356
|
+
expect(indexOf(chipRemove)).toBeLessThan(indexOf(availabilitySwitch));
|
|
357
|
+
expect(indexOf(chipRemove)).toBeLessThan(indexOf(firstCardLink));
|
|
358
|
+
expect(indexOf(firstCardLink)).toBeLessThan(indexOf(loadMoreButton));
|
|
359
|
+
expect(indexOf(loadMoreButton)).toBeLessThan(indexOf(ctaButton));
|
|
360
|
+
expect(indexOf(ctaButton)).toBeLessThan(indexOf(footerFirstLink));
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('keeps exactly one promotion between the grid and the footer', async () => {
|
|
364
|
+
const wrapper = await mountPage(page);
|
|
365
|
+
const children = pageBlockRoots(wrapper);
|
|
366
|
+
const between = children.slice(4, children.length - 1);
|
|
367
|
+
expect(between).toHaveLength(1);
|
|
368
|
+
|
|
369
|
+
const cta = between[0]!;
|
|
370
|
+
expect(cta.querySelector('h2')?.textContent).toBe('Not sure what to give?');
|
|
371
|
+
const button = Array.from(cta.querySelectorAll('a, button')).find(
|
|
372
|
+
(el) => el.textContent?.trim() === 'Send a gift card'
|
|
373
|
+
);
|
|
374
|
+
expect(button).toBeDefined();
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it('exposes exactly one banner, one main and one contentinfo landmark', async () => {
|
|
378
|
+
// Two `<header>` elements render on this page — `navigation`'s and `collection-header`'s — but
|
|
379
|
+
// only the first is a `banner`: the route renders it before `<main id="main">`, while
|
|
380
|
+
// `collection-header`'s sits inside `<main>` and so carries no landmark role at all
|
|
381
|
+
// (`app/utils/pageStructure.ts`).
|
|
382
|
+
const wrapper = await mountPage(page);
|
|
383
|
+
expectPageLandmarks(wrapper);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('puts the skip link first, landing the visitor after the header', async () => {
|
|
387
|
+
const wrapper = await mountPageWithSkipLink(page);
|
|
388
|
+
expectSkipLinkLandsAfterTheHeader(wrapper);
|
|
389
|
+
wrapper.unmount();
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it('has no axe violations over the whole rendered page', async () => {
|
|
393
|
+
const wrapper = await mountPage(page);
|
|
394
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
395
|
+
});
|
|
396
|
+
});
|