@eldrajs/theme-cli 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +21 -0
  3. package/README.md +26 -1
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +203 -0
  6. package/dist/index.d.ts +174 -0
  7. package/dist/index.js +3 -0
  8. package/dist/validate-C6jB8_Oc.js +510 -0
  9. package/package.json +50 -2
  10. package/template/.eldra/block-types.d.ts +429 -0
  11. package/template/.eldra/manifest.json +9377 -0
  12. package/template/.eldra/previews.json +36 -0
  13. package/template/.github/workflows/eldra-deploy.yml +24 -0
  14. package/template/.gitlab-ci.yml +16 -0
  15. package/template/.storybook/eldra.ts +123 -0
  16. package/template/.storybook/i18n.ts +23 -0
  17. package/template/.storybook/main.ts +59 -0
  18. package/template/.storybook/nuxt-link-stub.ts +23 -0
  19. package/template/.storybook/preview.ts +52 -0
  20. package/template/.storybook/shims-vue.d.ts +10 -0
  21. package/template/.storybook/virtual-eldra.d.ts +27 -0
  22. package/template/README.md +288 -0
  23. package/template/app/app.vue +126 -0
  24. package/template/app/assets/main.css +404 -0
  25. package/template/app/components/EldraIcon.vue +66 -0
  26. package/template/app/components/EldraRouterLink.vue +62 -0
  27. package/template/app/components/ui/UiImage.stories.ts +30 -0
  28. package/template/app/components/ui/UiImage.vue +224 -0
  29. package/template/app/components/ui/__tests__/UiImage.spec.ts +292 -0
  30. package/template/app/composables/iconComponent.ts +84 -0
  31. package/template/app/composables/iconFetcher.ts +14 -0
  32. package/template/app/composables/useBlockData.ts +30 -0
  33. package/template/app/composables/useEditing.ts +31 -0
  34. package/template/app/composables/useEldraIcon.ts +46 -0
  35. package/template/app/composables/useRevalidating.ts +69 -0
  36. package/template/app/composables/useRichTextScrollRegions.ts +80 -0
  37. package/template/app/composables/useStorefront.ts +18 -0
  38. package/template/app/composables/useStorefrontFeedback.ts +49 -0
  39. package/template/app/composables/useUiId.ts +18 -0
  40. package/template/app/composables/useWishlist.ts +42 -0
  41. package/template/app/i18n.d.ts +28 -0
  42. package/template/app/icons.ts +185 -0
  43. package/template/app/pages/[...slug].vue +134 -0
  44. package/template/app/plugins/eldra-i18n.ts +98 -0
  45. package/template/app/plugins/eldra-storefront.ts +288 -0
  46. package/template/app/plugins/eldra-ui-messages.ts +112 -0
  47. package/template/app/storefront/cart.ts +245 -0
  48. package/template/app/storefront/categories.ts +283 -0
  49. package/template/app/storefront/collectionSelector.ts +60 -0
  50. package/template/app/storefront/commerce.ts +58 -0
  51. package/template/app/storefront/demo.ts +1313 -0
  52. package/template/app/storefront/facets.ts +476 -0
  53. package/template/app/storefront/feedback.ts +122 -0
  54. package/template/app/storefront/gateway.ts +2256 -0
  55. package/template/app/storefront/history.ts +233 -0
  56. package/template/app/storefront/money.ts +247 -0
  57. package/template/app/storefront/options.ts +71 -0
  58. package/template/app/storefront/prerender.ts +77 -0
  59. package/template/app/storefront/refresh.ts +222 -0
  60. package/template/app/storefront/toProductCard.ts +154 -0
  61. package/template/app/storefront/types.ts +815 -0
  62. package/template/app/storefront/volatile.ts +211 -0
  63. package/template/app/templates.ts +544 -0
  64. package/template/app/utils/classes.ts +40 -0
  65. package/template/app/utils/links.ts +70 -0
  66. package/template/app/utils/pageStructure.ts +77 -0
  67. package/template/app/utils/pageTitle.ts +37 -0
  68. package/template/app/virtual-eldra.d.ts +12 -0
  69. package/template/bitbucket-pipelines.yml +19 -0
  70. package/template/blocks/announcement-bar/Block.vue +203 -0
  71. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +227 -0
  72. package/template/blocks/announcement-bar/block.json +45 -0
  73. package/template/blocks/announcement-bar/mock.json +7 -0
  74. package/template/blocks/announcement-bar/preview.png +0 -0
  75. package/template/blocks/article/Block.vue +317 -0
  76. package/template/blocks/article/__tests__/Block.spec.ts +229 -0
  77. package/template/blocks/article/block.json +148 -0
  78. package/template/blocks/article/mock.json +512 -0
  79. package/template/blocks/article/preview.json +16 -0
  80. package/template/blocks/article/preview.png +0 -0
  81. package/template/blocks/article-list/Block.vue +343 -0
  82. package/template/blocks/article-list/__tests__/Block.spec.ts +279 -0
  83. package/template/blocks/article-list/block.json +181 -0
  84. package/template/blocks/article-list/mock.json +68 -0
  85. package/template/blocks/article-list/preview.json +84 -0
  86. package/template/blocks/article-list/preview.png +0 -0
  87. package/template/blocks/breadcrumbs/Block.vue +278 -0
  88. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +461 -0
  89. package/template/blocks/breadcrumbs/block.json +89 -0
  90. package/template/blocks/breadcrumbs/mock.json +11 -0
  91. package/template/blocks/breadcrumbs/preview.json +3 -0
  92. package/template/blocks/breadcrumbs/preview.png +0 -0
  93. package/template/blocks/cart/Block.vue +372 -0
  94. package/template/blocks/cart/__tests__/Block.spec.ts +561 -0
  95. package/template/blocks/cart/__tests__/ShippingBar.spec.ts +78 -0
  96. package/template/blocks/cart/__tests__/Summary.spec.ts +245 -0
  97. package/template/blocks/cart/block.json +74 -0
  98. package/template/blocks/cart/mock.json +11 -0
  99. package/template/blocks/cart/parts/CartLines.vue +257 -0
  100. package/template/blocks/cart/parts/ShippingBar.vue +105 -0
  101. package/template/blocks/cart/parts/Summary.vue +291 -0
  102. package/template/blocks/cart/preview.png +0 -0
  103. package/template/blocks/collection-grid/Block.vue +1832 -0
  104. package/template/blocks/collection-grid/__tests__/Block.spec.ts +3037 -0
  105. package/template/blocks/collection-grid/__tests__/groups.spec.ts +731 -0
  106. package/template/blocks/collection-grid/block.json +187 -0
  107. package/template/blocks/collection-grid/mock.json +23 -0
  108. package/template/blocks/collection-grid/parts/groups.ts +861 -0
  109. package/template/blocks/collection-grid/preview.json +7 -0
  110. package/template/blocks/collection-grid/preview.png +0 -0
  111. package/template/blocks/collection-header/Block.vue +533 -0
  112. package/template/blocks/collection-header/__tests__/Block.spec.ts +381 -0
  113. package/template/blocks/collection-header/block.json +140 -0
  114. package/template/blocks/collection-header/mock.json +28 -0
  115. package/template/blocks/collection-header/preview.json +14 -0
  116. package/template/blocks/collection-header/preview.png +0 -0
  117. package/template/blocks/contact/Block.vue +621 -0
  118. package/template/blocks/contact/__tests__/Block.spec.ts +347 -0
  119. package/template/blocks/contact/block.json +174 -0
  120. package/template/blocks/contact/mock.json +28 -0
  121. package/template/blocks/contact/preview.json +9 -0
  122. package/template/blocks/contact/preview.png +0 -0
  123. package/template/blocks/cta/Block.vue +383 -0
  124. package/template/blocks/cta/__tests__/Block.spec.ts +309 -0
  125. package/template/blocks/cta/block.json +86 -0
  126. package/template/blocks/cta/mock.json +10 -0
  127. package/template/blocks/cta/preview.json +9 -0
  128. package/template/blocks/cta/preview.png +0 -0
  129. package/template/blocks/faq/Block.vue +254 -0
  130. package/template/blocks/faq/__tests__/Block.spec.ts +312 -0
  131. package/template/blocks/faq/block.json +113 -0
  132. package/template/blocks/faq/mock.json +115 -0
  133. package/template/blocks/faq/preview.png +0 -0
  134. package/template/blocks/feature-grid/Block.vue +241 -0
  135. package/template/blocks/feature-grid/__tests__/Block.spec.ts +311 -0
  136. package/template/blocks/feature-grid/block.json +106 -0
  137. package/template/blocks/feature-grid/mock.json +29 -0
  138. package/template/blocks/feature-grid/preview.json +45 -0
  139. package/template/blocks/feature-grid/preview.png +0 -0
  140. package/template/blocks/footer/Block.vue +652 -0
  141. package/template/blocks/footer/__tests__/Block.spec.ts +700 -0
  142. package/template/blocks/footer/block.json +240 -0
  143. package/template/blocks/footer/mock.json +161 -0
  144. package/template/blocks/footer/preview.png +0 -0
  145. package/template/blocks/gallery/Block.vue +416 -0
  146. package/template/blocks/gallery/__tests__/Block.spec.ts +289 -0
  147. package/template/blocks/gallery/block.json +87 -0
  148. package/template/blocks/gallery/mock.json +16 -0
  149. package/template/blocks/gallery/preview.json +64 -0
  150. package/template/blocks/gallery/preview.png +0 -0
  151. package/template/blocks/hero/Block.vue +378 -0
  152. package/template/blocks/hero/__tests__/Block.spec.ts +324 -0
  153. package/template/blocks/hero/block.json +146 -0
  154. package/template/blocks/hero/mock.json +11 -0
  155. package/template/blocks/hero/preview.json +55 -0
  156. package/template/blocks/hero/preview.png +0 -0
  157. package/template/blocks/image/Block.vue +232 -0
  158. package/template/blocks/image/__tests__/Block.spec.ts +224 -0
  159. package/template/blocks/image/block.json +67 -0
  160. package/template/blocks/image/mock.json +7 -0
  161. package/template/blocks/image/preview.json +9 -0
  162. package/template/blocks/image/preview.png +0 -0
  163. package/template/blocks/logo-cloud/Block.vue +206 -0
  164. package/template/blocks/logo-cloud/__tests__/Block.spec.ts +210 -0
  165. package/template/blocks/logo-cloud/block.json +79 -0
  166. package/template/blocks/logo-cloud/mock.json +15 -0
  167. package/template/blocks/logo-cloud/preview.json +92 -0
  168. package/template/blocks/logo-cloud/preview.png +0 -0
  169. package/template/blocks/navigation/Block.vue +1348 -0
  170. package/template/blocks/navigation/__tests__/Block.spec.ts +2030 -0
  171. package/template/blocks/navigation/block.json +167 -0
  172. package/template/blocks/navigation/mock.json +191 -0
  173. package/template/blocks/navigation/preview.png +0 -0
  174. package/template/blocks/navigation/useMegaMenuKeys.ts +276 -0
  175. package/template/blocks/newsletter/Block.vue +399 -0
  176. package/template/blocks/newsletter/__tests__/Block.spec.ts +365 -0
  177. package/template/blocks/newsletter/block.json +105 -0
  178. package/template/blocks/newsletter/mock.json +31 -0
  179. package/template/blocks/newsletter/preview.png +0 -0
  180. package/template/blocks/order-status/Block.vue +754 -0
  181. package/template/blocks/order-status/__tests__/Block.spec.ts +515 -0
  182. package/template/blocks/order-status/block.json +138 -0
  183. package/template/blocks/order-status/mock.json +19 -0
  184. package/template/blocks/order-status/preview.png +0 -0
  185. package/template/blocks/pricing-table/Block.vue +297 -0
  186. package/template/blocks/pricing-table/__tests__/Block.spec.ts +357 -0
  187. package/template/blocks/pricing-table/block.json +155 -0
  188. package/template/blocks/pricing-table/mock.json +47 -0
  189. package/template/blocks/pricing-table/preview.png +0 -0
  190. package/template/blocks/product-carousel/Block.vue +459 -0
  191. package/template/blocks/product-carousel/__tests__/Block.spec.ts +957 -0
  192. package/template/blocks/product-carousel/block.json +71 -0
  193. package/template/blocks/product-carousel/mock.json +9 -0
  194. package/template/blocks/product-carousel/preview.json +7 -0
  195. package/template/blocks/product-carousel/preview.png +0 -0
  196. package/template/blocks/product-detail/Block.vue +886 -0
  197. package/template/blocks/product-detail/__tests__/Block.spec.ts +1495 -0
  198. package/template/blocks/product-detail/__tests__/stock.spec.ts +119 -0
  199. package/template/blocks/product-detail/block.json +155 -0
  200. package/template/blocks/product-detail/mock.json +113 -0
  201. package/template/blocks/product-detail/parts/Gallery.vue +181 -0
  202. package/template/blocks/product-detail/parts/StickyBuyBar.vue +99 -0
  203. package/template/blocks/product-detail/preview.png +0 -0
  204. package/template/blocks/product-detail/stock.ts +150 -0
  205. package/template/blocks/quote/Block.vue +206 -0
  206. package/template/blocks/quote/__tests__/Block.spec.ts +265 -0
  207. package/template/blocks/quote/block.json +76 -0
  208. package/template/blocks/quote/mock.json +9 -0
  209. package/template/blocks/quote/preview.json +16 -0
  210. package/template/blocks/quote/preview.png +0 -0
  211. package/template/blocks/rich-text/Block.vue +143 -0
  212. package/template/blocks/rich-text/__tests__/Block.spec.ts +191 -0
  213. package/template/blocks/rich-text/block.json +57 -0
  214. package/template/blocks/rich-text/mock.json +87 -0
  215. package/template/blocks/rich-text/preview.png +0 -0
  216. package/template/blocks/search/Block.vue +589 -0
  217. package/template/blocks/search/PopularChips.vue +40 -0
  218. package/template/blocks/search/TypeSection.vue +148 -0
  219. package/template/blocks/search/__tests__/Block.spec.ts +718 -0
  220. package/template/blocks/search/__tests__/results.spec.ts +166 -0
  221. package/template/blocks/search/block.json +102 -0
  222. package/template/blocks/search/mock.json +18 -0
  223. package/template/blocks/search/preview.png +0 -0
  224. package/template/blocks/search/results.ts +85 -0
  225. package/template/blocks/split-content/Block.vue +195 -0
  226. package/template/blocks/split-content/__tests__/Block.spec.ts +225 -0
  227. package/template/blocks/split-content/block.json +70 -0
  228. package/template/blocks/split-content/mock.json +45 -0
  229. package/template/blocks/split-content/preview.json +58 -0
  230. package/template/blocks/split-content/preview.png +0 -0
  231. package/template/blocks/stats/Block.vue +159 -0
  232. package/template/blocks/stats/__tests__/Block.spec.ts +194 -0
  233. package/template/blocks/stats/block.json +73 -0
  234. package/template/blocks/stats/mock.json +12 -0
  235. package/template/blocks/stats/preview.png +0 -0
  236. package/template/blocks/tabs/Block.vue +278 -0
  237. package/template/blocks/tabs/__tests__/Block.spec.ts +303 -0
  238. package/template/blocks/tabs/block.json +97 -0
  239. package/template/blocks/tabs/mock.json +129 -0
  240. package/template/blocks/tabs/preview.json +153 -0
  241. package/template/blocks/tabs/preview.png +0 -0
  242. package/template/blocks/team/Block.vue +288 -0
  243. package/template/blocks/team/__tests__/Block.spec.ts +221 -0
  244. package/template/blocks/team/block.json +125 -0
  245. package/template/blocks/team/mock.json +39 -0
  246. package/template/blocks/team/preview.json +62 -0
  247. package/template/blocks/team/preview.png +0 -0
  248. package/template/blocks/testimonials/Block.vue +408 -0
  249. package/template/blocks/testimonials/__tests__/Block.spec.ts +319 -0
  250. package/template/blocks/testimonials/block.json +121 -0
  251. package/template/blocks/testimonials/mock.json +46 -0
  252. package/template/blocks/testimonials/preview.json +68 -0
  253. package/template/blocks/testimonials/preview.png +0 -0
  254. package/template/blocks/timeline/Block.vue +274 -0
  255. package/template/blocks/timeline/__tests__/Block.spec.ts +310 -0
  256. package/template/blocks/timeline/block.json +98 -0
  257. package/template/blocks/timeline/mock.json +27 -0
  258. package/template/blocks/timeline/preview.png +0 -0
  259. package/template/blocks/trust-strip/Block.vue +330 -0
  260. package/template/blocks/trust-strip/__tests__/Block.spec.ts +290 -0
  261. package/template/blocks/trust-strip/block.json +117 -0
  262. package/template/blocks/trust-strip/mock.json +37 -0
  263. package/template/blocks/trust-strip/preview.png +0 -0
  264. package/template/blocks/video-embed/Block.vue +354 -0
  265. package/template/blocks/video-embed/__tests__/Block.spec.ts +219 -0
  266. package/template/blocks/video-embed/__tests__/embed.spec.ts +76 -0
  267. package/template/blocks/video-embed/block.json +94 -0
  268. package/template/blocks/video-embed/embed.ts +84 -0
  269. package/template/blocks/video-embed/mock.json +13 -0
  270. package/template/blocks/video-embed/preview.json +9 -0
  271. package/template/blocks/video-embed/preview.png +0 -0
  272. package/template/blocks/wishlist/Block.vue +367 -0
  273. package/template/blocks/wishlist/__tests__/Block.spec.ts +508 -0
  274. package/template/blocks/wishlist/block.json +42 -0
  275. package/template/blocks/wishlist/mock.json +9 -0
  276. package/template/blocks/wishlist/preview.png +0 -0
  277. package/template/i18n/en-US.json +602 -0
  278. package/template/i18n/is-IS.json +602 -0
  279. package/template/nuxt.config.ts +148 -0
  280. package/template/package.json +55 -0
  281. package/template/pages/article.page.json +731 -0
  282. package/template/pages/cart.page.json +85 -0
  283. package/template/pages/category.page.json +133 -0
  284. package/template/pages/collection.page.json +194 -0
  285. package/template/pages/home.page.json +353 -0
  286. package/template/pages/product.page.json +323 -0
  287. package/template/pages/products.page.json +144 -0
  288. package/template/pages/search.page.json +83 -0
  289. package/template/pages/wishlist.page.json +88 -0
  290. package/template/public/demo/article-cover.svg +1 -0
  291. package/template/public/demo/article-figure.svg +1 -0
  292. package/template/public/demo/avatar-1.svg +3 -0
  293. package/template/public/demo/avatar-2.svg +3 -0
  294. package/template/public/demo/avatar-3.svg +3 -0
  295. package/template/public/demo/avatar-4.svg +3 -0
  296. package/template/public/demo/avatar-5.svg +3 -0
  297. package/template/public/demo/avatar-6.svg +3 -0
  298. package/template/public/demo/avatar-7.svg +3 -0
  299. package/template/public/demo/avatar-8.svg +3 -0
  300. package/template/public/demo/collection-1.svg +1 -0
  301. package/template/public/demo/collection-2.svg +1 -0
  302. package/template/public/demo/cta-split.svg +1 -0
  303. package/template/public/demo/feature-1.svg +1 -0
  304. package/template/public/demo/feature-2.svg +1 -0
  305. package/template/public/demo/feature-3.svg +1 -0
  306. package/template/public/demo/feature-4.svg +1 -0
  307. package/template/public/demo/gallery-1.svg +1 -0
  308. package/template/public/demo/gallery-2.svg +1 -0
  309. package/template/public/demo/gallery-3.svg +1 -0
  310. package/template/public/demo/gallery-4.svg +1 -0
  311. package/template/public/demo/gallery-5.svg +1 -0
  312. package/template/public/demo/gallery-6.svg +1 -0
  313. package/template/public/demo/gallery-7.svg +1 -0
  314. package/template/public/demo/gallery-8.svg +1 -0
  315. package/template/public/demo/hero-slide-1.svg +1 -0
  316. package/template/public/demo/hero-slide-2.svg +1 -0
  317. package/template/public/demo/hero-slide-3.svg +1 -0
  318. package/template/public/demo/hero-slide-4.svg +1 -0
  319. package/template/public/demo/hero-wide.svg +1 -0
  320. package/template/public/demo/hero.svg +1 -0
  321. package/template/public/demo/logo-1.svg +4 -0
  322. package/template/public/demo/logo-2.svg +4 -0
  323. package/template/public/demo/logo-3.svg +4 -0
  324. package/template/public/demo/logo-4.svg +4 -0
  325. package/template/public/demo/logo-5.svg +4 -0
  326. package/template/public/demo/logo-6.svg +4 -0
  327. package/template/public/demo/logo-7.svg +4 -0
  328. package/template/public/demo/logo-8.svg +4 -0
  329. package/template/public/demo/logo.svg +3 -0
  330. package/template/public/demo/map.svg +1 -0
  331. package/template/public/demo/poster.svg +1 -0
  332. package/template/public/demo/product-1.svg +4 -0
  333. package/template/public/demo/product-10.svg +4 -0
  334. package/template/public/demo/product-11.svg +4 -0
  335. package/template/public/demo/product-12.svg +4 -0
  336. package/template/public/demo/product-2.svg +4 -0
  337. package/template/public/demo/product-3.svg +4 -0
  338. package/template/public/demo/product-4.svg +4 -0
  339. package/template/public/demo/product-5.svg +4 -0
  340. package/template/public/demo/product-6.svg +4 -0
  341. package/template/public/demo/product-7.svg +4 -0
  342. package/template/public/demo/product-8.svg +4 -0
  343. package/template/public/demo/product-9.svg +4 -0
  344. package/template/public/demo/product-square-1.svg +4 -0
  345. package/template/public/demo/product-square-2.svg +4 -0
  346. package/template/public/demo/product-square-3.svg +4 -0
  347. package/template/public/demo/product-square-4.svg +4 -0
  348. package/template/public/demo/product-square-5.svg +4 -0
  349. package/template/public/demo/product-square-6.svg +4 -0
  350. package/template/public/demo/quote-portrait.svg +4 -0
  351. package/template/public/demo/split-1.svg +1 -0
  352. package/template/public/demo/split-2.svg +1 -0
  353. package/template/public/demo/split-3.svg +1 -0
  354. package/template/public/demo/split-4.svg +1 -0
  355. package/template/public/demo/team-1.svg +4 -0
  356. package/template/public/demo/team-2.svg +4 -0
  357. package/template/public/demo/team-3.svg +4 -0
  358. package/template/public/demo/team-4.svg +4 -0
  359. package/template/scripts/demo-images.mjs +393 -0
  360. package/template/scripts/generate-stories.mjs +156 -0
  361. package/template/scripts/previewHash.mjs +125 -0
  362. package/template/scripts/previews.mjs +149 -0
  363. package/template/stories/generated/announcement-bar.stories.ts +44 -0
  364. package/template/stories/generated/article-list.stories.ts +87 -0
  365. package/template/stories/generated/article.stories.ts +27 -0
  366. package/template/stories/generated/breadcrumbs.stories.ts +39 -0
  367. package/template/stories/generated/cart.stories.ts +38 -0
  368. package/template/stories/generated/collection-grid.stories.ts +117 -0
  369. package/template/stories/generated/collection-header.stories.ts +51 -0
  370. package/template/stories/generated/contact.stories.ts +45 -0
  371. package/template/stories/generated/cta.stories.ts +51 -0
  372. package/template/stories/generated/faq.stories.ts +56 -0
  373. package/template/stories/generated/feature-grid.stories.ts +69 -0
  374. package/template/stories/generated/footer.stories.ts +50 -0
  375. package/template/stories/generated/gallery.stories.ts +81 -0
  376. package/template/stories/generated/hero.stories.ts +75 -0
  377. package/template/stories/generated/image.stories.ts +99 -0
  378. package/template/stories/generated/logo-cloud.stories.ts +57 -0
  379. package/template/stories/generated/navigation.stories.ts +62 -0
  380. package/template/stories/generated/newsletter.stories.ts +68 -0
  381. package/template/stories/generated/order-status.stories.ts +32 -0
  382. package/template/stories/generated/pricing-table.stories.ts +44 -0
  383. package/template/stories/generated/product-carousel.stories.ts +75 -0
  384. package/template/stories/generated/product-detail.stories.ts +62 -0
  385. package/template/stories/generated/quote.stories.ts +69 -0
  386. package/template/stories/generated/rich-text.stories.ts +50 -0
  387. package/template/stories/generated/search.stories.ts +56 -0
  388. package/template/stories/generated/split-content.stories.ts +39 -0
  389. package/template/stories/generated/stats.stories.ts +68 -0
  390. package/template/stories/generated/tabs.stories.ts +45 -0
  391. package/template/stories/generated/team.stories.ts +45 -0
  392. package/template/stories/generated/testimonials.stories.ts +69 -0
  393. package/template/stories/generated/timeline.stories.ts +80 -0
  394. package/template/stories/generated/trust-strip.stories.ts +62 -0
  395. package/template/stories/generated/video-embed.stories.ts +63 -0
  396. package/template/stories/generated/wishlist.stories.ts +26 -0
  397. package/template/stories/pages/article.stories.ts +51 -0
  398. package/template/stories/pages/cart.stories.ts +56 -0
  399. package/template/stories/pages/category.stories.ts +56 -0
  400. package/template/stories/pages/collection.stories.ts +51 -0
  401. package/template/stories/pages/home.stories.ts +51 -0
  402. package/template/stories/pages/product.stories.ts +47 -0
  403. package/template/stories/pages/products.stories.ts +58 -0
  404. package/template/stories/pages/search.stories.ts +54 -0
  405. package/template/stories/pages/wishlist.stories.ts +53 -0
  406. package/template/stories/support/pageBlocks.ts +115 -0
  407. package/template/test/blocksEmptyData.spec.ts +52 -0
  408. package/template/test/carouselKeyboard.spec.ts +272 -0
  409. package/template/test/carouselRing.browser.spec.ts +193 -0
  410. package/template/test/carouselSlideWidth.browser.spec.ts +102 -0
  411. package/template/test/cartDrawer.spec.ts +295 -0
  412. package/template/test/cartToast.spec.ts +86 -0
  413. package/template/test/countPill.browser.spec.ts +196 -0
  414. package/template/test/demoImages.spec.ts +140 -0
  415. package/template/test/deps.spec.ts +102 -0
  416. package/template/test/eldraIcon.spec.ts +58 -0
  417. package/template/test/framing.spec.ts +76 -0
  418. package/template/test/i18n.spec.ts +200 -0
  419. package/template/test/iconComponent.spec.ts +91 -0
  420. package/template/test/inlineEditable.spec.ts +334 -0
  421. package/template/test/localePrefix.spec.ts +342 -0
  422. package/template/test/mainCss.spec.ts +107 -0
  423. package/template/test/mockGatewayContract.spec.ts +122 -0
  424. package/template/test/mocks/blocks.ts +20 -0
  425. package/template/test/mocks/breakpoints.ts +7 -0
  426. package/template/test/mocks/manifest.ts +11 -0
  427. package/template/test/moneyFormatting.spec.ts +89 -0
  428. package/template/test/pageTitle.spec.ts +49 -0
  429. package/template/test/pages/article.spec.ts +231 -0
  430. package/template/test/pages/category.spec.ts +185 -0
  431. package/template/test/pages/collection.spec.ts +396 -0
  432. package/template/test/pages/home.spec.ts +295 -0
  433. package/template/test/pages/hydration.spec.ts +557 -0
  434. package/template/test/pages/product.spec.ts +396 -0
  435. package/template/test/pages/seededPages.spec.ts +190 -0
  436. package/template/test/pages/ssr.spec.ts +393 -0
  437. package/template/test/prerenderCommerce.spec.ts +134 -0
  438. package/template/test/prerenderFailure.spec.ts +130 -0
  439. package/template/test/prerenderRefresh.browser.spec.ts +1431 -0
  440. package/template/test/previewsFresh.spec.ts +56 -0
  441. package/template/test/richText.spec.ts +161 -0
  442. package/template/test/richTextTypography.spec.ts +182 -0
  443. package/template/test/setup.ts +21 -0
  444. package/template/test/slugPage.spec.ts +244 -0
  445. package/template/test/slugPageTemplate.spec.ts +194 -0
  446. package/template/test/starter.spec.ts +1416 -0
  447. package/template/test/storefront/cart.spec.ts +404 -0
  448. package/template/test/storefront/categories.spec.ts +235 -0
  449. package/template/test/storefront/collectionSelector.spec.ts +74 -0
  450. package/template/test/storefront/demo.spec.ts +555 -0
  451. package/template/test/storefront/facets.spec.ts +425 -0
  452. package/template/test/storefront/feedback.spec.ts +97 -0
  453. package/template/test/storefront/gateway.spec.ts +2673 -0
  454. package/template/test/storefront/gatewayCart.spec.ts +289 -0
  455. package/template/test/storefront/gatewayPrerender.spec.ts +1037 -0
  456. package/template/test/storefront/history.spec.ts +341 -0
  457. package/template/test/storefront/money.spec.ts +171 -0
  458. package/template/test/storefront/toProductCard.spec.ts +138 -0
  459. package/template/test/storefront/volatile.spec.ts +284 -0
  460. package/template/test/support/axe.ts +14 -0
  461. package/template/test/support/dialog.ts +51 -0
  462. package/template/test/support/hydrate.ts +118 -0
  463. package/template/test/support/i18nText.ts +11 -0
  464. package/template/test/support/mockGateway.ts +1017 -0
  465. package/template/test/support/mountBlock.ts +194 -0
  466. package/template/test/support/mountPage.spec.ts +72 -0
  467. package/template/test/support/mountPage.ts +254 -0
  468. package/template/test/support/mountProbe.client.ts +69 -0
  469. package/template/test/support/renderSsr.ts +97 -0
  470. package/template/test/support/staticServer.ts +96 -0
  471. package/template/test/themeIcons.spec.ts +140 -0
  472. package/template/test/toastAnnouncement.spec.ts +133 -0
  473. package/template/test/tokens.spec.ts +102 -0
  474. package/template/test/uiMessagesPlugin.spec.ts +104 -0
  475. package/template/test/useBlockData.spec.ts +46 -0
  476. package/template/test/useEditing.spec.ts +54 -0
  477. package/template/test/useEldraIcon.spec.ts +126 -0
  478. package/template/test/useUiId.spec.ts +40 -0
  479. package/template/tokens.json +149 -0
  480. package/template/tsconfig.json +3 -0
  481. package/template/tsconfig.storybook.json +17 -0
  482. package/template/vitest-axe.d.ts +13 -0
  483. package/template/vitest.config.ts +44 -0
@@ -0,0 +1,196 @@
1
+ // @vitest-environment jsdom
2
+ import { readFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { chromium, type Browser, type Page } from '@playwright/test';
5
+ import { compile } from '@tailwindcss/node';
6
+ import { flushPromises, mount } from '@vue/test-utils';
7
+ import { computed } from 'vue';
8
+ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
9
+ import Block from '../blocks/navigation/Block.vue';
10
+ import mock from '../blocks/navigation/mock.json';
11
+ import { mountOptions } from './support/mountBlock';
12
+ import { STOREFRONT_KEY } from '../app/storefront/types';
13
+ import { createDemoStorefront } from '../app/storefront/demo';
14
+
15
+ /**
16
+ * **Does the header's cart count pill actually come out as a corner badge, in a real browser?**
17
+ *
18
+ * `blocks/navigation/__tests__/Block.spec.ts` proves the pill carries the operator's corner-badge
19
+ * classes (`COUNT_PILL_CLASSES` in `Block.vue`) — `min-h-3.5`/`min-w-3.5`/`h-3.5`, `-top-0.5
20
+ * -right-0.5`, no ring. That is a class-name assertion, in jsdom, which computes no layout at all —
21
+ * it cannot see whether those classes actually resolve to a 14px-tall box sitting on the icon's own
22
+ * corner once the theme's real Tailwind build and a real browser's box model are both in the loop,
23
+ * which is exactly the gap two reported defects in a row lived in: first a pill that read as too
24
+ * large next to the icon (fixed by shrinking it to spec), then — worse — a pill that, once moved onto
25
+ * the icon's corner, covered almost the whole glyph (fixed by shrinking it further and letting it
26
+ * mostly overlap the button's own padding rather than the icon).
27
+ *
28
+ * Same technique as `carouselRing.browser.spec.ts`: the real block is mounted with
29
+ * `@vue/test-utils`, its rendered markup is compiled against the theme's actual `main.css` with
30
+ * `@tailwindcss/node`, and the result is handed to a real Chromium page — no Nuxt build, no
31
+ * network, nothing but the markup, the stylesheet and the browser's own layout engine.
32
+ */
33
+
34
+ const assetsDir = `${join(import.meta.dirname, '../app/assets')}/`;
35
+ /** 1440px, the width the operator's screenshots showed the pill at. */
36
+ const VIEWPORT = { width: 1440, height: 900 };
37
+ /** Renders the header with a fixed cart count, against the theme's real stylesheet. */
38
+ async function renderHeaderWithCartCount(count: number): Promise<string> {
39
+ const base = mountOptions({ entry: { id: 'e1', data: mock } });
40
+ const storefront = createDemoStorefront();
41
+ const cart = { ...storefront.cart, count: computed(() => count) };
42
+ const wrapper = mount(Block, {
43
+ ...base,
44
+ global: {
45
+ ...base.global,
46
+ provide: { ...base.global.provide, [STOREFRONT_KEY]: { ...storefront, cart } },
47
+ },
48
+ });
49
+ // `cartCount` only reads the store after `onMounted` (so a prerendered page's first client
50
+ // render agrees with the server's) — the same wait `Block.spec.ts` gives every cart-count case.
51
+ await flushPromises();
52
+ await flushPromises();
53
+ const html = wrapper.html();
54
+ wrapper.unmount();
55
+ return html;
56
+ }
57
+
58
+ async function pageFor(html: string): Promise<Page> {
59
+ const candidates = [...html.matchAll(/class="([^"]*)"/g)].flatMap((match) =>
60
+ match[1]!.split(/\s+/).filter(Boolean)
61
+ );
62
+ const compiler = await compile(readFileSync(`${assetsDir}main.css`, 'utf8'), {
63
+ base: assetsDir,
64
+ onDependency() {},
65
+ });
66
+ const css = compiler.build([...new Set(candidates)]);
67
+
68
+ const page = await browser.newPage({ viewport: VIEWPORT, reducedMotion: 'reduce' });
69
+ // Nothing is fetched: icon markup and the brand logo are either inline or absent from the mock,
70
+ // and the pill owes nothing to either.
71
+ await page.route('**', (route) => route.abort());
72
+ await page.setContent(`<style>${css}</style><main>${html}</main>`, {
73
+ waitUntil: 'domcontentloaded',
74
+ });
75
+ return page;
76
+ }
77
+
78
+ /**
79
+ * The **bag's** pill, named by the control it annotates rather than by "the `aria-hidden` span in
80
+ * the actions row": the wishlist heart is that row's other pilled control and sits there in every
81
+ * header now, saved list or not, so a row-wide lookup only happens to be unique because this
82
+ * harness leaves the wishlist empty. `:has(> …)` pins it to the `relative inline-flex` span the bag
83
+ * and its badge share (`blocks/navigation/Block.vue`), and `span` rather than `[aria-hidden]` alone
84
+ * keeps the bag's own `aria-hidden` `<svg>` out of it.
85
+ */
86
+ const BAG_PILL =
87
+ 'header [data-eldra-header-actions] span:has(> [aria-label^="Cart"]) > span[aria-hidden="true"]';
88
+
89
+ interface Rect {
90
+ x: number;
91
+ y: number;
92
+ width: number;
93
+ height: number;
94
+ }
95
+
96
+ /** Overlap area of two axis-aligned rects, clamped to zero when they don't intersect. */
97
+ function intersectionArea(a: Rect, b: Rect): number {
98
+ const width = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);
99
+ const height = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);
100
+ return Math.max(width, 0) * Math.max(height, 0);
101
+ }
102
+
103
+ let browser: Browser;
104
+
105
+ describe('the header cart count pill, in a real browser at 1440px', () => {
106
+ beforeAll(async () => {
107
+ browser = await chromium.launch();
108
+ }, 120_000);
109
+
110
+ afterAll(async () => {
111
+ await browser?.close();
112
+ });
113
+
114
+ /**
115
+ * A corner badge is at most 14px tall — that is the
116
+ * whole point of shrinking it off the spec's 1.25rem minimum. The width floor comes along for
117
+ * free from `min-w-3.5`.
118
+ */
119
+ it('comes out at most 14px tall with one item', async () => {
120
+ const html = await renderHeaderWithCartCount(1);
121
+ const page = await pageFor(html);
122
+ try {
123
+ const pill = page.locator(BAG_PILL);
124
+ expect((await pill.textContent())?.trim()).toBe('1');
125
+ const box = await pill.boundingBox();
126
+ if (box === null) throw new Error('the pill never laid out');
127
+ expect(box.height).toBeLessThanOrEqual(14);
128
+ } finally {
129
+ await page.close();
130
+ }
131
+ });
132
+
133
+ /**
134
+ * The defect this change actually fixes: a pill moved onto the icon's own corner that then
135
+ * covered almost the whole glyph. Measured against the real `<svg>` the bag icon renders (not an
136
+ * assumed box), the pill's footprint must land mostly on the button's own padding — at most a
137
+ * quarter of the icon's area — so the icon stays recognisable with a badge sitting on its
138
+ * corner, not a badge sitting on top of it.
139
+ */
140
+ it('overlaps the bag icon by at most a quarter of its area, with no ring left behind', async () => {
141
+ const html = await renderHeaderWithCartCount(1);
142
+ const page = await pageFor(html);
143
+ try {
144
+ const pill = page.locator(BAG_PILL);
145
+ const pillBox = await pill.boundingBox();
146
+ if (pillBox === null) throw new Error('the pill never laid out');
147
+
148
+ // The bag's own icon: the leading-icon slot's `<svg>` inside the same wrapper the pill is a
149
+ // sibling of (`<span class="relative inline-flex"><Button>…<svg/></Button><Badge/></span>`).
150
+ const iconBox = await pill.evaluate((el): Rect | null => {
151
+ const svg = el.parentElement?.querySelector('[data-part="leadingIcon"] svg');
152
+ if (svg === null || svg === undefined) return null;
153
+ const rect = svg.getBoundingClientRect();
154
+ return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
155
+ });
156
+ if (iconBox === null) throw new Error('the bag icon never rendered');
157
+
158
+ const overlap = intersectionArea(pillBox, iconBox);
159
+ const iconArea = iconBox.width * iconBox.height;
160
+ expect(overlap / iconArea).toBeLessThanOrEqual(0.25);
161
+
162
+ // The ring the earlier version carried (`ring-2 ring-background`) painted as a box-shadow;
163
+ // a corner badge sitting on the icon must carry none, since a ring's job is separating a
164
+ // pill from what sits beside it, and this pill sits deliberately on top of the icon.
165
+ const boxShadow = await pill.evaluate((el) => getComputedStyle(el).boxShadow);
166
+ expect(boxShadow === 'none' || boxShadow === '').toBe(true);
167
+ } finally {
168
+ await page.close();
169
+ }
170
+ });
171
+
172
+ /** Spec: "Above 99 it reads `99+`." Three characters, bold, at 0.625rem — this is the row most
173
+ * likely to overflow its own box if the pill's padding or width ever regressed, now that both
174
+ * are smaller than the spec's original pill. */
175
+ it('fits "99+" with no clipping, above the 99 ceiling', async () => {
176
+ const html = await renderHeaderWithCartCount(120);
177
+ const page = await pageFor(html);
178
+ try {
179
+ const pill = page.locator(BAG_PILL);
180
+ expect((await pill.textContent())?.trim()).toBe('99+');
181
+ const overflow = await pill.evaluate((el) => ({
182
+ scrollWidth: el.scrollWidth,
183
+ clientWidth: el.clientWidth,
184
+ scrollHeight: el.scrollHeight,
185
+ clientHeight: el.clientHeight,
186
+ }));
187
+ expect(overflow.scrollWidth).toBeLessThanOrEqual(overflow.clientWidth);
188
+ expect(overflow.scrollHeight).toBeLessThanOrEqual(overflow.clientHeight);
189
+ const box = await pill.boundingBox();
190
+ if (box === null) throw new Error('the pill never laid out');
191
+ expect(box.height).toBeLessThanOrEqual(14);
192
+ } finally {
193
+ await page.close();
194
+ }
195
+ });
196
+ });
@@ -0,0 +1,140 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { describe, expect, it } from 'vitest';
5
+
6
+ const publicDemoDir = fileURLToPath(new URL('../public/demo', import.meta.url));
7
+
8
+ const expectedNames = [
9
+ 'hero',
10
+ 'hero-wide',
11
+ 'hero-slide-1',
12
+ 'hero-slide-2',
13
+ 'hero-slide-3',
14
+ 'hero-slide-4',
15
+ 'product-1',
16
+ 'product-2',
17
+ 'product-3',
18
+ 'product-4',
19
+ 'product-5',
20
+ 'product-6',
21
+ 'product-7',
22
+ 'product-8',
23
+ 'product-9',
24
+ 'product-10',
25
+ 'product-11',
26
+ 'product-12',
27
+ 'product-square-1',
28
+ 'product-square-2',
29
+ 'product-square-3',
30
+ 'product-square-4',
31
+ 'product-square-5',
32
+ 'product-square-6',
33
+ 'collection-1',
34
+ 'collection-2',
35
+ 'split-1',
36
+ 'split-2',
37
+ 'split-3',
38
+ 'split-4',
39
+ 'feature-1',
40
+ 'feature-2',
41
+ 'feature-3',
42
+ 'feature-4',
43
+ 'gallery-1',
44
+ 'gallery-2',
45
+ 'gallery-3',
46
+ 'gallery-4',
47
+ 'gallery-5',
48
+ 'gallery-6',
49
+ 'gallery-7',
50
+ 'gallery-8',
51
+ 'team-1',
52
+ 'team-2',
53
+ 'team-3',
54
+ 'team-4',
55
+ 'logo',
56
+ 'logo-1',
57
+ 'logo-2',
58
+ 'logo-3',
59
+ 'logo-4',
60
+ 'logo-5',
61
+ 'logo-6',
62
+ 'logo-7',
63
+ 'logo-8',
64
+ 'avatar-1',
65
+ 'avatar-2',
66
+ 'avatar-3',
67
+ 'avatar-4',
68
+ 'avatar-5',
69
+ 'avatar-6',
70
+ 'avatar-7',
71
+ 'avatar-8',
72
+ 'article-cover',
73
+ 'article-figure',
74
+ 'quote-portrait',
75
+ 'poster',
76
+ 'map',
77
+ 'cta-split',
78
+ ];
79
+
80
+ describe('demo images', () => {
81
+ it.each(expectedNames)('%s.svg exists and parses as SVG', (name) => {
82
+ const path = join(publicDemoDir, `${name}.svg`);
83
+ expect(existsSync(path), path).toBe(true);
84
+ const content = readFileSync(path, 'utf8');
85
+ expect(content.trimStart().startsWith('<svg')).toBe(true);
86
+ });
87
+
88
+ // Catches the other direction of drift: a name renamed or dropped from
89
+ // `scripts/demo-images.mjs`'s manifest (or from `expectedNames` above)
90
+ // without updating the other, which would otherwise leave a stale SVG on
91
+ // disk that nothing asserts on any more.
92
+ /**
93
+ * Every avatar draws initials from `scripts/demo-images.mjs`'s own `avatarNames` list, which was a
94
+ * *different* set of names from the ones the mocks print beside those avatars: the home page, the
95
+ * article page, Storybook and the shipped `testimonials/preview.png` all rendered
96
+ * "Hannah Reeve — AK", "Marcus Bell — PN", "Sofia Lind — JL". The list is now the mocks' own
97
+ * names; this is the guard, tying each avatar file to the mock field that references it.
98
+ */
99
+ it.each([
100
+ ['avatar-1', 'blocks/testimonials/preview.json', 'items.0.name'],
101
+ ['avatar-2', 'blocks/testimonials/preview.json', 'items.1.name'],
102
+ ['avatar-3', 'blocks/testimonials/preview.json', 'items.2.name'],
103
+ ['avatar-4', 'blocks/testimonials/preview.json', 'items.3.name'],
104
+ ['avatar-5', 'blocks/quote/mock.json', 'name'],
105
+ ['avatar-6', 'blocks/article/mock.json', 'authorName'],
106
+ ])("%s's initials are the ones %s's %s prints beside it", (avatar, mockPath, field) => {
107
+ const mock = JSON.parse(
108
+ readFileSync(fileURLToPath(new URL(`../${mockPath}`, import.meta.url)), 'utf8')
109
+ ) as Record<string, unknown>;
110
+ const name = field
111
+ .split('.')
112
+ .reduce<unknown>(
113
+ (value, key) => (value as Record<string, unknown> | unknown[])[key as never],
114
+ mock
115
+ );
116
+ expect(typeof name, `${mockPath} has no ${field}`).toBe('string');
117
+
118
+ // The same rule `demo-images.mjs`'s own `initialsFor` applies: first letter of the first two
119
+ // words.
120
+ const expectedInitials = (name as string)
121
+ .split(/\s+/)
122
+ .filter(Boolean)
123
+ .slice(0, 2)
124
+ .map((part) => part[0]!.toUpperCase())
125
+ .join('');
126
+
127
+ const svg = readFileSync(join(publicDemoDir, `${avatar}.svg`), 'utf8');
128
+ const rendered = /<text[^>]*>([^<]*)<\/text>/.exec(svg)?.[1];
129
+ expect(rendered, `${avatar}.svg renders no initials`).toBeDefined();
130
+ expect(rendered).toBe(expectedInitials);
131
+ });
132
+
133
+ it('has no SVG in public/demo that is not in expectedNames', () => {
134
+ const actual = readdirSync(publicDemoDir)
135
+ .filter((file) => file.endsWith('.svg'))
136
+ .map((file) => file.replace(/\.svg$/, ''))
137
+ .sort();
138
+ expect(actual).toEqual([...expectedNames].sort());
139
+ });
140
+ });
@@ -0,0 +1,102 @@
1
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { describe, expect, it } from 'vitest';
5
+ import pkg from '../package.json';
6
+
7
+ // SF-1: the starter is a standalone copy (`eldra-theme init` copies this
8
+ // directory verbatim, with no sibling monorepo to fall back on), so every
9
+ // bare import it uses at dev/build/test time must resolve to its OWN
10
+ // package.json — not something that happens to be hoisted from the
11
+ // workspace root only inside this monorepo. This test proves that by
12
+ // statically scanning source for bare import specifiers and checking each
13
+ // one against the starter's own dependencies/devDependencies, rather than
14
+ // trusting node's resolution (which would happily find a root-only
15
+ // devDependency here and pass).
16
+
17
+ const rootDir = fileURLToPath(new URL('..', import.meta.url));
18
+
19
+ const SCAN_DIRS = ['app', 'blocks', 'scripts', '.storybook', 'stories', 'test'];
20
+ const SCAN_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.mjs', '.cjs', '.vue']);
21
+
22
+ // Specifiers that are always allowed: relative/absolute paths, Node
23
+ // builtins, and the runtime-only ids this package never lists as a
24
+ // dependency because they are supplied by the framework/build tooling
25
+ // rather than resolved from node_modules.
26
+ const ALWAYS_ALLOWED = new Set(['nuxt', 'vue', '#imports']);
27
+
28
+ function listSourceFiles(dir: string): string[] {
29
+ const files: string[] = [];
30
+ for (const name of readdirSync(dir)) {
31
+ const full = join(dir, name);
32
+ const stat = statSync(full);
33
+ if (stat.isDirectory()) {
34
+ files.push(...listSourceFiles(full));
35
+ } else if (SCAN_EXTENSIONS.has(name.slice(name.lastIndexOf('.')))) {
36
+ files.push(full);
37
+ }
38
+ }
39
+ return files;
40
+ }
41
+
42
+ // Matches a static import (with or without `from`, so side-effect imports
43
+ // count too), a re-export, and a dynamic import call. Deliberately does not
44
+ // require a trailing semicolon so multi-line import blocks match.
45
+ const IMPORT_RE =
46
+ /(?:^|\n)\s*(?:import|export)(?:[^'"\n;]*\bfrom)?\s+['"]([^'"]+)['"]|import\(\s*['"]([^'"]+)['"]/g;
47
+
48
+ function extractSpecifiers(source: string): string[] {
49
+ const specifiers: string[] = [];
50
+ for (const match of source.matchAll(IMPORT_RE)) {
51
+ const spec = match[1] ?? match[2];
52
+ if (spec) specifiers.push(spec);
53
+ }
54
+ return specifiers;
55
+ }
56
+
57
+ function packageNameOf(specifier: string): string {
58
+ const segments = specifier.split('/');
59
+ return specifier.startsWith('@') ? segments.slice(0, 2).join('/') : segments[0];
60
+ }
61
+
62
+ function isDeclaredDependency(pkgName: string): boolean {
63
+ const deps = pkg.dependencies as Record<string, string> | undefined;
64
+ const devDeps = pkg.devDependencies as Record<string, string> | undefined;
65
+ const peerDeps = (pkg as { peerDependencies?: Record<string, string> }).peerDependencies;
66
+ return Boolean(deps?.[pkgName] || devDeps?.[pkgName] || peerDeps?.[pkgName]);
67
+ }
68
+
69
+ function isAllowed(specifier: string): boolean {
70
+ if (specifier.startsWith('.') || specifier.startsWith('/')) return true;
71
+ if (specifier.startsWith('node:')) return true;
72
+ if (specifier.startsWith('virtual:eldra/')) return true;
73
+ if (ALWAYS_ALLOWED.has(specifier)) return true;
74
+ return isDeclaredDependency(packageNameOf(specifier));
75
+ }
76
+
77
+ describe('starter dependencies', () => {
78
+ const files = SCAN_DIRS.flatMap((dir) => listSourceFiles(join(rootDir, dir)));
79
+
80
+ it('scans a non-trivial number of source files', () => {
81
+ // Guards the test itself against a refactor silently emptying SCAN_DIRS.
82
+ expect(files.length).toBeGreaterThan(20);
83
+ });
84
+
85
+ it('every bare import specifier resolves to a dependency declared in this package.json', () => {
86
+ const unresolved: string[] = [];
87
+ for (const file of files) {
88
+ const source = readFileSync(file, 'utf8');
89
+ for (const specifier of extractSpecifiers(source)) {
90
+ if (!isAllowed(specifier)) {
91
+ unresolved.push(`${file.slice(rootDir.length)} imports '${specifier}'`);
92
+ }
93
+ }
94
+ }
95
+ expect(
96
+ unresolved,
97
+ 'these imports resolve only via the monorepo root, so a standalone copy of this starter ' +
98
+ '(from `eldra-theme init`) would fail to install/build/test — add the package to this ' +
99
+ "package.json's dependencies/devDependencies"
100
+ ).toEqual([]);
101
+ });
102
+ });
@@ -0,0 +1,58 @@
1
+ // @vitest-environment jsdom
2
+ //
3
+ // `EldraIcon` (app/components/EldraIcon.vue) is the theme's name→component
4
+ // bridge to `@eldrajs/ui`'s `Icon`: it resolves a Tabler icon *name* to markup
5
+ // through `useEldraIcon`, which reads `app/icons.ts` — the icons the theme
6
+ // bundles at build time — so a plain `mount()` needs no server and no stub, and
7
+ // the assertions below run against the genuine SVG a real page renders.
8
+ import { flushPromises, mount } from '@vue/test-utils';
9
+ import { axe } from './support/axe';
10
+ import { describe, expect, it } from 'vitest';
11
+ import EldraIcon from '../app/components/EldraIcon.vue';
12
+
13
+ describe('EldraIcon', () => {
14
+ it('renders the Tabler outline paths with currentColor for a known icon', async () => {
15
+ const wrapper = mount(EldraIcon, { props: { name: 'lock' } });
16
+ await flushPromises();
17
+ const svg = wrapper.find('svg');
18
+ expect(svg.exists()).toBe(true);
19
+ expect(svg.attributes('stroke')).toBe('currentColor');
20
+ expect(svg.element.querySelector('path')).not.toBeNull();
21
+ });
22
+
23
+ // The primitive owns size, stroke weight and the decorative ARIA state —
24
+ // that is the whole reason the name goes through `Icon` instead of being
25
+ // inlined here (see the component's own doc comment).
26
+ it("lets @eldrajs/ui's Icon own the size, stroke and ARIA state", async () => {
27
+ const wrapper = mount(EldraIcon, { props: { name: 'lock' } });
28
+ await flushPromises();
29
+ const svg = wrapper.find('svg');
30
+ expect(svg.classes()).toContain('size-8');
31
+ expect(svg.attributes('stroke-width')).toBe('1.75');
32
+ expect(svg.attributes('aria-hidden')).toBe('true');
33
+ });
34
+
35
+ it('names the icon when it carries meaning of its own', async () => {
36
+ const wrapper = mount(EldraIcon, {
37
+ props: { name: 'lock', label: 'Fast delivery' },
38
+ });
39
+ await flushPromises();
40
+ const svg = wrapper.find('svg');
41
+ expect(svg.attributes('role')).toBe('img');
42
+ expect(svg.attributes('aria-label')).toBe('Fast delivery');
43
+ expect(svg.attributes('aria-hidden')).toBeUndefined();
44
+ });
45
+
46
+ it('renders nothing for an unknown icon name', async () => {
47
+ const wrapper = mount(EldraIcon, { props: { name: 'does-not-exist-xyz' } });
48
+ await flushPromises();
49
+ expect(wrapper.find('svg').exists()).toBe(false);
50
+ expect(wrapper.text()).toBe('');
51
+ });
52
+
53
+ it('has no axe violations', async () => {
54
+ const wrapper = mount(EldraIcon, { props: { name: 'lock' } });
55
+ await flushPromises();
56
+ expect(await axe(wrapper.element)).toHaveNoViolations();
57
+ });
58
+ });
@@ -0,0 +1,76 @@
1
+ // @vitest-environment jsdom
2
+ //
3
+ // `blocks/hero/Block.vue` and `blocks/image/Block.vue` render their image
4
+ // through `UiImage` (app/components/ui/UiImage.vue), which imports
5
+ // `imageFramingAttrs`/`imageFramingStyle` from `@eldrajs/theme-vue`; its
6
+ // single index entry also re-exports `EldraBlockZone`/`EldraLayout`, which
7
+ // import `virtual:eldra/blocks`/`virtual:eldra/manifest`/
8
+ // `virtual:eldra/breakpoints` at the top level, normally supplied only by
9
+ // the Nuxt build's vite plugin. `vitest.config.ts` aliases all three to
10
+ // mocks under `test/mocks/`, so the package — and therefore these blocks —
11
+ // resolve for real here.
12
+ import { mount } from '@vue/test-utils';
13
+ import { describe, expect, it } from 'vitest';
14
+ import Hero from '../blocks/hero/Block.vue';
15
+ import Image from '../blocks/image/Block.vue';
16
+ import { mountOptions } from './support/mountBlock';
17
+
18
+ const framed = {
19
+ assetId: 'a1',
20
+ url: 'https://cdn.example/hero.jpg',
21
+ altText: 'Ridge',
22
+ framing: { x: 0.2, y: 0.6, zoom: 2 },
23
+ };
24
+
25
+ describe('image framing opt-in', () => {
26
+ it('renders the hero image with the framing style and marking attributes', () => {
27
+ const wrapper = mount(
28
+ Hero,
29
+ mountOptions({
30
+ entry: { id: 'hero-1', data: { heading: 'Hi', image: framed, variant: 'image-right' } },
31
+ })
32
+ );
33
+ const img = wrapper.get('img');
34
+ expect(img.attributes('data-eldra-framing')).toBe('image');
35
+ expect(img.attributes('data-eldra-framing-entry')).toBe('hero-1');
36
+ expect(img.attributes('data-eldra-framing-value')).toBe('0.2,0.6,2');
37
+ expect(img.attributes('style')).toContain('object-position: 20% 60%');
38
+ expect(img.attributes('style')).toContain('transform: scale(2)');
39
+ expect(img.attributes('style')).toContain('transform-origin: 25% 60%');
40
+ });
41
+
42
+ it('renders an unframed hero with the default cover position and no transform', () => {
43
+ const wrapper = mount(
44
+ Hero,
45
+ mountOptions({
46
+ entry: {
47
+ id: 'hero-2',
48
+ data: {
49
+ heading: 'Hi',
50
+ image: { assetId: 'a2', url: 'https://cdn.example/a.jpg' },
51
+ variant: 'image-right',
52
+ },
53
+ },
54
+ })
55
+ );
56
+ const img = wrapper.get('img');
57
+ const style = img.attributes('style') ?? '';
58
+ expect(style).toContain('object-position: 50% 50%');
59
+ expect(style).not.toContain('transform');
60
+ // Marker attributes stay present (a default, centred framing value) even
61
+ // before an editor has framed anything — see blocks/hero/Block.vue's
62
+ // module doc comment.
63
+ expect(img.attributes('data-eldra-framing-value')).toBe('0.5,0.5,1');
64
+ });
65
+
66
+ it('frames the image block at its declared aspect ratio with the same helper', () => {
67
+ const wrapper = mount(
68
+ Image,
69
+ mountOptions({ entry: { id: 'img-1', data: { image: framed, caption: 'Cap' } } })
70
+ );
71
+ const img = wrapper.get('img');
72
+ expect(img.attributes('data-eldra-framing')).toBe('image');
73
+ expect(img.attributes('data-eldra-framing-entry')).toBe('img-1');
74
+ expect(img.attributes('style')).toContain('transform: scale(2)');
75
+ });
76
+ });