@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,56 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
// @ts-expect-error — plain JS module, shared with scripts/previews.mjs so the
|
|
7
|
+
// hash written to .eldra/previews.json and the hash checked here can never
|
|
8
|
+
// drift apart; see previewHash.mjs's own comment.
|
|
9
|
+
import { hashBlock, listBlockIds } from '../scripts/previewHash.mjs';
|
|
10
|
+
|
|
11
|
+
const rootDir = fileURLToPath(new URL('..', import.meta.url));
|
|
12
|
+
|
|
13
|
+
describe('block previews', () => {
|
|
14
|
+
const recorded: Record<string, string> = JSON.parse(
|
|
15
|
+
readFileSync(new URL('../.eldra/previews.json', import.meta.url), 'utf8')
|
|
16
|
+
);
|
|
17
|
+
const ids: string[] = listBlockIds(rootDir);
|
|
18
|
+
|
|
19
|
+
it('has a recorded hash for every block', () => {
|
|
20
|
+
expect(Object.keys(recorded).sort()).toEqual(ids);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it.each(ids)('preview for %s is current', (id) => {
|
|
24
|
+
const current = hashBlock(rootDir, id);
|
|
25
|
+
expect(
|
|
26
|
+
recorded[id],
|
|
27
|
+
`preview for ${id} is stale — run pnpm --filter starter-nuxt previews`
|
|
28
|
+
).toBe(current);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Each preview exists twice: `blocks/<id>/preview.png` is the source `scripts/previews.mjs`
|
|
33
|
+
* writes, and `.eldra/previews/<id>.png` is the copy `@eldrajs/vite-plugin-theme`'s scan makes of
|
|
34
|
+
* it on every theme build — the one Studio actually reads. The hashes above cannot see the second
|
|
35
|
+
* one: they hash a block's *sources*, never the image, so a commit can carry a current hash, a
|
|
36
|
+
* current `preview.png`, and a mirror still showing whatever the blocks rendered the last time a
|
|
37
|
+
* build happened to run. That shipped once, advertising prices the theme no longer rendered, and
|
|
38
|
+
* nothing in the suite noticed. The images are bytes from the same file, so equality is exact.
|
|
39
|
+
*/
|
|
40
|
+
it.each(ids)('mirror for %s matches the block’s own preview.png', (id) => {
|
|
41
|
+
const source = join(rootDir, 'blocks', id, 'preview.png');
|
|
42
|
+
const mirror = join(rootDir, '.eldra', 'previews', `${id}.png`);
|
|
43
|
+
expect(existsSync(source), `blocks/${id}/preview.png is missing`).toBe(true);
|
|
44
|
+
expect(existsSync(mirror), `.eldra/previews/${id}.png is missing — run a theme build`).toBe(
|
|
45
|
+
true
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const digest = (path: string): string =>
|
|
49
|
+
createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
50
|
+
expect(
|
|
51
|
+
digest(mirror),
|
|
52
|
+
`.eldra/previews/${id}.png is not the current blocks/${id}/preview.png — ` +
|
|
53
|
+
'run pnpm --filter starter-nuxt previews, then a theme build (nuxi prepare) to refresh it'
|
|
54
|
+
).toBe(digest(source));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
//
|
|
3
|
+
// `blocks/article/Block.vue` imports `EldraRichText` from `@eldrajs/theme-vue`;
|
|
4
|
+
// its single index entry also re-exports `EldraBlockZone`/`EldraLayout`,
|
|
5
|
+
// which import `virtual:eldra/blocks`/`virtual:eldra/manifest`/
|
|
6
|
+
// `virtual:eldra/breakpoints` at the top level, normally supplied only by
|
|
7
|
+
// the Nuxt build's vite plugin. `vitest.config.ts` aliases all three to
|
|
8
|
+
// mocks under `test/mocks/`, so the package — and therefore this block —
|
|
9
|
+
// resolves for real here.
|
|
10
|
+
import { mount } from '@vue/test-utils';
|
|
11
|
+
import { reactive } from 'vue';
|
|
12
|
+
import { createI18n } from 'vue-i18n';
|
|
13
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
14
|
+
import { ELDRA_KEY, createEldraPreviewState } from '@eldrajs/theme-vue';
|
|
15
|
+
import { registerBlockFields } from '@eldrajs/theme-core';
|
|
16
|
+
import blockManifest from '../blocks/article/block.json';
|
|
17
|
+
import Article from '../blocks/article/Block.vue';
|
|
18
|
+
import enUS from '../i18n/en-US.json';
|
|
19
|
+
import isIS from '../i18n/is-IS.json';
|
|
20
|
+
|
|
21
|
+
// The block calls `useI18n()` (its byline sentence, its rich-text table caption fallback, its
|
|
22
|
+
// editor-only hints), so every mount needs `vue-i18n` installed — see `test/support/mountBlock.ts`'s
|
|
23
|
+
// own doc comment. This spec builds its own narrow `global`/context by hand rather than
|
|
24
|
+
// `mountOptions()`'s fuller one, so it installs the same catalogue directly.
|
|
25
|
+
const i18n = createI18n({
|
|
26
|
+
legacy: false,
|
|
27
|
+
locale: 'en-US',
|
|
28
|
+
fallbackLocale: 'en-US',
|
|
29
|
+
messages: { 'en-US': enUS, 'is-IS': isIS },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const body = {
|
|
33
|
+
type: 'doc',
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: 'paragraph',
|
|
37
|
+
content: [
|
|
38
|
+
{ type: 'text', text: 'Plain, ' },
|
|
39
|
+
{ type: 'text', text: 'bold', marks: [{ type: 'bold' }] },
|
|
40
|
+
{ type: 'text', text: ' copy.' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The block's own `block.json`, exactly as `virtual:eldra/block-fields` would
|
|
48
|
+
* project it at build time — so `body`'s `localized: true` is the manifest's,
|
|
49
|
+
* not the test's invention.
|
|
50
|
+
*/
|
|
51
|
+
function registerArticleFields(): void {
|
|
52
|
+
registerBlockFields({
|
|
53
|
+
article: blockManifest.fields.map((field) => ({
|
|
54
|
+
fieldId: field.fieldId,
|
|
55
|
+
type: field.type,
|
|
56
|
+
...(field.localized === true ? { localized: true } : {}),
|
|
57
|
+
...(field.metadata === undefined ? {} : { metadata: field.metadata }),
|
|
58
|
+
})),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A preview bridge attached with an active content locale. */
|
|
63
|
+
function previewContext(locale: string | null): unknown {
|
|
64
|
+
return {
|
|
65
|
+
client: {},
|
|
66
|
+
designTokens: reactive({ colors: {}, containers: {} }),
|
|
67
|
+
preview: Object.assign(createEldraPreviewState(), { active: true, locale }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function mountArticle(context?: unknown, doc: unknown = body) {
|
|
72
|
+
return mount(Article, {
|
|
73
|
+
props: {
|
|
74
|
+
entry: {
|
|
75
|
+
id: 'article-1',
|
|
76
|
+
data: { title: 'Announcing our new platform', body: doc },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
global: {
|
|
80
|
+
plugins: [i18n],
|
|
81
|
+
...(context === undefined ? {} : { provide: { [ELDRA_KEY as symbol]: context } }),
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
afterEach(() => {
|
|
87
|
+
registerBlockFields({});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('article body renders through EldraRichText', () => {
|
|
91
|
+
it('renders the doc as real markup and marks the read-mode root', () => {
|
|
92
|
+
const wrapper = mountArticle();
|
|
93
|
+
|
|
94
|
+
const root = wrapper.get('[data-eldra-rich-text]');
|
|
95
|
+
expect(root.attributes('data-eldra-field')).toBe('body');
|
|
96
|
+
expect(root.attributes('data-eldra-entry')).toBe('article-1');
|
|
97
|
+
|
|
98
|
+
const paragraph = wrapper.get('p');
|
|
99
|
+
expect(paragraph.text()).toBe('Plain, bold copy.');
|
|
100
|
+
expect(wrapper.get('strong').text()).toBe('bold');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("stamps the body's node elements with their document positions", () => {
|
|
104
|
+
// §18 v3: the operator edits this render natively, so every node element
|
|
105
|
+
// carries the ProseMirror position the theme reports selections and text
|
|
106
|
+
// ops in. Mark elements are not nodes and carry nothing.
|
|
107
|
+
const wrapper = mountArticle();
|
|
108
|
+
|
|
109
|
+
const paragraph = wrapper.get('p');
|
|
110
|
+
expect(paragraph.attributes('data-eldra-node')).toBe('paragraph');
|
|
111
|
+
expect(paragraph.attributes('data-eldra-pos')).toBe('0');
|
|
112
|
+
expect(wrapper.get('strong').attributes('data-eldra-pos')).toBeUndefined();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('marks the root with the active content locale for the localized body field', () => {
|
|
116
|
+
registerArticleFields();
|
|
117
|
+
const wrapper = mountArticle(previewContext('is-IS'));
|
|
118
|
+
|
|
119
|
+
expect(wrapper.get('[data-eldra-rich-text]').attributes('data-eldra-locale')).toBe('is-IS');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('stays locale-less in static output, where no preview context is provided', () => {
|
|
123
|
+
registerArticleFields();
|
|
124
|
+
const wrapper = mountArticle();
|
|
125
|
+
|
|
126
|
+
expect(wrapper.get('[data-eldra-rich-text]').attributes('data-eldra-locale')).toBeUndefined();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A rich-text field cannot declare its own heading outline: `metadata.toolbar`'s `heading` control
|
|
132
|
+
* is one level-agnostic id, so an editor can insert any level anywhere. The page owns the outline,
|
|
133
|
+
* so each block passes `EldraRichText`'s `minHeadingLevel` floor for the place its document sits in
|
|
134
|
+
* (`clampHeadingLevel` in `@eldrajs/theme-core` does the clamping). Group A5 added that prop and
|
|
135
|
+
* exactly one of the nine call sites used it, which meant an `h1` in an article body still produced
|
|
136
|
+
* a second `<h1>` on the article page — the very invariant `test/pages/article.spec.ts` asserts,
|
|
137
|
+
* passing only because the fixture happens to use levels 2/2/2/3.
|
|
138
|
+
*/
|
|
139
|
+
describe('heading floors', () => {
|
|
140
|
+
const OUTLINE_DOC = {
|
|
141
|
+
type: 'doc',
|
|
142
|
+
content: [
|
|
143
|
+
{ type: 'heading', attrs: { level: 1 }, content: [{ type: 'text', text: 'Inserted h1' }] },
|
|
144
|
+
{ type: 'heading', attrs: { level: 3 }, content: [{ type: 'text', text: 'Already h3' }] },
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
it("floors the article body at h2, so an inserted h1 can never rival the article's title", () => {
|
|
149
|
+
const wrapper = mountArticle(undefined, OUTLINE_DOC);
|
|
150
|
+
|
|
151
|
+
// The block's own `h1` is the article title; the body's own headings start below it.
|
|
152
|
+
expect(wrapper.findAll('h1')).toHaveLength(1);
|
|
153
|
+
expect(wrapper.get('h1').text()).toBe('Announcing our new platform');
|
|
154
|
+
|
|
155
|
+
const body = wrapper.get('[data-eldra-rich-text]');
|
|
156
|
+
expect(body.get('h2').text()).toBe('Inserted h1');
|
|
157
|
+
// A floor, never an offset: a level already at or below the floor is untouched.
|
|
158
|
+
expect(body.get('h3').text()).toBe('Already h3');
|
|
159
|
+
expect(body.findAll('h4')).toHaveLength(0);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
//
|
|
3
|
+
// Two things live in this file because they are one contract: spec 2's
|
|
4
|
+
// single shared rich-text typography definition (blocks spec lines
|
|
5
|
+
// 2449–2526) and the DOM surgery that fills the two gaps the renderer
|
|
6
|
+
// leaves in it (contract addition #6 — focusable table regions and
|
|
7
|
+
// focusable `<pre>`). `test/mainCss.spec.ts` already establishes the
|
|
8
|
+
// "compile the real stylesheet and assert on its output" technique for
|
|
9
|
+
// `app/assets/main.css`; the CSS half below reuses it. The DOM half mounts
|
|
10
|
+
// a small fragment with `@vue/test-utils`, the same as `test/useUiId.spec.ts`.
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { beforeAll, describe, expect, it } from 'vitest';
|
|
14
|
+
import { compile } from '@tailwindcss/node';
|
|
15
|
+
import { mount } from '@vue/test-utils';
|
|
16
|
+
import { defineComponent, h, nextTick, reactive, ref, type Ref } from 'vue';
|
|
17
|
+
import { ELDRA_KEY, createEldraPreviewState } from '@eldrajs/theme-vue';
|
|
18
|
+
import { useRichTextScrollRegions } from '../app/composables/useRichTextScrollRegions';
|
|
19
|
+
|
|
20
|
+
// `import.meta.dirname` rather than `fileURLToPath(new URL(..., import.meta.url))`:
|
|
21
|
+
// under `@vitest-environment jsdom` (needed below for the scroll-region
|
|
22
|
+
// mount tests) Vite's dev transform rewrites the `new URL(relative,
|
|
23
|
+
// import.meta.url)` idiom into a browser dev-server URL (its usual
|
|
24
|
+
// asset-import handling), which is not a `file://` path and breaks a plain
|
|
25
|
+
// Node read — `import.meta.dirname` is untouched by that transform.
|
|
26
|
+
const assetsDir = `${join(import.meta.dirname, '../app/assets')}/`;
|
|
27
|
+
const mainCss = readFileSync(`${assetsDir}main.css`, 'utf8');
|
|
28
|
+
|
|
29
|
+
async function build(): Promise<string> {
|
|
30
|
+
const compiler = await compile(mainCss, { base: assetsDir, onDependency() {} });
|
|
31
|
+
// `.prose-eldra`'s rules are all `@apply`/plain CSS inside `@layer
|
|
32
|
+
// components` — resolved at compile time from the stylesheet's own text,
|
|
33
|
+
// not from a scanned candidate list (see mainCss.spec.ts's comment on
|
|
34
|
+
// this same API for the utilities that *do* need one). An empty
|
|
35
|
+
// candidate list is enough to prove that.
|
|
36
|
+
return compiler.build([]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns the declaration block for the first rule whose selector text is
|
|
41
|
+
* `selector` (pass the selector followed by ` {` so a short selector never
|
|
42
|
+
* matches as a prefix of a longer, unrelated one — `.prose-eldra
|
|
43
|
+
* :where(blockquote) {` must not match `.prose-eldra :where(blockquote)
|
|
44
|
+
* :where(footer, cite) {`). Brace-counts rather than stopping at the first
|
|
45
|
+
* `}`, so nested at-rules (the focus ring's own `@supports`/`@media`
|
|
46
|
+
* blocks) don't truncate the result early.
|
|
47
|
+
*/
|
|
48
|
+
function ruleBody(css: string, selector: string): string {
|
|
49
|
+
const start = css.indexOf(selector);
|
|
50
|
+
if (start === -1) throw new Error(`selector not found in compiled CSS: ${selector}`);
|
|
51
|
+
const openBrace = css.indexOf('{', start);
|
|
52
|
+
let depth = 0;
|
|
53
|
+
let i = openBrace;
|
|
54
|
+
for (; i < css.length; i++) {
|
|
55
|
+
if (css[i] === '{') depth++;
|
|
56
|
+
else if (css[i] === '}') {
|
|
57
|
+
depth--;
|
|
58
|
+
if (depth === 0) break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return css.slice(openBrace + 1, i);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('rich-text typography (main.css)', () => {
|
|
65
|
+
let css: string;
|
|
66
|
+
|
|
67
|
+
beforeAll(async () => {
|
|
68
|
+
css = await build();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('blockquote has no side bar and no italics, a hanging accent quote mark, and 2.25rem block margins', () => {
|
|
72
|
+
const blockquote = ruleBody(css, '.prose-eldra :where(blockquote) {');
|
|
73
|
+
expect(blockquote).not.toContain('border-left');
|
|
74
|
+
expect(blockquote).not.toContain('italic');
|
|
75
|
+
|
|
76
|
+
const openingMark = ruleBody(css, '.prose-eldra :where(blockquote)::before {');
|
|
77
|
+
expect(openingMark).toContain("content: '\\201C'");
|
|
78
|
+
expect(openingMark).toContain('var(--color-accent)');
|
|
79
|
+
|
|
80
|
+
expect(ruleBody(css, '.prose-eldra > * + :where(blockquote) {')).toContain(
|
|
81
|
+
'margin-top: 2.25rem'
|
|
82
|
+
);
|
|
83
|
+
expect(ruleBody(css, '.prose-eldra > :where(blockquote) {')).toContain(
|
|
84
|
+
'margin-bottom: 2.25rem'
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('pre does not wrap, scrolls horizontally, and draws a border outline', () => {
|
|
89
|
+
const pre = ruleBody(css, '.prose-eldra :where(pre) {');
|
|
90
|
+
expect(pre).toContain('white-space: pre');
|
|
91
|
+
expect(pre).toContain('overflow-x: auto');
|
|
92
|
+
expect(pre).toContain('border-width: 1px');
|
|
93
|
+
expect(pre).toContain('var(--color-border)');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('table collapses its borders, weights header cells 600, and rules them with border-strong', () => {
|
|
97
|
+
const table = ruleBody(css, '.prose-eldra :where(table) {');
|
|
98
|
+
expect(table).toContain('border-collapse: collapse');
|
|
99
|
+
|
|
100
|
+
const th = ruleBody(css, '.prose-eldra :where(th) {');
|
|
101
|
+
expect(th).toContain('font-weight: 600');
|
|
102
|
+
expect(th).toContain('var(--color-border-strong)');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('hr keeps a 2.75rem rhythm above and below', () => {
|
|
106
|
+
expect(ruleBody(css, '.prose-eldra > :where(hr) {')).toContain('margin-bottom: 2.75rem');
|
|
107
|
+
expect(ruleBody(css, '.prose-eldra > * + :where(hr) {')).toContain('margin-top: 2.75rem');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('links are underlined 1px thick at a 0.2em offset', () => {
|
|
111
|
+
const a = ruleBody(css, '.prose-eldra :where(a) {');
|
|
112
|
+
expect(a).toContain('text-decoration-thickness: 1px');
|
|
113
|
+
expect(a).toContain('text-underline-offset: 0.2em');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('the centred variant uses inside list markers and keeps pre/table left-aligned', () => {
|
|
117
|
+
expect(ruleBody(css, '.prose-eldra-center :where(ul, ol) {')).toContain(
|
|
118
|
+
'list-style-position: inside'
|
|
119
|
+
);
|
|
120
|
+
const leftAligned = ruleBody(
|
|
121
|
+
css,
|
|
122
|
+
'.prose-eldra-center :where(pre), .prose-eldra-center :where(table) {'
|
|
123
|
+
);
|
|
124
|
+
expect(leftAligned).toContain('text-align: left');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('useRichTextScrollRegions', () => {
|
|
129
|
+
function mountFragment(root: Ref<HTMLElement | null>, provide?: Record<symbol, unknown>) {
|
|
130
|
+
const Host = defineComponent({
|
|
131
|
+
setup() {
|
|
132
|
+
useRichTextScrollRegions(root, (caption) =>
|
|
133
|
+
caption !== null ? `${caption} table` : 'Table'
|
|
134
|
+
);
|
|
135
|
+
return () =>
|
|
136
|
+
h('div', { ref: root }, [
|
|
137
|
+
h('table', {}, [
|
|
138
|
+
h('caption', {}, 'Glaze recipes'),
|
|
139
|
+
h('tbody', {}, [h('tr', {}, [h('td', {}, 'Cone 6, matte white')])]),
|
|
140
|
+
]),
|
|
141
|
+
h('pre', {}, 'kiln.fire(2232)'),
|
|
142
|
+
]);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
return mount(Host, provide === undefined ? {} : { global: { provide } });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
it('wraps a captioned table in a focusable, labelled scroll region', () => {
|
|
149
|
+
const root: Ref<HTMLElement | null> = ref(null);
|
|
150
|
+
const wrapper = mountFragment(root);
|
|
151
|
+
|
|
152
|
+
const region = wrapper.find('div[role="region"]');
|
|
153
|
+
expect(region.exists()).toBe(true);
|
|
154
|
+
expect(region.attributes('tabindex')).toBe('0');
|
|
155
|
+
expect(region.attributes('aria-label')).toBe('Glaze recipes table');
|
|
156
|
+
expect(region.find('table').exists()).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('makes the code block focusable', () => {
|
|
160
|
+
const root: Ref<HTMLElement | null> = ref(null);
|
|
161
|
+
const wrapper = mountFragment(root);
|
|
162
|
+
expect(wrapper.find('pre').attributes('tabindex')).toBe('0');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('is idempotent: a render-revision bump never wraps an already-wrapped table again', async () => {
|
|
166
|
+
const context = {
|
|
167
|
+
client: {},
|
|
168
|
+
designTokens: reactive({ colors: {}, containers: {} }),
|
|
169
|
+
preview: createEldraPreviewState(),
|
|
170
|
+
};
|
|
171
|
+
const root: Ref<HTMLElement | null> = ref(null);
|
|
172
|
+
const wrapper = mountFragment(root, { [ELDRA_KEY]: context });
|
|
173
|
+
|
|
174
|
+
expect(wrapper.findAll('div[role="region"]')).toHaveLength(1);
|
|
175
|
+
|
|
176
|
+
context.preview.richTextRenderRevision += 1;
|
|
177
|
+
await nextTick();
|
|
178
|
+
|
|
179
|
+
expect(wrapper.findAll('div[role="region"]')).toHaveLength(1);
|
|
180
|
+
expect(wrapper.find('div[role="region"]').attributes('aria-label')).toBe('Glaze recipes table');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Mirrors packages/vue/src/test-setup.ts: registers vitest-axe's matchers
|
|
2
|
+
// (`toHaveNoViolations`) globally so every `__tests__/*.spec.ts` accessibility
|
|
3
|
+
// assertion (`expect(await axe(wrapper.element)).toHaveNoViolations()`) just
|
|
4
|
+
// works, without each spec file importing/extending it itself. The matching
|
|
5
|
+
// `declare module 'vitest'` type augmentation lives in the package-root
|
|
6
|
+
// `vitest-axe.d.ts` instead of here — `nuxi typecheck` does not include
|
|
7
|
+
// `test/**`, but does include a root-level `*.d.ts` (see that file).
|
|
8
|
+
import { afterEach, expect } from 'vitest';
|
|
9
|
+
import * as matchers from 'vitest-axe/matchers';
|
|
10
|
+
import { enableAutoUnmount } from '@vue/test-utils';
|
|
11
|
+
|
|
12
|
+
expect.extend(matchers);
|
|
13
|
+
|
|
14
|
+
// `UiDialog` (and anything built on it, like `UiDrawer`) locks document
|
|
15
|
+
// scroll and adds a document-level Escape/focus-trap keydown listener while
|
|
16
|
+
// mounted and open. A spec that doesn't explicitly `wrapper.unmount()`
|
|
17
|
+
// would otherwise leak both across to the next test in the same file (they
|
|
18
|
+
// share one jsdom `document`) — auto-unmounting after every test is the
|
|
19
|
+
// standard `@vue/test-utils` fix, and it also runs `onBeforeUnmount`/
|
|
20
|
+
// `onScopeDispose` cleanup no test needs to remember to write.
|
|
21
|
+
enableAutoUnmount(afterEach);
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
//
|
|
3
|
+
// `app/pages/[...slug].vue` reads `useEldraPage()`, `useRoute()`, and
|
|
4
|
+
// `useHead()` as bare Nuxt-auto-imported globals (no imports in the source
|
|
5
|
+
// file — see test/useEldraIcon.test.ts for the same pattern). Outside a
|
|
6
|
+
// Nuxt build we install them ourselves with `vi.stubGlobal` before mounting,
|
|
7
|
+
// the same technique used there. `NuxtLink` is stubbed via `global.stubs` so
|
|
8
|
+
// its `to` prop renders as a real `href` we can assert against.
|
|
9
|
+
//
|
|
10
|
+
// This test exists to lock in the not-found/error branch priority: `/404`
|
|
11
|
+
// must always render the not-found shell even when useEldraPage() reports an
|
|
12
|
+
// error (the credential-free generate reaches the error branch before this
|
|
13
|
+
// fix — see test/starter.test.ts), while a real content route's error state
|
|
14
|
+
// must remain visible and not be swallowed by the not-found branch.
|
|
15
|
+
import { mount } from '@vue/test-utils';
|
|
16
|
+
import { computed, ref } from 'vue';
|
|
17
|
+
import { createI18n } from 'vue-i18n';
|
|
18
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
19
|
+
import enUS from '../i18n/en-US.json';
|
|
20
|
+
import isIS from '../i18n/is-IS.json';
|
|
21
|
+
|
|
22
|
+
// EldraLayout/EldraBlockZone (via @eldrajs/theme-vue) pull in a
|
|
23
|
+
// `virtual:eldra/blocks` module supplied only by the Nuxt build's vite
|
|
24
|
+
// plugin, so the module is stubbed here. `EldraBlockZone` renders the ids it
|
|
25
|
+
// was handed (rather than nothing) so the landmark-partition test below can
|
|
26
|
+
// see *which* blocks landed in which of the route's three zones without
|
|
27
|
+
// needing a real block component; `getBlockSchemaApiId` is the real thing's
|
|
28
|
+
// own behaviour, reimplemented in one line.
|
|
29
|
+
vi.mock('@eldrajs/theme-vue', () => ({
|
|
30
|
+
EldraLayout: { template: '<div data-eldra-layout />' },
|
|
31
|
+
EldraBlockZone: {
|
|
32
|
+
props: ['blocks'],
|
|
33
|
+
template:
|
|
34
|
+
'<div class="zone"><span v-for="b in blocks" :key="b.id" :data-block="b.schemaApiId" /></div>',
|
|
35
|
+
},
|
|
36
|
+
getBlockSchemaApiId: (entry: { schemaApiId?: string }) => entry.schemaApiId ?? null,
|
|
37
|
+
// `EldraRouterLink` (the not-found shell's "back home" button) reads the active content locale
|
|
38
|
+
// to prefix its destination. One unprefixed site is this mock's answer, which is what the
|
|
39
|
+
// branch-priority cases here are about.
|
|
40
|
+
useEldraLocale: () => ({
|
|
41
|
+
active: null,
|
|
42
|
+
defaultLocale: null,
|
|
43
|
+
supported: [],
|
|
44
|
+
path: (href: string) => href,
|
|
45
|
+
switchPath: () => '/',
|
|
46
|
+
select: () => {},
|
|
47
|
+
}),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const { default: SlugPage } = await import('../app/pages/[...slug].vue');
|
|
51
|
+
|
|
52
|
+
const NuxtLinkStub = {
|
|
53
|
+
props: ['to'],
|
|
54
|
+
template: '<a :href="to"><slot /></a>',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// `[...slug].vue` calls `useI18n()` directly now (the not-found shell's own copy), so every mount
|
|
58
|
+
// needs `vue-i18n` installed.
|
|
59
|
+
const i18n = createI18n({
|
|
60
|
+
legacy: false,
|
|
61
|
+
locale: 'en-US',
|
|
62
|
+
fallbackLocale: 'en-US',
|
|
63
|
+
messages: { 'en-US': enUS, 'is-IS': isIS },
|
|
64
|
+
});
|
|
65
|
+
const mountGlobal = { plugins: [i18n], stubs: { NuxtLink: NuxtLinkStub } };
|
|
66
|
+
|
|
67
|
+
describe('[...slug].vue not-found vs. error branch priority', () => {
|
|
68
|
+
afterEach(() => {
|
|
69
|
+
vi.unstubAllGlobals();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('renders the not-found shell, not the error alert, for /404 even when useEldraPage reports an error', () => {
|
|
73
|
+
vi.stubGlobal('useRoute', () => ({ path: '/404' }));
|
|
74
|
+
vi.stubGlobal('useHead', () => {});
|
|
75
|
+
vi.stubGlobal('useEldraPage', () => ({
|
|
76
|
+
page: ref(null),
|
|
77
|
+
template: ref(null),
|
|
78
|
+
entry: ref(null),
|
|
79
|
+
catalog: computed(() => null),
|
|
80
|
+
layout: computed(() => null),
|
|
81
|
+
blocks: computed(() => []),
|
|
82
|
+
reusableComponentProjection: computed(() => undefined),
|
|
83
|
+
pending: ref(false),
|
|
84
|
+
error: ref('boom'),
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
const wrapper = mount(SlugPage, { global: mountGlobal });
|
|
88
|
+
|
|
89
|
+
expect(wrapper.find('[data-eldra-not-found]').exists()).toBe(true);
|
|
90
|
+
expect(wrapper.find('[role="alert"]').exists()).toBe(false);
|
|
91
|
+
expect(wrapper.find('a').attributes('href')).toBe('/');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('renders the error alert, not the not-found shell, for a real route with an error', () => {
|
|
95
|
+
vi.stubGlobal('useRoute', () => ({ path: '/some-real-page' }));
|
|
96
|
+
vi.stubGlobal('useHead', () => {});
|
|
97
|
+
vi.stubGlobal('useEldraPage', () => ({
|
|
98
|
+
page: ref(null),
|
|
99
|
+
template: ref(null),
|
|
100
|
+
entry: ref(null),
|
|
101
|
+
catalog: computed(() => null),
|
|
102
|
+
layout: computed(() => null),
|
|
103
|
+
blocks: computed(() => []),
|
|
104
|
+
reusableComponentProjection: computed(() => undefined),
|
|
105
|
+
pending: ref(false),
|
|
106
|
+
error: ref('boom'),
|
|
107
|
+
}));
|
|
108
|
+
|
|
109
|
+
const wrapper = mount(SlugPage, { global: mountGlobal });
|
|
110
|
+
|
|
111
|
+
expect(wrapper.find('[role="alert"]').exists()).toBe(true);
|
|
112
|
+
expect(wrapper.find('[role="alert"]').text()).toBe('boom');
|
|
113
|
+
expect(wrapper.find('[data-eldra-not-found]').exists()).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// C2: the leading structure blocks render *before* `<main id="main">` and a trailing `footer`
|
|
117
|
+
// *after* it, so `navigation`'s `<header>` and `footer`'s `<footer>` are siblings of `<main>` and
|
|
118
|
+
// therefore really carry the `banner`/`contentinfo` landmark roles. Inside `<main>` (which is
|
|
119
|
+
// what this template used to do) they carry none, and `app/app.vue`'s `#main` skip link lands
|
|
120
|
+
// above the navigation it exists to skip. The rule itself is `app/utils/pageStructure.ts`.
|
|
121
|
+
it('renders the header blocks before <main> and a trailing footer after it', () => {
|
|
122
|
+
vi.stubGlobal('useRoute', () => ({ path: '/' }));
|
|
123
|
+
vi.stubGlobal('useHead', () => {});
|
|
124
|
+
const blocks = [
|
|
125
|
+
{ id: 'b1', schemaApiId: 'announcement-bar' },
|
|
126
|
+
{ id: 'b2', schemaApiId: 'navigation' },
|
|
127
|
+
{ id: 'b3', schemaApiId: 'hero' },
|
|
128
|
+
{ id: 'b4', schemaApiId: 'breadcrumbs' },
|
|
129
|
+
{ id: 'b5', schemaApiId: 'footer' },
|
|
130
|
+
];
|
|
131
|
+
vi.stubGlobal('useEldraPage', () => ({
|
|
132
|
+
page: ref({ data: { title: 'Home' } }),
|
|
133
|
+
template: ref(null),
|
|
134
|
+
entry: ref(null),
|
|
135
|
+
catalog: computed(() => null),
|
|
136
|
+
layout: computed(() => null),
|
|
137
|
+
blocks: computed(() => blocks),
|
|
138
|
+
reusableComponentProjection: computed(() => undefined),
|
|
139
|
+
pending: ref(false),
|
|
140
|
+
error: ref(null),
|
|
141
|
+
}));
|
|
142
|
+
|
|
143
|
+
const wrapper = mount(SlugPage, { global: mountGlobal });
|
|
144
|
+
|
|
145
|
+
// `wrapper.element.querySelectorAll` rather than `wrapper.findAll`: the template has three root
|
|
146
|
+
// nodes now, and `findAll` walks the component's vnode tree (roots first, then into each), so
|
|
147
|
+
// it does not report them in document order — which is the whole point of this assertion.
|
|
148
|
+
const zones = [...wrapper.element.querySelectorAll('.zone')];
|
|
149
|
+
expect(zones).toHaveLength(3);
|
|
150
|
+
const apiIdsOf = (index: number) =>
|
|
151
|
+
[...zones[index]!.querySelectorAll('[data-block]')].map((el) =>
|
|
152
|
+
el.getAttribute('data-block')
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
expect(apiIdsOf(0)).toEqual(['announcement-bar', 'navigation']);
|
|
156
|
+
expect(apiIdsOf(1)).toEqual(['hero', 'breadcrumbs']);
|
|
157
|
+
expect(apiIdsOf(2)).toEqual(['footer']);
|
|
158
|
+
|
|
159
|
+
const main = wrapper.get('main#main').element;
|
|
160
|
+
expect(main.contains(zones[0]!)).toBe(false);
|
|
161
|
+
expect(main.contains(zones[1]!)).toBe(true);
|
|
162
|
+
expect(main.contains(zones[2]!)).toBe(false);
|
|
163
|
+
|
|
164
|
+
// Every block appears exactly once on the page — the partition never duplicates one.
|
|
165
|
+
expect(wrapper.element.querySelectorAll('[data-block]')).toHaveLength(blocks.length);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// A layout-driven page is the documented exception: `EldraLayout` arranges the same flat block
|
|
169
|
+
// list through an authored layout tree whose nodes reference block ids, so nothing can be split
|
|
170
|
+
// out of it without breaking the layout. The header/footer blocks then stay inside `<main>` and
|
|
171
|
+
// the page has no `banner`/`contentinfo` — see `docs/starter-kit.md`, "Page structure and
|
|
172
|
+
// landmarks". This asserts the *no double render* half of that: the header/footer zones must not
|
|
173
|
+
// also render the blocks `EldraLayout` is already rendering.
|
|
174
|
+
it('renders a layout-driven page through EldraLayout alone, with no extra zones', () => {
|
|
175
|
+
vi.stubGlobal('useRoute', () => ({ path: '/' }));
|
|
176
|
+
vi.stubGlobal('useHead', () => {});
|
|
177
|
+
vi.stubGlobal('useEldraPage', () => ({
|
|
178
|
+
page: ref({ data: { title: 'Home' } }),
|
|
179
|
+
template: ref(null),
|
|
180
|
+
entry: ref(null),
|
|
181
|
+
catalog: computed(() => null),
|
|
182
|
+
layout: computed(() => ({ nodes: [] })),
|
|
183
|
+
blocks: computed(() => [
|
|
184
|
+
{ id: 'b1', schemaApiId: 'navigation' },
|
|
185
|
+
{ id: 'b2', schemaApiId: 'footer' },
|
|
186
|
+
]),
|
|
187
|
+
reusableComponentProjection: computed(() => undefined),
|
|
188
|
+
pending: ref(false),
|
|
189
|
+
error: ref(null),
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
const wrapper = mount(SlugPage, { global: mountGlobal });
|
|
193
|
+
|
|
194
|
+
expect(wrapper.element.querySelectorAll('.zone')).toHaveLength(0);
|
|
195
|
+
expect(wrapper.find('[data-eldra-layout]').exists()).toBe(true);
|
|
196
|
+
expect(wrapper.get('main#main').element.querySelector('[data-eldra-layout]')).not.toBeNull();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('[...slug].vue document title', () => {
|
|
201
|
+
afterEach(() => {
|
|
202
|
+
vi.unstubAllGlobals();
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
/** `useHead` is called with a function, so the title is read back by calling it. */
|
|
206
|
+
function titleFor(page: Record<string, unknown>): string {
|
|
207
|
+
let head: (() => { title: string }) | undefined;
|
|
208
|
+
vi.stubGlobal('useRoute', () => ({ path: '/products/ash-glaze-mug' }));
|
|
209
|
+
vi.stubGlobal('useHead', (input: () => { title: string }) => {
|
|
210
|
+
head = input;
|
|
211
|
+
});
|
|
212
|
+
vi.stubGlobal('useEldraPage', () => ({
|
|
213
|
+
page: ref(null),
|
|
214
|
+
template: ref(null),
|
|
215
|
+
entry: ref(null),
|
|
216
|
+
catalog: computed(() => null),
|
|
217
|
+
layout: computed(() => null),
|
|
218
|
+
blocks: computed(() => []),
|
|
219
|
+
reusableComponentProjection: computed(() => undefined),
|
|
220
|
+
pending: ref(false),
|
|
221
|
+
error: ref(null),
|
|
222
|
+
...page,
|
|
223
|
+
}));
|
|
224
|
+
mount(SlugPage, { global: mountGlobal });
|
|
225
|
+
return head!().title;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
it('titles a catalog route with the product’s own name, not the template’s', () => {
|
|
229
|
+
// A product page renders through the shared "Product" route template, so its own document
|
|
230
|
+
// title names the template — every product page's tab read "Product" before this.
|
|
231
|
+
expect(
|
|
232
|
+
titleFor({
|
|
233
|
+
template: ref({ data: { title: 'Product' } }),
|
|
234
|
+
entry: ref({ data: { title: 'Ash glaze mug' } }),
|
|
235
|
+
catalog: computed(() => ({ kind: 'product', slug: 'ash-glaze-mug' })),
|
|
236
|
+
blocks: computed(() => [{ id: 'b1', schemaApiId: 'product-detail' }]),
|
|
237
|
+
})
|
|
238
|
+
).toBe('Ash glaze mug');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('titles an ordinary page with its own document title', () => {
|
|
242
|
+
expect(titleFor({ page: ref({ data: { title: 'About us' } }) })).toBe('About us');
|
|
243
|
+
});
|
|
244
|
+
});
|