@eldrajs/theme-cli 0.2.1 → 0.2.3

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 (67) hide show
  1. package/package.json +3 -3
  2. package/template/.eldra/previews.json +35 -35
  3. package/template/.github/workflows/eldra-deploy.yml +29 -2
  4. package/template/.gitlab-ci.yml +37 -10
  5. package/template/README.md +4 -4
  6. package/template/app/composables/useFormSpam.ts +1 -0
  7. package/template/app/plugins/chunk-reload.client.ts +29 -0
  8. package/template/app/plugins/eldra-storefront.ts +8 -0
  9. package/template/app/storefront/gateway.ts +34 -11
  10. package/template/app/storefront/sharedRead.ts +34 -0
  11. package/template/app/storefront/structuredData.ts +17 -0
  12. package/template/app/utils/chunkReload.ts +11 -0
  13. package/template/bitbucket-pipelines.yml +26 -6
  14. package/template/blocks/announcement-bar/preview.png +0 -0
  15. package/template/blocks/article/preview.png +0 -0
  16. package/template/blocks/article-list/preview.png +0 -0
  17. package/template/blocks/breadcrumbs/preview.png +0 -0
  18. package/template/blocks/cart/preview.png +0 -0
  19. package/template/blocks/collection-grid/Block.vue +146 -94
  20. package/template/blocks/collection-grid/__tests__/Block.spec.ts +116 -2
  21. package/template/blocks/collection-grid/preview.png +0 -0
  22. package/template/blocks/collection-header/preview.png +0 -0
  23. package/template/blocks/contact/preview.png +0 -0
  24. package/template/blocks/cta/preview.png +0 -0
  25. package/template/blocks/faq/preview.png +0 -0
  26. package/template/blocks/feature-grid/preview.png +0 -0
  27. package/template/blocks/footer/Block.vue +11 -4
  28. package/template/blocks/footer/__tests__/Block.spec.ts +68 -3
  29. package/template/blocks/footer/preview.png +0 -0
  30. package/template/blocks/form/preview.png +0 -0
  31. package/template/blocks/gallery/preview.png +0 -0
  32. package/template/blocks/hero/preview.png +0 -0
  33. package/template/blocks/image/preview.png +0 -0
  34. package/template/blocks/logo-cloud/preview.png +0 -0
  35. package/template/blocks/navigation/Block.vue +125 -541
  36. package/template/blocks/navigation/__tests__/Block.spec.ts +172 -73
  37. package/template/blocks/navigation/parts/MenuLink.vue +15 -0
  38. package/template/blocks/navigation/preview.png +0 -0
  39. package/template/blocks/newsletter/preview.png +0 -0
  40. package/template/blocks/order-status/preview.png +0 -0
  41. package/template/blocks/pricing-table/preview.png +0 -0
  42. package/template/blocks/product-carousel/preview.png +0 -0
  43. package/template/blocks/product-detail/preview.png +0 -0
  44. package/template/blocks/quote/preview.png +0 -0
  45. package/template/blocks/rich-text/preview.png +0 -0
  46. package/template/blocks/search/preview.png +0 -0
  47. package/template/blocks/split-content/preview.png +0 -0
  48. package/template/blocks/stats/preview.png +0 -0
  49. package/template/blocks/tabs/preview.png +0 -0
  50. package/template/blocks/team/preview.png +0 -0
  51. package/template/blocks/testimonials/preview.png +0 -0
  52. package/template/blocks/timeline/preview.png +0 -0
  53. package/template/blocks/trust-strip/preview.png +0 -0
  54. package/template/blocks/video-embed/preview.png +0 -0
  55. package/template/blocks/wishlist/preview.png +0 -0
  56. package/template/test/chunkReload.spec.ts +20 -0
  57. package/template/test/imageFraming.browser.spec.ts +125 -0
  58. package/template/test/pages/article.spec.ts +1 -1
  59. package/template/test/pages/collection.spec.ts +1 -1
  60. package/template/test/pages/home.spec.ts +1 -1
  61. package/template/test/pages/product.spec.ts +1 -1
  62. package/template/test/prerenderRefresh.browser.spec.ts +8 -13
  63. package/template/test/storefront/gateway.spec.ts +6 -0
  64. package/template/test/storefront/gatewayPrerender.spec.ts +26 -1
  65. package/template/test/storefront/sharedRead.spec.ts +43 -0
  66. package/template/test/storefront/structuredData.spec.ts +31 -0
  67. package/template/blocks/navigation/useMegaMenuKeys.ts +0 -276
@@ -1,4 +1,5 @@
1
1
  // @vitest-environment jsdom
2
+ import { computed } from 'vue';
2
3
  import { flushPromises, mount } from '@vue/test-utils';
3
4
  import { afterEach, describe, expect, it, vi } from 'vitest';
4
5
  import { ELDRA_KEY, type EldraLocaleState } from '@eldrajs/theme-vue';
@@ -11,6 +12,7 @@ import { STOREFRONT_KEY } from '../../../app/storefront/types';
11
12
  import type {
12
13
  StorefrontCommerce,
13
14
  StorefrontFormSubmitResult,
15
+ StorefrontSource,
14
16
  StorefrontForms,
15
17
  } from '../../../app/storefront/types';
16
18
  import { createDemoStorefront } from '../../../app/storefront/demo';
@@ -79,6 +81,8 @@ function mountFooter(
79
81
  options: {
80
82
  failForms?: boolean;
81
83
  subscribe?: StorefrontForms['submit'];
84
+ /** A whole storefront, for a spec that needs a form definition the demo does not have. */
85
+ storefront?: StorefrontSource;
82
86
  /** Turn Cloudflare Turnstile on for the sign-up form (with `subscribe` as its submit). */
83
87
  turnstile?: boolean;
84
88
  /** Studio's edit mode — what `useEditing()` reads, and the only state that shows hints. */
@@ -113,14 +117,15 @@ function mountFooter(
113
117
  context.preview.mode = 'edit';
114
118
  }
115
119
  const storefront =
116
- options.subscribe && options.turnstile
120
+ options.storefront ??
121
+ (options.subscribe && options.turnstile
117
122
  ? storefrontWithTurnstile(options.subscribe)
118
123
  : options.subscribe
119
124
  ? (() => {
120
125
  const demo = createDemoStorefront();
121
126
  return { ...demo, forms: { ...demo.forms, submit: options.subscribe! } };
122
127
  })()
123
- : undefined;
128
+ : undefined);
124
129
  return mount(Block, {
125
130
  ...base,
126
131
  // Real focus tracking (`document.activeElement`, and `Select`'s own focus-return behaviour)
@@ -316,7 +321,67 @@ describe('footer block', () => {
316
321
  const label = wrapper.find(`label[for="${id}"]`);
317
322
  expect(label.exists()).toBe(true);
318
323
  expect(label.text()).toBe(enUS.footer.emailLabel);
319
- expect(label.classes()).toContain('sr-only');
324
+ expect(label.classes()).not.toContain('sr-only');
325
+ });
326
+
327
+ it("labels the email field with the form definition's own label", async () => {
328
+ const demo = createDemoStorefront();
329
+ const storefront = {
330
+ ...demo,
331
+ forms: {
332
+ ...demo.forms,
333
+ definition: (key: string) => {
334
+ const result = demo.forms.definition(key);
335
+ return {
336
+ ...result,
337
+ data: computed(() =>
338
+ result.data.value === null
339
+ ? null
340
+ : {
341
+ ...result.data.value,
342
+ fields: result.data.value.fields.map((field) =>
343
+ field.type === 'email' ? { ...field, label: 'Where should we write?' } : field
344
+ ),
345
+ }
346
+ ) as typeof result.data,
347
+ };
348
+ },
349
+ },
350
+ };
351
+ const wrapper = mountFooter(mock, { storefront });
352
+ await flushPromises();
353
+ const input = wrapper.get('input[type="email"]');
354
+ expect(wrapper.get(`label[for="${input.attributes('id')}"]`).text()).toBe(
355
+ 'Where should we write?'
356
+ );
357
+ });
358
+
359
+ it("shows the placeholder the form's email field carries, not its label", async () => {
360
+ const wrapper = mountFooter(mock);
361
+ await flushPromises();
362
+ expect(wrapper.get('input[type="email"]').attributes('placeholder')).toBe('name@example.com');
363
+ });
364
+
365
+ it('keeps the email error in the field cell, directly under the input', async () => {
366
+ const wrapper = mountFooter(mock);
367
+ await flushPromises();
368
+ // The field wrapper is `display: contents` by default, which turns its error into a flex item of
369
+ // its own that lands after the button row; a real block keeps the two together.
370
+ const cell = wrapper.get('input[type="email"]').element.closest('.content-start');
371
+ expect(cell?.parentElement?.classList.contains('block')).toBe(true);
372
+ });
373
+
374
+ it('keeps the sign-up button and its consent sentence in one column as wide as the form', async () => {
375
+ const wrapper = mountFooter(mock);
376
+ await flushPromises();
377
+ // The library's actions row is `shrink-0` and the grid's auto column follows the sentence's
378
+ // max-content, so both pushed the button past the footer column; happy-dom has no layout,
379
+ // so this guards the two classes that prevent it.
380
+ const actions = wrapper.get('[data-part="consent-sentence"]').element.parentElement;
381
+ expect(actions?.classList.contains('grid-cols-[minmax(0,1fr)]')).toBe(true);
382
+ expect(actions?.parentElement?.classList.contains('w-full')).toBe(true);
383
+ // The form's own 0.25rem row gap leaves the button touching the field; the row adds the rest.
384
+ expect(actions?.parentElement?.classList.contains('mt-3')).toBe(true);
320
385
  });
321
386
 
322
387
  it('shows the platform consent sentence under the sign-up button, tied to it with aria-describedby', async () => {
Binary file
Binary file
Binary file
Binary file
Binary file